Merge "Fix app standby bugs."

This commit is contained in:
TreeHugger Robot
2020-05-27 19:04:52 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 0 deletions

View File

@@ -1353,6 +1353,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

@@ -446,6 +446,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();
@@ -686,6 +687,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();
}
}
}
}