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

Commit e7b71347 authored by arangelov's avatar arangelov
Browse files

Use startActivityAsCaller instead of startActivity.

Also make canForward return null for ACTION_CHOOSER.

Fixes: 154225763
Test: manual
Test: atest IntentForwarderActivityTest
Change-Id: If035607a751af857a39f42e45633a35b44e3e83e
parent 4ae27323
Loading
Loading
Loading
Loading
+2 −18
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public class IntentForwarderActivity extends Activity {
            return;
        }
        sanitizeIntent(innerIntent);
        startActivity(intentReceived);
        startActivityAsCaller(intentReceived, null, null, false, getUserId());
        finish();
    }

@@ -234,24 +234,8 @@ public class IntentForwarderActivity extends Activity {

        Intent intentToCheck = forwardIntent;
        if (Intent.ACTION_CHOOSER.equals(forwardIntent.getAction())) {
            // The EXTRA_INITIAL_INTENTS may not be allowed to be forwarded.
            if (forwardIntent.hasExtra(Intent.EXTRA_INITIAL_INTENTS)) {
                Slog.wtf(TAG, "An chooser intent with extra initial intents cannot be forwarded to"
                        + " a different user");
            return null;
        }
            if (forwardIntent.hasExtra(Intent.EXTRA_REPLACEMENT_EXTRAS)) {
                Slog.wtf(TAG, "A chooser intent with replacement extras cannot be forwarded to a"
                        + " different user");
                return null;
            }
            intentToCheck = forwardIntent.getParcelableExtra(Intent.EXTRA_INTENT);
            if (intentToCheck == null) {
                Slog.wtf(TAG, "Cannot forward a chooser intent with no extra "
                        + Intent.EXTRA_INTENT);
                return null;
            }
        }
        if (forwardIntent.getSelector() != null) {
            intentToCheck = forwardIntent.getSelector();
        }
+0 −6
Original line number Diff line number Diff line
@@ -647,12 +647,6 @@ public class IntentForwarderActivityTest {
            mUserIdActivityLaunchedIn = userId;
        }

        @Override
        public void startActivity(Intent intent) {
            mStartActivityIntent = intent;
            mUserIdActivityLaunchedIn = getUserId();
        }

        @Override
        protected MetricsLogger getMetricsLogger() {
            return mMetricsLogger;