Loading packages/SystemUI/src/com/android/systemui/statusbar/charging/WiredChargingRippleController.kt +7 −8 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ class WiredChargingRippleController @Inject constructor( private val windowManager: WindowManager, private val systemClock: SystemClock ) { private var charging: Boolean? = null private var pluggedIn: Boolean? = null private val rippleEnabled: Boolean = featureFlags.isChargingRippleEnabled && !SystemProperties.getBoolean("persist.debug.suppress-charging-ripple", false) private var normalizedPortPosX: Float = context.resources.getFloat( Loading Loading @@ -86,18 +86,17 @@ class WiredChargingRippleController @Inject constructor( val batteryStateChangeCallback = object : BatteryController.BatteryStateChangeCallback { override fun onBatteryLevelChanged( level: Int, pluggedIn: Boolean, nowCharging: Boolean nowPluggedIn: Boolean, charging: Boolean ) { // Suppresses the ripple when it's disabled, or when the state change comes // from wireless charging. if (!rippleEnabled || batteryController.isWirelessCharging) { if (!rippleEnabled || batteryController.isPluggedInWireless) { return } val wasCharging = charging charging = nowCharging // Only triggers when the keyguard is active and the device is just plugged in. if ((wasCharging == null || !wasCharging) && nowCharging) { val wasPluggedIn = pluggedIn pluggedIn = nowPluggedIn if ((wasPluggedIn == null || !wasPluggedIn) && nowPluggedIn) { startRippleWithDebounce() } } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java +7 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,13 @@ public interface BatteryController extends DemoMode, Dumpable, */ boolean isPluggedIn(); /** * Returns {@code true} if the device is currently plugged in via wireless charger. */ default boolean isPluggedInWireless() { return false; } /** * Returns {@code true} if the device is currently in power save mode. */ Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC protected int mLevel; protected boolean mPluggedIn; private boolean mPluggedInWireless; protected boolean mCharging; private boolean mStateUnknown = false; private boolean mCharged; Loading Loading @@ -175,6 +176,8 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0) / intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100)); mPluggedIn = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0; mPluggedInWireless = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) == BatteryManager.BATTERY_PLUGGED_WIRELESS; final int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN); Loading Loading @@ -259,6 +262,11 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC return mWirelessCharging; } @Override public boolean isPluggedInWireless() { return mPluggedInWireless; } @Override public void getEstimatedTimeRemainingString(EstimateFetchCompletion completion) { // Need to fetch or refresh the estimate, but it may involve binder calls so offload the Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/charging/WiredChargingRippleControllerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -71,8 +71,8 @@ class WiredChargingRippleControllerTest : SysuiTestCase() { // Verify ripple added to window manager. captor.value.onBatteryLevelChanged( 0 /* unusedBatteryLevel */, false /* plugged in */, true /* charging */) true /* plugged in */, false /* charging */) val attachListenerCaptor = ArgumentCaptor.forClass(View.OnAttachStateChangeListener::class.java) verify(rippleView).addOnAttachStateChangeListener(attachListenerCaptor.capture()) Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/charging/WiredChargingRippleController.kt +7 −8 Original line number Diff line number Diff line Loading @@ -57,7 +57,7 @@ class WiredChargingRippleController @Inject constructor( private val windowManager: WindowManager, private val systemClock: SystemClock ) { private var charging: Boolean? = null private var pluggedIn: Boolean? = null private val rippleEnabled: Boolean = featureFlags.isChargingRippleEnabled && !SystemProperties.getBoolean("persist.debug.suppress-charging-ripple", false) private var normalizedPortPosX: Float = context.resources.getFloat( Loading Loading @@ -86,18 +86,17 @@ class WiredChargingRippleController @Inject constructor( val batteryStateChangeCallback = object : BatteryController.BatteryStateChangeCallback { override fun onBatteryLevelChanged( level: Int, pluggedIn: Boolean, nowCharging: Boolean nowPluggedIn: Boolean, charging: Boolean ) { // Suppresses the ripple when it's disabled, or when the state change comes // from wireless charging. if (!rippleEnabled || batteryController.isWirelessCharging) { if (!rippleEnabled || batteryController.isPluggedInWireless) { return } val wasCharging = charging charging = nowCharging // Only triggers when the keyguard is active and the device is just plugged in. if ((wasCharging == null || !wasCharging) && nowCharging) { val wasPluggedIn = pluggedIn pluggedIn = nowPluggedIn if ((wasPluggedIn == null || !wasPluggedIn) && nowPluggedIn) { startRippleWithDebounce() } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java +7 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,13 @@ public interface BatteryController extends DemoMode, Dumpable, */ boolean isPluggedIn(); /** * Returns {@code true} if the device is currently plugged in via wireless charger. */ default boolean isPluggedInWireless() { return false; } /** * Returns {@code true} if the device is currently in power save mode. */ Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java +8 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC protected int mLevel; protected boolean mPluggedIn; private boolean mPluggedInWireless; protected boolean mCharging; private boolean mStateUnknown = false; private boolean mCharged; Loading Loading @@ -175,6 +176,8 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0) / intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100)); mPluggedIn = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0; mPluggedInWireless = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) == BatteryManager.BATTERY_PLUGGED_WIRELESS; final int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN); Loading Loading @@ -259,6 +262,11 @@ public class BatteryControllerImpl extends BroadcastReceiver implements BatteryC return mWirelessCharging; } @Override public boolean isPluggedInWireless() { return mPluggedInWireless; } @Override public void getEstimatedTimeRemainingString(EstimateFetchCompletion completion) { // Need to fetch or refresh the estimate, but it may involve binder calls so offload the Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/charging/WiredChargingRippleControllerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -71,8 +71,8 @@ class WiredChargingRippleControllerTest : SysuiTestCase() { // Verify ripple added to window manager. captor.value.onBatteryLevelChanged( 0 /* unusedBatteryLevel */, false /* plugged in */, true /* charging */) true /* plugged in */, false /* charging */) val attachListenerCaptor = ArgumentCaptor.forClass(View.OnAttachStateChangeListener::class.java) verify(rippleView).addOnAttachStateChangeListener(attachListenerCaptor.capture()) Loading