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
diff --git a/api/system-current.txt b/api/system-current.txt
index 891e764..ffb8f30 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1134,7 +1134,7 @@
}
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 {
diff --git a/core/java/android/content/pm/CrossProfileApps.java b/core/java/android/content/pm/CrossProfileApps.java
index 740fd7f..b7366f1 100644
--- a/core/java/android/content/pm/CrossProfileApps.java
+++ b/core/java/android/content/pm/CrossProfileApps.java
@@ -18,6 +18,7 @@
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 @@
}
/**
- * 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 @@
*/
@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);
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 449a7b3..dd48670 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -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"