[AAPM] Update ActionDisabledByAdminDialog and ExternalSourcesDetails strings

The new advanced protection support intent will be launched by the
existing ActionDisabledByAdminDialog if the enforcing admin of a certain
restriction is advanced protection. To determine that, Change-Id
If931dcddad508f88aac1280b587da4767b937875 introduces an API to query the
enforcing admin.

In addition, this change updates ExternalSourcesDetails to display
a disabled by advanced protection string in the preference summary.

Tests will be written in a follow up change.

Bug: 358229113
Bug: 369361373
Test: manual
Test: atest ActionDisabledByAdminDialogTest
Test: atest ExternalSourcesDetailsTest
Test: atest LocationInjectedServicesPreferenceControllerTest
Flag: android.security.aapm_api
Flag: android.security.aapm_feature_disable_install_unknown_sources
Change-Id: Icedef421d65f7ccde6562734e39a87d4458567ff
This commit is contained in:
Azhara Assanova
2024-10-31 11:00:25 +00:00
parent e1573f84b3
commit 47e665802b
4 changed files with 89 additions and 25 deletions

View File

@@ -26,6 +26,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyResourcesManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.UserInfo;
@@ -83,6 +84,8 @@ public class LocationInjectedServicesPreferenceControllerTest {
private AppSettingsInjector mSettingsInjector;
@Mock
private DevicePolicyManager mDevicePolicyManager;
@Mock
private DevicePolicyResourcesManager mDevicePolicyResourcesManager;
private Context mContext;
private LocationInjectedServicesPreferenceController mController;
@@ -104,6 +107,7 @@ public class LocationInjectedServicesPreferenceControllerTest {
when(mCategoryPrimary.getKey()).thenReturn(key);
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
.thenReturn(mDevicePolicyManager);
when(mDevicePolicyManager.getResources()).thenReturn(mDevicePolicyResourcesManager);
}
@Test
@@ -276,6 +280,7 @@ public class LocationInjectedServicesPreferenceControllerTest {
UserHandle.of(userId),
enforcingUsers);
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(componentName);
when(mDevicePolicyResourcesManager.getString(any(), any())).thenReturn(any());
mController.displayPreference(mScreen);