Merge "Fix sharing to another profile where an app has multiple targets" into tm-qpr-dev
This commit is contained in:
@@ -1283,9 +1283,6 @@ public class ResolverActivity extends Activity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (intent != null && isLaunchingTargetInOtherProfile()) {
|
|
||||||
prepareIntentForCrossProfileLaunch(intent);
|
|
||||||
}
|
|
||||||
safelyStartActivity(target);
|
safelyStartActivity(target);
|
||||||
|
|
||||||
// Rely on the ActivityManager to pop up a dialog regarding app suspension
|
// Rely on the ActivityManager to pop up a dialog regarding app suspension
|
||||||
@@ -1298,15 +1295,6 @@ public class ResolverActivity extends Activity implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareIntentForCrossProfileLaunch(Intent intent) {
|
|
||||||
intent.fixUris(UserHandle.myUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isLaunchingTargetInOtherProfile() {
|
|
||||||
return mMultiProfilePagerAdapter.getCurrentUserHandle().getIdentifier()
|
|
||||||
!= UserHandle.myUserId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public void safelyStartActivity(TargetInfo cti) {
|
public void safelyStartActivity(TargetInfo cti) {
|
||||||
// We're dispatching intents that might be coming from legacy apps, so
|
// We're dispatching intents that might be coming from legacy apps, so
|
||||||
@@ -1513,9 +1501,6 @@ public class ResolverActivity extends Activity implements
|
|||||||
|
|
||||||
findViewById(R.id.button_open).setOnClickListener(v -> {
|
findViewById(R.id.button_open).setOnClickListener(v -> {
|
||||||
Intent intent = otherProfileResolveInfo.getResolvedIntent();
|
Intent intent = otherProfileResolveInfo.getResolvedIntent();
|
||||||
if (intent != null) {
|
|
||||||
prepareIntentForCrossProfileLaunch(intent);
|
|
||||||
}
|
|
||||||
safelyStartActivityAsUser(otherProfileResolveInfo,
|
safelyStartActivityAsUser(otherProfileResolveInfo,
|
||||||
inactiveAdapter.mResolverListController.getUserHandle());
|
inactiveAdapter.mResolverListController.getUserHandle());
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@@ -172,12 +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);
|
||||||
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());
|
||||||
activity.startActivityAsUser(mResolvedIntent, options, user);
|
activity.startActivityAsUser(mResolvedIntent, options, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -222,6 +224,13 @@ 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();
|
||||||
|
|||||||
Reference in New Issue
Block a user