笔者这里有一部Piex 6p 手机(400RMB)(编号:5.170623.007),因为大多数定制手机手机都是基于谷歌原生修改而来,所以有必要准备一部,方便学习,那么现在开始吧。。
我们先思考下划分步骤进行
sudo apt install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libncurses5 libxml2-utils python xsltproc unzip
repo.sh
是我们创建的第一个文件,然后复制粘贴下面的文件内容即可创建文件 | 复制 | 粘贴 | 编辑 | 授权 | 执行 |
---|---|---|---|---|---|
touch repo.sh |
Ctrl +Shift + C | Ctrl +Shift + V or Shift +Insert | gedit repo.sh |
sudo chmod 777 repo.sh |
./repo.sh |
repo.sh
.#!/usr/bin/env bash
export LOG_ACCOUNT=tmp
export LOG_FILENAME=repo-sync
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
aosp_branch=android-8.0.0_r17
if [ ! -d ".repo" ]; then
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b $aosp_branch
repo_stat=$?
if [ $repo_stat -ne 0 ]; then
echo "init repo faild, please try again"
exit 0
fi
else
echo "local .repo dir exists"
fi
try_count=0
echo "from remote sync aosp"
repo sync
repo_stat=$?
while [ $repo_stat -ne 0 ]; do
echo "sync faild, status: $repo_stat, try again in 5s ..."
sleep 5
repo sync
repo_stat=$?
((try_count++))
done
echo "sync repo over, try_count: $try_count"
echo "sync over, success"
先等着吧··,得好几个小时,建议晚上去拉
方式二
Android小码家
公众号回复
Android源码
获取百度云资源
PS:还没玩转之前下不建议这样操作
驱动程序
上图红框内还有两个文件没有提到,即设备驱动程序
extract-huawei-angler.sh
extract-qcom-angler.sh
https://developers.google.com/android/drivers
安装
使用上述的 ./extract-huawei-angler.sh
./extract-qcom-angler.sh
安装
1. 存放位置在哪?
解:即/data/android-8.0.0_r17/
,前面截图已给出位置
2. 没找到这两个文件?
解:当然没有,需要解压上述两个文件后,复制到/data/android-8.0.0_r17/
解压命令
tgz | bz2 | 更多请参考 |
---|---|---|
tar -zxvf FileName.tar.gz |
tar -jxvf FileName.tar.bz2 | 解压缩 |
开始编译
source build/envsetup.sh
// 进行清除操作,以避免之前进行的build干扰到接下来的build
make clobber
// 选择编译开发工程师的版本,方便debug
lunch aosp_x86_64-eng
make -j4
source build/envsetup.sh
lunch aosp_x86_64-eng
emulator
问题 make: *** [run_soong_ui] Error 1
sudo apt-get install libc6:i386 libstdc++6:i386
开启虚拟化
maqi@maqi-virtual-machine:/data/android-8.0.0_r17$ emulator
emulator: WARNING: system partition size adjusted to match image file (2560 MB > 200 MB)
emulator: WARNING: data partition size adjusted to match image file (550 MB > 200 MB)
emulator: WARNING: encryption is off
emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: KVM requires a CPU that supports vmx or svm
解决方法:
注意
另外上图的配置特别是内存10G 存储300G 能让你避免很多问题
libGL error
原因:libstdc++.so与ubuntun不匹配
mv libstdc++.so.6{,.bak}
mv libstdc++.so.6.0.18 {,.bak}
ln -s /usr/lib/libstdc++.so
nautilus . | ls -l | mv | ln -s |
---|---|---|---|
gun 查看当前文件夹 | 命令行 查看当前文件夹 | 重命名 | 创建快捷方式(软链接) |
开始编译
整体编译
source build/envsetup.sh
# 进行清除操作,以避免之前进行的build干扰到接下来的build
#一般别用
make clobber
# 6p对应的版本
lunch aosp_angler-userdebug
make -j4
或者单独编译
#编译bootloader,
make bootloader
#编译kernel生成boot.img,
make bootimage
#编译system生成system.img,
make systemimage
#编译userdata生成userdata.img,
make userdataimage
#编译recovery生成recovery.img,
make recoveryimage
连接设备
VMware Ubuntu 连接USB,如下主动点击连接
编译成功
刷机
编译输出路径 | |
---|---|
echo ${ANDROID_PRODUCT_OUT} |
adb reboot bootloader
cd ${ANDROID_PRODUCT_OUT}
fastboot flashall -w
方式二
fastboot erase cache (清理一下)
fastboot flash boot boot.img (引导,依次刷入几个ROM的关键数据)
fastboot flash recovery recovery.img (官方RECOVERY)
fastboot flash system system.img (如果bl radio 不同的话,刷这个就会报错了,如果提示的不是版本不同,那么重刷一下就行,可能是线没插好)
fastboot flash userdata userdata.img (这个是用户数据,具说不刷的话你原来的数据不丢,没试过,建议刷)
fastboot flash cache cache.img (缓存,刷下)
fastboot flash vendor vendor.img (具说是补丁数据,反正要刷)
fastboot reboot (重启进系统,底包刷写完成,一定要进系统的,不完成设置,后面也是没办法继续刷的)
挂载
adb remount
修改源代码后只有挂在才能写入system
案例一
修改默认壁纸
frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.png
frameworks/base/core/res/res/drawable-sw600dp-nodpi/default_wallpaper.png
frameworks/base/core/res/res/drawable-sw720dp-nodpi/default_wallpaper.png
案例二
修改默认语言
build/make/tools/buildinfo.sh
-- echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE"
++ echo "ro.product.locale=zh-CN"
语言种类如下
ja-JP, es-PE, en, ja-JP-JP, es-PA, sr-BA, mk, es-GT, ar-AE, no-NO, sq-AL, bg, ar-IQ, ar-YE, hu, pt-PT, el-CY, ar-QA, mk-MK, sv, de-CH, en-US, fi-FI, is, cs, en-MT, sl-SI, sk-SK, it, tr-TR, zh, th, ar-SA, no, en-GB, sr-CS, lt, ro, en-NZ, no-NO-NY, lt-LT, es-NI, nl, ga-IE, fr-BE, es-ES, ar-LB, ko, fr-CA, et-EE, ar-KW, sr-RS, es-US, es-MX, ar-SD, in-ID, ru, lv, es-UY, lv-LV, iw, pt-BR, ar-SY, hr, et, es-DO, fr-CH, hi-IN, es-VE, ar-BH, en-PH, ar-TN, fi, de-AT, es, nl-NL, es-EC, zh-TW, ar-JO, be, is-IS, es-CO, es-CR, es-CL, ar-EG, en-ZA, th-TH, el-GR, it-IT, ca, hu-HU, fr, en-IE, uk-UA, pl-PL, fr-LU, nl-BE, en-IN, ca-ES, ar-MA, es-BO, en-AU, sr, zh-SG, pt, uk, es-SV, ru-RU, ko-KR, vi, ar-DZ, vi-VN, sr-ME, sq, ar-LY, ar, zh-CN, be-BY, zh-HK, ja, iw-IL, bg-BG, in, mt-MT,es-PY, sl, fr-FR, cs-CZ, it-CH, ro-RO, es-PR, en-CA, de-DE, ga, de-LU, de, es-AR, sk, ms-MY, hr-HR, en-SG, da, mt, pl,ar-OM, tr, th-TH-TH, el, ms, sv-SE, da-DK, es-HN
问题一
Framework层代码变更 push 之后为什么不能生效?
参考 :https://www.jianshu.com/p/df79d1dd97b4
刷入framwork
adb root
adb remount
adb push framework /system/
adb reboot
问题二
Jack-server怎么还没执行完?
解:观察以下文件内容
gedit $HOME/.jack-server/logs/jack-server-0-0.log
AndroidXRef
Source Insight 3
内存够玩的话 直接装一个AndroidStudio
AndroidDevTools
工具下载
https://developer.android.com/studio/releases/platform-tools#downloads
USB连接手机,输入以下命令
https://source.android.com/docs/setup/build/running#flashing-a-device
C:\Users\05878mq>adb reboot bootloader
C:\Users\05878mq>fastboot devices
8XV7N16125004864 fastboot
下载刷机包
https://source.android.com/source/build-numbers#platform-code-names-versions-api-levels-and-ndk-releases
双击flash-all.bat
大概两分钟,手机就会自动重启了
@ECHO OFF
:: Copyright 2012 The Android Open Source Project
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
PATH=%PATH%;"%SYSTEMROOT%\System32"
fastboot flash bootloader bootloader-angler-angler-03.75.img
fastboot reboot-bootloader
ping -n 5 127.0.0.1 >nul
fastboot flash radio radio-angler-angler-03.84.img
fastboot reboot-bootloader
ping -n 5 127.0.0.1 >nul
fastboot -w update image-angler-opr5.170623.007.zip
echo Press any key to exit...
pause >nul
exit
bootloader
fastboot flash bootloader bootloader-angler-angler-03.54.img
重启进入bootloader
fastboot reboot-bootloader
刷入射频
fastboot flash radio radio-angler-angler-03.61.img
重启进入bootloader
fastboot reboot-bootloader
刷入boot cache recovery system userdata vendor
fastboot -w update image-angler-opr5.170623.007.zip