Skip to content

Commit d5d87b2

Browse files
author
Kenneth Andersson
committed
Make the LED colors when charging customizable by the vendor
This commit will make the default LED colors in the NotificationManager for battery charge customizable via overlays. The blink on/off times are customizable in the same manner. Change-Id: I57ce93656cc4080f5b99554df0ada44c5b31e959
1 parent 0f0dd44 commit d5d87b2

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

core/res/res/values/config.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,21 @@
227227
<!-- Default LED off time for notification LED in milliseconds. -->
228228
<integer name="config_defaultNotificationLedOff">2000</integer>
229229

230+
<!-- Default value for led color when battery is low on charge -->
231+
<integer name="config_notificationsBatteryLowARGB">0xFFFF0000</integer>
232+
233+
<!-- Default value for led color when battery is medium charged -->
234+
<integer name="config_notificationsBatteryMediumARGB">0xFFFFFF00</integer>
235+
236+
<!-- Default value for led color when battery is fully charged -->
237+
<integer name="config_notificationsBatteryFullARGB">0xFF00FF00</integer>
238+
239+
<!-- Default value for LED on time when the battery is low on charge in miliseconds -->
240+
<integer name="config_notificationsBatteryLedOn">125</integer>
241+
242+
<!-- Default value for LED off time when the battery is low on charge in miliseconds -->
243+
<integer name="config_notificationsBatteryLedOff">2875</integer>
244+
230245
<!-- Allow the menu hard key to be disabled in LockScreen on some devices -->
231246
<bool name="config_disableMenuKeyInLockScreen">false</bool>
232247

services/java/com/android/server/NotificationManagerService.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ class NotificationManagerService extends INotificationManager.Stub
127127
private boolean mBatteryFull;
128128
private NotificationRecord mLedNotification;
129129

130-
private static final int BATTERY_LOW_ARGB = 0xFFFF0000; // Charging Low - red solid on
131-
private static final int BATTERY_MEDIUM_ARGB = 0xFFFFFF00; // Charging - orange solid on
132-
private static final int BATTERY_FULL_ARGB = 0xFF00FF00; // Charging Full - green solid on
133-
private static final int BATTERY_BLINK_ON = 125;
134-
private static final int BATTERY_BLINK_OFF = 2875;
130+
private static int mBatteryLowARGB;
131+
private static int mBatteryMediumARGB;
132+
private static int mBatteryFullARGB;
133+
private static int mBatteryLedOn;
134+
private static int mBatteryLedOff;
135135

136136
private static String idDebugString(Context baseContext, String packageName, int id) {
137137
Context c = null;
@@ -432,6 +432,17 @@ public void update() {
432432
mDefaultNotificationLedOff = resources.getInteger(
433433
com.android.internal.R.integer.config_defaultNotificationLedOff);
434434

435+
mBatteryLowARGB = mContext.getResources().getInteger(
436+
com.android.internal.R.integer.config_notificationsBatteryLowARGB);
437+
mBatteryMediumARGB = mContext.getResources().getInteger(
438+
com.android.internal.R.integer.config_notificationsBatteryMediumARGB);
439+
mBatteryFullARGB = mContext.getResources().getInteger(
440+
com.android.internal.R.integer.config_notificationsBatteryFullARGB);
441+
mBatteryLedOn = mContext.getResources().getInteger(
442+
com.android.internal.R.integer.config_notificationsBatteryLedOn);
443+
mBatteryLedOff = mContext.getResources().getInteger(
444+
com.android.internal.R.integer.config_notificationsBatteryLedOff);
445+
435446
// Don't start allowing notifications until the setup wizard has run once.
436447
// After that, including subsequent boots, init with notifications turned on.
437448
// This works on the first boot because the setup wizard will toggle this
@@ -1043,17 +1054,17 @@ private void updateLightsLocked()
10431054
// Battery low always shows, other states only show if charging.
10441055
if (mBatteryLow) {
10451056
if (mBatteryCharging) {
1046-
mBatteryLight.setColor(BATTERY_LOW_ARGB);
1057+
mBatteryLight.setColor(mBatteryLowARGB);
10471058
} else {
10481059
// Flash when battery is low and not charging
1049-
mBatteryLight.setFlashing(BATTERY_LOW_ARGB, LightsService.LIGHT_FLASH_TIMED,
1050-
BATTERY_BLINK_ON, BATTERY_BLINK_OFF);
1060+
mBatteryLight.setFlashing(mBatteryLowARGB, LightsService.LIGHT_FLASH_TIMED,
1061+
mBatteryLedOn, mBatteryLedOff);
10511062
}
10521063
} else if (mBatteryCharging) {
10531064
if (mBatteryFull) {
1054-
mBatteryLight.setColor(BATTERY_FULL_ARGB);
1065+
mBatteryLight.setColor(mBatteryFullARGB);
10551066
} else {
1056-
mBatteryLight.setColor(BATTERY_MEDIUM_ARGB);
1067+
mBatteryLight.setColor(mBatteryMediumARGB);
10571068
}
10581069
} else {
10591070
mBatteryLight.turnOff();

0 commit comments

Comments
 (0)