Only add user id to content uri if launching cross-profile target

Test: manual
Test: atest ResolverActivityTest
Test: atest ChooserActivityTest
Bug: 156552093
Change-Id: Icbdf0ea33f35785322eb6bfb23e88dfdacf7fd34
This commit is contained in:
arangelov
2020-06-01 14:17:32 +01:00
parent c45de5abfa
commit 9a8a6744ef
2 changed files with 13 additions and 2 deletions

View File

@@ -3024,6 +3024,10 @@ public class ChooserActivity extends ResolverActivity implements
currentRootAdapter.updateDirectShareExpansion();
}
void prepareIntentForCrossProfileLaunch(Intent intent) {
intent.fixUris(UserHandle.myUserId());
}
/**
* Adapter for all types of items and targets in ShareSheet.
* Note that ranked sections like Direct Share - while appearing grid-like - are handled on the

View File

@@ -1246,8 +1246,8 @@ public class ResolverActivity extends Activity implements
}
if (target != null) {
if (intent != null) {
intent.fixUris(UserHandle.myUserId());
if (intent != null && isLaunchingTargetInOtherProfile()) {
prepareIntentForCrossProfileLaunch(intent);
}
safelyStartActivity(target);
@@ -1261,6 +1261,13 @@ public class ResolverActivity extends Activity implements
return true;
}
void prepareIntentForCrossProfileLaunch(Intent intent) {}
private boolean isLaunchingTargetInOtherProfile() {
return mMultiProfilePagerAdapter.getCurrentUserHandle().getIdentifier()
!= UserHandle.myUserId();
}
@VisibleForTesting
public void safelyStartActivity(TargetInfo cti) {
// We're dispatching intents that might be coming from legacy apps, so