Merge "Fix app standby bugs." into rvc-dev am: 9d62182591

Change-Id: Idbbd4057092a921f37d0178e9d8246705d7f04bd
This commit is contained in:
TreeHugger Robot
2020-05-27 23:44:59 +00:00
committed by Automerger Merge Worker
2 changed files with 10 additions and 0 deletions

View File

@@ -1322,6 +1322,8 @@ public class AppStandbyController implements AppStandbyInternal {
private void setAppStandbyBucket(String packageName, int userId, @StandbyBuckets int newBucket,
int reason, long elapsedRealtime, boolean resetTimeout) {
if (!mAppIdleEnabled) return;
synchronized (mAppIdleLock) {
// If the package is not installed, don't allow the bucket to be set.
if (!mInjector.isPackageInstalled(packageName, 0, userId)) {

View File

@@ -448,6 +448,7 @@ public class AppStateTracker {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_REMOVED);
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
mContext.registerReceiver(new MyReceiver(), filter);
refreshForcedAppStandbyUidPackagesLocked();
@@ -688,6 +689,13 @@ public class AppStateTracker {
mIsPluggedIn = (intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0);
}
updateForceAllAppStandbyState();
} else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())
&& !intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
final String pkgName = intent.getData().getSchemeSpecificPart();
if (mExemptedPackages.remove(userId, pkgName)) {
mHandler.notifyExemptChanged();
}
}
}
}