Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdb849f8 authored by Varun Shah's avatar Varun Shah
Browse files

Clarified CrossProfileApps API and documentation.

Changed CrossProfileApps#startAnyActivity to #startAcitivty.

Updated documentation for the usage of startActivity vs startMainActivity.
Also clarified that the INTERACT_ACROSS_PROFILES permission is a two-way
channel between personal and managed profiles.

Bug: 122886462
Test: n/a (documentation changes only)
Change-Id: I67772aef0cf24110432a2dbde0f87c91354fd4a0
parent 27b6918c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1134,7 +1134,7 @@ package android.content.pm {
  }

  public class CrossProfileApps {
    method public void startAnyActivity(android.content.ComponentName, android.os.UserHandle);
    method public void startActivity(android.content.ComponentName, android.os.UserHandle);
  }

  public final class InstantAppInfo implements android.os.Parcelable {
+19 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
@@ -76,9 +77,23 @@ public class CrossProfileApps {
    }

    /**
     * Starts the specified activity of the caller package in the specified profile if the caller
     * has {@link android.Manifest.permission#INTERACT_ACROSS_PROFILES} permission and
     * both the caller and target user profiles are in the same user group.
     * @deprecated use {@link #startActivity(ComponentName, UserHandle)} instead.
     *
     * @removed
     * @hide
     */
    @Deprecated
    @UnsupportedAppUsage
    public void startAnyActivity(@NonNull ComponentName component, @NonNull UserHandle targetUser) {
        startActivity(component, targetUser);
    }

    /**
     * Starts the specified activity of the caller package in the specified profile. Unlike
     * {@link #startMainActivity}, this can start any activity of the caller package, not just
     * the main activity.
     * The caller must have the {@link android.Manifest.permission#INTERACT_ACROSS_PROFILES}
     * permission and both the caller and target user profiles must be in the same profile group.
     *
     * @param component The ComponentName of the activity to launch. It must be exported.
     * @param targetUser The UserHandle of the profile, must be one of the users returned by
@@ -88,7 +103,7 @@ public class CrossProfileApps {
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_PROFILES)
    public void startAnyActivity(@NonNull ComponentName component, @NonNull UserHandle targetUser) {
    public void startActivity(@NonNull ComponentName component, @NonNull UserHandle targetUser) {
        try {
            mService.startActivityAsUser(mContext.getIApplicationThread(),
                    mContext.getPackageName(), component, targetUser.getIdentifier(), false);
+3 −2
Original line number Diff line number Diff line
@@ -2208,8 +2208,9 @@
    <permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
        android:protectionLevel="signature|installer" />

    <!-- @SystemApi Allows an application to start an activity within its managed profile from
         the personal profile.
    <!-- @SystemApi Allows an application to start its own activities, but on a different profile
         associated with the user. For example, an application running on the main profile of a user
         can start an activity on a managed profile of that user.
         This permission is not available to third party applications.
         @hide -->
    <permission android:name="android.permission.INTERACT_ACROSS_PROFILES"