Bug 1411968 - Only try launching BrowserApp when handling notifications. r=nechen, a=gchang
authorJim Chen <nchen@mozilla.com>
Fri, 10 Nov 2017 18:26:18 -0500
changeset 444785 66ecc5020b847eb2f705ee474b57e52507e09db2
parent 444784 58c90e9bf49fae19507b3deb50ce3fffdb09db48
child 444786 2ef9343f628d39f1bad2280b01fd86fbfd1775c1
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnechen, gchang
Bug 1411968 - Only try launching BrowserApp when handling notifications. r=nechen, a=gchang Usually when we handle notification events, we try to launch whatever Activity showed the notification so that the user can see results. However, only BrowserApp supports being launched this way, so we should restrict launching Activites to BrowserApp. For others like CustomTabsActivity, we should just handle the notification event directly. Currently, only download notifications are supported for these other Activities, so it's okay if we don't display the Activity. MozReview-Commit-ID: CNVRSEWBOQ6
--- a/mobile/android/base/java/org/mozilla/gecko/notifications/NotificationReceiver.java
+++ b/mobile/android/base/java/org/mozilla/gecko/notifications/NotificationReceiver.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 package org.mozilla.gecko.notifications;
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoThread;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -57,17 +58,27 @@ public class NotificationReceiver extend
         forwardMessageToActivity(intent, context);
     private void forwardMessageToActivity(final Intent intent, final Context context) {
-        final ComponentName name = intent.getExtras().getParcelable(NotificationHelper.ORIGINAL_EXTRA_COMPONENT);
+        final ComponentName name =
+                intent.getExtras().getParcelable(NotificationHelper.ORIGINAL_EXTRA_COMPONENT);
+        if (!AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS.equals(
+                name != null ? name.getClassName() : null)) {
+            // Don't try to start anything other than the browser Activity.
+            NotificationHelper.getInstance(context.getApplicationContext())
+                              .handleNotificationIntent(new SafeIntent(intent));
+            return;
+        }
     private void onNotificationClientAction(final Context context, final String action,
                                             final Uri data, final Intent intent) {
         final String name = data.getQueryParameter("name");