使用adb 在macOS上 为Nexus Android 手机线刷原生镜像固件

1.
去 Google 开发者网站,下载对承诺手机型号的整版本工厂镜像 解压

  1. 下载操作所待Android SDK
    Platform-tools工具,并开展解压备用

3.  下载TWRP for
shamu

4.  下载Zip
ROOT工具 SuperSU

Download Factory
Images  https://developers.google.com/android/images

https://dl.google.com/dl/android/aosp/shamu-n6f27m-factory-bf5cce08.zip

1.  进入Bootloader模式

极输入:        adb reboot bootloader

2.  解压镜像文件   cd到此文件夹路径下

**终端输入:        cd /Users/XLsn0w/Desktop/shamu-mob31t**

3.  执行命令行” sh ./ ”   运行” flash-all.sh “文件,  执行刷机

**终极输入:**    sh ./flash-all.sh

手机拿电动执行刷机脚本操作,请耐心等直至手机再次开并出现开机画面…

$  adb push /Users/XLsn0w/Desktop/SuperSU.zip /sdcard

$  adb reboot bootloader

$  cd /Users/XLsn0w/Desktop

$  fastboot flash recovery
twrp-3.1.1-0-shamu.img 

adb reboot bootloader    进入bootloader刷机界面

fastboot reboot                重启

adb shell reboot -p          关机

fastboot devices               判断设备是否连

fastboot flash recovery twrp.img    刷入TWRP

adb devices                    确定手机和计算机不断

adb reboot recovery    进入刷机界面

Mac 通过命令行adb install安装apk

$      cd 到apk所当文件夹路径

$    adb install xlsn0w.apk

1、安装APK(如果加 -r 参数,保留已设定数据,重新安装filename.apk)

adb install xxx.apk

adb install -r xxx.apk

2、卸载APK(如果加 -k 参数,为卸载软件而保留配置以及缓存文件)

adb uninstall xxx.apk

adb uninstall -k xxx.apk

3、查看时具备连接的模拟器设备

adb devices

4、对有同模拟器操作

adb -s 模拟器编号 命令

5、导入文本及拟器
(该令也可以实现设置APK,只要将APK导入到”/system/app”或者”/data/app”就OK)

adb push 文件 模拟器路径

6、从模拟器导出文件

adb pull 模拟器文件 本地路径

7、查看模拟器log信息

adb logcat

8、获取管理员权限

adb root

9、进入shell模式

adb shell

10、启动activity (adb
shell后面和的授命主要来自源码\system\core\toolbox目录及源码\frameworks\base\cmds目录)

adb shell am start -n 包名/包名+类名(-n 类名,-a action,-d date,-m
MIME-TYPE,-c category,-e 扩展数据,等)

11、获取装备ID号

adb get-serialno

12、开启adb服务

adb start-server

13、关闭adb服务

adb kill-server

14、访问sqlite3

adb shell

sqlite3

15、重开设备

adb reboot

16、挂于细分区(可若系统分区重新可写)

adb remount

17、发布端口(可以安装任意的端口号,做吧主机向模拟器或配备的乞求端口)

adb forward tcp:5555 tcp:8000

18、关机命令

adb shell reboot -p

Android SDK Platform-tools
工具中包含的 adb 及 fastboot 指令环境,是咱于后面运行相关指令所欲的,接下去先讲解如何让
macOS 运行 Android SDK。

布局 macOS 中 Android SDK 的环境变量

不管 Windows 还是 macOS 环境受到,我们都是经过 Terminal(Windows 称为「命令提示符」) 来针对手机下达操作指令的。

假定以对手机控制前,我们需要先增建筑好 Android SDK 的环境变量,使得 Terminal 能够调取、运行 adb 和 fastboot 指令。在 macOS 中追加建筑 Android SDK 的操作如下:

启动 Spotlight,输入「终端」找到 Terminal;

1.  
 在 Terminal 中输入cd ~,并依下回车执行,将 Terminal 中目录位置切换至当下登陆用户之「Home目录」位置;

