adb shell一些有用的命令

Activity相关

启动Activity前停止app

1
adb shell am start-activity -S -n com.example.app/.MainActivity

启动activity并等待打开

1
adb shell am start-activity -W -n com.example.app/.MainActivity

系统属性

列出存在的属性

1
2
3
4
adb shell settings list system
adb shell settings list global
adb shell settings list secure
adb shell getprop

网络相关

WIFI相关

开启WIFI

1
adb shell cmd -w wifi set-wifi-enabled enabled

扫描WIFI

1
adb shell cmd -w wifi start-scan

列出WIFI扫描结果

1
adb shell cmd -w wifi list-scan-results

列出当前保存的WIFI列表

1
adb shell cmd -w wifi list-networks

连接指定的WIFI

1
adb shell cmd -w wifi connect-network home-wifi wpa2 password

nc命令

1
2
adb shell nc -l -p 8888 # 监听客户端连接
adb shell nc 127.0.0.1 8888 # 连接服务端

设备安全

设置不锁屏

1
adb shell locksettings set-disabled true

恢复出厂设置

1
am broadcast -a android.intent.action.FACTORY_RESET -n android/com.android.server.MasterClearReceiver

移动安全相关

监控目录下文件事件

1
2
inotifywait -r -m /path/to/directory # 监控所有事件
inotifywait -r -m -e create /path/to/directory # 监控特定事件

另辟蹊径检测app是否安装

1
stat -c %u /data/data/com.example # 测试在Android11上可用

使用Magisk root允许所有进程调试

参考:https://danylokos.github.io/0x02/

1
2
magisk resetprop ro.debuggable 1
stop; start

系统启动状态

1
2
adb shell getprop sys.boot_completed # 等于1时启动完成
adb shell getprop init.svc.bootanim # 等于stopped时开机动画完成

重启zygote进程

1
adb shell setprop ctl.restart zygote

屏幕相关

检查是否亮屏

1
adb shell dumpsys deviceidle | grep mScreenOn
1
adb shell dumpsys power | grep "Display Power"

显示触摸点

1
adb shell settings put system show_touches 1

显示触摸位置

1
adb shell settings put system pointer_location 1

录制触屏轨迹

1
2
3
adb shell getevent | grep --line-buffered ^/ | tee /tmp/android-touch-events.log # 录制

awk '{printf "%s %d %d %d\n", substr($1, 1, length($1) -1), strtonum("0x"$2), strtonum("0x"$3), strtonum("0x"$4)}' /tmp/android-touch-events.log | xargs -l adb shell sendevent # 重放

语言相关

设置系统语言

1
2
3
4
5
6
7
adb shell content query --uri content://settings/system --where "name=\'system_locales\'"

adb shell content delete --uri content://settings/system --where "name=\'system_locales\'"

adb shell content insert --uri content://settings/system --bind name:s:system_locales --bind value:s:en-US
adb shell content insert --uri content://settings/system --bind name:s:system_locales --bind value:s:zh-Hant-TW
adb shell content insert --uri content://settings/system --bind name:s:system_locales --bind value:s:zh-Hant-TW,en-US,ja-JP

显示相关

字体缩放

1
2
3
4
5
adb shell settings put system font_scale 0.85 # (small)
adb shell settings put system font_scale 1.0 # (default)
adb shell settings put system font_scale 1.15 # (large)
adb shell settings put system font_scale 1.30 # (largest)
adb shell settings put system font_scale 2.0 # (sizes like this can only be achieved with custom adb setting, not from ui)

窗口管理

分屏模式Split screen

1
2
adb shell am start-activity -n com.whatsapp/.Main --windowingMode 3
adb shell am start-activity -n org.telegram.messenger/.DefaultIcon --windowingMode 4

悬浮窗模式Flating window

1
2
adb shell am start-activity -n com.whatsapp/.Main --windowingMode 5
adb shell am start-activity -n org.telegram.messenger/.DefaultIcon --windowingMode 5

账户相关

请求同步

1
requestsync
Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2015-2024 Kaisar
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信