手機(jī)基于Pixel 2XL
環(huán)境基于VMWARE: Kali Linux
鏡像基于Android 10(Q)
VMWARE 拖拽緩存清除:rm -rf /root/.cache/vmware/drag_and_drop/*
VMWARE 記得隨手打快照
1 先解鎖
#Check version should be same if you have used sdk manager
#Check version to ensure the tools are running
adb --version
fastboot --version
#Check if your device is showing up. If not you need to make sure #you have proper Google USB driver installed and Device manager #should not show any warning. If everything is alright you can see #android device in device manager without any warning
adb devices
#To switch to bootloader mode use this command. You can #alternatively use pwr+vol_down, but i prefer using adb.
adb reboot bootloader
#Once bootloader has started run the command below to make sure #fastboot command can detect your device.
fastboot devices
#Now you can unlock your bootloader
fastboot flashing unlock
2 刷入TWRP并進(jìn)行系統(tǒng)擴(kuò)容
2.1 下載 TWRP
https://twrp.me/google/googlepixel2xl.html
2.2 刷入 TWRP
重啟到 bootloader:
adb reboot bootloader
啟動 twrp
fastboot boot /twrp-3.7.0_9-0-taimen.img
adb push /twrp-installer-3.zip /
在twrp中安裝zip。
2.3 系統(tǒng)擴(kuò)容
只有在第一次刷android 9 以上的系統(tǒng)需要擴(kuò)容镶摘,以后可略過此步驟嫉鲸。
Flash the HH.R version of TWRP and launch it
Open terminal (TWRP -> Advanced -> Terminal)
Type hh_repart -m
Wait until your phone reboots
Install your rom
3 刷入谷歌原生鏡像
3.1查看源碼對應(yīng)的版本和支持的設(shè)備
https://source.android.com/docs/setup/about/build-numbers?hl=zh-cn
Pixel 2XL 選擇這個版本, 其他手機(jī)同理在這里找對應(yīng)版本:
3.2下載選擇版本的鏡像
https://developers.google.com/android/images?hl=zh-cn#taimen
Version | Flash | Download | SHA-256 |
---|---|---|---|
10.0.0 (QQ3A.200805.001, Aug 2020) | https://flash.android.com/build/6578210?target=taimen-user&hl=zh-cn | https://dl.google.com/dl/android/aosp/taimen-qq3a.200805.001-factory-305df20c.zip?hl=zh-cn | 305df20c865426b9be467cc6a44081a8cac3992257f86ab9c5c91321596fd6b8 |
3.3刷入鏡像
下載adb和flashboot工具,并放入環(huán)境變量中:https://developer.android.com/studio/releases/platform-tools.html?hl=zh-cn
設(shè)置環(huán)境變零:ANDROID_PRODUCT_OUT
為鏡像所在目錄钮莲。
手機(jī)進(jìn)入 bootloader
(完全關(guān)機(jī)忿磅,音量向下鍵+安卓電源鍵), 進(jìn)入鏡像文件夾執(zhí)行./flash-all.sh
進(jìn)行刷入另患。
如果出錯則替換 fastboot
文件繼續(xù)嘗試。 fastboot
目錄查看:which fastboot
芳绩。
如果出現(xiàn)
archive does not contain 'system.sig'
, 就緩緩喝杯茶掀亥,等會再重復(fù)命令繼續(xù)刷機(jī)。
3.4 刷三方鏡像
3.4.1 lineageos
下載鏡像:
https://download.lineageos.org/devices/taimen/builds
刷機(jī)教程:
https://wiki.lineageos.org/devices/taimen/
3.4.2 blissroms
https://sourceforge.net/projects/blissroms/files/Q/taimen/
3.5 安裝原生鏡像網(wǎng)絡(luò)受限制
// 刪除變量 Captive Portal
adb shell settings delete global captive_portal_mode
// 關(guān)閉谷歌服務(wù)檢測檢測
adb shell settings put global captive_portal_mode 0 (注:Android 8 不需要執(zhí)行這一條)
adb shell settings get global captive_portal_mode (返回0)
// 刪除默認(rèn)的強(qiáng)制門戶設(shè)置
adb shell settings delete global captive_portal_https_url
adb shell settings delete global captive_portal_http_url
// 修改新的設(shè)置
adb shell settings put global captive_portal_https_url https://connect.rom.miui.com/generate_204
adb shell settings put global captive_portal_http_url http://connect.rom.miui.com/generate_204
//設(shè)置中國時區(qū)
adb shell setprop persist.sys.timezone Asia/Shanghai
//設(shè)置NTP服務(wù)器
adb shell settings put global ntp_server ntp1.aliyun.com
這是幾個國內(nèi)可用的服務(wù)器地址妥色,也可以使用自己的服務(wù)器搪花,返回204即可。
小米:http://connect.rom.miui.com/generate_204
華為:http://connectivitycheck.platform.hicloud.com/generate_204
Vivo:http://wifi.vivo.com.cn/generate_204
Google 大陸: g.cn/generate_204
國內(nèi)還可以用 connectivitycheck.gstatic.com / www.gstatic.com / ssl.gstatic.com 嘹害,國內(nèi)會自動解析到北京Google那邊鳍侣,在境外的話又能解析到Google全球網(wǎng)絡(luò)去。
4 刷入 Magisk
4.1 下載
下載最新的APK并安裝在手機(jī)上:https://github.com/topjohnwu/Magisk
4.2 安裝
根據(jù)官方文檔進(jìn)行安裝:https://topjohnwu.github.io/Magisk/install.html#patching-images
4.3 檢測ROOT權(quán)限
$ adb shell
$ su -
5 源碼編譯
https://source.android.com/setup/build/building
5.1 下載 AOSP源碼包
使用清華鏡像站下載:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/
下面是每月打包的最新初始化包:
https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar
5.2 創(chuàng)建新分區(qū)用于源碼編譯
啟動Gparted軟件吼拥,在unallocated部分右擊倚聚,選擇新建,按照默認(rèn)即可凿可,即可新建分區(qū)惑折,點擊選擇Apply授账,應(yīng)用到磁盤。然后將這個新建的磁盤mount到某個文件夾:
$ cd Desktop
$ mkdir COMPILE
$ mount /dev/sdaX/ /root/Desktop/COMPILE
sdaX根據(jù)軟件提示修改
將下載好的 aosp-latest.tar
放入 /root/Desktop/COMPILE
中惨驶,并解壓:
`tar xvf aosp-latest.tar`
解壓完成后刪除壓縮包釋放空間rm aosp-latest.tar
5.2 準(zhǔn)備編譯環(huán)境
$ apt update
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
$ apt install bison tree
$ dpkg --add-architecture i386
$ apt update
$ apt install libc6:i386 libncurses5:i386 libstdc++6:i386
$ apt install libxml2-utils
安裝JDK11或8白热,11報錯就用8:
$ apt install openjdk-11-jdk
下載aosp源碼版本管理工具,并設(shè)置可運(yùn)行
$ curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo
$ chmod a+x /usr/bin/repo
裝htop,CPU粗卜、內(nèi)存屋确、緩存查詢
$ apt install htop
裝jnettop,系統(tǒng)網(wǎng)絡(luò)流量連接查詢
$ wget http://ftp.us.debian.org/debian/pool/main/j/jnettop/jnettop_0.13.0-1+b3_amd64.deb
$ dpkg -i jnettop_0.13.0-1+b3_amd64.deb
裝tmux,窗口分屏軟件
$ apt install tmux
將源碼同步到最新狀態(tài)
$ cd /root/Desktop/COMPILE/aosp/
同步源碼樹
$ repo sync -j8
-j8 是開啟八個線程同時下載, 看你CPU牛不牛
此后,每次只需運(yùn)行repo sync
即可保持同步续扔。
5.3 驅(qū)動安裝
Nexus 和 Pixel 設(shè)備的驅(qū)動程序二進(jìn)制文件
https://developers.google.com/android/drivers?hl=zh-cn#taimenqq3a.200805.001
下載對應(yīng)版本的驅(qū)動文件
[圖片上傳失敗...(image-c80aaf-1699237827415)]
適用于 Android 10.0.0 (QQ3A.200805.001) 的 Pixel 2 XL 二進(jìn)制文件
硬件組件 | 公司 | 下載 | SHA-256 |
---|---|---|---|
供應(yīng)商映像 | https://dl.google.com/dl/android/aosp/google_devices-taimen-qq3a.200805.001-bbe1141b.tgz?hl=zh-cn | 1821dd417bc57cf70dbd69da7e3fb3ca5fd564a1755e1b7a83c95962ff6f1889 | |
GPS攻臀、音頻、相機(jī)纱昧、手勢刨啸、圖形、DRM识脆、視頻设联、傳感器 | Qualcomm | https://dl.google.com/dl/android/aosp/qcom-taimen-qq3a.200805.001-a89eddab.tgz?hl=zh-cn | 0405a1638911e5d16dd56afd68438f1d0dbf5a2309768b57fb0da741fb5c7a43 |
下載Google 和高通的版本驅(qū)動,分別解壓和shell腳本執(zhí)行:
$ cd /root/Desktop/COMPILE/aosp/
$ wget https://dl.google.com/dl/android/aosp/qcom-taimen-qq3a.200805.001-a89eddab.tgz?hl=zh-cn
$ wget https://dl.google.com/dl/android/aosp/google_devices-taimen-qq3a.200805.001-bbe1141b.tgz?hl=zh-cn
$ tar zxvf google_devices-taimen-qq3a.200805.001-bbe1141b.tar
$ ./extract-google_devices-taimen.sh
$ tar zxvf qcom-taimen-qq3a.200805.001-a89eddab.tar
$ ./extract-qcom-taimen.sh
5.4 編譯
一定要先掛載磁盤:
$ mount /dev/sdaX/ /root/Desktop/COMPILE
建立工作目錄:
$ cd /root/Desktop/COMPILE/aosp/
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
指定特定的版本, 這里用的支持Pixel 2xl的android10:https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds
$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r41
$ repo sync --current-branch
開始編譯:導(dǎo)入環(huán)境變量
# cd /root/Desktop/COMPILE/aosp/
# source build/envsetup.sh
選擇設(shè)備:
# lunch
選擇 Pixel2xl灼捂,可調(diào)試帶ROOT的combo:
aosp_taimen-userdebug
或者不帶調(diào)試和ROOT的生產(chǎn)combo:aosp_taimen-user
(推薦)
user:適合生產(chǎn)環(huán)境
userdebug:與user類似离例,但具有 root 訪問權(quán)限和調(diào)試功能; 調(diào)試的首選
eng:帶有附加調(diào)試工具的開發(fā)配置
export LC_ALL-C
python環(huán)境需要2.7.
開始編譯,你的cpu牛起來:
make -j8
編譯完成的系統(tǒng)鏡像位于當(dāng)前目錄的out/target/product/sailfish/下悉稠,后綴.img
宫蛆。
替換原生鏡像中的IMG:
重新打zip,替換原文件偎球。
使用編譯出來的fastboot進(jìn)行刷機(jī)。