Merge "[2/2] Fix sharing to another profile where an app has multiple targets" into tm-qpr-dev am: dd4fc6db67
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20063949 Change-Id: I6175a98e7c4b596916fd3b5bc08629a9d64176bb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -172,14 +172,14 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) {
|
public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) {
|
||||||
prepareIntentForCrossProfileLaunch(mResolvedIntent, userId);
|
TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, userId);
|
||||||
activity.startActivityAsCaller(mResolvedIntent, options, false, userId);
|
activity.startActivityAsCaller(mResolvedIntent, options, false, userId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startAsUser(Activity activity, Bundle options, UserHandle user) {
|
public boolean startAsUser(Activity activity, Bundle options, UserHandle user) {
|
||||||
prepareIntentForCrossProfileLaunch(mResolvedIntent, user.getIdentifier());
|
TargetInfo.prepareIntentForCrossProfileLaunch(mResolvedIntent, user.getIdentifier());
|
||||||
activity.startActivityAsUser(mResolvedIntent, options, user);
|
activity.startActivityAsUser(mResolvedIntent, options, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -224,13 +224,6 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static void prepareIntentForCrossProfileLaunch(Intent intent, int targetUserId) {
|
|
||||||
final int currentUserId = UserHandle.myUserId();
|
|
||||||
if (targetUserId != currentUserId) {
|
|
||||||
intent.fixUris(currentUserId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DisplayResolveInfo(Parcel in) {
|
private DisplayResolveInfo(Parcel in) {
|
||||||
mDisplayLabel = in.readCharSequence();
|
mDisplayLabel = in.readCharSequence();
|
||||||
mExtendedInfo = in.readCharSequence();
|
mExtendedInfo = in.readCharSequence();
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ public final class SelectableTargetInfo implements ChooserTargetInfo {
|
|||||||
}
|
}
|
||||||
intent.setComponent(mChooserTarget.getComponentName());
|
intent.setComponent(mChooserTarget.getComponentName());
|
||||||
intent.putExtras(mChooserTarget.getIntentExtras());
|
intent.putExtras(mChooserTarget.getIntentExtras());
|
||||||
|
TargetInfo.prepareIntentForCrossProfileLaunch(intent, userId);
|
||||||
|
|
||||||
// Important: we will ignore the target security checks in ActivityManager
|
// Important: we will ignore the target security checks in ActivityManager
|
||||||
// if and only if the ChooserTarget's target package is the same package
|
// if and only if the ChooserTarget's target package is the same package
|
||||||
|
|||||||
@@ -130,4 +130,15 @@ public interface TargetInfo {
|
|||||||
* @return true if this target should be pinned to the front by the request of the user
|
* @return true if this target should be pinned to the front by the request of the user
|
||||||
*/
|
*/
|
||||||
boolean isPinned();
|
boolean isPinned();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix the URIs in {@code intent} if cross-profile sharing is required. This should be called
|
||||||
|
* before launching the intent as another user.
|
||||||
|
*/
|
||||||
|
static void prepareIntentForCrossProfileLaunch(Intent intent, int targetUserId) {
|
||||||
|
final int currentUserId = UserHandle.myUserId();
|
||||||
|
if (targetUserId != currentUserId) {
|
||||||
|
intent.fixUris(currentUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user