Loading apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +1 −37 Original line number Diff line number Diff line Loading @@ -489,14 +489,6 @@ public class AppStandbyController | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE; /** * Whether we should allow apps into the * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} bucket or not. * If false, any attempts to put an app into the bucket will put the app into the * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RARE} bucket instead. */ private boolean mAllowRestrictedBucket; private volatile boolean mAppIdleEnabled; private volatile boolean mIsCharging; private boolean mSystemServicesReady = false; Loading Loading @@ -1058,13 +1050,6 @@ public class AppStandbyController Slog.d(TAG, "Bringing down to RESTRICTED due to timeout"); } } if (newBucket == STANDBY_BUCKET_RESTRICTED && !mAllowRestrictedBucket) { newBucket = STANDBY_BUCKET_RARE; // Leave the reason alone. if (DEBUG) { Slog.d(TAG, "Bringing up from RESTRICTED to RARE due to off switch"); } } if (newBucket > minBucket) { newBucket = minBucket; // Leave the reason alone. Loading Loading @@ -1689,7 +1674,7 @@ public class AppStandbyController final int reason = (REASON_MAIN_MASK & mainReason) | (REASON_SUB_MASK & restrictReason); final long nowElapsed = mInjector.elapsedRealtime(); final int bucket = mAllowRestrictedBucket ? STANDBY_BUCKET_RESTRICTED : STANDBY_BUCKET_RARE; final int bucket = STANDBY_BUCKET_RESTRICTED; setAppStandbyBucket(packageName, userId, bucket, reason, nowElapsed, false); } Loading Loading @@ -1793,9 +1778,6 @@ public class AppStandbyController Slog.e(TAG, "Tried to set bucket of uninstalled app: " + packageName); return; } if (newBucket == STANDBY_BUCKET_RESTRICTED && !mAllowRestrictedBucket) { newBucket = STANDBY_BUCKET_RARE; } AppIdleHistory.AppUsageHistory app = mAppIdleHistory.getAppUsageHistory(packageName, userId, elapsedRealtime); boolean predicted = (reason & REASON_MAIN_MASK) == REASON_MAIN_PREDICTED; Loading Loading @@ -1921,7 +1903,6 @@ public class AppStandbyController + " due to min timeout"); } } else if (newBucket == STANDBY_BUCKET_RARE && mAllowRestrictedBucket && getBucketForLocked(packageName, userId, elapsedRealtime) == STANDBY_BUCKET_RESTRICTED) { // Prediction doesn't think the app will be used anytime soon and Loading Loading @@ -2529,8 +2510,6 @@ public class AppStandbyController pw.println(); pw.print("mAppIdleEnabled="); pw.print(mAppIdleEnabled); pw.print(" mAllowRestrictedBucket="); pw.print(mAllowRestrictedBucket); pw.print(" mIsCharging="); pw.print(mIsCharging); pw.println(); Loading Loading @@ -2711,12 +2690,6 @@ public class AppStandbyController } } boolean isRestrictedBucketEnabled() { return Global.getInt(mContext.getContentResolver(), Global.ENABLE_RESTRICTED_BUCKET, Global.DEFAULT_ENABLE_RESTRICTED_BUCKET) == 1; } File getDataSystemDirectory() { return Environment.getDataSystemDirectory(); } Loading Loading @@ -3079,11 +3052,6 @@ public class AppStandbyController // APP_STANDBY_ENABLED is a SystemApi that some apps may be watching, so best to // leave it in Settings. cr.registerContentObserver(Global.getUriFor(Global.APP_STANDBY_ENABLED), false, this); // Leave ENABLE_RESTRICTED_BUCKET as a user-controlled setting which will stay in // Settings. // TODO: make setting user-specific cr.registerContentObserver(Global.getUriFor(Global.ENABLE_RESTRICTED_BUCKET), false, this); // ADAPTIVE_BATTERY_MANAGEMENT_ENABLED is a user setting, so it has to stay in Settings. cr.registerContentObserver(Global.getUriFor(Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED), false, this); Loading Loading @@ -3284,10 +3252,6 @@ public class AppStandbyController Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED)); } synchronized (mAppIdleLock) { mAllowRestrictedBucket = mInjector.isRestrictedBucketEnabled(); } setAppIdleEnabled(mInjector.isAppIdleEnabled()); } Loading core/java/android/provider/Settings.java +0 −17 Original line number Diff line number Diff line Loading @@ -14776,23 +14776,6 @@ public final class Settings { public static final String ADAPTIVE_BATTERY_MANAGEMENT_ENABLED = "adaptive_battery_management_enabled"; /** * Whether or not apps are allowed into the * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} bucket. * Type: int (0 for false, 1 for true) * Default: {@value #DEFAULT_ENABLE_RESTRICTED_BUCKET} * * @hide */ @Readable public static final String ENABLE_RESTRICTED_BUCKET = "enable_restricted_bucket"; /** * @see #ENABLE_RESTRICTED_BUCKET * @hide */ public static final int DEFAULT_ENABLE_RESTRICTED_BUCKET = 1; /** * Whether or not app auto restriction is enabled. When it is enabled, settings app will * auto restrict the app if it has bad behavior (e.g. hold wakelock for long time). packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +0 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,6 @@ public class SettingsBackupTest { Settings.Global.ENABLE_DELETION_HELPER_NO_THRESHOLD_TOGGLE, Settings.Global.ENABLE_DISKSTATS_LOGGING, Settings.Global.ENABLE_EPHEMERAL_FEATURE, Settings.Global.ENABLE_RESTRICTED_BUCKET, Settings.Global.ENABLE_TARE, Settings.Global.DYNAMIC_POWER_SAVINGS_ENABLED, Settings.Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD, Loading services/core/java/com/android/server/am/AppRestrictionController.java +2 −36 Original line number Diff line number Diff line Loading @@ -106,7 +106,6 @@ import android.app.role.RoleManager; import android.app.usage.AppStandbyInfo; import android.app.usage.UsageStatsManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; Loading @@ -117,7 +116,6 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo.ForegroundServiceType; import android.database.ContentObserver; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.AppBackgroundRestrictionsInfo; Loading @@ -137,7 +135,6 @@ import android.provider.DeviceConfig; import android.provider.DeviceConfig.OnPropertiesChangedListener; import android.provider.DeviceConfig.Properties; import android.provider.Settings; import android.provider.Settings.Global; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArraySet; Loading Loading @@ -1069,8 +1066,7 @@ public final class AppRestrictionController { } } final class ConstantsObserver extends ContentObserver implements OnPropertiesChangedListener { final class ConstantsObserver implements OnPropertiesChangedListener { /** * Whether or not to set the app to restricted standby bucket automatically * when it's background-restricted. Loading Loading @@ -1181,8 +1177,6 @@ public final class AppRestrictionController { volatile boolean mBgAutoRestrictAbusiveApps; volatile boolean mRestrictedBucketEnabled; volatile long mBgAbusiveNotificationMinIntervalMs; volatile long mBgLongFgsNotificationMinIntervalMs; Loading Loading @@ -1215,7 +1209,6 @@ public final class AppRestrictionController { volatile boolean mBgPromptAbusiveAppsToBgRestricted; ConstantsObserver(Handler handler, Context context) { super(handler); mDefaultBgPromptFgsWithNotiToBgRestricted = context.getResources().getBoolean( com.android.internal.R.bool.config_bg_prompt_fgs_with_noti_to_bg_restricted); mDefaultBgPromptAbusiveAppToBgRestricted = context.getResources().getBoolean( Loading Loading @@ -1261,29 +1254,10 @@ public final class AppRestrictionController { } } @Override public void onChange(boolean selfChange) { updateSettings(); } public void start() { final ContentResolver cr = mContext.getContentResolver(); cr.registerContentObserver(Global.getUriFor(Global.ENABLE_RESTRICTED_BUCKET), false, this); updateSettings(); updateDeviceConfig(); } void updateSettings() { mRestrictedBucketEnabled = isRestrictedBucketEnabled(); } private boolean isRestrictedBucketEnabled() { return Global.getInt(mContext.getContentResolver(), Global.ENABLE_RESTRICTED_BUCKET, Global.DEFAULT_ENABLE_RESTRICTED_BUCKET) == 1; } void updateDeviceConfig() { updateBgAutoRestrictedBucketChanged(); updateBgAutoRestrictAbusiveApps(); Loading Loading @@ -1763,8 +1737,7 @@ public final class AppRestrictionController { .isAppBackgroundRestricted(uid, packageName)) { return new Pair<>(RESTRICTION_LEVEL_BACKGROUND_RESTRICTED, mEmptyTrackerInfo); } level = mConstantsObserver.mRestrictedBucketEnabled && standbyBucket == STANDBY_BUCKET_RESTRICTED level = standbyBucket == STANDBY_BUCKET_RESTRICTED ? RESTRICTION_LEVEL_RESTRICTED_BUCKET : RESTRICTION_LEVEL_ADAPTIVE_BUCKET; if (calcTrackers) { Loading Loading @@ -1811,13 +1784,9 @@ public final class AppRestrictionController { @RestrictionLevel int level = RESTRICTION_LEVEL_UNKNOWN; @RestrictionLevel int prevLevel = level; BaseAppStateTracker resultTracker = null; final boolean isRestrictedBucketEnabled = mConstantsObserver.mRestrictedBucketEnabled; for (int i = mAppStateTrackers.size() - 1; i >= 0; i--) { @RestrictionLevel int l = mAppStateTrackers.get(i).getPolicy() .getProposedRestrictionLevel(packageName, uid, maxLevel); if (!isRestrictedBucketEnabled && l == RESTRICTION_LEVEL_RESTRICTED_BUCKET) { l = RESTRICTION_LEVEL_ADAPTIVE_BUCKET; } level = Math.max(level, l); if (level != prevLevel) { resultTracker = mAppStateTrackers.get(i); Loading Loading @@ -2193,9 +2162,6 @@ public final class AppRestrictionController { } if (level >= RESTRICTION_LEVEL_RESTRICTED_BUCKET && curLevel < RESTRICTION_LEVEL_RESTRICTED_BUCKET) { if (!mConstantsObserver.mRestrictedBucketEnabled) { return; } // Moving the app standby bucket to restricted in the meanwhile. if (DEBUG_BG_RESTRICTION_CONTROLLER && level == RESTRICTION_LEVEL_BACKGROUND_RESTRICTED) { Loading services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java +0 −50 Original line number Diff line number Diff line Loading @@ -232,7 +232,6 @@ public class AppStandbyControllerTests { long mElapsedRealtime; boolean mIsAppIdleEnabled = true; boolean mIsCharging; boolean mIsRestrictedBucketEnabled = true; List<String> mNonIdleWhitelistApps = new ArrayList<>(); boolean mDisplayOn; DisplayManager.DisplayListener mDisplayListener; Loading Loading @@ -315,11 +314,6 @@ public class AppStandbyControllerTests { void updatePowerWhitelistCache() { } @Override boolean isRestrictedBucketEnabled() { return mIsRestrictedBucketEnabled; } @Override File getDataSystemDirectory() { return new File(getContext().getFilesDir(), Long.toString(sRandom.nextLong())); Loading Loading @@ -1353,50 +1347,6 @@ public class AppStandbyControllerTests { assertBucket(STANDBY_BUCKET_RESTRICTED); } @Test @FlakyTest(bugId = 185169504) public void testRestrictedBucketDisabled() throws Exception { mInjector.mIsRestrictedBucketEnabled = false; // Get the controller to read the new value. Capturing the ContentObserver isn't possible // at the moment. mController.onBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY); reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1); mInjector.mElapsedRealtime += RESTRICTED_THRESHOLD; // Nothing should be able to put it into the RESTRICTED bucket. mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_TIMEOUT); assertNotBucket(STANDBY_BUCKET_RESTRICTED); mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_PREDICTED); assertNotBucket(STANDBY_BUCKET_RESTRICTED); mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_FORCED_BY_SYSTEM); assertNotBucket(STANDBY_BUCKET_RESTRICTED); mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_FORCED_BY_USER); assertNotBucket(STANDBY_BUCKET_RESTRICTED); } @Test @FlakyTest(bugId = 185169504) public void testRestrictedBucket_EnabledToDisabled() throws Exception { reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1); mInjector.mElapsedRealtime += RESTRICTED_THRESHOLD; mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_FORCED_BY_SYSTEM); assertBucket(STANDBY_BUCKET_RESTRICTED); mInjector.mIsRestrictedBucketEnabled = false; // Get the controller to read the new value. Capturing the ContentObserver isn't possible // at the moment. mController.onBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY); mController.checkIdleStates(USER_ID); assertNotBucket(STANDBY_BUCKET_RESTRICTED); } @Test @FlakyTest(bugId = 185169504) public void testPredictionRaiseFromRestrictedTimeout_highBucket() throws Exception { Loading Loading
apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +1 −37 Original line number Diff line number Diff line Loading @@ -489,14 +489,6 @@ public class AppStandbyController | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE; /** * Whether we should allow apps into the * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} bucket or not. * If false, any attempts to put an app into the bucket will put the app into the * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RARE} bucket instead. */ private boolean mAllowRestrictedBucket; private volatile boolean mAppIdleEnabled; private volatile boolean mIsCharging; private boolean mSystemServicesReady = false; Loading Loading @@ -1058,13 +1050,6 @@ public class AppStandbyController Slog.d(TAG, "Bringing down to RESTRICTED due to timeout"); } } if (newBucket == STANDBY_BUCKET_RESTRICTED && !mAllowRestrictedBucket) { newBucket = STANDBY_BUCKET_RARE; // Leave the reason alone. if (DEBUG) { Slog.d(TAG, "Bringing up from RESTRICTED to RARE due to off switch"); } } if (newBucket > minBucket) { newBucket = minBucket; // Leave the reason alone. Loading Loading @@ -1689,7 +1674,7 @@ public class AppStandbyController final int reason = (REASON_MAIN_MASK & mainReason) | (REASON_SUB_MASK & restrictReason); final long nowElapsed = mInjector.elapsedRealtime(); final int bucket = mAllowRestrictedBucket ? STANDBY_BUCKET_RESTRICTED : STANDBY_BUCKET_RARE; final int bucket = STANDBY_BUCKET_RESTRICTED; setAppStandbyBucket(packageName, userId, bucket, reason, nowElapsed, false); } Loading Loading @@ -1793,9 +1778,6 @@ public class AppStandbyController Slog.e(TAG, "Tried to set bucket of uninstalled app: " + packageName); return; } if (newBucket == STANDBY_BUCKET_RESTRICTED && !mAllowRestrictedBucket) { newBucket = STANDBY_BUCKET_RARE; } AppIdleHistory.AppUsageHistory app = mAppIdleHistory.getAppUsageHistory(packageName, userId, elapsedRealtime); boolean predicted = (reason & REASON_MAIN_MASK) == REASON_MAIN_PREDICTED; Loading Loading @@ -1921,7 +1903,6 @@ public class AppStandbyController + " due to min timeout"); } } else if (newBucket == STANDBY_BUCKET_RARE && mAllowRestrictedBucket && getBucketForLocked(packageName, userId, elapsedRealtime) == STANDBY_BUCKET_RESTRICTED) { // Prediction doesn't think the app will be used anytime soon and Loading Loading @@ -2529,8 +2510,6 @@ public class AppStandbyController pw.println(); pw.print("mAppIdleEnabled="); pw.print(mAppIdleEnabled); pw.print(" mAllowRestrictedBucket="); pw.print(mAllowRestrictedBucket); pw.print(" mIsCharging="); pw.print(mIsCharging); pw.println(); Loading Loading @@ -2711,12 +2690,6 @@ public class AppStandbyController } } boolean isRestrictedBucketEnabled() { return Global.getInt(mContext.getContentResolver(), Global.ENABLE_RESTRICTED_BUCKET, Global.DEFAULT_ENABLE_RESTRICTED_BUCKET) == 1; } File getDataSystemDirectory() { return Environment.getDataSystemDirectory(); } Loading Loading @@ -3079,11 +3052,6 @@ public class AppStandbyController // APP_STANDBY_ENABLED is a SystemApi that some apps may be watching, so best to // leave it in Settings. cr.registerContentObserver(Global.getUriFor(Global.APP_STANDBY_ENABLED), false, this); // Leave ENABLE_RESTRICTED_BUCKET as a user-controlled setting which will stay in // Settings. // TODO: make setting user-specific cr.registerContentObserver(Global.getUriFor(Global.ENABLE_RESTRICTED_BUCKET), false, this); // ADAPTIVE_BATTERY_MANAGEMENT_ENABLED is a user setting, so it has to stay in Settings. cr.registerContentObserver(Global.getUriFor(Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED), false, this); Loading Loading @@ -3284,10 +3252,6 @@ public class AppStandbyController Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED)); } synchronized (mAppIdleLock) { mAllowRestrictedBucket = mInjector.isRestrictedBucketEnabled(); } setAppIdleEnabled(mInjector.isAppIdleEnabled()); } Loading
core/java/android/provider/Settings.java +0 −17 Original line number Diff line number Diff line Loading @@ -14776,23 +14776,6 @@ public final class Settings { public static final String ADAPTIVE_BATTERY_MANAGEMENT_ENABLED = "adaptive_battery_management_enabled"; /** * Whether or not apps are allowed into the * {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} bucket. * Type: int (0 for false, 1 for true) * Default: {@value #DEFAULT_ENABLE_RESTRICTED_BUCKET} * * @hide */ @Readable public static final String ENABLE_RESTRICTED_BUCKET = "enable_restricted_bucket"; /** * @see #ENABLE_RESTRICTED_BUCKET * @hide */ public static final int DEFAULT_ENABLE_RESTRICTED_BUCKET = 1; /** * Whether or not app auto restriction is enabled. When it is enabled, settings app will * auto restrict the app if it has bad behavior (e.g. hold wakelock for long time).
packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +0 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,6 @@ public class SettingsBackupTest { Settings.Global.ENABLE_DELETION_HELPER_NO_THRESHOLD_TOGGLE, Settings.Global.ENABLE_DISKSTATS_LOGGING, Settings.Global.ENABLE_EPHEMERAL_FEATURE, Settings.Global.ENABLE_RESTRICTED_BUCKET, Settings.Global.ENABLE_TARE, Settings.Global.DYNAMIC_POWER_SAVINGS_ENABLED, Settings.Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD, Loading
services/core/java/com/android/server/am/AppRestrictionController.java +2 −36 Original line number Diff line number Diff line Loading @@ -106,7 +106,6 @@ import android.app.role.RoleManager; import android.app.usage.AppStandbyInfo; import android.app.usage.UsageStatsManager; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; Loading @@ -117,7 +116,6 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo.ForegroundServiceType; import android.database.ContentObserver; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.AppBackgroundRestrictionsInfo; Loading @@ -137,7 +135,6 @@ import android.provider.DeviceConfig; import android.provider.DeviceConfig.OnPropertiesChangedListener; import android.provider.DeviceConfig.Properties; import android.provider.Settings; import android.provider.Settings.Global; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.ArraySet; Loading Loading @@ -1069,8 +1066,7 @@ public final class AppRestrictionController { } } final class ConstantsObserver extends ContentObserver implements OnPropertiesChangedListener { final class ConstantsObserver implements OnPropertiesChangedListener { /** * Whether or not to set the app to restricted standby bucket automatically * when it's background-restricted. Loading Loading @@ -1181,8 +1177,6 @@ public final class AppRestrictionController { volatile boolean mBgAutoRestrictAbusiveApps; volatile boolean mRestrictedBucketEnabled; volatile long mBgAbusiveNotificationMinIntervalMs; volatile long mBgLongFgsNotificationMinIntervalMs; Loading Loading @@ -1215,7 +1209,6 @@ public final class AppRestrictionController { volatile boolean mBgPromptAbusiveAppsToBgRestricted; ConstantsObserver(Handler handler, Context context) { super(handler); mDefaultBgPromptFgsWithNotiToBgRestricted = context.getResources().getBoolean( com.android.internal.R.bool.config_bg_prompt_fgs_with_noti_to_bg_restricted); mDefaultBgPromptAbusiveAppToBgRestricted = context.getResources().getBoolean( Loading Loading @@ -1261,29 +1254,10 @@ public final class AppRestrictionController { } } @Override public void onChange(boolean selfChange) { updateSettings(); } public void start() { final ContentResolver cr = mContext.getContentResolver(); cr.registerContentObserver(Global.getUriFor(Global.ENABLE_RESTRICTED_BUCKET), false, this); updateSettings(); updateDeviceConfig(); } void updateSettings() { mRestrictedBucketEnabled = isRestrictedBucketEnabled(); } private boolean isRestrictedBucketEnabled() { return Global.getInt(mContext.getContentResolver(), Global.ENABLE_RESTRICTED_BUCKET, Global.DEFAULT_ENABLE_RESTRICTED_BUCKET) == 1; } void updateDeviceConfig() { updateBgAutoRestrictedBucketChanged(); updateBgAutoRestrictAbusiveApps(); Loading Loading @@ -1763,8 +1737,7 @@ public final class AppRestrictionController { .isAppBackgroundRestricted(uid, packageName)) { return new Pair<>(RESTRICTION_LEVEL_BACKGROUND_RESTRICTED, mEmptyTrackerInfo); } level = mConstantsObserver.mRestrictedBucketEnabled && standbyBucket == STANDBY_BUCKET_RESTRICTED level = standbyBucket == STANDBY_BUCKET_RESTRICTED ? RESTRICTION_LEVEL_RESTRICTED_BUCKET : RESTRICTION_LEVEL_ADAPTIVE_BUCKET; if (calcTrackers) { Loading Loading @@ -1811,13 +1784,9 @@ public final class AppRestrictionController { @RestrictionLevel int level = RESTRICTION_LEVEL_UNKNOWN; @RestrictionLevel int prevLevel = level; BaseAppStateTracker resultTracker = null; final boolean isRestrictedBucketEnabled = mConstantsObserver.mRestrictedBucketEnabled; for (int i = mAppStateTrackers.size() - 1; i >= 0; i--) { @RestrictionLevel int l = mAppStateTrackers.get(i).getPolicy() .getProposedRestrictionLevel(packageName, uid, maxLevel); if (!isRestrictedBucketEnabled && l == RESTRICTION_LEVEL_RESTRICTED_BUCKET) { l = RESTRICTION_LEVEL_ADAPTIVE_BUCKET; } level = Math.max(level, l); if (level != prevLevel) { resultTracker = mAppStateTrackers.get(i); Loading Loading @@ -2193,9 +2162,6 @@ public final class AppRestrictionController { } if (level >= RESTRICTION_LEVEL_RESTRICTED_BUCKET && curLevel < RESTRICTION_LEVEL_RESTRICTED_BUCKET) { if (!mConstantsObserver.mRestrictedBucketEnabled) { return; } // Moving the app standby bucket to restricted in the meanwhile. if (DEBUG_BG_RESTRICTION_CONTROLLER && level == RESTRICTION_LEVEL_BACKGROUND_RESTRICTED) { Loading
services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java +0 −50 Original line number Diff line number Diff line Loading @@ -232,7 +232,6 @@ public class AppStandbyControllerTests { long mElapsedRealtime; boolean mIsAppIdleEnabled = true; boolean mIsCharging; boolean mIsRestrictedBucketEnabled = true; List<String> mNonIdleWhitelistApps = new ArrayList<>(); boolean mDisplayOn; DisplayManager.DisplayListener mDisplayListener; Loading Loading @@ -315,11 +314,6 @@ public class AppStandbyControllerTests { void updatePowerWhitelistCache() { } @Override boolean isRestrictedBucketEnabled() { return mIsRestrictedBucketEnabled; } @Override File getDataSystemDirectory() { return new File(getContext().getFilesDir(), Long.toString(sRandom.nextLong())); Loading Loading @@ -1353,50 +1347,6 @@ public class AppStandbyControllerTests { assertBucket(STANDBY_BUCKET_RESTRICTED); } @Test @FlakyTest(bugId = 185169504) public void testRestrictedBucketDisabled() throws Exception { mInjector.mIsRestrictedBucketEnabled = false; // Get the controller to read the new value. Capturing the ContentObserver isn't possible // at the moment. mController.onBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY); reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1); mInjector.mElapsedRealtime += RESTRICTED_THRESHOLD; // Nothing should be able to put it into the RESTRICTED bucket. mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_TIMEOUT); assertNotBucket(STANDBY_BUCKET_RESTRICTED); mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_PREDICTED); assertNotBucket(STANDBY_BUCKET_RESTRICTED); mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_FORCED_BY_SYSTEM); assertNotBucket(STANDBY_BUCKET_RESTRICTED); mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_FORCED_BY_USER); assertNotBucket(STANDBY_BUCKET_RESTRICTED); } @Test @FlakyTest(bugId = 185169504) public void testRestrictedBucket_EnabledToDisabled() throws Exception { reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1); mInjector.mElapsedRealtime += RESTRICTED_THRESHOLD; mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RESTRICTED, REASON_MAIN_FORCED_BY_SYSTEM); assertBucket(STANDBY_BUCKET_RESTRICTED); mInjector.mIsRestrictedBucketEnabled = false; // Get the controller to read the new value. Capturing the ContentObserver isn't possible // at the moment. mController.onBootPhase(SystemService.PHASE_SYSTEM_SERVICES_READY); mController.checkIdleStates(USER_ID); assertNotBucket(STANDBY_BUCKET_RESTRICTED); } @Test @FlakyTest(bugId = 185169504) public void testPredictionRaiseFromRestrictedTimeout_highBucket() throws Exception { Loading