diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 269aa1bb77299..be79cdd59680b 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -5795,7 +5795,7 @@ - 9 + 25 diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java index 053551309661f..8ccb7ed57ef1f 100644 --- a/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java @@ -58,6 +58,7 @@ import static com.android.server.am.AppPermissionTracker.AppPermissionPolicy; import static com.android.server.am.AppRestrictionController.STOCK_PM_FLAGS; import static com.android.server.am.BaseAppStateTracker.STATE_TYPE_FGS_LOCATION; import static com.android.server.am.BaseAppStateTracker.STATE_TYPE_FGS_MEDIA_PLAYBACK; +import static com.android.server.am.BaseAppStateTracker.STATE_TYPE_FGS_WITH_NOTIFICATION; import static com.android.server.am.BaseAppStateTracker.STATE_TYPE_MEDIA_SESSION; import static com.android.server.am.BaseAppStateTracker.STATE_TYPE_PERMISSION; @@ -112,6 +113,7 @@ import android.os.UidBatteryConsumer; import android.os.UserHandle; import android.permission.PermissionManager; import android.provider.DeviceConfig; +import android.service.notification.StatusBarNotification; import android.telephony.TelephonyManager; import android.util.Log; import android.util.Pair; @@ -563,6 +565,7 @@ public final class BackgroundRestrictionTest { DeviceConfigSession bgCurrentDrainBgRestrictedThreshold = null; DeviceConfigSession bgPromptFgsWithNotiToBgRestricted = null; DeviceConfigSession bgNotificationMinInterval = null; + DeviceConfigSession bgBatteryExemptionTypes = null; mBgRestrictionController.addAppBackgroundRestrictionListener(listener); @@ -624,16 +627,25 @@ public final class BackgroundRestrictionTest { ConstantsObserver.DEFAULT_BG_ABUSIVE_NOTIFICATION_MINIMAL_INTERVAL_MS); bgNotificationMinInterval.set(windowMs); + bgBatteryExemptionTypes = new DeviceConfigSession<>( + DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, + AppBatteryPolicy.KEY_BG_CURRENT_DRAIN_EXEMPTED_TYPES, + DeviceConfig::getInt, + mContext.getResources().getInteger( + R.integer.config_bg_current_drain_exempted_types)); + bgBatteryExemptionTypes.set(0); + mCurrentTimeMillis = 10_000L; doReturn(mCurrentTimeMillis - windowMs).when(stats).getStatsStartTimestamp(); doReturn(mCurrentTimeMillis).when(stats).getStatsEndTimestamp(); doReturn(statsList).when(mBatteryStatsInternal).getBatteryUsageStats(anyObject()); - doReturn(true).when(mNotificationManagerInternal).isNotificationShown( - testPkgName, null, notificationId, testUser); mAppFGSTracker.onForegroundServiceStateChanged(testPkgName, testUid, testPid, true); mAppFGSTracker.onForegroundServiceNotificationUpdated( testPkgName, testUid, notificationId); + mAppFGSTracker.mNotificationListener.onNotificationPosted(new StatusBarNotification( + testPkgName, null, notificationId, null, testUid, testPid, + new Notification(), UserHandle.of(testUser), null, mCurrentTimeMillis), null); runTestBgCurrentDrainMonitorOnce(listener, stats, uids, new double[]{restrictBucketThresholdMah - 1, 0}, @@ -912,6 +924,7 @@ public final class BackgroundRestrictionTest { closeIfNotNull(bgCurrentDrainBgRestrictedThreshold); closeIfNotNull(bgPromptFgsWithNotiToBgRestricted); closeIfNotNull(bgNotificationMinInterval); + closeIfNotNull(bgBatteryExemptionTypes); } } @@ -1247,14 +1260,15 @@ public final class BackgroundRestrictionTest { List, Long>> mediaControllers, List topStateChanges, VerificationMode mode) throws Exception { runExemptionTestOnce( - packageName, uid, pid, serviceType, sleepMs, true, perm, mediaControllers, + packageName, uid, pid, serviceType, sleepMs, true, false, perm, mediaControllers, topStateChanges, true, true, () -> checkNotificationShown(new String[] {packageName}, mode, false) ); } private void runExemptionTestOnce(String packageName, int uid, int pid, - int serviceType, long sleepMs, boolean stopAfterSleep, String perm, + int serviceType, long sleepMs, boolean stopAfterSleep, + boolean withNotification, String perm, List, Long>> mediaControllers, List topStateChanges, boolean resetFGSTracker, boolean resetController, RunnableWithException r) throws Exception { @@ -1299,7 +1313,20 @@ public final class BackgroundRestrictionTest { FOREGROUND_SERVICE_TYPE_NONE); } } - + if (withNotification) { + final int notificationId = 1000; + mAppFGSTracker.onForegroundServiceNotificationUpdated( + packageName, uid, notificationId); + final StatusBarNotification noti = new StatusBarNotification( + packageName, null, notificationId, null, uid, pid, + new Notification(), UserHandle.of(UserHandle.getUserId(uid)), + null, mCurrentTimeMillis); + mAppFGSTracker.mNotificationListener.onNotificationPosted(noti, null); + Thread.sleep(sleepMs); + if (stopAfterSleep) { + mAppFGSTracker.mNotificationListener.onNotificationRemoved(noti, null, 0); + } + } if (perm != null) { doReturn(PERMISSION_GRANTED) .when(mPermissionManagerServiceInternal) @@ -1510,7 +1537,8 @@ public final class BackgroundRestrictionTest { mContext.getResources().getInteger( R.integer.config_bg_current_drain_exempted_types)); bgBatteryExemptionTypes.set(STATE_TYPE_MEDIA_SESSION | STATE_TYPE_FGS_MEDIA_PLAYBACK - | STATE_TYPE_FGS_LOCATION | STATE_TYPE_PERMISSION); + | STATE_TYPE_FGS_LOCATION | STATE_TYPE_PERMISSION + | STATE_TYPE_FGS_WITH_NOTIFICATION); bgPermissionMonitorEnabled = new DeviceConfigSession<>( DeviceConfig.NAMESPACE_ACTIVITY_MANAGER, @@ -1543,7 +1571,7 @@ public final class BackgroundRestrictionTest { // Run with a media playback service which starts/stops immediately, we should // goto the restricted bucket. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, 0, true, + FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, 0, true, false, null, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1553,7 +1581,7 @@ public final class BackgroundRestrictionTest { // Run with a media playback service with extended time. We should be back to normal. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, bgMediaPlaybackMinDuration * 2, false, - null, null, null, listener, stats, uids, + false, null, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, true, RESTRICTION_LEVEL_ADAPTIVE_BUCKET, timeout, false, @@ -1582,7 +1610,7 @@ public final class BackgroundRestrictionTest { // Run with a media playback service with extended time, with higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, bgMediaPlaybackMinDuration * 2, false, - null, null, null, listener, stats, uids, + false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah - 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, true, RESTRICTION_LEVEL_RESTRICTED_BUCKET, timeout, true, @@ -1591,7 +1619,7 @@ public final class BackgroundRestrictionTest { // Run with a media playback service with extended time, with even higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, bgMediaPlaybackMinDuration * 2, false, - null, null, null, listener, stats, uids, + false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, false, RESTRICTION_LEVEL_RESTRICTED_BUCKET, timeout, false, @@ -1604,8 +1632,8 @@ public final class BackgroundRestrictionTest { // Run with a media session with extended time, with higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, null, - List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, + FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, false, + null, List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, new int[] {testUid1}), bgMediaPlaybackMinDuration * 2)), null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah - 1, 0}, @@ -1615,8 +1643,8 @@ public final class BackgroundRestrictionTest { // Run with a media session with extended time, with even higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, null, - List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, + FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, false, + null, List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, new int[] {testUid1}), bgMediaPlaybackMinDuration * 2)), null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah + 1, 0}, @@ -1632,8 +1660,8 @@ public final class BackgroundRestrictionTest { // Run with a media session with extended time, with moderate current drain, // but it ran on the top when the location service is active. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, null, - List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, + FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, false, + null, List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, new int[] {testUid1}), bgMediaPlaybackMinDuration * 2)), List.of(0L, timeout * 2), listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, @@ -1648,7 +1676,7 @@ public final class BackgroundRestrictionTest { // Run with a location service with extended time, with higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, + FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah - 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1657,7 +1685,7 @@ public final class BackgroundRestrictionTest { // Run with a location service with extended time, with even higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, + FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1672,7 +1700,7 @@ public final class BackgroundRestrictionTest { // Run with a location service with extended time, with moderate current drain, // but it ran on the top when the location service is active. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, + FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, false, null, null, List.of(0L, timeout * 2), listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1689,7 +1717,7 @@ public final class BackgroundRestrictionTest { // Run with bg location permission, with moderate current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, 0, false, + FOREGROUND_SERVICE_TYPE_NONE, 0, false, false, ACCESS_BACKGROUND_LOCATION, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah - 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1698,7 +1726,7 @@ public final class BackgroundRestrictionTest { // Run with bg location permission, with a bit higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, 0, false, + FOREGROUND_SERVICE_TYPE_NONE, 0, false, false, ACCESS_BACKGROUND_LOCATION, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1715,7 +1743,7 @@ public final class BackgroundRestrictionTest { // Run with bg location permission, with higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, 0, false, + FOREGROUND_SERVICE_TYPE_NONE, 0, false, false, ACCESS_BACKGROUND_LOCATION , null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah - 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1724,7 +1752,7 @@ public final class BackgroundRestrictionTest { // Run with bg location permission, with even higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, 0, false, + FOREGROUND_SERVICE_TYPE_NONE, 0, false, false, ACCESS_BACKGROUND_LOCATION , null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1746,7 +1774,7 @@ public final class BackgroundRestrictionTest { // Run with a media playback service which starts/stops immediately, we should // goto the restricted bucket. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, 0, true, + FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, 0, true, false, null, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1756,7 +1784,7 @@ public final class BackgroundRestrictionTest { // Run with a media playback service with extended time. We should be back to normal. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, bgMediaPlaybackMinDuration * 2, false, - null, null, null, listener, stats, uids, + false, null, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, true, RESTRICTION_LEVEL_ADAPTIVE_BUCKET, timeout, false, @@ -1787,7 +1815,7 @@ public final class BackgroundRestrictionTest { // Run with a media playback service with extended time, with higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, bgMediaPlaybackMinDuration * 2, false, - null, null, null, listener, stats, uids, + false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah - 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, true, RESTRICTION_LEVEL_RESTRICTED_BUCKET, timeout, true, @@ -1798,7 +1826,7 @@ public final class BackgroundRestrictionTest { // playback. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, bgMediaPlaybackMinDuration * 2, false, - null, null, null, listener, stats, uids, + false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah + 100, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, true, RESTRICTION_LEVEL_RESTRICTED_BUCKET, timeout, false, @@ -1813,7 +1841,7 @@ public final class BackgroundRestrictionTest { // Run with coarse location permission, with high current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, 0, false, + FOREGROUND_SERVICE_TYPE_NONE, 0, false, false, ACCESS_COARSE_LOCATION, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1827,7 +1855,7 @@ public final class BackgroundRestrictionTest { // Run with fine location permission, with high current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, 0, false, + FOREGROUND_SERVICE_TYPE_NONE, 0, false, false, ACCESS_FINE_LOCATION, null, null, listener, stats, uids, new double[]{restrictBucketThresholdMah + 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1841,8 +1869,8 @@ public final class BackgroundRestrictionTest { // Run with a media session with extended time, with higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, null, - List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, + FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, false, + null, List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, new int[] {testUid1}), bgMediaPlaybackMinDuration * 2)), null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah - 1, 0}, @@ -1854,8 +1882,8 @@ public final class BackgroundRestrictionTest { // it still should stay in the current restriction level as we exempt the media // session. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, null, - List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, + FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, false, + null, List.of(Pair.create(createMediaControllers(new String[] {testPkgName1}, new int[] {testUid1}), bgMediaPlaybackMinDuration * 2)), null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah + 100, 0}, @@ -1863,9 +1891,51 @@ public final class BackgroundRestrictionTest { true, RESTRICTION_LEVEL_RESTRICTED_BUCKET, timeout, true, null, windowMs, initialBg, initialFgs, initialFg); + // Set the policy to exempt fgs with notifications. + bgBatteryExemptionTypes.set(STATE_TYPE_FGS_WITH_NOTIFICATION); + // Start over. + resetBgRestrictionController(); + setUidBatteryConsumptions(stats, uids, zeros, zeros, zeros); + mAppBatteryPolicy.reset(); + + // Run with a FGS with notification posted/removed immediately, we should + // goto the restricted bucket. + runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, + FOREGROUND_SERVICE_TYPE_NONE, 0, true, true, + null, null, null, listener, stats, uids, + new double[]{restrictBucketThresholdMah + 1, 0}, + new double[]{0, restrictBucketThresholdMah - 1}, zeros, + false, RESTRICTION_LEVEL_RESTRICTED_BUCKET, timeout, true, + null, windowMs, null, null, null); + + // Run with a service with notification for extended time. We should be back to normal. + runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, + FOREGROUND_SERVICE_TYPE_NONE, bgMediaPlaybackMinDuration * 2, false, + true, null, null, null, listener, stats, uids, + new double[]{restrictBucketThresholdMah + 1, 0}, + new double[]{0, restrictBucketThresholdMah - 1}, zeros, + true, RESTRICTION_LEVEL_ADAPTIVE_BUCKET, timeout, false, + () -> { + // A user interaction will bring it back to normal. + mIdleStateListener.onUserInteractionStarted(testPkgName1, + UserHandle.getUserId(testUid1)); + waitForIdleHandler(mBgRestrictionController.getBackgroundHandler()); + // It should have been back to normal. + listener.verify(timeout, testUid1, testPkgName1, + RESTRICTION_LEVEL_ADAPTIVE_BUCKET); + verify(mInjector.getAppStandbyInternal(), times(1)).maybeUnrestrictApp( + eq(testPkgName1), + eq(UserHandle.getUserId(testUid1)), + eq(REASON_MAIN_FORCED_BY_SYSTEM), + eq(REASON_SUB_FORCED_SYSTEM_FLAG_ABUSE), + eq(REASON_MAIN_USAGE), + eq(REASON_SUB_USAGE_USER_INTERACTION)); + }, windowMs, null, null, null); + // Set the policy to exempt all. bgBatteryExemptionTypes.set(STATE_TYPE_MEDIA_SESSION | STATE_TYPE_FGS_MEDIA_PLAYBACK - | STATE_TYPE_FGS_LOCATION | STATE_TYPE_PERMISSION); + | STATE_TYPE_FGS_LOCATION | STATE_TYPE_PERMISSION + | STATE_TYPE_FGS_WITH_NOTIFICATION); // Start over. resetBgRestrictionController(); @@ -1874,7 +1944,7 @@ public final class BackgroundRestrictionTest { // Run with a location service with extended time, with higher current drain. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, + FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah - 1, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1884,7 +1954,7 @@ public final class BackgroundRestrictionTest { // Run with a location service with extended time, with even higher current drain. // it still should stay in the current restriction level as we exempt the location. runTestBgCurrentDrainExemptionOnce(testPkgName1, testUid1, testPid1, - FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, + FOREGROUND_SERVICE_TYPE_LOCATION, bgMediaPlaybackMinDuration * 2, false, false, null, null, null, listener, stats, uids, new double[]{restrictBucketHighThresholdMah + 100, 0}, new double[]{0, restrictBucketThresholdMah - 1}, zeros, @@ -1909,8 +1979,8 @@ public final class BackgroundRestrictionTest { } private void runTestBgCurrentDrainExemptionOnce(String packageName, int uid, int pid, - int serviceType, long sleepMs, boolean stopAfterSleep, String perm, - List, Long>> mediaControllers, + int serviceType, long sleepMs, boolean stopAfterSleep, boolean withNotification, + String perm, List, Long>> mediaControllers, List topStateChanges, TestAppRestrictionLevelListener listener, BatteryUsageStats stats, int[] uids, double[] bg, double[] fgs, double[] fg, boolean expectingTimeout, int expectingLevel, long timeout, boolean resetFGSTracker, @@ -1936,7 +2006,7 @@ public final class BackgroundRestrictionTest { } waitForIdleHandler(mBgRestrictionController.getBackgroundHandler()); runExemptionTestOnce( - packageName, uid, pid, serviceType, sleepMs, stopAfterSleep, + packageName, uid, pid, serviceType, sleepMs, stopAfterSleep, withNotification, perm, mediaControllers, topStateChanges, resetFGSTracker, false, () -> { clearInvocations(mInjector.getAppStandbyInternal());