diff options
author | Steve Kondik <steve@cyngn.com> | 2016-05-03 03:03:49 -0700 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2016-05-04 02:33:39 -0700 |
commit | ef03777a5be9c94624dd7b08652ff3086202eaa7 (patch) | |
tree | 65a9c9323f03c560c1b3c8a03083d97afd461968 /services/core | |
parent | d8a30fc958a9e5cf780c6dc437a4487e73eba956 (diff) | |
download | frameworks_base-ef03777a5be9c94624dd7b08652ff3086202eaa7.zip frameworks_base-ef03777a5be9c94624dd7b08652ff3086202eaa7.tar.gz frameworks_base-ef03777a5be9c94624dd7b08652ff3086202eaa7.tar.bz2 |
batteryservice: Add support for segmented power LEDs
* A certain device has a segmented LED which is going to be
repurposed as a battery level indicator. Add support for this
by sending the battery level in the alpha component of the
ARGB value sent to the HAL.
Change-Id: I97a4459aa8069447ce7d153a0c03c743935b0937
Diffstat (limited to 'services/core')
-rw-r--r-- | services/core/java/com/android/server/BatteryService.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java index f20cfe9..fd04811 100644 --- a/services/core/java/com/android/server/BatteryService.java +++ b/services/core/java/com/android/server/BatteryService.java @@ -165,6 +165,7 @@ public final class BatteryService extends SystemService { private boolean mAdjustableNotificationLedBrightness; private int mNotificationLedBrightnessLevel = LIGHT_BRIGHTNESS_MAXIMUM; + private boolean mUseSegmentedBatteryLed = false; private boolean mMultipleNotificationLeds; private boolean mMultipleLedsEnabled = false; @@ -1048,6 +1049,11 @@ public final class BatteryService extends SystemService { com.android.internal.R.integer.config_notificationsBatteryLedOn); mBatteryLedOff = context.getResources().getInteger( com.android.internal.R.integer.config_notificationsBatteryLedOff); + + // Does a device have a segmented battery LED? In this case, we send the level + // in the lower 8 bits of the color and let the HAL sort it out. + mUseSegmentedBatteryLed = context.getResources().getBoolean( + org.cyanogenmod.platform.internal.R.bool.config_useSegmentedBatteryLed); } private boolean isHvdcpPresent() { @@ -1089,9 +1095,14 @@ public final class BatteryService extends SystemService { final int level = mBatteryProps.batteryLevel; final int status = mBatteryProps.batteryStatus; + if (!mLightEnabled) { // No lights if explicitly disabled mBatteryLight.turnOff(); + } else if (mUseSegmentedBatteryLed && + (status == BatteryManager.BATTERY_STATUS_CHARGING + || status == BatteryManager.BATTERY_STATUS_FULL)) { + mBatteryLight.setColor(level); } else if (level < mLowBatteryWarningLevel) { mBatteryLight.setModes(mNotificationLedBrightnessLevel, mMultipleLedsEnabled); |