Wired remaining SpecialAppAccess for ECM.

This change enables the remaining settings for ECM, and adds tests for
both this and previous ECM changes.

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: I73d39d765dba0c1a75111c37b29ccf1c85d2cdd8
This commit is contained in:
Hani Kazmi
2023-11-10 16:19:51 +00:00
parent 73b273d781
commit 96ab2b9e25
11 changed files with 343 additions and 14 deletions

View File

@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -137,14 +138,19 @@ public class ApprovalPreferenceControllerTest {
@Test
public void restrictedSettings_appOpsDisabled() {
when(mAppOpsManager.noteOpNoThrow(anyInt(), anyInt(), anyString())).thenReturn(
AppOpsManager.MODE_ERRORED);
when(mAppOpsManager.noteOpNoThrow(anyInt(), anyInt(), anyString(), isNull(), isNull()))
.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.setAppOpStr(AppOpsManager.OPSTR_ACCESS_NOTIFICATIONS);
mController.updateState(pref);
verify(mContext).getSystemService(Context.APP_OPS_SERVICE);
verify(mAppOpsManager).noteOpNoThrow(anyInt(), anyInt(), anyString(), isNull(), isNull());
assertThat(pref.isEnabled()).isFalse();
}