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

Commit 40c2abc1 authored by Sam Mortimer's avatar Sam Mortimer Committed by Steve Kondik
Browse files

[1/2] frameworks/base: Battery and Notification Lights

PS2: *) Add back a few missing pieces
     *) Do not clear light state in onPanelRevealed(),
        update lights on ACTION_SCREEN_ON instead

PS3: *) Wrap long lines
     *) Disable config_multiColorNotificationLed by default
     *) Revert config_defaultNotificationLedOff
        from 1000 back to AOSP default of 2000

PS4: *) Clear lights in onPanelRevealed() if
        keyguard is not active.

PS5: Coding style tuning

Pulled together from:

Author: DvTonder <david.vantonder@gmail.com>
Author: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
Date:   Mon Nov 4 00:57:51 2013 +0000
Framework: Port CM9 features to CM10
Change-Id: Ibd63116df90b06f6ce6adb8a0343059bbb999bfb

Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Date:   Sun Dec 8 15:24:41 2013 +0700
BatteryService: fix FC on boot until battery stat is present
updateLightsLocked() can be called from CM's added SettingsObserver
when battery stat is not present, causing an FC and a loop until
battery stat is present.
Change-Id: Ic4438fe50e98f1aa05ae1d0d26240bf9410fd92f

Author: Sam Mortimer <sam@mortimer.me.uk>
Date:   Tue Dec 31 16:22:05 2013 -0800
[2/2] Framework: instant led test
Adds support a new notification extra boolean
EXTRA_FORCE_SHOW_LIGHTS.  Used by settings
notification light picker to force lights on
when the screen is on.
Change-Id: If0a42d32b28fe8c02ef5f7dd148db7eb478fac17

Author: Danny Baumann <dannybaumann@web.de>
Date:   Wed Apr 24 11:09:55 2013 +0200
Allow creating custom dialogs in DialogPreference.
This allows creating non-AlertDialogs while still using the click and
state handling of DialogPreference.
Change-Id: I54fd7d6d6b9f6a49fef1ae95e0178838b3edfa56

Author: Michael Bestas <mikeioannina@gmail.com>
Date:   Mon Aug 18 04:56:28 2014 +0300
Add support for single color notification LED (1/2)
Change-Id: I367af77036da9e87c6dd0df552ce4c56d945a44d

