Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac0fe8d0 authored by Alison Cichowlas's avatar Alison Cichowlas Committed by Automerger Merge Worker
Browse files

Merge "Sharesheet: action bar is independent of WP tabs, should always launch...

Merge "Sharesheet: action bar is independent of WP tabs, should always launch as primary user." into sc-dev am: 9197f7b2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15363687

Change-Id: Iabd652260d26a99cbed33b5b05ec44e653f73831
parents 60c58f0f 9197f7b2
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -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();
                }
                }
        );
        );
+25 −7
Original line number Original line Diff line number Diff line
@@ -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