adb 以编程方式更改开发人员设置选项

adb change developer settings options programmatically

如何更改在浓缩咖啡测试中不保持活动?我需要知道 adb 中这个命令的名称。如何从 adb 访问所有可用的开发人员设置命令?

我需要类似以下命令的东西;

getInstrumentation().getUiAutomation().executeShellCommand("settings put global window_animation_scale 0.0");

$ adb shell settings put global wifi_on 0

您可以使用:

adb shell settings put global always_finish_activities 1 

激活设置,0禁用它。

您可以找到 android here 的其他可用设置的官方列表。

以下命令将列出所有可用设置:

  • adb shell 设置列表系统
  • adb shell 全局设置列表
  • adb shell 安全设置列表
$ adb shell settings 
Settings provider (settings) commands:
  help
      Print this help text.
  get [--user <USER_ID> | current] NAMESPACE KEY
      Retrieve the current value of KEY.
  put [--user <USER_ID> | current] NAMESPACE KEY VALUE [TAG] [default]
      Change the contents of KEY to VALUE.
      TAG to associate with the setting.
      {default} to set as the default, case-insensitive only for global/secure namespace
  delete [--user <USER_ID> | current] NAMESPACE KEY
      Delete the entry for KEY.
  reset [--user <USER_ID> | current] NAMESPACE {PACKAGE_NAME | RESET_MODE}
      Reset the global/secure table for a package with mode.
      RESET_MODE is one of {untrusted_defaults, untrusted_clear, trusted_defaults}, case-insensitive
  list [--user <USER_ID> | current] NAMESPACE
      Print all defined keys.
      NAMESPACE is one of {system, secure, global}, case-insensitive

对于root设备你可以运行两个命令

  1. 在命令

    下更改设置首选项运行

    adb shell settings put system system_locales fr-CA

此命令将更改区域设置但需要重新启动

  1. 在命令

    下更改系统属性运行

    亚行 shell setprop persist.sys.locale fr-CA;停止;睡眠 5;开始

这将重新启动您的设备,并且语言将更改 设备恢复出厂设置后语言也会更改