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

Commit 1615c3ff authored by Nicolas Prévot's avatar Nicolas Prévot Committed by Android (Google) Code Review
Browse files

Merge "IntentForwarderActivity shouldn't crash if intent has no action."

parents 49d34d99 decd9ea2
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -85,8 +85,10 @@ public class IntentForwarderActivity extends Activity {
        int callingUserId = getUserId();

        if (canForward(newIntent, targetUserId)) {
            if (newIntent.getAction().equals(Intent.ACTION_CHOOSER)) {
            if (Intent.ACTION_CHOOSER.equals(newIntent.getAction())) {
                Intent innerIntent = (Intent) newIntent.getParcelableExtra(Intent.EXTRA_INTENT);
                // At this point, innerIntent is not null. Otherwise, canForward would have returned
                // false.
                innerIntent.prepareToLeaveUser(callingUserId);
            } else {
                newIntent.prepareToLeaveUser(callingUserId);
@@ -132,7 +134,7 @@ public class IntentForwarderActivity extends Activity {

    boolean canForward(Intent intent, int targetUserId)  {
        IPackageManager ipm = AppGlobals.getPackageManager();
        if (intent.getAction().equals(Intent.ACTION_CHOOSER)) {
        if (Intent.ACTION_CHOOSER.equals(intent.getAction())) {
            // The EXTRA_INITIAL_INTENTS may not be allowed to be forwarded.
            if (intent.hasExtra(Intent.EXTRA_INITIAL_INTENTS)) {
                Slog.wtf(TAG, "An chooser intent with extra initial intents cannot be forwarded to"
@@ -145,6 +147,11 @@ public class IntentForwarderActivity extends Activity {
                return false;
            }
            intent = (Intent) intent.getParcelableExtra(Intent.EXTRA_INTENT);
            if (intent == null) {
                Slog.wtf(TAG, "Cannot forward a chooser intent with no extra "
                        + Intent.EXTRA_INTENT);
                return false;
            }
        }
        String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
        if (intent.getSelector() != null) {