Merge "Ensure hibernation exemption toggle uses pre-S flag" into sc-dev

This commit is contained in:
Rajeev Kumar
2021-05-26 16:46:58 +00:00
committed by Android (Google) Code Review
3 changed files with 30 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ import static android.app.AppOpsManager.OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED;
import static android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION;
import static com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED;
import static com.android.settings.Utils.PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
@@ -143,4 +144,18 @@ public class HibernationSwitchPreferenceControllerTest {
verify(mPreference).setChecked(false);
}
@Test
public void updateState_exemptedByDefaultPackageOverriddenByPreSFlag_shouldCheck() {
DeviceConfig.setProperty(NAMESPACE_APP_HIBERNATION, PROPERTY_HIBERNATION_TARGETS_PRE_S_APPS,
"true", true /* makeDefault */);
when(mAppOpsManager.unsafeCheckOpNoThrow(
eq(OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED), anyInt(), eq(EXEMPTED_PACKAGE_NAME)))
.thenReturn(MODE_DEFAULT);
mController.setPackage(EXEMPTED_PACKAGE_NAME);
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
}
}