Merge "Sharesheet: action bar is independent of WP tabs, should always launch as primary user." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9197f7b260
@@ -1269,7 +1269,8 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
SELECTION_TYPE_NEARBY,
|
SELECTION_TYPE_NEARBY,
|
||||||
"",
|
"",
|
||||||
-1);
|
-1);
|
||||||
safelyStartActivity(ti);
|
// Action bar is user-independent, always start as primary
|
||||||
|
safelyStartActivityAsUser(ti, getPersonalProfileUserHandle());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -1290,7 +1291,8 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
SELECTION_TYPE_EDIT,
|
SELECTION_TYPE_EDIT,
|
||||||
"",
|
"",
|
||||||
-1);
|
-1);
|
||||||
safelyStartActivity(ti);
|
// Action bar is user-independent, always start as primary
|
||||||
|
safelyStartActivityAsUser(ti, getPersonalProfileUserHandle());
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1257,13 +1257,32 @@ public class ResolverActivity extends Activity implements
|
|||||||
// don't kill ourselves.
|
// don't kill ourselves.
|
||||||
StrictMode.disableDeathOnFileUriExposure();
|
StrictMode.disableDeathOnFileUriExposure();
|
||||||
try {
|
try {
|
||||||
safelyStartActivityInternal(cti);
|
UserHandle currentUserHandle = mMultiProfilePagerAdapter.getCurrentUserHandle();
|
||||||
|
safelyStartActivityInternal(cti, currentUserHandle);
|
||||||
} finally {
|
} finally {
|
||||||
StrictMode.enableDeathOnFileUriExposure();
|
StrictMode.enableDeathOnFileUriExposure();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void safelyStartActivityInternal(TargetInfo cti) {
|
/**
|
||||||
|
* Start activity as a fixed user handle.
|
||||||
|
* @param cti TargetInfo to be launched.
|
||||||
|
* @param user User to launch this activity as.
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
public void safelyStartActivityAsUser(TargetInfo cti, UserHandle user) {
|
||||||
|
// We're dispatching intents that might be coming from legacy apps, so
|
||||||
|
// don't kill ourselves.
|
||||||
|
StrictMode.disableDeathOnFileUriExposure();
|
||||||
|
try {
|
||||||
|
safelyStartActivityInternal(cti, user);
|
||||||
|
} finally {
|
||||||
|
StrictMode.enableDeathOnFileUriExposure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void safelyStartActivityInternal(TargetInfo cti, UserHandle user) {
|
||||||
// If the target is suspended, the activity will not be successfully launched.
|
// If the target is suspended, the activity will not be successfully launched.
|
||||||
// Do not unregister from package manager updates in this case
|
// Do not unregister from package manager updates in this case
|
||||||
if (!cti.isSuspended() && mRegistered) {
|
if (!cti.isSuspended() && mRegistered) {
|
||||||
@@ -1280,18 +1299,17 @@ public class ResolverActivity extends Activity implements
|
|||||||
if (mProfileSwitchMessageId != -1) {
|
if (mProfileSwitchMessageId != -1) {
|
||||||
Toast.makeText(this, getString(mProfileSwitchMessageId), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, getString(mProfileSwitchMessageId), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
UserHandle currentUserHandle = mMultiProfilePagerAdapter.getCurrentUserHandle();
|
|
||||||
if (!mSafeForwardingMode) {
|
if (!mSafeForwardingMode) {
|
||||||
if (cti.startAsUser(this, null, currentUserHandle)) {
|
if (cti.startAsUser(this, null, user)) {
|
||||||
onActivityStarted(cti);
|
onActivityStarted(cti);
|
||||||
maybeLogCrossProfileTargetLaunch(cti, currentUserHandle);
|
maybeLogCrossProfileTargetLaunch(cti, user);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (cti.startAsCaller(this, null, currentUserHandle.getIdentifier())) {
|
if (cti.startAsCaller(this, null, user.getIdentifier())) {
|
||||||
onActivityStarted(cti);
|
onActivityStarted(cti);
|
||||||
maybeLogCrossProfileTargetLaunch(cti, currentUserHandle);
|
maybeLogCrossProfileTargetLaunch(cti, user);
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Slog.wtf(TAG, "Unable to launch as uid " + mLaunchedFromUid
|
Slog.wtf(TAG, "Unable to launch as uid " + mLaunchedFromUid
|
||||||
|
|||||||
Reference in New Issue
Block a user