2.  
 输入touch .bash_profile,并据下回车执行,创建有「.bash_profile」环境布置文件;

3.
 输入open -e .bash_profile,并依照下回车执行,编辑「.bash_profile」环境布置文件;

4.   输入路径

export PATH=$PATH:/Users/XLsn0w/Desktop/platform-tools

此时将会晤打开「.bash_profile」文件,在里头输入export
PATH=$PATH:/Users/登陆用户名/存放的公文夹路径名称/platform-tools/代码。在行动只例证,若电脑登陆用户名为xlsn0w,且
Platform-tools
工具解压并放置在了「下充斥」文件夹,则此处需输入的代码为:export
PATH=$PATH:/Users/
xlsn0w/Downloads/platform-tools/,随后保存并关闭即可;

5.  
输入source .bash_profile,并遵循下回车执行,执行创建好的条件布置。

完了上述几步简单的一声令下操作后,我们即便好了 Android SDK 的环境变量配置,往后运作 Platform-tools 工具的根基准备工作为曾经做到。

解锁 Bootloader

Bootloader 是咱于启动 Android
系统基本之前运行的平底模式,在是底色模式下,我们能针对手机进行初始化硬件装置、建立内存空间映射图等操作。刷入官方工厂镜像等操作为是要以斯模式下实施的。

(注意:此操作以辟手机遭的具备素材,建议备份好手机中之所需要资料后,再进行下述解锁 Bootloader 操作)

打开「开发者选项」:在「设置」中跻身「关于手机」,持续点击「 版本号」7次等;

次第打开「USB 调试」及「OEM 解锁」:在「设置」找到「开发者选项」,找到并开拓对应选项。而
Pixel 用户要小心的是,「OEM 解锁」选项必须是在能够接连到 Google 服务器的联网状态才不过打开;

跟着上 Bootloader 界面等候操作:将手机关机,随后以据停「电源键+音量下键」,进入到 Bootloader 界面并运用数据线以及电脑连;

尽解锁 Bootloader 操作指令:在 macOS 打开 Terminal,并输入fastboot flashing unlock指令,手机将会晤提示而是不是如解锁 Bootloader。

完成 Bootloader 解锁:随后循音量键选中「Yes」选项 ,并遵循下电源键确认,此时手机就成功了解锁 Bootloader,此时告无关闭手机,我们拿继续执行刷机操作。

完刷入 Android 官方系统操作

得了 Bootloader 解锁操作,我们本好实施刷入官方工厂镜像到手机了。

以 Finder 找到下载好的总体版本工厂镜像,并确认就解压完成;

于 Terminal 将路径切换到镜像文件夹饱受。假设我的文书夹路径为/Users/jackcivlie/Downloads/bullhead-opp1.170223.012/,则输入cd /Users/jackcivlie/Downloads/bullhead-opp1.170223.012/即可;

一旦对 macOS 文件夹路径不熟识,难以识别其路径位置的话,这里可以下一个取巧的法门:先以
Terminal 中输入cd(注意「cd」后面有空格),并于 Finder
镜像文件夹下拖拽任意一个文书及 Terminal 窗口,并拿变的门道代码中,将文件称的一部分去,按下回车便一挥而就了操作;

顶点代码如下

XLsn0ws-MacBook:~ XLsn0w$ adb reboot bootloader

* daemon not running. starting it now at tcp:5037 *

* daemon started successfully *

XLsn0ws-MacBook:~ XLsn0w$ cd /Users/XLsn0w/Desktop/shamu-mob31t

XLsn0ws-MacBook:shamu-mob31t XLsn0w$ sh ./flash-all.sh

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

(bootloader) slot-suffixes: not found

(bootloader) has-slot:bootloader: not found

target reported max download size of 536870912 bytes

sending ‘bootloader’ (3807 KB)…

OKAY [0.120s]

writing ‘bootloader’…

(bootloader) flashing partition …

(bootloader) This may take a few seconds if a

(bootloader) different partition table is being

(bootloader) flashed since we need to backup

(bootloader) and restore a few partitions

(bootloader) Flashing primary GPT image…

