Bug 1465323 - Update NotificationReceiver; r?JanH draft
authorPetru Lingurar <petru.lingurar@softvision.ro>
Tue, 12 Jun 2018 13:01:23 +0300
changeset 817983 42ac3d92b32fad825d64411ebefd0d48207f1f3d
parent 817982 fdd4bf6ff67f07d93233f1e964e6321326696ca0
child 817984 b20c9125e9ba3e1ae7de5ba0616cb02c4bc7b2cc
push id116231
push userplingurar@mozilla.com
push dateFri, 13 Jul 2018 19:23:06 +0000
reviewersJanH
bugs1465323
milestone63.0a1
Bug 1465323 - Update NotificationReceiver; r?JanH The only change needed was to make sure the broadcast for NotificationHelper.HELPER_BROADCAST_ACTION is sent explicitly to our receiver. The other 2 broadcasts that this receiver listens for are already explicit. MozReview-Commit-ID: C3A88ijqIsd
mobile/android/base/java/org/mozilla/gecko/notifications/NotificationHelper.java
--- a/mobile/android/base/java/org/mozilla/gecko/notifications/NotificationHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/notifications/NotificationHelper.java
@@ -1,47 +1,46 @@
 /* -*- 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 java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.util.List;
-
-import org.mozilla.gecko.AppConstants;
-import org.mozilla.gecko.EventDispatcher;
-import org.mozilla.gecko.GeckoActivityMonitor;
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.R;
-import org.mozilla.gecko.mozglue.SafeIntent;
-import org.mozilla.gecko.util.BitmapUtils;
-import org.mozilla.gecko.util.BundleEventListener;
-import org.mozilla.gecko.util.EventCallback;
-import org.mozilla.gecko.util.GeckoBundle;
-import org.mozilla.gecko.util.ThreadUtils;
-
 import android.app.Activity;
 import android.app.PendingIntent;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.graphics.Bitmap;
 import android.net.Uri;
 import android.os.StrictMode;
 import android.support.v4.app.NotificationCompat;
 import android.support.v4.util.SimpleArrayMap;
 import android.util.Log;
 
+import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.EventDispatcher;
+import org.mozilla.gecko.GeckoActivityMonitor;
+import org.mozilla.gecko.GeckoAppShell;
+import org.mozilla.gecko.mozglue.SafeIntent;
+import org.mozilla.gecko.util.BitmapUtils;
+import org.mozilla.gecko.util.BundleEventListener;
+import org.mozilla.gecko.util.EventCallback;
+import org.mozilla.gecko.util.GeckoBundle;
+import org.mozilla.gecko.util.ThreadUtils;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.util.List;
+
 public final class NotificationHelper implements BundleEventListener {
     public static final String HELPER_BROADCAST_ACTION = AppConstants.ANDROID_PACKAGE_NAME + ".helperBroadcastAction";
 
     public static final String NOTIFICATION_ID = "NotificationHelper_ID";
     private static final String LOGTAG = "GeckoNotificationHelper";
     private static final String HELPER_NOTIFICATION = "helperNotif";
 
     // Attributes mandatory to be used while sending a notification from js.
@@ -178,16 +177,17 @@ public final class NotificationHelper im
         final String handler = message.getString(HANDLER_ATTR);
         b.appendQueryParameter(HANDLER_ATTR, handler);
 
         return b;
     }
 
     private Intent buildNotificationIntent(final GeckoBundle message, final Uri.Builder builder) {
         final Intent notificationIntent = new Intent(HELPER_BROADCAST_ACTION);
+        notificationIntent.setClass(mContext, NotificationReceiver.class);
         final boolean ongoing = message.getBoolean(ONGOING_ATTR);
         notificationIntent.putExtra(ONGOING_ATTR, ongoing);
 
         final Uri dataUri = builder.build();
         notificationIntent.setData(dataUri);
         notificationIntent.putExtra(HELPER_NOTIFICATION, true);
         notificationIntent.putExtra(COOKIE_ATTR, message.getString(COOKIE_ATTR, ""));