Android adb的一些用法

adb查看包名/Activity名

adb shell "logcat | grep START"
adb shell dumpsys activity | find “mFocusedActivity”
adb shell pm list packages
adb shell dumpsys window | findstr mCurrentFocus

adb查看安装apk

adb shell
ls system/app

  

按名称找到包名和位置

1|HWVOG:/ $ pm list packages |grep "chaoxi"
package:org.chaoxi.android
HWVOG:/ $ pm path org.chaoxi.android
package:/data/app/org.chaoxi.android-7E1kSgZtxy-AP6zLzDHyIA==/base.apk

adb把手机中已有的apk导出来

adb pull system/app/Bluetooth.apk Buluetooth.apk

 

连接多台手机时,给其中一台install

C:Users1>adb -s 127.0.0.1:7555 install base.apk
Performing Push Install
base.apk: 1 file pushed. 2.5 MB/s (20811337 bytes in 7.786s)
        pkg: /data/local/tmp/base.apk
Success

参考https://developer.android.google.cn/guide/topics/resources/localization

 更新手机的所在地和语言

从adb shell更改模拟器区域设置
使用adb shell更改模拟器中的区域设置。

选择您要测试的区域设置并确定其BCP-47语言标记,例如,加拿大法语fr-CA。
启动模拟器。
从主机上的命令行shell运行以下命令:
adb shell
或者如果已连接设备,请通过添加-e选项指定您希望模拟器:
adb -e shell
在adb shell prompt(#)中,运行以下命令:使用步骤1中的相应代码替换括号内的部分。
setprop persist.sys.locale [BCP-47 language tag];stop;sleep 5;start 
例如,用加拿大法语进行测试:

setprop persist.sys.locale fr-CA;stop;sleep 5;start

这会导致模拟器重新启动。(看起来像完全重启,但事实并非如此。)再次出现主屏幕后,重新启动应用程序,应用程序将使用新的区域设置启动。

  

查看应用权限:

参考 https://developer.android.google.cn/training/permissions/usage-notes

相机应用可能会在其清单中列出CAMERAREAD_CONTACTSACCESS_FINE_LOCATION。您应在测试应用时逐一开启和关闭这些权限,确保应用可以妥善处理所有权限配置。

按组列出权限和状态:
$ adb shell pm list permissions -d -g

授予或撤消一项或多项权限:
$ adb shell pm [grant|revoke] <permission-name> ...

  

查看android的shell命令

ls /system/bin

  

#查看地址
which uiautomator
#查看uiautomator的命令
uiautomator --help

  

原文地址:https://www.cnblogs.com/zhizhiyin/p/11362448.html