Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e37473e authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

Merge commit 'android-4.2.1_r1' into mr1-staging

Change-Id: I1f5dddb99c9d381607124ae963fdadf990715e18
parents a3caca7c b361b304
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -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.
     *
     * <strong>Note:</strong> 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.
     *
     * <strong>Note:</strong> 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.
     *
     * <strong>Note:</strong> 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);
        }
+21 −0
Original line number Diff line number Diff line
@@ -1007,6 +1007,27 @@
         where if the preferred is used we don't try the others. -->
    <bool name="config_dontPreferApn">false</bool>

    <!-- Vibrator pattern to be used as the default for notifications
         that specify DEFAULT_VIBRATE.
     -->
    <integer-array name="config_defaultNotificationVibePattern">
        <item>0</item>
        <item>250</item>
        <item>250</item>
        <item>250</item>
    </integer-array>

    <!-- Vibrator pattern to be used as the default for notifications
         that do not specify vibration but vibrate anyway because the device
         is in vibrate mode.
     -->
    <integer-array name="config_notificationFallbackVibePattern">
        <item>0</item>
        <item>250</item>
        <item>250</item>
        <item>250</item>
    </integer-array>

    <!-- Values greater or equal to 0 will enable electronbeam screen-on
         animation with the specified delay (in milliseconds), -1 will disable the animation -->
    <integer name="config_screenOnAnimation">-1</integer>
+2 −0
Original line number Diff line number Diff line
@@ -1525,6 +1525,8 @@
  <java-symbol type="array" name="radioAttributes" />
  <java-symbol type="array" name="config_oemUsbModeOverride" />
  <java-symbol type="array" name="config_locationProviderPackageNames" />
  <java-symbol type="array" name="config_defaultNotificationVibePattern" />
  <java-symbol type="array" name="config_notificationFallbackVibePattern" />
  <java-symbol type="bool" name="config_animateScreenLights" />
  <java-symbol type="bool" name="config_automatic_brightness_available" />
  <java-symbol type="bool" name="config_sf_limitedAlpha" />
+51 −9
Original line number Diff line number Diff line
@@ -113,6 +113,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;
@@ -138,6 +139,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;

@@ -711,6 +715,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<len; i++) {
            out[i] = ar[i];
        }
        return out;
    }

    NotificationManagerService(Context context, StatusBarManagerService statusBar,
            LightsService lights)
    {
@@ -746,6 +763,16 @@ public class NotificationManagerService extends INotificationManager.Stub
            mPackageNameMappings.put(map[0], map[1]);
        }

        mDefaultVibrationPattern = getLongArray(resources,
                com.android.internal.R.array.config_defaultNotificationVibePattern,
                VIBRATE_PATTERN_MAXLEN,
                DEFAULT_VIBRATE_PATTERN);

        mFallbackVibrationPattern = getLongArray(resources,
                com.android.internal.R.array.config_notificationFallbackVibePattern,
                VIBRATE_PATTERN_MAXLEN,
                DEFAULT_VIBRATE_PATTERN);

        // Don't start allowing notifications until the setup wizard has run once.
        // After that, including subsequent boots, init with notifications turned on.
        // This works on the first boot because the setup wizard will toggle this
@@ -1226,26 +1253,41 @@ public class NotificationManagerService extends INotificationManager.Stub
                }

                // vibrate
                // Does the notification want to specify its own vibration?
                final boolean hasCustomVibrate = notification.vibrate != null;

                // new in 4.2: if there was supposed to be a sound and we're in vibrate mode,
                // we always vibrate, even if no vibration was specified
                // and no other vibration is specified, we apply the default vibration anyway
                final boolean convertSoundToVibration =
                           notification.vibrate == null
                           !hasCustomVibrate
                        && (useDefaultSound || notification.sound != null)
                        && (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE);

                // The DEFAULT_VIBRATE flag trumps any custom vibration.
                final boolean useDefaultVibrate =
                    (notification.defaults & Notification.DEFAULT_VIBRATE) != 0
                    || convertSoundToVibration;
                        (notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
                if (!(inQuietHours && mQuietHoursStill)
                        && (useDefaultVibrate || notification.vibrate != null)
                        && (useDefaultVibrate || convertSoundToVibration || hasCustomVibrate)
                        && !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) {
                    mVibrateNotification = r;

                    mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN
                                                        : notification.vibrate,
                    if (useDefaultVibrate || convertSoundToVibration) {
                        // Escalate privileges so we can use the vibrator even if the notifying app
                        // does not have the VIBRATE permission.
                        long identity = Binder.clearCallingIdentity();
                        try {
                            mVibrator.vibrate(convertSoundToVibration ? mFallbackVibrationPattern
                                                                      : mDefaultVibrationPattern,
                                ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);
                        } finally {
                            Binder.restoreCallingIdentity(identity);
                        }
                    } else if (notification.vibrate.length > 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);
                    }
                }
            }

            // this option doesn't shut off the lights