Add overloaded API with activity options parameter am: a9f0052af5
Change-Id: I6992551c89d878c785ad97cf9d9da64c5069d692
This commit is contained in:
@@ -11572,6 +11572,7 @@ package android.content.pm {
|
|||||||
method @NonNull public CharSequence getProfileSwitchingLabel(@NonNull android.os.UserHandle);
|
method @NonNull public CharSequence getProfileSwitchingLabel(@NonNull android.os.UserHandle);
|
||||||
method @NonNull public java.util.List<android.os.UserHandle> getTargetUserProfiles();
|
method @NonNull public java.util.List<android.os.UserHandle> getTargetUserProfiles();
|
||||||
method @RequiresPermission(anyOf={android.Manifest.permission.INTERACT_ACROSS_PROFILES, "android.permission.INTERACT_ACROSS_USERS"}) public void startActivity(@NonNull android.content.Intent, @NonNull android.os.UserHandle, @Nullable android.app.Activity);
|
method @RequiresPermission(anyOf={android.Manifest.permission.INTERACT_ACROSS_PROFILES, "android.permission.INTERACT_ACROSS_USERS"}) public void startActivity(@NonNull android.content.Intent, @NonNull android.os.UserHandle, @Nullable android.app.Activity);
|
||||||
|
method @RequiresPermission(anyOf={android.Manifest.permission.INTERACT_ACROSS_PROFILES, "android.permission.INTERACT_ACROSS_USERS"}) public void startActivity(@NonNull android.content.Intent, @NonNull android.os.UserHandle, @Nullable android.app.Activity, @Nullable android.os.Bundle);
|
||||||
method public void startMainActivity(@NonNull android.content.ComponentName, @NonNull android.os.UserHandle);
|
method public void startMainActivity(@NonNull android.content.ComponentName, @NonNull android.os.UserHandle);
|
||||||
field public static final String ACTION_CAN_INTERACT_ACROSS_PROFILES_CHANGED = "android.content.pm.action.CAN_INTERACT_ACROSS_PROFILES_CHANGED";
|
field public static final String ACTION_CAN_INTERACT_ACROSS_PROFILES_CHANGED = "android.content.pm.action.CAN_INTERACT_ACROSS_PROFILES_CHANGED";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.content.Intent;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -128,6 +129,35 @@ public class CrossProfileApps {
|
|||||||
@NonNull Intent intent,
|
@NonNull Intent intent,
|
||||||
@NonNull UserHandle targetUser,
|
@NonNull UserHandle targetUser,
|
||||||
@Nullable Activity callingActivity) {
|
@Nullable Activity callingActivity) {
|
||||||
|
startActivity(intent, targetUser, callingActivity, /* options= */ null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the specified activity of the caller package in the specified profile.
|
||||||
|
*
|
||||||
|
* <p>The caller must have the {@link android.Manifest.permission#INTERACT_ACROSS_PROFILES},
|
||||||
|
* {@code android.Manifest.permission#INTERACT_ACROSS_USERS}, or {@code
|
||||||
|
* android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission. Both the caller and
|
||||||
|
* target user profiles must be in the same profile group. The target user must be a valid user
|
||||||
|
* returned from {@link #getTargetUserProfiles()}.
|
||||||
|
*
|
||||||
|
* @param intent The intent to launch. A component in the caller package must be specified.
|
||||||
|
* @param targetUser The {@link UserHandle} of the profile; must be one of the users returned by
|
||||||
|
* {@link #getTargetUserProfiles()} if different to the calling user, otherwise a
|
||||||
|
* {@link SecurityException} will be thrown.
|
||||||
|
* @param callingActivity The activity to start the new activity from for the purposes of
|
||||||
|
* deciding which task the new activity should belong to. If {@code null}, the activity
|
||||||
|
* will always be started in a new task.
|
||||||
|
* @param options The activity options or {@code null}. See {@link android.app.ActivityOptions}.
|
||||||
|
*/
|
||||||
|
@RequiresPermission(anyOf = {
|
||||||
|
android.Manifest.permission.INTERACT_ACROSS_PROFILES,
|
||||||
|
android.Manifest.permission.INTERACT_ACROSS_USERS})
|
||||||
|
public void startActivity(
|
||||||
|
@NonNull Intent intent,
|
||||||
|
@NonNull UserHandle targetUser,
|
||||||
|
@Nullable Activity callingActivity,
|
||||||
|
@Nullable Bundle options) {
|
||||||
try {
|
try {
|
||||||
mService.startActivityAsUserByIntent(
|
mService.startActivityAsUserByIntent(
|
||||||
mContext.getIApplicationThread(),
|
mContext.getIApplicationThread(),
|
||||||
@@ -135,7 +165,8 @@ public class CrossProfileApps {
|
|||||||
mContext.getFeatureId(),
|
mContext.getFeatureId(),
|
||||||
intent,
|
intent,
|
||||||
targetUser.getIdentifier(),
|
targetUser.getIdentifier(),
|
||||||
callingActivity != null ? callingActivity.getActivityToken() : null);
|
callingActivity != null ? callingActivity.getActivityToken() : null,
|
||||||
|
options);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
throw ex.rethrowFromSystemServer();
|
throw ex.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ interface ICrossProfileApps {
|
|||||||
in String callingFeatureId, in ComponentName component, int userId,
|
in String callingFeatureId, in ComponentName component, int userId,
|
||||||
boolean launchMainActivity);
|
boolean launchMainActivity);
|
||||||
void startActivityAsUserByIntent(in IApplicationThread caller, in String callingPackage,
|
void startActivityAsUserByIntent(in IApplicationThread caller, in String callingPackage,
|
||||||
in String callingFeatureId, in Intent intent, int userId, in IBinder callingActivity);
|
in String callingFeatureId, in Intent intent, int userId, in IBinder callingActivity,
|
||||||
|
in Bundle options);
|
||||||
List<UserHandle> getTargetUserProfiles(in String callingPackage);
|
List<UserHandle> getTargetUserProfiles(in String callingPackage);
|
||||||
boolean canInteractAcrossProfiles(in String callingPackage);
|
boolean canInteractAcrossProfiles(in String callingPackage);
|
||||||
boolean canRequestInteractAcrossProfiles(in String callingPackage);
|
boolean canRequestInteractAcrossProfiles(in String callingPackage);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManagerInternal;
|
import android.content.pm.PackageManagerInternal;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -183,7 +184,8 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
|
|||||||
String callingFeatureId,
|
String callingFeatureId,
|
||||||
Intent intent,
|
Intent intent,
|
||||||
@UserIdInt int userId,
|
@UserIdInt int userId,
|
||||||
IBinder callingActivity) throws RemoteException {
|
IBinder callingActivity,
|
||||||
|
Bundle options) throws RemoteException {
|
||||||
Objects.requireNonNull(callingPackage);
|
Objects.requireNonNull(callingPackage);
|
||||||
Objects.requireNonNull(intent);
|
Objects.requireNonNull(intent);
|
||||||
Objects.requireNonNull(intent.getComponent(), "The intent must have a Component set");
|
Objects.requireNonNull(intent.getComponent(), "The intent must have a Component set");
|
||||||
@@ -226,7 +228,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {
|
|||||||
launchIntent,
|
launchIntent,
|
||||||
callingActivity,
|
callingActivity,
|
||||||
/* startFlags= */ 0,
|
/* startFlags= */ 0,
|
||||||
/* options= */ null,
|
options,
|
||||||
userId);
|
userId);
|
||||||
logStartActivityByIntent(callingPackage);
|
logStartActivityByIntent(callingPackage);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user