Revert "Revert "[AAPM] Add advanced protection dialog according ..."
Revert submission 31078830-revert-30767017-aapm-dialog-api-feedback-TBLFTCNTUN Reason for revert: Addressed failing test Reverted changes: /q/submissionid:31078830-revert-30767017-aapm-dialog-api-feedback-TBLFTCNTUN Change-Id: I3321b4f5baaca9dd270350b9201998ffe0d40473
This commit is contained in:
committed by
Android (Google) Code Review
parent
2574343b43
commit
8e28132ba2
@@ -20,9 +20,14 @@ import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.security.advancedprotection.AdvancedProtectionManager.ACTION_SHOW_ADVANCED_PROTECTION_SUPPORT_DIALOG;
|
||||
import static android.security.advancedprotection.AdvancedProtectionManager.ADVANCED_PROTECTION_SYSTEM_ENTITY;
|
||||
import static android.security.advancedprotection.AdvancedProtectionManager.EXTRA_SUPPORT_DIALOG_FEATURE;
|
||||
import static android.security.advancedprotection.AdvancedProtectionManager.EXTRA_SUPPORT_DIALOG_TYPE;
|
||||
import static android.security.advancedprotection.AdvancedProtectionManager.FEATURE_ID_DISALLOW_INSTALL_UNKNOWN_SOURCES;
|
||||
import static android.security.advancedprotection.AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_UNKNOWN;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -40,7 +45,6 @@ import android.os.UserManager;
|
||||
import android.platform.test.annotations.RequiresFlagsEnabled;
|
||||
import android.platform.test.flag.junit.CheckFlagsRule;
|
||||
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
|
||||
import android.security.advancedprotection.AdvancedProtectionManager;
|
||||
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
@@ -48,6 +52,7 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
@@ -59,8 +64,6 @@ public class ActionDisabledByAdminDialogTest {
|
||||
|
||||
@Mock
|
||||
private DevicePolicyManager mDevicePolicyManager;
|
||||
@Mock
|
||||
private AdvancedProtectionManager mAdvancedProtectionManager;
|
||||
|
||||
private ActionDisabledByAdminDialog mDialog;
|
||||
private final ComponentName mAdminComponent = new ComponentName("admin", "adminclass");
|
||||
@@ -70,8 +73,6 @@ public class ActionDisabledByAdminDialogTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mDialog = spy(new ActionDisabledByAdminDialog());
|
||||
doReturn(mDevicePolicyManager).when(mDialog).getSystemService(DevicePolicyManager.class);
|
||||
doReturn(mAdvancedProtectionManager).when(mDialog).getSystemService(
|
||||
AdvancedProtectionManager.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,24 +119,28 @@ public class ActionDisabledByAdminDialogTest {
|
||||
advancedProtectionAuthority, UserHandle.of(userId), mAdminComponent);
|
||||
final String userRestriction = UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY;
|
||||
|
||||
final Intent apmIntent = new Intent(ACTION_SHOW_ADVANCED_PROTECTION_SUPPORT_DIALOG);
|
||||
apmIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||
apmIntent.putExtra(EXTRA_SUPPORT_DIALOG_FEATURE, "featureId");
|
||||
|
||||
final Intent dialogIntent = new Intent();
|
||||
dialogIntent.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||
dialogIntent.putExtra(DevicePolicyManager.EXTRA_RESTRICTION, userRestriction);
|
||||
|
||||
when(mDevicePolicyManager.getEnforcingAdmin(userId, userRestriction))
|
||||
.thenReturn(advancedProtectionEnforcingAdmin);
|
||||
when(mAdvancedProtectionManager.createSupportIntentForPolicyIdentifierOrRestriction(
|
||||
userRestriction, /* type */ null)).thenReturn(apmIntent);
|
||||
doNothing().when(mDialog).startActivityAsUser(apmIntent, UserHandle.of(userId));
|
||||
doNothing().when(mDialog).startActivityAsUser(any(), eq(UserHandle.of(userId)));
|
||||
|
||||
mDialog.getAdminDetailsFromIntent(dialogIntent);
|
||||
|
||||
verify(mDialog).startActivityAsUser(apmIntent, UserHandle.of(userId));
|
||||
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
verify(mDialog).startActivityAsUser(intentCaptor.capture(), eq(UserHandle.of(userId)));
|
||||
assertTrue(mDialog.isFinishing());
|
||||
|
||||
Intent launchedIntent = intentCaptor.getValue();
|
||||
assertEquals("Intent action is incorrect", ACTION_SHOW_ADVANCED_PROTECTION_SUPPORT_DIALOG,
|
||||
launchedIntent.getAction());
|
||||
assertEquals("Feature ID extra is incorrect", FEATURE_ID_DISALLOW_INSTALL_UNKNOWN_SOURCES,
|
||||
launchedIntent.getIntExtra(EXTRA_SUPPORT_DIALOG_FEATURE, -1));
|
||||
assertEquals("Type is incorrect", SUPPORT_DIALOG_TYPE_UNKNOWN,
|
||||
launchedIntent.getIntExtra(EXTRA_SUPPORT_DIALOG_TYPE, -1));
|
||||
assertEquals(FLAG_ACTIVITY_NEW_TASK, launchedIntent.getFlags());
|
||||
}
|
||||
|
||||
@RequiresFlagsEnabled(android.security.Flags.FLAG_AAPM_API)
|
||||
|
@@ -200,7 +200,6 @@ class WepNetworksPreferenceControllerTest {
|
||||
fun whenClick_aapmEnabled_openDialog() {
|
||||
mockAapmManager.stub {
|
||||
on { isAdvancedProtectionEnabled } doReturn true
|
||||
on { createSupportIntent(any(), any()) } doReturn Intent()
|
||||
}
|
||||
doNothing().whenever(context).startActivity(any())
|
||||
composeTestRule.setContent { controller.Content() }
|
||||
|
Reference in New Issue
Block a user