Disabling or detecting the app specific power saving mode

自闭症网瘾萝莉.ら 提交于 2019-12-31 10:39:47

问题


Samsung devices (well, at least some of them) add all installed apps to an "App Power Saving Mode" list which affects the background services listening to some crucial info for the app.

Some apps, somehow, disable this mode after installation without any extra steps. Comments on Programmatically disable app power saving mode on Samsung thread suggest that apps like Facebook and WhatsApp might be in the OS whitelist but I've seen apps that are not as popular doing the same. Any idea how to achieve this?

I've tried using ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent but no success. PowerManager#isIgnoringBatteryOptimizations starts returning true but neither App Power Saving Mode nor the thing in Battery Saver Settings is disabled for the app.

If you think the only way is to contact Samsung to whitelist the app, where's the best place to do so?

Also, if there's no way to disable App Power Saving Mode programmatically, is there a way to detect if it's enabled for the app so that I can open the app and ask the user to disable it?


回答1:


Hi there are two power save modes:

  • the regular android Doze mode,

  • and the custom "Power save mode.

For doze mode the action:

Intent intent = new Intent(); intent.setAction((Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName))

and start the intent.

But for custom power save modes (especially Huawei and some others) you have to start custom power save modes intents based on vendor. The list is here: https://stackoverflow.com/a/48641229/4606542



来源:https://stackoverflow.com/questions/41722516/disabling-or-detecting-the-app-specific-power-saving-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!