0

Question about changing the parameters of the transition to doze mode I have a non-rooted Android 12 device There are a number of parameters for changing the transition time in doze mode:

  • inactive_to
  • motion_inactive_to
  • light_after_inactive_to

If you change these parameters through the PC using ADB, then the parameters are set. For instance:

adb shell device_config put device_idle inactive_to 2592000000

The problem is that after a reboot, the settings are reset. Tried to change them directly in the program

//            val command = arrayOf("/system/bin/device_config", "put", "device_idle", "motion_inactive_to", "2592000000")
val command = arrayOf("/system/bin/settings", "put", "global", "device_idle_constants", "light_after_inactive_to", "2592000000")
Log.d("ADB", "Start ${command.joinToString(separator = " ")}")
val process = Runtime.getRuntime().exec(command)
val bufReader = BufferedReader(InputStreamReader(process.errorStream))
val log = StringBuilder()
var line: String?
line = bufReader.readLine()
while (line != null) {
    log.append(line + "\n")
    line = bufReader.readLine()
}
Log.d("ADB", "Command: $log")

But the first command is answered:

“cmd: Can't find service: "device_config"”

And the second command gives an error:

Permission Denial: getCurrentUser() from pid=28435, uid=10245 requires android.permission.INTERACT_ACROSS_USERS

After searching for information about the INTERACT_ACROSS_USERS permission, I understand that it is necessary for it to make the application system. And for this I need to root the device.

Is there any other way to change the parameters of doze mode or disable it altogether? It's confusing that you can run a command with adb on a non-rooted device, but you can't directly in the program.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • 1
    Apps are way more restricted than `adb shell`. With each new Android version app restrictions were added. So it is no surprise that you get an permission denied from within an app. – Robert Jan 04 '23 at 16:40

1 Answers1

0

Is there any other way to change the parameters of doze mode or disable it altogether?

No. If there were, it would have been pointless to add Doze mode, as every developer would opt out of it.

It's confusing that you can run a command with adb on a non-rooted device, but you can't directly in the program.

Different users/processes having different privileges has been a common concept in operating systems for at least 30 years.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491