Loading core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -1890,6 +1890,13 @@ public final class Settings { */ public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse"; /** * 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"; /** * Show pointer location on screen? * 0 = no Loading core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -437,6 +437,9 @@ <!-- Is the notification LED intrusive? Used to decide if there should be a disable option --> <bool name="config_intrusiveNotificationLed">false</bool> <!-- Is the battery LED intrusive? Used to decide if there should be a disable option --> <bool name="config_intrusiveBatteryLed">false</bool> <!-- Default value for LED off time when the battery is low on charge in miliseconds --> <integer name="config_notificationsBatteryLedOff">2875</integer> Loading services/java/com/android/server/BatteryService.java +41 −1 Original line number Diff line number Diff line Loading @@ -24,9 +24,11 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.os.BatteryManager; import android.os.Binder; import android.os.FileUtils; import android.os.Handler; import android.os.IBinder; import android.os.DropBoxManager; import android.os.RemoteException; Loading Loading @@ -122,6 +124,7 @@ class BatteryService extends Binder { private int mDischargeStartLevel; private Led mLed; private boolean mLedPulseEnabled; private boolean mSentLowBatteryBroadcast = false; Loading @@ -144,6 +147,9 @@ class BatteryService extends Binder { mInvalidChargerObserver.startObserving("DEVPATH=/devices/virtual/switch/invalid_charger"); } SettingsObserver observer = new SettingsObserver(new Handler()); observer.observe(); // set initial status update(); } Loading Loading @@ -542,6 +548,10 @@ class BatteryService extends Binder { } } private synchronized void updateLedPulse() { mLed.updateLightsLocked(); } class Led { private LightsService mLightsService; private LightsService.Light mBatteryLight; Loading Loading @@ -582,10 +592,13 @@ class BatteryService extends Binder { if (status == BatteryManager.BATTERY_STATUS_CHARGING) { // Solid red when battery is charging mBatteryLight.setColor(mBatteryLowARGB); } else { } else if (mLedPulseEnabled) { // Flash red when battery is low and not charging mBatteryLight.setFlashing(mBatteryLowARGB, LightsService.LIGHT_FLASH_TIMED, mBatteryLedOn, mBatteryLedOff); } else { // "Pulse low battery light" is disabled, no lights. mBatteryLight.turnOff(); } } else if (status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL) { Loading @@ -602,5 +615,32 @@ class BatteryService extends Binder { } } } class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { super(handler); } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.BATTERY_LIGHT_PULSE), false, this); update(); } @Override public void onChange(boolean selfChange) { update(); } public void update() { ContentResolver resolver = mContext.getContentResolver(); boolean pulseEnabled = Settings.System.getInt(resolver, Settings.System.BATTERY_LIGHT_PULSE, 1) != 0; if (mLedPulseEnabled != pulseEnabled) { mLedPulseEnabled = pulseEnabled; updateLedPulse(); } } } } Loading
core/java/android/provider/Settings.java +7 −0 Original line number Diff line number Diff line Loading @@ -1890,6 +1890,13 @@ public final class Settings { */ public static final String NOTIFICATION_LIGHT_PULSE = "notification_light_pulse"; /** * 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"; /** * Show pointer location on screen? * 0 = no Loading
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -437,6 +437,9 @@ <!-- Is the notification LED intrusive? Used to decide if there should be a disable option --> <bool name="config_intrusiveNotificationLed">false</bool> <!-- Is the battery LED intrusive? Used to decide if there should be a disable option --> <bool name="config_intrusiveBatteryLed">false</bool> <!-- Default value for LED off time when the battery is low on charge in miliseconds --> <integer name="config_notificationsBatteryLedOff">2875</integer> Loading
services/java/com/android/server/BatteryService.java +41 −1 Original line number Diff line number Diff line Loading @@ -24,9 +24,11 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.os.BatteryManager; import android.os.Binder; import android.os.FileUtils; import android.os.Handler; import android.os.IBinder; import android.os.DropBoxManager; import android.os.RemoteException; Loading Loading @@ -122,6 +124,7 @@ class BatteryService extends Binder { private int mDischargeStartLevel; private Led mLed; private boolean mLedPulseEnabled; private boolean mSentLowBatteryBroadcast = false; Loading @@ -144,6 +147,9 @@ class BatteryService extends Binder { mInvalidChargerObserver.startObserving("DEVPATH=/devices/virtual/switch/invalid_charger"); } SettingsObserver observer = new SettingsObserver(new Handler()); observer.observe(); // set initial status update(); } Loading Loading @@ -542,6 +548,10 @@ class BatteryService extends Binder { } } private synchronized void updateLedPulse() { mLed.updateLightsLocked(); } class Led { private LightsService mLightsService; private LightsService.Light mBatteryLight; Loading Loading @@ -582,10 +592,13 @@ class BatteryService extends Binder { if (status == BatteryManager.BATTERY_STATUS_CHARGING) { // Solid red when battery is charging mBatteryLight.setColor(mBatteryLowARGB); } else { } else if (mLedPulseEnabled) { // Flash red when battery is low and not charging mBatteryLight.setFlashing(mBatteryLowARGB, LightsService.LIGHT_FLASH_TIMED, mBatteryLedOn, mBatteryLedOff); } else { // "Pulse low battery light" is disabled, no lights. mBatteryLight.turnOff(); } } else if (status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL) { Loading @@ -602,5 +615,32 @@ class BatteryService extends Binder { } } } class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { super(handler); } void observe() { ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(Settings.System.getUriFor( Settings.System.BATTERY_LIGHT_PULSE), false, this); update(); } @Override public void onChange(boolean selfChange) { update(); } public void update() { ContentResolver resolver = mContext.getContentResolver(); boolean pulseEnabled = Settings.System.getInt(resolver, Settings.System.BATTERY_LIGHT_PULSE, 1) != 0; if (mLedPulseEnabled != pulseEnabled) { mLedPulseEnabled = pulseEnabled; updateLedPulse(); } } } }