Ensure hibernation exemption toggle uses pre-S flag
For dogfood, we want hibernation to target apps that target pre-S. This was done on the PermissionController side but the toggle in Settings did not visually reflect this policy, confusing dogfood/teamfood participants. This updates the default toggle position to consider whether the pre-S flag is on and then default to the "on" position for apps targeting pre-S if the flag was on for the device. Bug: 189260947 Test: atest HibernationSwitchPreferenceControllerTest Test: manual Change-Id: I9cd16e82e1eee4589cb17a356b6bf2e3297a8dd2
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user