Merge changes from topics "ecm-manager", "ecm-tests" into main
* changes: Replace ECM AppOps call with service Wired remaining SpecialAppAccess for ECM.
This commit is contained in:
@@ -36,6 +36,9 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.annotations.RequiresFlagsDisabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -45,6 +48,7 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -58,6 +62,8 @@ public class ApprovalPreferenceControllerTest {
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(
|
||||
SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT);
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
|
||||
private Context mContext;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
@@ -122,6 +128,7 @@ public class ApprovalPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS)
|
||||
public void updateState_checked() {
|
||||
when(mAppOpsManager.noteOpNoThrow(anyInt(), anyInt(), anyString())).thenReturn(
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
@@ -136,19 +143,26 @@ public class ApprovalPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS)
|
||||
public void restrictedSettings_appOpsDisabled() {
|
||||
when(mAppOpsManager.noteOpNoThrow(anyInt(), anyInt(), anyString())).thenReturn(
|
||||
AppOpsManager.MODE_ERRORED);
|
||||
Assert.assertFalse(android.security.Flags.extendEcmToAllSettings());
|
||||
when(mAppOpsManager.noteOpNoThrow(anyInt(), anyInt(), anyString()))
|
||||
.thenReturn(AppOpsManager.MODE_ERRORED);
|
||||
doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
|
||||
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(false);
|
||||
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(
|
||||
mContext);
|
||||
pref.setAppOps(mAppOpsManager);
|
||||
mController.setSettingIdentifier(AppOpsManager.OPSTR_ACCESS_NOTIFICATIONS);
|
||||
|
||||
mController.updateState(pref);
|
||||
|
||||
verify(mAppOpsManager).noteOpNoThrow(anyInt(), anyInt(), anyString());
|
||||
assertThat(pref.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsDisabled(android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS)
|
||||
public void restrictedSettings_serviceAlreadyEnabled() {
|
||||
when(mAppOpsManager.noteOpNoThrow(anyInt(), anyInt(), anyString())).thenReturn(
|
||||
AppOpsManager.MODE_ERRORED);
|
||||
|
||||
Reference in New Issue
Block a user