diff options
| author | 2023-01-24 15:32:31 +0000 | |
|---|---|---|
| committer | 2023-01-24 15:32:31 +0000 | |
| commit | e220dd0547d09ffb778bb8ccacf8baf07259b7fa (patch) | |
| tree | 36a38f7db3aae1dfda22e7c24f8b372462304aba | |
| parent | 34e978c30c819d9c34b6b97f8deb6439fad016f4 (diff) | |
| parent | c644d2b9685d4d7ce14766b3521655d39394ba3d (diff) | |
Merge "Unsuppress USI low battery notifications when new stylus used." into tm-qpr-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/stylus/StylusUsiPowerStartable.kt | 11 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/stylus/StylusUsiPowerStartableTest.kt | 14 |
2 files changed, 25 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/stylus/StylusUsiPowerStartable.kt b/packages/SystemUI/src/com/android/systemui/stylus/StylusUsiPowerStartable.kt index 5a8850a9f89b..dde2a80b05f7 100644 --- a/packages/SystemUI/src/com/android/systemui/stylus/StylusUsiPowerStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/stylus/StylusUsiPowerStartable.kt @@ -39,6 +39,17 @@ constructor( private val featureFlags: FeatureFlags, ) : CoreStartable, StylusManager.StylusCallback, StylusManager.StylusBatteryCallback { + override fun onStylusAdded(deviceId: Int) { + // On some devices, the addition of a new internal stylus indicates the use of a + // USI stylus with a different vendor/product ID. We would therefore like to reset + // the battery notification suppression, in case the user has dismissed a low battery + // notification of the previous stylus. + val device = inputManager.getInputDevice(deviceId) ?: return + if (!device.isExternal) { + stylusUsiPowerUi.updateSuppression(false) + } + } + override fun onStylusBluetoothConnected(deviceId: Int, btAddress: String) { stylusUsiPowerUi.refresh() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/stylus/StylusUsiPowerStartableTest.kt b/packages/SystemUI/tests/src/com/android/systemui/stylus/StylusUsiPowerStartableTest.kt index 1cccd65c8dbc..cc6be5e09fbc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/stylus/StylusUsiPowerStartableTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/stylus/StylusUsiPowerStartableTest.kt @@ -92,6 +92,20 @@ class StylusUsiPowerStartableTest : SysuiTestCase() { } @Test + fun onStylusAdded_internal_updatesNotificationSuppression() { + startable.onStylusAdded(STYLUS_DEVICE_ID) + + verify(stylusUsiPowerUi, times(1)).updateSuppression(false) + } + + @Test + fun onStylusAdded_external_noop() { + startable.onStylusAdded(EXTERNAL_DEVICE_ID) + + verifyZeroInteractions(stylusUsiPowerUi) + } + + @Test fun onStylusBluetoothConnected_refreshesNotification() { startable.onStylusBluetoothConnected(STYLUS_DEVICE_ID, "ANY") |