天天看点

ADB&Fastboot常用命令

分区解释

system:系统分区.

userdata:数据分区.

cache:缓存分区

recovery:Recovery分区.

boot:存放内核和ramdisk的分区。

ADB

  • adb wait-for-device && adb shell logcat -b main > main.txt
  • 安装APK(如果加 -r 参数,保留已设定数据,重新安装filename.apk)

    adb install xxx.apk

    adb install -r xxx.apk

    adb push AppName.apk /system/app/.

  • 卸载APK(如果加 -k 参数,为卸载软件但是保留配置和缓存文件)

    adb uninstall xxx.a

    adb uninstall -k xxx.apk

  • 查看当前所有连接的模拟器设备

    adb devices

  • 对某一模拟器操作

    adb -s 模拟器编号 命令

  • 导入文件到模拟器 (该命令也可以实现安装APK,只要把APK导入到"/system/app"或者"/data/app"就OK)

    adb push 文件 模拟器路径

  • 从模拟器导出文件

    adb pull 模拟器文件 本地路径

  • 查看模拟器log信息

    adb logcat

  • 获取管理员权限

    adb root

  • 进入shell模式

    adb shell

  • 启动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 扩展数据,等)

  • 获取设备ID号

    adb get-serialno

  • 开启adb服务

    adb start-server

  • 关闭adb服务

    adb kill-server

  • 访问sqlite3

    adb shell sqlite3

  • 重启设备

    adb reboot

  • 挂在分区(可使系统分区重新可写)

    adb remount

  • 发布端口(可以设置任意的端口号,做为主机向模拟器或设备的请求端口)

    adb forward tcp:5555 tcp:8000

  • 关机命令

    adb shell reboot -p

  • 高通进入紧急下载模式

    adb reboot edl

  • 进入fastboot

    adb reboot bootloader

  • 进入recovery

    adb reboot recovery

  • 修改只读文件系统

    busybox mount -o rw,remount /system 改回去 rw替换为ro

  • 调试vold fstrim

    (Android P)adb shell sm idle-maint [run|abort]

    (Android O)adb shell sm fstrim

  • dumpsys jobscheduler

    adb shell dumpsys jobscheduler

  • monkey测试
    adb shell monkey --throttle 500 --ignore-timeouts --ignore-crashes --ignore-native-crashes --ignore-security-exceptions --pct-syskeys 10 --pct-touch 45 --pct-motion 25 --pct-appswitch 20 -c android.intent.category.LAUNCHER -c android.intent.category.MONKEY -c android.intent.category.DEFAULT -v -v 500000
    
               

Fastboot

  • 加载驱动:

    fastboot devices //加载fastboot驱动

  • 擦除:

    fastboot erase xxxx //假如我要擦除RECOVERY 就是:fastboot erase recovery

  • 刷BOOT:

    fastboot flash boot boot.img

  • 临时刷recovery:

    fastboot boot recovery.img

  • 刷system:

    fastboot flash system system.img

  • 刷系统:

    fastboot flash userdata userdata.Img

  • 刷系统:

    fastboot

    flash recovery recovery.img

  • 重启:

    fastboot reboot or fastboot continue

  • 刷modem:

    fastboot flash modem NON-HLOS.bin

  • 解锁AVB校验:

    fastboot flashing unlock or fastboot flashing critical_unlock

  • 重新上锁AVB校验:

    fastboot flashing lock or fastboot flashing critical_lock