Add restrict and unrestrict dialog
Add a fake unrestrict tip so we could reuse the BatteryTipDialogFragment to build the unrestrict dialog. After this cl, restrict dialog has two types: 1. dialog to only restrict one app 2. dialog to restrict more than one app Will add dialog to restrict more than 5 apps when strings are finalized. Bug: 72385333 Bug: 72227981 Test: RunSettingsRoboTests Change-Id: Ib0328f0386efad525b331fd713dd15d060a1a649
This commit is contained in:
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -523,4 +524,27 @@ public class BatteryUtilsTest {
|
||||
public void testIsLegacyApp_SdkLargerOrEqualThanO_ReturnFalse() {
|
||||
assertThat(mBatteryUtils.isLegacyApp(HIGH_SDK_PACKAGE)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetForceAppStandby_forcePreOApp_forceTwoRestrictions() {
|
||||
mBatteryUtils.setForceAppStandby(UID, LOW_SDK_PACKAGE, AppOpsManager.MODE_IGNORED);
|
||||
|
||||
// Restrict both OP_RUN_IN_BACKGROUND and OP_RUN_ANY_IN_BACKGROUND
|
||||
verify(mAppOpsManager).setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, UID, LOW_SDK_PACKAGE,
|
||||
AppOpsManager.MODE_IGNORED);
|
||||
verify(mAppOpsManager).setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UID, LOW_SDK_PACKAGE,
|
||||
AppOpsManager.MODE_IGNORED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetForceAppStandby_forceOApp_forceOneRestriction() {
|
||||
mBatteryUtils.setForceAppStandby(UID, HIGH_SDK_PACKAGE, AppOpsManager.MODE_IGNORED);
|
||||
|
||||
// Don't restrict OP_RUN_IN_BACKGROUND because it is already been restricted for O app
|
||||
verify(mAppOpsManager, never()).setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, UID,
|
||||
HIGH_SDK_PACKAGE, AppOpsManager.MODE_IGNORED);
|
||||
// Restrict OP_RUN_ANY_IN_BACKGROUND
|
||||
verify(mAppOpsManager).setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, UID,
|
||||
HIGH_SDK_PACKAGE, AppOpsManager.MODE_IGNORED);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user