Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Power Manager of all android manufactures to enable background and push notification?

Some Android devices due to custom Android tweaks are done by manufacturers has some politics about Power Management that breaks some features like push notifications.

  • Huawei - Only Pre-EMUI 5.0 / Android 7 - Go to Settings > "Protected apps", check your app.
  • Sony - Tap on the battery icon. Go to Power Management > STAMINA mode > Apps active in standby > Add your app.
  • Asus - Check your app in the Auto-start Manager.
  • Xiaomi - Security (App) > Permissions > Autostart - Enable your app
  • *New Xiaomi - Settings > Developer Options. Disable "memory optimization". To enabled Developer Options go to Settings > About. Tap on MIUI 8 times.
  • Oppo - Go to Settings > "Security settings" > "Data saving" and enable your app.
  • Samsung - Disable battery usage optimizations

I want to collect intents to launch respective tools, but I have found only for Huawei and Xiaomi.

Intent INTENT_HUAWEI = new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")); Intent INTENT_XIAOMI = new Intent().setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));  if (getPackageManager().resolveActivity(INTENT_HUAWEI, PackageManager.MATCH_DEFAULT_ONLY) != null)     startActivity(INTENT_HUAWEI); else if (getPackageManager().resolveActivity(INTENT_XIAOMI, PackageManager.MATCH_DEFAULT_ONLY) != null)     startActivity(INTENT_XIAOMI); 

I need help from all other producers, thz

like image 205
Xan Avatar asked Jan 09 '18 10:01

Xan


1 Answers

i have collected some intent from various post:

    private static final Intent[] POWERMANAGER_INTENTS = {             new Intent().setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")),             new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),             new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity")),             new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")),             new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity")),             new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")),             new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),             new Intent().setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),             new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")),             new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),             new Intent().setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")),             new Intent().setComponent(new ComponentName("com.samsung.android.lool", "com.samsung.android.sm.battery.ui.BatteryActivity")),             new Intent().setComponent(new ComponentName("com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity")),             new Intent().setComponent(new ComponentName("com.htc.pitroad", "com.htc.pitroad.landingpage.activity.LandingPageActivity")),             new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.MainActivity")),             new Intent().setComponent(new ComponentName("com.transsion.phonemanager", "com.itel.autobootmanager.activity.AutoBootMgrActivity"))     };               for (Intent intent : POWERMANAGER_INTENTS)                 if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {                     // show dialog to ask user action                     break;                 } 

after user agree

for (Intent intent : POWERMANAGER_INTENTS)   if (getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {   startActivity(intent);   break; } 

seams new releases require this permissions

<uses-permission android:name="oppo.permission.OPPO_COMPONENT_SAFE"/> <uses-permission android:name="com.huawei.permission.external_app_settings.USE_COMPONENT"/> 

i want to collect all intent to open power manager, if anyone found mistake or want to improve something, comment here

like image 177
Xan Avatar answered Oct 21 '22 16:10

Xan