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

Commit eaed3219 authored by Dan Sandler's avatar Dan Sandler
Browse files

Protect System UI from crashing when sharing file: URIs.

This workaround already existed in ResolverActivity.java.

Bug: 123628236
Test: ensure there are multiple image viewers on device:
	adb shell \
	am start -a android.intent.action.VIEW -d \
	file:///sdcard/foo.jpg

Change-Id: I978805a2d2b108bc91753e0cb4cfd90707f63a46
parent dc40440e
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.ActivityTaskManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.StrictMode;

/**
 * When a target is chosen from the SystemUI Chooser activity, unpack its arguments and
@@ -40,7 +41,15 @@ public class ChooserHelper {
        final boolean ignoreTargetSecurity =
                thisIntent.getBooleanExtra(ActivityTaskManager.EXTRA_IGNORE_TARGET_SECURITY, false);
        final int userId = thisIntent.getIntExtra(Intent.EXTRA_USER_ID, -1);

        // We're dispatching intents that might be coming from legacy apps, so
        // (as in com.android.internal.app.ResolverActivity) exempt ourselves from death.
        StrictMode.disableDeathOnFileUriExposure();
        try {
            activity.startActivityAsCaller(
                    chosenIntent, options, permissionToken, ignoreTargetSecurity, userId);
        } finally {
            StrictMode.enableDeathOnFileUriExposure();
        }
    }
}