kpen

hey

[Android] ADB 指令

安卓【设置】中设置项大都可以使用settings命令设置

1
2
3
4
5
6
7
usage:  settings [--user <USER_ID> | current] get namespace key
settings [--user <USER_ID> | current] put namespace key value
settings [--user <USER_ID> | current] delete namespace key
settings [--user <USER_ID> | current] list namespace

'namespace' is one of {system, secure, global}, case-insensitive
If '--user <USER_ID> | current' is not given, the operations are performed on the system user.

1.代理设置

1
2
3
4
5
6
7
8
9
10

# 设定指令
settings put global global_http_proxy_host 192.168.0.35
settings put global global_http_proxy_port 8888

# 清空指令
settings delete global global_http_proxy_host
settings delete global global_http_proxy_port

# 注意: 可能需要重启应用或者重启机器才能生效

2. 触摸点显示

1
2
settings put system show_touches 1  # 启用
settings put system show_touches 0 # 禁用

3. 触摸线跟踪

1
2
settings put system pointer_location 1 # 启用
settings put system pointer_location 0 # 禁用

4. 清空数据

清空 userdata 和 cache

1
2
adb shell "echo \"--wipe_data\" >> /cache/recovery/command"
adb reboot recovery

清空cache

1
2
adb shell "echo \"--wipe_cache\" >> /cache/recovery/command"
adb reboot recovery

5. 升级

1
2
3
adb push update.zip /cache/update_bak.zip
adb shell "echo \"--update_package=/cache/update_bak.zip\" >> /cache/recovery/command"
adb reboot recovery

6. 授权

1
2
3
4
5
6
7
8
9
10
11
12
13
# 授权
adb shell pm grant <PACKAGE_NAME> <PERMISSION_NAME>
# 取消授权
adb shell pm revoke <PACKAGE_NAME> <PERMISSION_NAME>
# 查看所有可用授权
adb shell pm list permissions
# 列出所有授权
adb shell dumpsys package <PACKAGE_NAME> | grep "granted=true"
# 自动授权列表中所有申请的权限
adb install -g your_app.apk
# 自动授权
adb shell pm grant com.example.test android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.example.test android.permission.ACCESS_FINE_LOCATION