From 2b9eb89aedf42717bede1d5c6fc3c854a9536fdb Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 16 Feb 2016 09:21:51 -0700 Subject: [PATCH] Disable StrictMode when starting activity. Since intents can come in from older apps, don't let them crash us by including file:// Uris. This narrows the relaxation to only apply when starting the requested intent. Bug: 27070755 Change-Id: Ifcf9068424e072f52758c8feeab5fbf23d678a2e --- .../android/internal/app/ResolverActivity.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index 3fb768f68ee60..9897b125dea33 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -174,10 +174,6 @@ public class ResolverActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { - // We're dispatching intents that might be coming from legacy apps, so - // don't kill ourselves. - StrictMode.disableDeathOnFileUriExposure(); - // Use a specialized prompt when we're handling the 'Home' app startActivity() final Intent intent = makeMyIntent(); final Set categories = intent.getCategories(); @@ -768,6 +764,17 @@ public class ResolverActivity extends Activity { } public void safelyStartActivity(TargetInfo cti) { + // We're dispatching intents that might be coming from legacy apps, so + // don't kill ourselves. + StrictMode.disableDeathOnFileUriExposure(); + try { + safelyStartActivityInternal(cti); + } finally { + StrictMode.enableDeathOnFileUriExposure(); + } + } + + private void safelyStartActivityInternal(TargetInfo cti) { // If needed, show that intent is forwarded // from managed profile to owner or other way around. if (mProfileSwitchMessageId != -1) {