Loading core/java/android/content/pm/ILauncherApps.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ interface ILauncherApps { PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component, in UserHandle user); LauncherUserInfo getLauncherUserInfo(in UserHandle user); List<String> getPreInstalledSystemPackages(in UserHandle user); void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage, String callingFeatureId, in ComponentName component, in Rect sourceBounds, in Bundle opts, in UserHandle user); Loading core/java/android/content/pm/LauncherApps.java +23 −0 Original line number Diff line number Diff line Loading @@ -799,6 +799,29 @@ 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. * * @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) public List<String> getPreInstalledSystemPackages(@NonNull UserHandle userHandle) { if (DEBUG) { Log.i(TAG, "getPreInstalledSystemPackages for user: " + userHandle); } try { return mService.getPreInstalledSystemPackages(userHandle); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns the activity info for a given intent and user handle, if it resolves. Otherwise it * returns null. Loading services/core/java/com/android/server/pm/LauncherAppsService.java +24 −0 Original line number Diff line number Diff line Loading @@ -1574,6 +1574,30 @@ public class LauncherAppsService extends SystemService { } } @Override public List<String> getPreInstalledSystemPackages(UserHandle user) { // Only system launchers, which have access to recents should have access to this API. // TODO(b/303803157): Update access control for this API to default Launcher app. if (!mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid())) { throw new SecurityException("Caller is not the recents app"); } if (!canAccessProfile(user.getIdentifier(), "Can't access preinstalled packages for another user")) { return null; } final long identity = Binder.clearCallingIdentity(); try { String userType = mUm.getUserInfo(user.getIdentifier()).userType; Set<String> preInstalledPackages = mUm.getPreInstallableSystemPackages(userType); if (preInstalledPackages == null) { return new ArrayList<>(); } return List.copyOf(preInstalledPackages); } finally { Binder.restoreCallingIdentity(identity); } } @Override public void startActivityAsUser(IApplicationThread caller, String callingPackage, String callingFeatureId, ComponentName component, Rect sourceBounds, Loading Loading
core/java/android/content/pm/ILauncherApps.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ interface ILauncherApps { PendingIntent getActivityLaunchIntent(String callingPackage, in ComponentName component, in UserHandle user); LauncherUserInfo getLauncherUserInfo(in UserHandle user); List<String> getPreInstalledSystemPackages(in UserHandle user); void showAppDetailsAsUser(in IApplicationThread caller, String callingPackage, String callingFeatureId, in ComponentName component, in Rect sourceBounds, in Bundle opts, in UserHandle user); Loading
core/java/android/content/pm/LauncherApps.java +23 −0 Original line number Diff line number Diff line Loading @@ -799,6 +799,29 @@ 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. * * @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) public List<String> getPreInstalledSystemPackages(@NonNull UserHandle userHandle) { if (DEBUG) { Log.i(TAG, "getPreInstalledSystemPackages for user: " + userHandle); } try { return mService.getPreInstalledSystemPackages(userHandle); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns the activity info for a given intent and user handle, if it resolves. Otherwise it * returns null. Loading
services/core/java/com/android/server/pm/LauncherAppsService.java +24 −0 Original line number Diff line number Diff line Loading @@ -1574,6 +1574,30 @@ public class LauncherAppsService extends SystemService { } } @Override public List<String> getPreInstalledSystemPackages(UserHandle user) { // Only system launchers, which have access to recents should have access to this API. // TODO(b/303803157): Update access control for this API to default Launcher app. if (!mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid())) { throw new SecurityException("Caller is not the recents app"); } if (!canAccessProfile(user.getIdentifier(), "Can't access preinstalled packages for another user")) { return null; } final long identity = Binder.clearCallingIdentity(); try { String userType = mUm.getUserInfo(user.getIdentifier()).userType; Set<String> preInstalledPackages = mUm.getPreInstallableSystemPackages(userType); if (preInstalledPackages == null) { return new ArrayList<>(); } return List.copyOf(preInstalledPackages); } finally { Binder.restoreCallingIdentity(identity); } } @Override public void startActivityAsUser(IApplicationThread caller, String callingPackage, String callingFeatureId, ComponentName component, Rect sourceBounds, Loading