Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java |
| index 476649c033582edc57650aacd2cff7e3363ef4ee..037181b6d397a28339ef07d948dbf5d5dc295aea 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationUIManager.java |
| @@ -303,11 +303,13 @@ public class NotificationUIManager { |
| * text by the Android notification system. |
| * @param icon Icon to be displayed in the notification. When this isn't a valid Bitmap, a |
| * default icon will be generated instead. |
| + * @param vibrate Vibration pattern for the Notification. A notification that vibrates is |
|
Peter Beverloo
2015/04/26 23:26:41
nit: Remove the "A notification...heads-up notific
Sanghyun Park
2015/04/27 14:00:00
I missunderstood about this.
I'll add "@see https
|
| + * more likely to be presented as a heads-up notification. |
| * @param silent Whether the default sound, vibration and lights should be suppressed. |
| */ |
| @CalledByNative |
| private void displayNotification(long persistentNotificationId, String origin, String tag, |
| - String title, String body, Bitmap icon, boolean silent) { |
| + String title, String body, Bitmap icon, int[] vibrate, boolean silent) { |
| if (icon == null || icon.getWidth() == 0) { |
| icon = getIconGenerator().generateIconForUrl(origin, true); |
| } |
| @@ -349,7 +351,26 @@ public class NotificationUIManager { |
| // Use the system's default ringtone, vibration and indicator lights unless the notification |
| // has been marked as being silent, for example because it's low priority. |
| - if (!silent) notificationBuilder.setDefaults(Notification.DEFAULT_ALL); |
| + // If a vibration pattern is set, the notification should use the provided pattern |
|
Peter Beverloo
2015/04/26 23:26:41
Could we perhaps extract this block to a separate
Sanghyun Park
2015/04/27 14:00:00
Sure, I'll make method and add testcase.
|
| + // rather than the defaulting to system settings. |
| + assert silent && vibrate.length == 0; |
| + |
| + int defaults = Notification.DEFAULT_ALL; |
| + if (silent) defaults = 0; |
| + |
| + if (vibrate.length > 0) { |
| + // In Android platform, the first value indicates the number of |
| + // milliseconds to wait before turning the vibrator on unlike Blink. |
| + // So, we need to insert any value at the beginning of vibrate value. |
| + long[] pattern = new long[vibrate.length + 1]; |
| + pattern[0] = 0; |
| + for (int i = 0; i < vibrate.length; ++i) { |
|
Peter Beverloo
2015/04/26 23:26:41
Check out System.arraycopy() :-)
Sanghyun Park
2015/04/27 14:00:00
Unfortunately, we cannot use "arraycopy()".
For us
|
| + pattern[i + 1] = vibrate[i]; |
| + } |
| + defaults &= ~Notification.DEFAULT_VIBRATE; |
|
Peter Beverloo
2015/04/26 23:26:41
nit: I'd have this line as the first line in the i
Sanghyun Park
2015/04/27 14:00:00
Done.
|
| + notificationBuilder.setVibrate(pattern); |
| + } |
| + notificationBuilder.setDefaults(defaults); |
| String platformTag = makePlatformTag(persistentNotificationId, origin, tag); |
| mNotificationManager.notify(platformTag, PLATFORM_ID, notificationBuilder.build()); |