summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorAdam Bookatz <bookatz@google.com>2021-06-04 11:35:21 -0700
committerAdam Bookatz <bookatz@google.com>2021-06-07 14:33:35 -0700
commit55fdb3106a9285b5f4ea3727e19df247276faa3d (patch)
tree2b61bd52260173e990e1e88637686d7a91b87eff /core/java/android
parent1e372e67447df15b52a687066a12097fc38e7a60 (diff)
TestApi for UserSystemPackageInstaller
Introduces a TestApi that lists which system packages will be pre-installed for the given user type, for use with CTS tests that need to predict which packages are installed on a new user. Test: atest com.android.cts.devicepolicy.DeviceOwnerTest#testCreateAndManageUser_LeaveAllSystemApps Bug: 189873486 Change-Id: I471c5da55f8cf500a07de5773050a997ea391892
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/IUserManager.aidl1
-rw-r--r--core/java/android/os/UserManager.java29
2 files changed, 30 insertions, 0 deletions
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index 9a8194240f8e..3bee4b73dc22 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -46,6 +46,7 @@ interface IUserManager {
UserInfo createProfileForUserWithThrow(in String name, in String userType, int flags, int userId,
in String[] disallowedPackages);
UserInfo createRestrictedProfileWithThrow(String name, int parentUserHandle);
+ String[] getPreInstallableSystemPackages(in String userType);
void setUserEnabled(int userId);
void setUserAdmin(int userId);
void evictCredentialEncryptionKey(int userId);
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 224cd84bc777..59b6ae278e40 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -26,6 +26,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.StringDef;
import android.annotation.SuppressAutoDoc;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
@@ -53,6 +54,7 @@ import android.location.LocationManager;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.AndroidException;
+import android.util.ArraySet;
import android.view.WindowManager.LayoutParams;
import com.android.internal.R;
@@ -3200,6 +3202,33 @@ public class UserManager {
}
/**
+ * Returns the list of the system packages that would be installed on this type of user upon
+ * its creation.
+ *
+ * Returns {@code null} if all system packages would be installed.
+ *
+ * @hide
+ */
+ @TestApi
+ @SuppressLint("NullableCollection")
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.MANAGE_USERS,
+ android.Manifest.permission.CREATE_USERS
+ })
+ public @Nullable Set<String> getPreInstallableSystemPackages(@NonNull String userType) {
+ try {
+ final String[] installableSystemPackages
+ = mService.getPreInstallableSystemPackages(userType);
+ if (installableSystemPackages == null) {
+ return null;
+ }
+ return new ArraySet<>(installableSystemPackages);
+ } catch (RemoteException re) {
+ throw re.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* @hide
*
* Returns the preferred account name for user creation.