Add number of enterprise-installed apps to Privacy Settings page
This CL adds information about the number of apps that were installed by the admin to the Enterprise Privacy Settings page. Test: make RunSettingsRoboTests Bug: 32692748 Change-Id: Ib710a1249db6d285da962122fd3dfb35a43752a1
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.applications;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
@@ -49,6 +50,9 @@ public final class ApplicationFeatureProviderImplTest {
|
||||
private final int MAIN_USER_ID = 0;
|
||||
private final int MANAGED_PROFILE_ID = 10;
|
||||
|
||||
private final String APP_1 = "app1";
|
||||
private final String APP_2 = "app2";
|
||||
|
||||
private @Mock UserManager mUserManager;
|
||||
private @Mock Context mContext;
|
||||
private @Mock PackageManagerWrapper mPackageManager;
|
||||
@@ -78,22 +82,32 @@ public final class ApplicationFeatureProviderImplTest {
|
||||
| PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS
|
||||
| PackageManager.MATCH_ANY_USER,
|
||||
MAIN_USER_ID)).thenReturn(Arrays.asList(
|
||||
ApplicationTestUtils.buildInfo(MAIN_USER_ID, "app1", 0 /* flags */)));
|
||||
ApplicationTestUtils.buildInfo(MAIN_USER_ID, APP_1, 0 /* flags */)));
|
||||
when(mPackageManager.getInstallReason(APP_1, new UserHandle(MAIN_USER_ID)))
|
||||
.thenReturn(PackageManager.INSTALL_REASON_UNKNOWN);
|
||||
|
||||
when(mPackageManager.getInstalledApplicationsAsUser(PackageManager.GET_DISABLED_COMPONENTS
|
||||
| PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS,
|
||||
MANAGED_PROFILE_ID)).thenReturn(Arrays.asList(
|
||||
ApplicationTestUtils.buildInfo(MANAGED_PROFILE_ID, "app2", 0 /* flags */)));
|
||||
ApplicationTestUtils.buildInfo(MANAGED_PROFILE_ID, APP_2, 0 /* flags */)));
|
||||
when(mPackageManager.getInstallReason(APP_2, new UserHandle(MANAGED_PROFILE_ID)))
|
||||
.thenReturn(PackageManager.INSTALL_REASON_POLICY);
|
||||
|
||||
mProvider.calculateNumberOfInstalledApps(
|
||||
new ApplicationFeatureProvider.NumberOfInstalledAppsCallback() {
|
||||
@Override
|
||||
public void onNumberOfInstalledAppsResult(int num) {
|
||||
numberOfInstalledApps[0] = num;
|
||||
}
|
||||
// Count all installed apps.
|
||||
mProvider.calculateNumberOfInstalledApps(ApplicationFeatureProvider.IGNORE_INSTALL_REASON,
|
||||
(num) -> {
|
||||
numberOfInstalledApps[0] = num;
|
||||
});
|
||||
ShadowApplication.runBackgroundTasks();
|
||||
|
||||
assertThat(numberOfInstalledApps[0]).isEqualTo(2);
|
||||
|
||||
// Count apps with specific install reason only.
|
||||
numberOfInstalledApps[0] = null;
|
||||
mProvider.calculateNumberOfInstalledApps(PackageManager.INSTALL_REASON_POLICY,
|
||||
(num) -> {
|
||||
numberOfInstalledApps[0] = num;
|
||||
});
|
||||
ShadowApplication.runBackgroundTasks();
|
||||
assertThat(numberOfInstalledApps[0]).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user