BatteryLights: Add ability to turn off LED when fully charged
Change-Id: I01b8c753a1f92838462a797fd97b5f6a3c666158
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
* 2017-2020 The LineageOS Project
|
||||
* 2017-2021 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -1315,6 +1315,17 @@ public final class LineageSettings {
|
||||
public static final Validator BATTERY_LIGHT_ENABLED_VALIDATOR =
|
||||
sBooleanValidator;
|
||||
|
||||
/**
|
||||
* Whether the battery LED should be disabled when the battery is fully charged.
|
||||
* The value is boolean (1 or 0).
|
||||
*/
|
||||
public static final String BATTERY_LIGHT_FULL_CHARGE_DISABLED =
|
||||
"battery_light_full_charge_disabled";
|
||||
|
||||
/** @hide */
|
||||
public static final Validator BATTERY_LIGHT_FULL_CHARGE_DISABLED_VALIDATOR =
|
||||
sBooleanValidator;
|
||||
|
||||
/**
|
||||
* Whether the battery LED should repeatedly flash when the battery is low
|
||||
* on charge. The value is boolean (1 or 0).
|
||||
@@ -2160,6 +2171,7 @@ public final class LineageSettings {
|
||||
LineageSettings.System.STYLUS_ICON_ENABLED,
|
||||
LineageSettings.System.SWAP_VOLUME_KEYS_ON_ROTATION,
|
||||
LineageSettings.System.BATTERY_LIGHT_ENABLED,
|
||||
LineageSettings.System.BATTERY_LIGHT_FULL_CHARGE_DISABLED,
|
||||
LineageSettings.System.BATTERY_LIGHT_PULSE,
|
||||
LineageSettings.System.BATTERY_LIGHT_LOW_COLOR,
|
||||
LineageSettings.System.BATTERY_LIGHT_MEDIUM_COLOR,
|
||||
@@ -2298,6 +2310,8 @@ public final class LineageSettings {
|
||||
VALIDATORS.put(BUTTON_BACKLIGHT_ONLY_WHEN_PRESSED,
|
||||
BUTTON_BACKLIGHT_ONLY_WHEN_PRESSED_VALIDATOR);
|
||||
VALIDATORS.put(BATTERY_LIGHT_ENABLED, BATTERY_LIGHT_ENABLED_VALIDATOR);
|
||||
VALIDATORS.put(BATTERY_LIGHT_FULL_CHARGE_DISABLED,
|
||||
BATTERY_LIGHT_FULL_CHARGE_DISABLED_VALIDATOR);
|
||||
VALIDATORS.put(BATTERY_LIGHT_PULSE, BATTERY_LIGHT_PULSE_VALIDATOR);
|
||||
VALIDATORS.put(BATTERY_LIGHT_LOW_COLOR, BATTERY_LIGHT_LOW_COLOR_VALIDATOR);
|
||||
VALIDATORS.put(BATTERY_LIGHT_MEDIUM_COLOR, BATTERY_LIGHT_MEDIUM_COLOR_VALIDATOR);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017-2018 The LineageOS Project
|
||||
* Copyright (C) 2017-2019,2021 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,6 +48,7 @@ public final class LineageBatteryLights {
|
||||
|
||||
// Battery light intended operational state.
|
||||
private boolean mLightEnabled = false; // Disable until observer is started
|
||||
private boolean mLightFullChargeDisabled;
|
||||
private boolean mLedPulseEnabled;
|
||||
private int mBatteryLowARGB;
|
||||
private int mBatteryMediumARGB;
|
||||
@@ -133,7 +134,7 @@ public final class LineageBatteryLights {
|
||||
ledValues.setEnabled(false);
|
||||
ledValues.setColor(0);
|
||||
|
||||
if (!mLightEnabled) {
|
||||
if (!mLightEnabled || mLightFullChargeDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -215,6 +216,11 @@ public final class LineageBatteryLights {
|
||||
LineageSettings.System.BATTERY_LIGHT_ENABLED), false, this,
|
||||
UserHandle.USER_ALL);
|
||||
|
||||
// Battery light disabled if fully charged
|
||||
resolver.registerContentObserver(LineageSettings.System.getUriFor(
|
||||
LineageSettings.System.BATTERY_LIGHT_FULL_CHARGE_DISABLED), false, this,
|
||||
UserHandle.USER_ALL);
|
||||
|
||||
// Low battery pulse
|
||||
resolver.registerContentObserver(LineageSettings.System.getUriFor(
|
||||
LineageSettings.System.BATTERY_LIGHT_PULSE), false, this,
|
||||
@@ -261,6 +267,11 @@ public final class LineageBatteryLights {
|
||||
LineageSettings.System.BATTERY_LIGHT_ENABLED,
|
||||
1, UserHandle.USER_CURRENT) != 0;
|
||||
|
||||
// Battery light disabled if fully charged
|
||||
mLightFullChargeDisabled = LineageSettings.System.getIntForUser(resolver,
|
||||
LineageSettings.System.BATTERY_LIGHT_FULL_CHARGE_DISABLED,
|
||||
1, UserHandle.USER_CURRENT) != 0;
|
||||
|
||||
// Low battery pulse
|
||||
mLedPulseEnabled = LineageSettings.System.getIntForUser(resolver,
|
||||
LineageSettings.System.BATTERY_LIGHT_PULSE,
|
||||
|
||||
Reference in New Issue
Block a user