diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d9e759b8366..26e7e12e3d6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -4460,19 +4460,6 @@
-
-
-
-
-
-
-
Your device administrator may be able to access data
associated with this device, manage apps, and change this device\’s settings.
-
- Prevented by Advanced Protection
-
- This action is not allowed because Advanced Protection is on for your device.
-
Turn off
diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java
index b0d0af1eefb..e05ae71a05a 100644
--- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java
+++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java
@@ -109,9 +109,12 @@ public class ActionDisabledByAdminDialog extends Activity
}
if (enforcingAdmin.getAuthority() instanceof UnknownAuthority authority
&& ADVANCED_PROTECTION_SYSTEM_ENTITY.equals(authority.getName())) {
- Intent apmSupportIntent = AdvancedProtectionManager
- .createSupportIntentForPolicyIdentifierOrRestriction(restriction,
- AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_UNKNOWN);
+ AdvancedProtectionManager apm = getSystemService(AdvancedProtectionManager.class);
+ if (apm == null) {
+ return;
+ }
+ Intent apmSupportIntent = apm.createSupportIntentForPolicyIdentifierOrRestriction(
+ restriction, /* type */ null);
startActivityAsUser(apmSupportIntent, UserHandle.of(userId));
finish();
} else {
diff --git a/src/com/android/settings/security/ActionDisabledByAdvancedProtectionDialog.kt b/src/com/android/settings/security/ActionDisabledByAdvancedProtectionDialog.kt
deleted file mode 100644
index d56f8958ac3..00000000000
--- a/src/com/android/settings/security/ActionDisabledByAdvancedProtectionDialog.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.security;
-
-import android.app.Activity
-import android.content.DialogInterface
-import android.os.Bundle
-import android.view.View
-import android.view.ViewGroup
-import android.widget.TextView
-import com.android.settings.R
-
-import androidx.appcompat.app.AlertDialog;
-
-class ActionDisabledByAdvancedProtectionDialog : Activity(), DialogInterface.OnDismissListener {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- val dialogView = layoutInflater.inflate(R.layout.support_details_dialog, null) as ViewGroup
- val builder = AlertDialog.Builder(this)
- .setPositiveButton(R.string.okay, null)
- .setView(dialogView)
- .setOnDismissListener(this)
- initializeDialogView(dialogView)
- builder.show()
- }
-
- override fun onDismiss(dialog: DialogInterface) {
- finish()
- }
-
- private fun initializeDialogView(dialogView: View) {
- setSupportTitle(dialogView)
- setSupportDetails(dialogView)
- }
-
- private fun setSupportTitle(root: View) {
- val titleView: TextView = root.findViewById(R.id.admin_support_dialog_title) ?: return
- titleView.setText(R.string.disabled_by_advanced_protection_title)
- }
-
- private fun setSupportDetails(root: View) {
- val textView: TextView = root.findViewById(R.id.admin_support_msg)
- textView.setText(R.string.disabled_by_advanced_protection_message)
- }
-}
diff --git a/src/com/android/settings/wifi/WepNetworksPreferenceController.kt b/src/com/android/settings/wifi/WepNetworksPreferenceController.kt
index 59c67eef9ff..92716bec4ff 100644
--- a/src/com/android/settings/wifi/WepNetworksPreferenceController.kt
+++ b/src/com/android/settings/wifi/WepNetworksPreferenceController.kt
@@ -162,10 +162,10 @@ class WepNetworksPreferenceController(context: Context, preferenceKey: String) :
emit(aapmManager?.isAdvancedProtectionEnabled ?: false) }.flowOn(Dispatchers.Default)
private fun startSupportIntent() {
- AdvancedProtectionManager.createSupportIntent(
+ aapmManager?.createSupportIntent(
AdvancedProtectionManager.FEATURE_ID_DISALLOW_WEP,
AdvancedProtectionManager.SUPPORT_DIALOG_TYPE_DISABLED_SETTING
- ).let { mContext.startActivity(it) }
+ )?.let { mContext.startActivity(it) }
}
val wepAllowedFlow =
diff --git a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogTest.java b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogTest.java
index 37e04247f89..4b7abec906a 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogTest.java
@@ -20,14 +20,9 @@ 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;
@@ -45,6 +40,7 @@ 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;
@@ -52,7 +48,6 @@ 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;
@@ -64,6 +59,8 @@ public class ActionDisabledByAdminDialogTest {
@Mock
private DevicePolicyManager mDevicePolicyManager;
+ @Mock
+ private AdvancedProtectionManager mAdvancedProtectionManager;
private ActionDisabledByAdminDialog mDialog;
private final ComponentName mAdminComponent = new ComponentName("admin", "adminclass");
@@ -73,6 +70,8 @@ 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
@@ -119,28 +118,24 @@ 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);
- doNothing().when(mDialog).startActivityAsUser(any(), eq(UserHandle.of(userId)));
+ when(mAdvancedProtectionManager.createSupportIntentForPolicyIdentifierOrRestriction(
+ userRestriction, /* type */ null)).thenReturn(apmIntent);
+ doNothing().when(mDialog).startActivityAsUser(apmIntent, UserHandle.of(userId));
mDialog.getAdminDetailsFromIntent(dialogIntent);
- ArgumentCaptor intentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mDialog).startActivityAsUser(intentCaptor.capture(), eq(UserHandle.of(userId)));
+ verify(mDialog).startActivityAsUser(apmIntent, 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)
diff --git a/tests/spa_unit/src/com/android/settings/wifi/WepNetworksPreferenceControllerTest.kt b/tests/spa_unit/src/com/android/settings/wifi/WepNetworksPreferenceControllerTest.kt
index 74107571b0d..1f0a4916310 100644
--- a/tests/spa_unit/src/com/android/settings/wifi/WepNetworksPreferenceControllerTest.kt
+++ b/tests/spa_unit/src/com/android/settings/wifi/WepNetworksPreferenceControllerTest.kt
@@ -200,6 +200,7 @@ 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() }