diff options
author | Dianne Hackborn <hackbod@google.com> | 2015-10-12 10:59:47 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2015-10-12 10:59:47 -0700 |
commit | 1b79ad74ef392540ee6ba39348d041716f027be7 (patch) | |
tree | 74a2e45e0a64680f05e02bfff03404d2bc4351fb /services | |
parent | 09e405d660c0fe696402d10732084888192ca446 (diff) | |
download | frameworks_base-1b79ad74ef392540ee6ba39348d041716f027be7.zip frameworks_base-1b79ad74ef392540ee6ba39348d041716f027be7.tar.gz frameworks_base-1b79ad74ef392540ee6ba39348d041716f027be7.tar.bz2 |
Fix issue #23581553: Ignore Battery Optimization not work for re-install app
Remove from whitelist as appropriate. Also be sure we can find whitelisted
apps even if they are not installed in the primary user.
Change-Id: I3ed13dca99b3ba177af8f7bd26a75258df9b6949
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/DeviceIdleController.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java index 80fd441..d2d4b7b 100644 --- a/services/core/java/com/android/server/DeviceIdleController.java +++ b/services/core/java/com/android/server/DeviceIdleController.java @@ -242,6 +242,14 @@ public class DeviceIdleController extends SystemService if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { int plugged = intent.getIntExtra("plugged", 0); updateChargingLocked(plugged != 0); + } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { + if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { + Uri data = intent.getData(); + String ssp; + if (data != null && (ssp=data.getSchemeSpecificPart()) != null) { + removePowerSaveWhitelistAppInternal(ssp); + } + } } else if (ACTION_STEP_IDLE_STATE.equals(intent.getAction())) { synchronized (DeviceIdleController.this) { stepIdleStateLocked(); @@ -912,6 +920,10 @@ public class DeviceIdleController extends SystemService filter.addAction(Intent.ACTION_BATTERY_CHANGED); filter.addAction(ACTION_STEP_IDLE_STATE); getContext().registerReceiver(mReceiver, filter); + filter = new IntentFilter(); + filter.addAction(Intent.ACTION_PACKAGE_REMOVED); + filter.addDataScheme("package"); + getContext().registerReceiver(mReceiver, filter); mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray); @@ -924,7 +936,10 @@ public class DeviceIdleController extends SystemService public boolean addPowerSaveWhitelistAppInternal(String name) { synchronized (this) { try { - ApplicationInfo ai = getContext().getPackageManager().getApplicationInfo(name, 0); + ApplicationInfo ai = getContext().getPackageManager().getApplicationInfo(name, + PackageManager.GET_UNINSTALLED_PACKAGES + | PackageManager.GET_DISABLED_COMPONENTS + | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS); if (mPowerSaveWhitelistUserApps.put(name, UserHandle.getAppId(ai.uid)) == null) { reportPowerSaveWhitelistChangedLocked(); updateWhitelistAppIdsLocked(); @@ -1518,7 +1533,6 @@ public class DeviceIdleController extends SystemService } catch (IOException e) { } } - } private void readConfigFileLocked(XmlPullParser parser) { @@ -1547,7 +1561,10 @@ public class DeviceIdleController extends SystemService String name = parser.getAttributeValue(null, "n"); if (name != null) { try { - ApplicationInfo ai = pm.getApplicationInfo(name, 0); + ApplicationInfo ai = pm.getApplicationInfo(name, + PackageManager.GET_UNINSTALLED_PACKAGES + | PackageManager.GET_DISABLED_COMPONENTS + | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS); mPowerSaveWhitelistUserApps.put(ai.packageName, UserHandle.getAppId(ai.uid)); } catch (PackageManager.NameNotFoundException e) { |