LineageBatteryLights: Rename some class members and add more debugging
* Follow LineageNotificationLights debug logic Change-Id: I6b4a91db45a119c8c0b8b30684386765b73b93d2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
* Copyright (C) 2017-2018 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.
|
||||
@@ -41,7 +41,7 @@ public final class LineageBatteryLights {
|
||||
|
||||
// Battery light capabilities.
|
||||
private final boolean mHasBatteryLed;
|
||||
private final boolean mMultiColorLed;
|
||||
private final boolean mMultiColorBatteryLed;
|
||||
// Whether the lights HAL supports changing brightness.
|
||||
private final boolean mHALAdjustableBrightness;
|
||||
// Whether the light should be considered brightness adjustable
|
||||
@@ -55,8 +55,8 @@ public final class LineageBatteryLights {
|
||||
private int mBatteryLowARGB;
|
||||
private int mBatteryMediumARGB;
|
||||
private int mBatteryFullARGB;
|
||||
private int mBatteryBrightness;
|
||||
private int mBatteryBrightnessZen;
|
||||
private int mBatteryBrightnessLevel;
|
||||
private int mBatteryBrightnessZenLevel;
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
@@ -72,12 +72,12 @@ public final class LineageBatteryLights {
|
||||
mContext = context;
|
||||
mLedUpdater = ledUpdater;
|
||||
|
||||
// Does the device have a battery LED ?
|
||||
// Does the device have a battery LED?
|
||||
mHasBatteryLed = LightsCapabilities.supports(
|
||||
mContext, LightsCapabilities.LIGHTS_BATTERY_LED);
|
||||
|
||||
// Does the device support changing battery LED colors?
|
||||
mMultiColorLed = LightsCapabilities.supports(
|
||||
mMultiColorBatteryLed = LightsCapabilities.supports(
|
||||
mContext, LightsCapabilities.LIGHTS_RGB_BATTERY_LED);
|
||||
|
||||
mHALAdjustableBrightness = LightsCapabilities.supports(
|
||||
@@ -85,7 +85,7 @@ public final class LineageBatteryLights {
|
||||
|
||||
// We support brightness adjustment if either the HAL supports it
|
||||
// or the light is RGB adjustable.
|
||||
mCanAdjustBrightness = mHALAdjustableBrightness || mMultiColorLed;
|
||||
mCanAdjustBrightness = mHALAdjustableBrightness || mMultiColorBatteryLed;
|
||||
|
||||
// Does the device have segmented battery LED support? In this case, we send the level
|
||||
// in the alpha channel of the color and let the HAL sort it out.
|
||||
@@ -115,9 +115,21 @@ public final class LineageBatteryLights {
|
||||
|
||||
public void calcLights(LedValues ledValues, int level, int status, boolean low) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "calcLights input: ledValues={ " + ledValues + " } level="
|
||||
+ level + " status=" + status + " low=" + low);
|
||||
Slog.i(TAG, "calcLights input:"
|
||||
+ " ledValues={ " + ledValues + " }"
|
||||
+ " level=" + level
|
||||
+ " status=" + status
|
||||
+ " low=" + low
|
||||
+ " mCanAdjustBrightness=" + mCanAdjustBrightness
|
||||
+ " mHALAdjustableBrightness=" + mHALAdjustableBrightness
|
||||
+ " mMultiColorBatteryLed=" + mMultiColorBatteryLed
|
||||
+ " mUseSegmentedBatteryLed=" + mUseSegmentedBatteryLed
|
||||
+ " mBatteryBrightnessLevel=" + mBatteryBrightnessLevel
|
||||
+ " mBatteryBrightnessZenLevel=" + mBatteryBrightnessZenLevel
|
||||
+ " mZenMode=" + mZenMode
|
||||
);
|
||||
}
|
||||
|
||||
// The only meaningful ledValues values received by frameworks BatteryService
|
||||
// are the pulse times (for low battery). Explicitly set enabled state and
|
||||
// color to ensure that we arrive at a deterministic outcome.
|
||||
@@ -135,9 +147,9 @@ public final class LineageBatteryLights {
|
||||
} else if (mUseSegmentedBatteryLed) {
|
||||
brightness = level;
|
||||
} else if (mZenMode == Global.ZEN_MODE_OFF) {
|
||||
brightness = mBatteryBrightness;
|
||||
brightness = mBatteryBrightnessLevel;
|
||||
} else {
|
||||
brightness = mBatteryBrightnessZen;
|
||||
brightness = mBatteryBrightnessZenLevel;
|
||||
}
|
||||
ledValues.setBrightness(brightness);
|
||||
|
||||
@@ -203,7 +215,7 @@ public final class LineageBatteryLights {
|
||||
LineageSettings.System.BATTERY_LIGHT_PULSE), false, this,
|
||||
UserHandle.USER_ALL);
|
||||
|
||||
if (mMultiColorLed) {
|
||||
if (mMultiColorBatteryLed) {
|
||||
// Light colors
|
||||
resolver.registerContentObserver(LineageSettings.System.getUriFor(
|
||||
LineageSettings.System.BATTERY_LIGHT_LOW_COLOR), false, this,
|
||||
@@ -258,13 +270,14 @@ public final class LineageBatteryLights {
|
||||
LineageSettings.System.BATTERY_LIGHT_FULL_COLOR, res.getInteger(
|
||||
com.android.internal.R.integer.config_notificationsBatteryFullARGB));
|
||||
|
||||
// Adustable battery LED brightness.
|
||||
if (mCanAdjustBrightness) {
|
||||
// Battery brightness level
|
||||
mBatteryBrightness = LineageSettings.System.getInt(resolver,
|
||||
mBatteryBrightnessLevel = LineageSettings.System.getInt(resolver,
|
||||
LineageSettings.System.BATTERY_LIGHT_BRIGHTNESS_LEVEL,
|
||||
LedValues.LIGHT_BRIGHTNESS_MAXIMUM);
|
||||
// Battery brightness level in Do Not Disturb mode
|
||||
mBatteryBrightnessZen = LineageSettings.System.getInt(resolver,
|
||||
mBatteryBrightnessZenLevel = LineageSettings.System.getInt(resolver,
|
||||
LineageSettings.System.BATTERY_LIGHT_BRIGHTNESS_LEVEL_ZEN,
|
||||
LedValues.LIGHT_BRIGHTNESS_MAXIMUM);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user