From 0773069dad1e1711a47b8100000948ce5823e54d Mon Sep 17 00:00:00 2001 From: Emily Kager Date: Tue, 30 Jul 2019 15:07:24 -0700 Subject: [PATCH] For #3829 - Ignore Intents Launched From History --- .../org/mozilla/fenix/IntentReceiverActivity.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt b/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt index 2859f83ac..395532df8 100644 --- a/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt @@ -56,10 +56,19 @@ class IntentReceiverActivity : Activity() { } intent.action == Intent.ACTION_VIEW || intent.action == Intent.ACTION_SEND -> { intent.setClassName(applicationContext, HomeActivity::class.java.name) - if (!intent.getBooleanExtra(NotificationManager.RECEIVE_TABS_TAG, false)) { - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + if ((intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { + // This Intent was launched from history (recent apps). Android will redeliver the + // original Intent (which might be a VIEW intent). However if there's no active browsing + // session then we do not want to re-process the Intent and potentially re-open a website + // from a session that the user already "erased". + false + } else { + if (!intent.getBooleanExtra(NotificationManager.RECEIVE_TABS_TAG, false)) { + intent.flags = + Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + } + true } - true } else -> { intent.setClassName(applicationContext, HomeActivity::class.java.name)