Replace ECM AppOps call with service
A new ECM service was introcuded in changeId I831391e4437b51b3312b5273a2360bd029a3d8ee. We begin calling it, and update/cleanup method signatures to match. Note: There are two feature flags: 1. enhancedConfirmationModeApisEnabled - read only, protects the mainline API. 2. extendEcmToAllSettings - runtime - gates calls to the above APIs. We use both so we can ramp up in teamfood as needed. Bug: 297372999 Test: Tested on device Test: atest SpaPrivilegedLibTests Test: atest com.android.settings.applications.specialaccess.notificationaccess Test: atest com.android.settings.datausage Test: atest PremiumSmsAccessTest Test: atest RestrictedPreferenceHelperTest Change-Id: I945ec51df5cd63de548a8ffdd1acc4f09f2301e5
This commit is contained in:
@@ -31,8 +31,10 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
import android.security.Flags;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
@@ -81,6 +83,8 @@ public class RestrictedPreferenceHelperTest {
|
||||
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
@Rule
|
||||
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
|
||||
|
||||
@Test
|
||||
public void createAccessibilityServicePreferenceList_hasOneInfo_containsSameKey() {
|
||||
@@ -96,8 +100,9 @@ public class RestrictedPreferenceHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(value = {android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS,
|
||||
android.permission.flags.Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED})
|
||||
public void createAccessibilityServicePreferenceList_ecmRestricted_prefIsEcmRestricted() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS);
|
||||
ShadowRestrictedLockUtilsInternal.setEcmRestrictedPkgs(
|
||||
mServiceInfo.getResolveInfo().serviceInfo.packageName);
|
||||
final List<AccessibilityServiceInfo> infoList = new ArrayList<>(
|
||||
@@ -111,8 +116,9 @@ public class RestrictedPreferenceHelperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresFlagsEnabled(value = {android.security.Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS,
|
||||
android.permission.flags.Flags.FLAG_ENHANCED_CONFIRMATION_MODE_APIS_ENABLED})
|
||||
public void createAccessibilityServicePreferenceList_ecmNotRestricted_prefIsNotEcmRestricted() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_EXTEND_ECM_TO_ALL_SETTINGS);
|
||||
ShadowRestrictedLockUtilsInternal.setEcmRestrictedPkgs();
|
||||
final List<AccessibilityServiceInfo> infoList = new ArrayList<>(
|
||||
singletonList(mServiceInfo));
|
||||
|
||||
Reference in New Issue
Block a user