From cc2e849fa992ebcf99c63837e96a6c8950d2cebf Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Tue, 13 Nov 2012 20:49:47 -0800 Subject: [PATCH 1/2] Notification vibration improvements: [DO NOT MERGE] - When notifications vibrate as a fallback (that is, because they want to play a sound but the device is in vibrate mode), this no longer requires the VIBRATE permission. - As a bonus, if your notifications use DEFAULT_VIBRATE, you don't need the VIBRATE permission either. - If you specify a custom vibration pattern, you'll still need the VIBRATE permission for that. - Notifications vibrating in fallback mode use same vibration pattern but can be changed easily in future. - The DEFAULT_VIBRATE and fallback vibrate patterns are now specified in config.xml. Bug: 7531442 Change-Id: I7a2d8413d1becc53b9d31f0d1abbc2acc3f650c6 --- core/res/res/values/config.xml | 21 +++++++ core/res/res/values/symbols.xml | 2 + .../server/NotificationManagerService.java | 59 ++++++++++++++++--- 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 3b7d73a44cbc1..f91df99ab6d11 100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -1000,4 +1000,25 @@ provisioning on some carriers, working around a bug (7305641) where if the preferred is used we don't try the others. --> false + + + + 0 + 250 + 250 + 250 + + + + + 0 + 250 + 250 + 250 + diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 68a0289756816..68587321b2078 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1525,6 +1525,8 @@ + + diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index f3a38f0c7cdba..70d37bfc82851 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -101,6 +101,7 @@ public class NotificationManagerService extends INotificationManager.Stub private static final int SHORT_DELAY = 2000; // 2 seconds private static final long[] DEFAULT_VIBRATE_PATTERN = {0, 250, 250, 250}; + private static final int VIBRATE_PATTERN_MAXLEN = 8 * 2 + 1; // up to eight bumps private static final int DEFAULT_STREAM_TYPE = AudioManager.STREAM_NOTIFICATION; private static final boolean SCORE_ONGOING_HIGHER = false; @@ -125,6 +126,9 @@ public class NotificationManagerService extends INotificationManager.Stub private int mDefaultNotificationLedOn; private int mDefaultNotificationLedOff; + private long[] mDefaultVibrationPattern; + private long[] mFallbackVibrationPattern; + private boolean mSystemReady; private int mDisabledNotifications; @@ -596,6 +600,19 @@ public class NotificationManagerService extends INotificationManager.Stub } } + static long[] getLongArray(Resources r, int resid, int maxlen, long[] def) { + int[] ar = r.getIntArray(resid); + if (ar == null) { + return def; + } + final int len = ar.length > maxlen ? maxlen : ar.length; + long[] out = new long[len]; + for (int i=0; i 1) { + // If you want your own vibration pattern, you need the VIBRATE permission + mVibrator.vibrate(notification.vibrate, + ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); + } } } From b361b3043bb351ab175ae1ff3dae4de9fe31d42b Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Mon, 19 Nov 2012 12:33:41 -0800 Subject: [PATCH 2/2] Revert "NumberPicker should adjust min and max when displayed values are set." (a.k.a. Santa is back) This reverted change was adjusting the min and max values for the NumberPicker which is not desirable since it changes behavior and it will be possible for an app that works on the current platform to crash on an older one. Also the adjustment was not implemented correctly. Updated the documentation to clarify the reltionship between the min value, max value, and the displayed values array. Bug:7518172 This reverts commit a1410e6789ce72bc423793315a51aea8b6bad6c7 Change-Id: I109f1b1f54c1e609941243cabab9241871b6b12b --- core/java/android/widget/NumberPicker.java | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index 4918e488d13f8..ac21671720234 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -1284,7 +1284,12 @@ public class NumberPicker extends LinearLayout { /** * Sets the min value of the picker. * - * @param minValue The min value. + * @param minValue The min value inclusive. + * + * Note: The length of the displayed values array + * set via {@link #setDisplayedValues(String[])} must be equal to the + * range of selectable numbers which is equal to + * {@link #getMaxValue()} - {@link #getMinValue()} + 1. */ public void setMinValue(int minValue) { if (mMinValue == minValue) { @@ -1317,7 +1322,12 @@ public class NumberPicker extends LinearLayout { /** * Sets the max value of the picker. * - * @param maxValue The max value. + * @param maxValue The max value inclusive. + * + * Note: The length of the displayed values array + * set via {@link #setDisplayedValues(String[])} must be equal to the + * range of selectable numbers which is equal to + * {@link #getMaxValue()} - {@link #getMinValue()} + 1. */ public void setMaxValue(int maxValue) { if (mMaxValue == maxValue) { @@ -1351,6 +1361,10 @@ public class NumberPicker extends LinearLayout { * Sets the values to be displayed. * * @param displayedValues The displayed values. + * + * Note: The length of the displayed values array + * must be equal to the range of selectable numbers which is equal to + * {@link #getMaxValue()} - {@link #getMinValue()} + 1. */ public void setDisplayedValues(String[] displayedValues) { if (mDisplayedValues == displayedValues) { @@ -1361,14 +1375,6 @@ public class NumberPicker extends LinearLayout { // Allow text entry rather than strictly numeric entry. mInputText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - // Make sure the min, max, respect the size of the displayed - // values. This will take care of the current value as well. - if (getMinValue() >= displayedValues.length) { - setMinValue(0); - } - if (getMaxValue() >= displayedValues.length) { - setMaxValue(displayedValues.length - 1); - } } else { mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER); }