使用 adb 更改打盹模式设置

Changing doze mode setting using adb

根据我从 Doze Editor app 的源代码中学到的知识,可以使用 adb 更改休眠设置。

我的问题是,我一次只能更改一个设置吗?

例如:

adb shell settings put global device_idle_constants KEY_INACTIVE_TIMEOUT=720000

或者我应该把所有的值对用逗号分隔吗?

例如:

adb shell settings put global device_idle_constants KEY_INACTIVE_TIMEOUT=720000, KEY_SENSING_TIMEOUT=xxxx, KEY_LOCATING_TIMEOUT=yyyy ... and so on

can I change only one setting at a time?

是的,您不能一次更改多个设置。

命令adb shell settings一次只支持一个key/value,在命令帮助中可以看到:

adb shell settings
usage:  settings [--user NUM] get namespace key
        settings [--user NUM] put namespace key value
        settings [--user NUM] delete namespace key

'namespace' is one of {system, secure, global}, case-insensitive
If '--user NUM' is not given, the operations are performed on the owner user.

根据官方在AndroidSDK中的注释,需要将所有的值对放在"device_idle_constants"键下,例如: "inactive_timeout=60000,sensing_timeout=400000"