Bug 1479532 - Part 1 - Create notification channel for receiving synced tabs. r=jchen
authorJan Henning <jh+bugzilla@buttercookie.de>
Sun, 02 Sep 2018 20:09:09 +0000
changeset 492186 24d55d7791012c595503c2da02365a511c9cdb9b
parent 492185 88b606c56fedc9027c0c07f39e13ff18b71b298b
child 492199 ce85e9d3f366766c061cf893fda5c9689bf05b0c
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1479532
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1479532 - Part 1 - Create notification channel for receiving synced tabs. r=jchen Differential Revision: https://phabricator.services.mozilla.com/D4366
mobile/android/base/java/org/mozilla/gecko/notifications/NotificationHelper.java
mobile/android/base/java/org/mozilla/gecko/tabqueue/TabReceivedService.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/strings.xml.in
--- a/mobile/android/base/java/org/mozilla/gecko/notifications/NotificationHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/notifications/NotificationHelper.java
@@ -100,37 +100,44 @@ public final class NotificationHelper im
         /**
          *  Media notification channel
          */
         MEDIA,
         /**
          * Built-in updater - use only when <code>AppConstants.MOZ_UPDATER</code> is true.
          */
         UPDATER,
+        /**
+         * Synced tabs notification channel
+         */
+        SYNCED_TABS,
     }
 
     // Holds the mapping between the Channel enum used by the rest of our codebase and the
     // channel ID used for communication with the system NotificationManager.
-    private final Map<Channel, String> mDefinedNotificationChannels = new HashMap<Channel, String>(5) {{
+    private final Map<Channel, String> mDefinedNotificationChannels = new HashMap<Channel, String>(6) {{
         final String DEFAULT_CHANNEL_TAG = "default-notification-channel";
         put(Channel.DEFAULT, DEFAULT_CHANNEL_TAG);
 
         final String MLS_CHANNEL_TAG = "mls-notification-channel";
         put(Channel.MLS, MLS_CHANNEL_TAG);
 
         final String DOWNLOAD_NOTIFICATION_TAG = "download-notification-channel";
         put(Channel.DOWNLOAD, DOWNLOAD_NOTIFICATION_TAG);
 
         final String MEDIA_CHANNEL_TAG = "media-notification-channel";
         put(Channel.MEDIA, MEDIA_CHANNEL_TAG);
 
         if (AppConstants.MOZ_UPDATER) {
             final String UPDATER_CHANNEL_TAG = "updater-notification-channel";
             put(Channel.UPDATER, UPDATER_CHANNEL_TAG);
         }
+
+        final String SYNCED_TABS_CHANNEL_TAG = "synced-tabs-notification-channel";
+        put(Channel.SYNCED_TABS, SYNCED_TABS_CHANNEL_TAG);
     }};
 
     // Holds a list of notifications that should be cleared if the Fennec Activity is shut down.
     // Will not include ongoing or persistent notifications that are tied to Gecko's lifecycle.
     private SimpleArrayMap<String, GeckoBundle> mClearableNotifications;
 
     private boolean mInitialized;
     private static NotificationHelper sInstance;
@@ -204,16 +211,23 @@ public final class NotificationHelper im
 
                 case UPDATER: {
                     channel = new NotificationChannel(mDefinedNotificationChannels.get(definedChannel),
                             mContext.getString(R.string.updater_notification_channel),
                             NotificationManager.IMPORTANCE_LOW);
                 }
                 break;
 
+                case SYNCED_TABS: {
+                    channel = new NotificationChannel(mDefinedNotificationChannels.get(definedChannel),
+                            mContext.getString(R.string.synced_tabs_notification_channel),
+                            NotificationManager.IMPORTANCE_HIGH);
+                }
+                break;
+
                 case DEFAULT:
                 default: {
                     channel = new NotificationChannel(mDefinedNotificationChannels.get(definedChannel),
                             mContext.getString(R.string.default_notification_channel),
                             NotificationManager.IMPORTANCE_HIGH);
                 }
                 break;
             }
--- a/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabReceivedService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabqueue/TabReceivedService.java
@@ -65,17 +65,17 @@ public class TabReceivedService extends 
         builder.setContentTitle(notificationTitle);
         builder.setWhen(System.currentTimeMillis());
         builder.setAutoCancel(true);
         builder.setContentText(uri);
         builder.setContentIntent(contentIntent);
 
         if (!AppConstants.Versions.preO) {
             builder.setChannelId(NotificationHelper.getInstance(this)
-                    .getNotificationChannel(NotificationHelper.Channel.DEFAULT).getId());
+                    .getNotificationChannel(NotificationHelper.Channel.SYNCED_TABS).getId());
         }
 
         // Trigger "heads-up" notification mode on supported Android versions.
         builder.setPriority(NotificationCompat.PRIORITY_HIGH);
         final Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
         if (notificationSoundUri != null) {
             builder.setSound(notificationSoundUri);
         }
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -895,8 +895,9 @@ Picture-in-picture mini window -->
 <!ENTITY pip_pause_button_description "Pause playing">
 
 <!-- Notification channels names -->
 <!ENTITY default_notification_channel "&brandShortName;">
 <!ENTITY mls_notification_channel "&vendorShortName; Location Service">
 <!ENTITY download_notification_channel "Downloads">
 <!ENTITY media_notification_channel "Media playback">
 <!ENTITY updater_notification_channel "App updates">
+<!ENTITY synced_tabs_notification_channel "Synced tabs">
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -648,9 +648,10 @@
   <string name="pip_pause_button_title">&pip_pause_button_title;</string>
   <string name="pip_pause_button_description">&pip_pause_button_description;</string>
 
   <string name="default_notification_channel">&default_notification_channel;</string>
   <string name="mls_notification_channel">&mls_notification_channel;</string>
   <string name="media_notification_channel">&media_notification_channel;</string>
   <string name="download_notification_channel">&download_notification_channel;</string>
   <string name="updater_notification_channel">&updater_notification_channel;</string>
+  <string name="synced_tabs_notification_channel">&synced_tabs_notification_channel;</string>
 </resources>