Loading core/java/android/content/pm/ILauncherApps.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ interface ILauncherApps { in UserHandle user); LauncherUserInfo getLauncherUserInfo(in UserHandle user); List<String> getPreInstalledSystemPackages(in UserHandle user); IntentSender getAppMarketActivityIntent(String callingPackage, String packageName, 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 +49 −0 Original line number Diff line number Diff line Loading @@ -799,6 +799,55 @@ public class LauncherApps { } } /** * Returns an intent sender which can be used to start the App Market activity (Installer * Activity). * This method is primarily used to get an intent sender which starts App Market activity for * another profile, if the caller is not otherwise allowed to start activity in that profile. * * <p>When packageName is set, intent sender to start the App Market Activity which installed * the package in calling user will be returned, but for the profile passed. * * <p>When packageName is not set, intent sender to launch the default App Market Activity for * the profile will be returned. In case there are multiple App Market Activities available for * the profile, IntentPicker will be started, allowing user to choose the preferred activity. * * <p>The method will fall back to the behaviour of not having the packageName set, in case: * <ul> * <li>No activity for the packageName is found in calling user-space.</li> * <li>The App Market Activity which installed the package in calling user-space is not * present.</li> * <li>The App Market Activity which installed the package in calling user-space is not * present in the profile passed.</li> * </ul> * </p> * * * * @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) public IntentSender getAppMarketActivityIntent(@Nullable String packageName, @NonNull UserHandle user) { if (DEBUG) { Log.i(TAG, "getAppMarketActivityIntent for package: " + packageName + " user: " + user); } try { return mService.getAppMarketActivityIntent(mContext.getPackageName(), packageName, user); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns the list of the system packages that are installed at user creation. * Loading services/core/java/com/android/server/pm/LauncherAppsService.java +27 −0 Original line number Diff line number Diff line Loading @@ -1598,6 +1598,33 @@ public class LauncherAppsService extends SystemService { } } @Override public @Nullable IntentSender getAppMarketActivityIntent(@NonNull String callingPackage, @Nullable String packageName, @NonNull 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 AppMarketActivity for another user")) { return null; } final long identity = Binder.clearCallingIdentity(); try { // TODO(b/316118005): Add code to launch the app installer for the packageName. Intent appMarketIntent = new Intent(Intent.ACTION_MAIN); appMarketIntent.addCategory(Intent.CATEGORY_APP_MARKET); final PendingIntent pi = PendingIntent.getActivityAsUser( mContext, /* requestCode */ 0, appMarketIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT, /* options */ null, user); return pi == null ? null : pi.getIntentSender(); } 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 +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ interface ILauncherApps { in UserHandle user); LauncherUserInfo getLauncherUserInfo(in UserHandle user); List<String> getPreInstalledSystemPackages(in UserHandle user); IntentSender getAppMarketActivityIntent(String callingPackage, String packageName, 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 +49 −0 Original line number Diff line number Diff line Loading @@ -799,6 +799,55 @@ public class LauncherApps { } } /** * Returns an intent sender which can be used to start the App Market activity (Installer * Activity). * This method is primarily used to get an intent sender which starts App Market activity for * another profile, if the caller is not otherwise allowed to start activity in that profile. * * <p>When packageName is set, intent sender to start the App Market Activity which installed * the package in calling user will be returned, but for the profile passed. * * <p>When packageName is not set, intent sender to launch the default App Market Activity for * the profile will be returned. In case there are multiple App Market Activities available for * the profile, IntentPicker will be started, allowing user to choose the preferred activity. * * <p>The method will fall back to the behaviour of not having the packageName set, in case: * <ul> * <li>No activity for the packageName is found in calling user-space.</li> * <li>The App Market Activity which installed the package in calling user-space is not * present.</li> * <li>The App Market Activity which installed the package in calling user-space is not * present in the profile passed.</li> * </ul> * </p> * * * * @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) public IntentSender getAppMarketActivityIntent(@Nullable String packageName, @NonNull UserHandle user) { if (DEBUG) { Log.i(TAG, "getAppMarketActivityIntent for package: " + packageName + " user: " + user); } try { return mService.getAppMarketActivityIntent(mContext.getPackageName(), packageName, user); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Returns the list of the system packages that are installed at user creation. * Loading
services/core/java/com/android/server/pm/LauncherAppsService.java +27 −0 Original line number Diff line number Diff line Loading @@ -1598,6 +1598,33 @@ public class LauncherAppsService extends SystemService { } } @Override public @Nullable IntentSender getAppMarketActivityIntent(@NonNull String callingPackage, @Nullable String packageName, @NonNull 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 AppMarketActivity for another user")) { return null; } final long identity = Binder.clearCallingIdentity(); try { // TODO(b/316118005): Add code to launch the app installer for the packageName. Intent appMarketIntent = new Intent(Intent.ACTION_MAIN); appMarketIntent.addCategory(Intent.CATEGORY_APP_MARKET); final PendingIntent pi = PendingIntent.getActivityAsUser( mContext, /* requestCode */ 0, appMarketIntent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT, /* options */ null, user); return pi == null ? null : pi.getIntentSender(); } finally { Binder.restoreCallingIdentity(identity); } } @Override public void startActivityAsUser(IApplicationThread caller, String callingPackage, String callingFeatureId, ComponentName component, Rect sourceBounds, Loading