diff options
| author | 2024-02-14 18:07:50 +0000 | |
|---|---|---|
| committer | 2024-02-14 18:07:50 +0000 | |
| commit | 0b95567e7baefe1b6419918a7a069d795cd3dada (patch) | |
| tree | 3a5db7231fa02bf6e4da81c3f0ae6e1392b74bf8 | |
| parent | a27b3a52273a9266706cede34425a458f6c03261 (diff) | |
| parent | b1482d7fb289554cba8c9bde0809d86e520a9657 (diff) | |
Merge "Making hidden LauncherApps APIs public" into main
| -rw-r--r-- | core/api/current.txt | 14 | ||||
| -rw-r--r-- | core/api/system-current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/content/pm/LauncherApps.java | 36 | ||||
| -rw-r--r-- | core/java/android/content/pm/LauncherUserInfo.java | 7 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 9 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/LauncherAppsService.java | 3 |
6 files changed, 45 insertions, 27 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 301dbfa0b9b4..9758791eae39 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12475,8 +12475,11 @@ package android.content.pm { public class LauncherApps { method public java.util.List<android.content.pm.LauncherActivityInfo> getActivityList(String, android.os.UserHandle); method @NonNull public java.util.List<android.content.pm.PackageInstaller.SessionInfo> getAllPackageInstallerSessions(); + method @FlaggedApi("android.os.allow_private_profile") @Nullable @RequiresPermission(conditional=true, anyOf={"android.permission.ACCESS_HIDDEN_PROFILES_FULL", android.Manifest.permission.ACCESS_HIDDEN_PROFILES}) public android.content.IntentSender getAppMarketActivityIntent(@Nullable String, @NonNull android.os.UserHandle); method public android.content.pm.ApplicationInfo getApplicationInfo(@NonNull String, int, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException; + method @FlaggedApi("android.os.allow_private_profile") @Nullable @RequiresPermission(conditional=true, anyOf={"android.permission.ACCESS_HIDDEN_PROFILES_FULL", android.Manifest.permission.ACCESS_HIDDEN_PROFILES}) public final android.content.pm.LauncherUserInfo getLauncherUserInfo(@NonNull android.os.UserHandle); method public android.content.pm.LauncherApps.PinItemRequest getPinItemRequest(android.content.Intent); + method @FlaggedApi("android.os.allow_private_profile") @NonNull @RequiresPermission(conditional=true, anyOf={"android.permission.ACCESS_HIDDEN_PROFILES_FULL", android.Manifest.permission.ACCESS_HIDDEN_PROFILES}) public java.util.List<java.lang.String> getPreInstalledSystemPackages(@NonNull android.os.UserHandle); method public java.util.List<android.os.UserHandle> getProfiles(); method public android.graphics.drawable.Drawable getShortcutBadgedIconDrawable(android.content.pm.ShortcutInfo, int); method @Nullable public android.content.IntentSender getShortcutConfigActivityIntent(@NonNull android.content.pm.LauncherActivityInfo); @@ -12558,6 +12561,14 @@ package android.content.pm { field public static final int FLAG_MATCH_PINNED_BY_ANY_LAUNCHER = 1024; // 0x400 } + @FlaggedApi("android.os.allow_private_profile") public final class LauncherUserInfo implements android.os.Parcelable { + method @FlaggedApi("android.os.allow_private_profile") public int describeContents(); + method @FlaggedApi("android.os.allow_private_profile") public int getUserSerialNumber(); + method @FlaggedApi("android.os.allow_private_profile") @NonNull public String getUserType(); + method @FlaggedApi("android.os.allow_private_profile") public void writeToParcel(@NonNull android.os.Parcel, int); + field @FlaggedApi("android.os.allow_private_profile") @NonNull public static final android.os.Parcelable.Creator<android.content.pm.LauncherUserInfo> CREATOR; + } + public final class ModuleInfo implements android.os.Parcelable { method public int describeContents(); method @Nullable public CharSequence getName(); @@ -34036,6 +34047,9 @@ package android.os { field public static final int USER_OPERATION_ERROR_MAX_USERS = 6; // 0x6 field public static final int USER_OPERATION_ERROR_UNKNOWN = 1; // 0x1 field public static final int USER_OPERATION_SUCCESS = 0; // 0x0 + field @FlaggedApi("android.os.allow_private_profile") public static final String USER_TYPE_PROFILE_CLONE = "android.os.usertype.profile.CLONE"; + field @FlaggedApi("android.os.allow_private_profile") public static final String USER_TYPE_PROFILE_MANAGED = "android.os.usertype.profile.MANAGED"; + field @FlaggedApi("android.os.allow_private_profile") public static final String USER_TYPE_PROFILE_PRIVATE = "android.os.usertype.profile.PRIVATE"; } public static class UserManager.UserOperationException extends java.lang.RuntimeException { diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 5f6b66df9e2b..e4f76fea1631 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -11094,9 +11094,6 @@ package android.os { field public static final String USER_TYPE_FULL_GUEST = "android.os.usertype.full.GUEST"; field public static final String USER_TYPE_FULL_SECONDARY = "android.os.usertype.full.SECONDARY"; field public static final String USER_TYPE_FULL_SYSTEM = "android.os.usertype.full.SYSTEM"; - field public static final String USER_TYPE_PROFILE_CLONE = "android.os.usertype.profile.CLONE"; - field public static final String USER_TYPE_PROFILE_MANAGED = "android.os.usertype.profile.MANAGED"; - field @FlaggedApi("android.os.allow_private_profile") public static final String USER_TYPE_PROFILE_PRIVATE = "android.os.usertype.profile.PRIVATE"; field public static final String USER_TYPE_SYSTEM_HEADLESS = "android.os.usertype.system.HEADLESS"; } diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index 7c264f65d471..9c859c442355 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -17,6 +17,8 @@ package android.content.pm; import static android.Manifest.permission; +import static android.Manifest.permission.ACCESS_HIDDEN_PROFILES; +import static android.Manifest.permission.ACCESS_HIDDEN_PROFILES_FULL; import static android.Manifest.permission.READ_FRAME_BUFFER; import android.annotation.CallbackExecutor; @@ -779,15 +781,20 @@ public class LauncherApps { /** * Returns information related to a user which is useful for displaying UI elements - * to distinguish it from other users (eg, badges). Only system launchers should - * call this API. + * to distinguish it from other users (eg, badges). * - * @param userHandle user handle of the user for which LauncherUserInfo is requested - * @return the LauncherUserInfo object related to the user specified. - * @hide + * <p>If the user in question is a hidden profile like + * {@link UserManager.USER_TYPE_PROFILE_PRIVATE}, caller should have + * {@link android.app.role.RoleManager.ROLE_HOME} and either of the permissions required. + * + * @param userHandle user handle of the user for which LauncherUserInfo is requested. + * @return the {@link LauncherUserInfo} object related to the user specified, null in case + * the user is inaccessible. */ @Nullable @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) + @RequiresPermission(conditional = true, + anyOf = {ACCESS_HIDDEN_PROFILES_FULL, ACCESS_HIDDEN_PROFILES}) public final LauncherUserInfo getLauncherUserInfo(@NonNull UserHandle userHandle) { if (DEBUG) { Log.i(TAG, "getLauncherUserInfo " + userHandle); @@ -823,17 +830,20 @@ public class LauncherApps { * </ul> * </p> * - * + * <p>If the user in question is a hidden profile + * {@link UserManager.USER_TYPE_PROFILE_PRIVATE}, caller should have + * {@link android.app.role.RoleManager.ROLE_HOME} and either of the permissions required. * * @param packageName the package for which intent sender to launch App Market Activity is * required. * @param user the profile for which intent sender to launch App Market Activity is required. * @return {@link IntentSender} object which launches the App Market Activity, null in case * there is no such activity. - * @hide */ @Nullable @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) + @RequiresPermission(conditional = true, + anyOf = {ACCESS_HIDDEN_PROFILES_FULL, ACCESS_HIDDEN_PROFILES}) public IntentSender getAppMarketActivityIntent(@Nullable String packageName, @NonNull UserHandle user) { if (DEBUG) { @@ -851,15 +861,21 @@ public class LauncherApps { /** * Returns the list of the system packages that are installed at user creation. * - * <p>An empty list denotes that all system packages are installed for that user at creation. - * This behaviour is inherited from the underlining UserManager API. + * <p>An empty list denotes that all system packages should be treated as pre-installed for that + * user at creation. + * + * <p>If the user in question is a hidden profile like + * {@link UserManager.USER_TYPE_PROFILE_PRIVATE}, caller should have + * {@link android.app.role.RoleManager.ROLE_HOME} and either of the permissions required. * * @param userHandle the user for which installed system packages are required. * @return {@link List} of {@link String}, representing the package name of the installed * package. Can be empty but not null. - * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) + @NonNull + @RequiresPermission(conditional = true, + anyOf = {ACCESS_HIDDEN_PROFILES_FULL, ACCESS_HIDDEN_PROFILES}) public List<String> getPreInstalledSystemPackages(@NonNull UserHandle userHandle) { if (DEBUG) { Log.i(TAG, "getPreInstalledSystemPackages for user: " + userHandle); diff --git a/core/java/android/content/pm/LauncherUserInfo.java b/core/java/android/content/pm/LauncherUserInfo.java index 214c3e48db71..8426f54d4754 100644 --- a/core/java/android/content/pm/LauncherUserInfo.java +++ b/core/java/android/content/pm/LauncherUserInfo.java @@ -27,8 +27,6 @@ import android.os.UserManager; /** * The LauncherUserInfo object holds information about an Android user that is required to display * the Launcher related UI elements specific to the user (like badges). - * - * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public final class LauncherUserInfo implements Parcelable { @@ -41,11 +39,9 @@ public final class LauncherUserInfo implements Parcelable { /** * Returns type of the user as defined in {@link UserManager}. e.g., * {@link UserManager.USER_TYPE_PROFILE_MANAGED} or {@link UserManager.USER_TYPE_PROFILE_ClONE} - * TODO(b/303812736): Make the return type public and update javadoc here once the linked bug - * is resolved. + * or {@link UserManager.USER_TYPE_PROFILE_PRIVATE} * * @return the userType for the user whose LauncherUserInfo this is - * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) @NonNull @@ -58,7 +54,6 @@ public final class LauncherUserInfo implements Parcelable { * {@link UserManager#getSerialNumberForUser(UserHandle)} * * @return the serial number associated with the user - * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_PRIVATE_PROFILE) public int getUserSerialNumber() { diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 8b31f8bed4b5..4cf45f7344ef 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -163,19 +163,16 @@ public class UserManager { * User type representing a managed profile, which is a profile that is to be managed by a * device policy controller (DPC). * The intended purpose is for work profiles, which are managed by a corporate entity. - * @hide */ - @SystemApi + @FlaggedApi(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE) public static final String USER_TYPE_PROFILE_MANAGED = "android.os.usertype.profile.MANAGED"; /** * User type representing a clone profile. Clone profile is a user profile type used to run * second instance of an otherwise single user App (eg, messengers). Currently only the * {@link android.content.pm.UserInfo#isMain()} user can have a clone profile. - * - * @hide */ - @SystemApi + @FlaggedApi(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE) public static final String USER_TYPE_PROFILE_CLONE = "android.os.usertype.profile.CLONE"; @@ -184,10 +181,8 @@ public class UserManager { * as an alternative user-space to install and use sensitive apps. * UI surfaces can adopt an alternative strategy to show apps belonging to this profile, in line * with their sensitive nature. - * @hide */ @FlaggedApi(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE) - @SystemApi public static final String USER_TYPE_PROFILE_PRIVATE = "android.os.usertype.profile.PRIVATE"; /** diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index 295528e14ca7..f9d81127fd86 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -1625,10 +1625,11 @@ public class LauncherAppsService extends SystemService { } @Override + @NonNull public List<String> getPreInstalledSystemPackages(UserHandle user) { if (!canAccessProfile(user.getIdentifier(), "Can't access preinstalled packages for another user")) { - return null; + return new ArrayList<>(); } final long identity = Binder.clearCallingIdentity(); try { |