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

Commit decd9ea2 authored by Nicolas Prevot's avatar Nicolas Prevot
Browse files

IntentForwarderActivity shouldn't crash if intent has no action.

Also don't crash when receiving a chooser intent with no
extra initial intent.

BUG:26445101
Change-Id: Icaf55881a015cf8cc76e5269b9bb67784dbf33c3
parent 95aaf5d5
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) {