(bootloader) Flashing backup GPT image…

(bootloader) flashing aboot …

(bootloader) flashing sbl1 …

(bootloader) flashing rpm …

(bootloader) flashing tz …

(bootloader) flashing sdi …

(bootloader) flashing logo …

OKAY [0.788s]

finished. total time: 0.908s

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

(bootloader) slot-suffixes: not found

rebooting into bootloader…

OKAY [0.002s]

finished. total time: 0.002s

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

(bootloader) slot-suffixes: not found

(bootloader) has-slot:radio: not found

target reported max download size of 536870912 bytes

sending ‘radio’ (115508 KB)…

OKAY [3.619s]

writing ‘radio’…

(bootloader) flashing modem …

(bootloader) flashing mdm1m9kefs1 …

(bootloader) flashing mdm1m9kefs2 …

(bootloader) flashing mdm1m9kefs3 …

(bootloader) flashing versions …

OKAY [1.689s]

finished. total time: 5.308s

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

(bootloader) slot-suffixes: not found

rebooting into bootloader…

OKAY [0.002s]

finished. total time: 0.002s

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

(bootloader) slot-suffixes: not found

(bootloader) current-slot: not found

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

target reported max download size of 536870912 bytes

(bootloader) has-slot:boot: not found

archive does not contain ‘boot.sig’

(bootloader) has-slot:recovery: not found

archive does not contain ‘recovery.sig’

(bootloader) has-slot:system: not found

archive does not contain ‘system.sig’

archive does not contain ‘vendor.img’

(bootloader) slot-count: not found

(bootloader) slot-suffixes: not found

(bootloader) slot-suffixes: not found

wiping userdata…

Creating filesystem with parameters:

Size: 59751923712

Block size: 4096

Blocks per group: 32768

Inodes per group: 8192

Inode size: 256

Journal blocks: 32768

Label:

Blocks: 14587872

Block groups: 446

Reserved block group size: 1024

Created filesystem with 11/3653632 inodes and 275392/14587872 blocks

wiping cache…

Creating filesystem with parameters:

Size: 268435456

Block size: 4096

Blocks per group: 32768

Inodes per group: 8192

Inode size: 256

Journal blocks: 1024

Label:

Blocks: 65536

Block groups: 2

Reserved block group size: 15

Created filesystem with 11/16384 inodes and 2089/65536 blocks


Bootloader Version…: moto-apq8084-71.22

Baseband Version…..: D4.01-9625-05.34+FSG-9625-02.111

Serial Number……..: ZX1G3268PW


checking product…

OKAY [0.002s]

checking version-bootloader…

OKAY [0.002s]

checking version-baseband…

OKAY [0.002s]

sending ‘boot’ (8183 KB)…

OKAY [0.259s]

writing ‘boot’…

OKAY [0.275s]

sending ‘recovery’ (8901 KB)…

OKAY [0.284s]

writing ‘recovery’…

OKAY [0.126s]

sending sparse ‘system’ 1/4 (517178 KB)…

OKAY [ 18.982s]

writing ‘system’ 1/4…

OKAY [7.726s]

sending sparse ‘system’ 2/4 (515137 KB)…

OKAY [ 19.296s]

writing ‘system’ 2/4…

OKAY [7.407s]

sending sparse ‘system’ 3/4 (515644 KB)…

OKAY [ 19.295s]

writing ‘system’ 3/4…

OKAY [7.353s]

sending sparse ‘system’ 4/4 (514697 KB)…

OKAY [ 19.084s]

writing ‘system’ 4/4…

OKAY [6.867s]

erasing ‘userdata’…

OKAY [9.301s]

sending ‘userdata’ (141067 KB)…

OKAY [4.432s]

writing ‘userdata’…

OKAY [2.187s]

erasing ‘cache’…

OKAY [0.043s]

sending ‘cache’ (6248 KB)…

OKAY [0.210s]

writing ‘cache’…

OKAY [0.094s]

rebooting…

finished. total time: 123.237s

XLsn0ws-MacBook:shamu-mob31t XLsn0w$

网站地图xml地图