Android (ADB) (Fastboot) cheatsheet
Table of Contents
都怪 MIUI
Android Shell
Activity Manager (am)
eg: 通话
adb shell am start -a android.intent.action.CALL -d tel:<phone_number>
模拟输入
adb shell input keyevent <keycode>
Keycode 在这里有定义。
eg:
# KEYCODE_POWER
# Added in API level 1
# public static final int KEYCODE_POWER
# Key code constant: Power key.
# Constant Value: 26 (0x0000001a)
adb shell input keyevent 26
Get Props
adb shell getprop ro.product.cpu.abi
Device Policy Manager
# usage: dpm [subcommand] [options]
# usage: dpm set-device-owner <COMPONENT>
# usage: dpm set-profile-owner <COMPONENT> <USER_ID>
# dpm set-device-owner: Sets the given component as active admin, and its package as device owner.
# dpm set-profile-owner: Sets the given component as active admin and profile owner for an existing user.
adb shell dpm set-device-owner <package>/<component(receiver)>
eg: 设置空调狗(操作前登出所有“账户”)
adb shell dpm set-device-owner me.yourbay.airfrozen/.main.core.mgmt.MDeviceAdminReceiver
Invoke Service
cmd package set-home-activity <package>/<activity>
eg: 直接设置启动器(标题回收)
sudo cmd package set-home-activity com.nfwebdev.launcher10/com.nfwebdev.launcher10.Start
ADB
网络 ADB 调试
adb connect
eg:
adb connect 192.168.1.4
启动 Shell
adb shell
以 Root 权限重启 adbd
adb root
以读写(R/W)重新挂载分区
adb remount
安装应用
adb install ./glass-movies.apk
文件操作
adb push <source_path(local)> <target_path(remote)>
adb pull <source_path(remote)> <target_path(local)>
eg:
adb push './test.mp3' '/mnt/sdcard/Music'
adb pull /sdcard/WeiboInternational "E:/Redmi 5 Plus"
咕了
adb kill-server
adb devices
Fastboot
fastboot flash recovery ./recovery.img
fastboot reboot recovery
fastboot reboot
fastboot erase userdata
fastboot oem unlock
fastboot flash boot ./boot.img
fastboot flash system ./system.img