Change-Id: I564fdb6ca6c5bbcf890afa4b9a2f9fa7bf8b9604
parent bbd00b78
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -990,6 +990,13 @@ public class Notification implements Parcelable
    private Icon mSmallIcon;
    private Icon mLargeIcon;

    /**
     * Used by light picker in Settings to force
     * notification lights on when screen is on
     * @hide
     */
    public static final String EXTRA_FORCE_SHOW_LIGHTS = "android.forceShowLights";

    /**
     * Structure to encapsulate a named action that can be shown as part of this notification.
     * It must include an icon, a label, and a {@link PendingIntent} to be fired when the action is
+18 −11
Original line number Diff line number Diff line
@@ -285,6 +285,22 @@ public abstract class DialogPreference extends Preference implements
     * @param state Optional instance state to restore on the dialog
     */
    protected void showDialog(Bundle state) {
        // Create the dialog
        final Dialog dialog = mDialog = createDialog();
        if (state != null) {
            dialog.onRestoreInstanceState(state);
        }
        if (needInputMethod()) {
            requestInputMethod(dialog);
        }
        dialog.setOnDismissListener(this);
        dialog.show();
    }

    /**
     * @hide
     */
    protected Dialog createDialog() {
        Context context = getContext();

        mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE;
@@ -307,16 +323,7 @@ public abstract class DialogPreference extends Preference implements
        
        getPreferenceManager().registerOnActivityDestroyListener(this);

        // Create the dialog
        final Dialog dialog = mDialog = mBuilder.create();
        if (state != null) {
            dialog.onRestoreInstanceState(state);
        }
        if (needInputMethod()) {
            requestInputMethod(dialog);
        }
        dialog.setOnDismissListener(this);
        dialog.show();
        return mBuilder.create();
    }

    /**
+108 −0
Original line number Diff line number Diff line
@@ -3340,6 +3340,114 @@ public final class Settings {
        /** @hide */
        public static final Validator NOTIFICATION_LIGHT_PULSE_VALIDATOR = sBooleanValidator;

        /**
         * What color to use for the notification LED by default
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR =
                "notification_light_pulse_default_color";

        /**
         * How long to flash the notification LED by default
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_ON =
                "notification_light_pulse_default_led_on";

        /**
         * How long to wait between flashes for the notification LED by default
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_OFF =
                "notification_light_pulse_default_led_off";

        /**
         * What color to use for the missed call notification LED
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_CALL_COLOR =
                "notification_light_pulse_call_color";

        /**
         * How long to flash the missed call notification LED
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_CALL_LED_ON =
                "notification_light_pulse_call_led_on";

        /**
         * How long to wait between flashes for the missed call notification LED
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_CALL_LED_OFF =
                "notification_light_pulse_call_led_off";
        /**
         * What color to use for the voicemail notification LED
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR =
                "notification_light_pulse_vmail_color";

        /**
         * How long to flash the voicemail notification LED
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON =
                "notification_light_pulse_vmail_led_on";

        /**
         * How long to wait between flashes for the voicemail notification LED
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF =
                "notification_light_pulse_vmail_led_off";

        /**
         * Whether to use the custom LED values for the notification pulse LED.
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE =
                "notification_light_pulse_custom_enable";

        /**
         * Which custom LED values to use for the notification pulse LED.
         * @hide
         */
        public static final String NOTIFICATION_LIGHT_PULSE_CUSTOM_VALUES =
                "notification_light_pulse_custom_values";

        /**
         * Whether the battery light should be enabled (if hardware supports it)
         * The value is boolean (1 or 0).
         * @hide
         */
        public static final String BATTERY_LIGHT_ENABLED = "battery_light_enabled";

        /**
         * Whether the battery LED should repeatedly flash when the battery is low
         * on charge. The value is boolean (1 or 0).
         * @hide
         */
        public static final String BATTERY_LIGHT_PULSE = "battery_light_pulse";

        /**
         * What color to use for the battery LED while charging - low
         * @hide
         */
        public static final String BATTERY_LIGHT_LOW_COLOR = "battery_light_low_color";

        /**
         * What color to use for the battery LED while charging - medium
         * @hide
         */
        public static final String BATTERY_LIGHT_MEDIUM_COLOR = "battery_light_medium_color";

        /**
         * What color to use for the battery LED while charging - full
         * @hide
         */
        public static final String BATTERY_LIGHT_FULL_COLOR = "battery_light_full_color";

        /**
         * Show pointer location on screen?
         * 0 = no
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2013-2014 The CyanogenMod Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- Do not translate. Defines the mapping of notification package names
         from the actual triggering package to the user selectable package.
         E.g. GTalk notifications come via Google Services Framework
         Format: [triggering package]|[user package] -->
    <string-array name="notification_light_package_mapping" translatable="false">
        <item>com.google.android.gsf|com.google.android.talk</item>
    </string-array>

</resources>
+21 −0
Original line number Diff line number Diff line
@@ -931,6 +931,17 @@
    <!-- Is the notification LED intrusive? Used to decide if there should be a disable option -->
    <bool name="config_intrusiveNotificationLed">false</bool>

    <!-- Does the notification LED support multiple colors?
         Used to decide if the user can change the colors -->
    <bool name="config_multiColorNotificationLed">false</bool>

    <!-- Is the battery LED intrusive? Used to decide if there should be a disable option -->
    <bool name="config_intrusiveBatteryLed">false</bool>

    <!-- Does the battery LED support multiple colors?
         Used to decide if the user can change the colors -->
    <bool name="config_multiColorBatteryLed">false</bool>

    <!-- Default value for LED off time when the battery is low on charge in miliseconds -->
    <integer name="config_notificationsBatteryLedOff">2875</integer>

@@ -1935,6 +1946,16 @@
        <item>100</item>
    </integer-array>

    <!-- Vibrator pattern to be used as for notifications while alerts
         are disabled (e.g. during phone calls) if enabled by the user.
     -->
    <integer-array name="config_notificationNoAlertsVibePattern">
        <item>0</item>
        <item>50</item>
        <item>100</item>
        <item>50</item>
    </integer-array>

    <!-- Flag indicating if the speed up audio on mt call code should be executed -->
    <bool name="config_speed_up_audio_on_mt_calls">false</bool>

Loading