Merge "Unsuppress USI low battery notifications when new stylus used." into tm-qpr-dev am: e220dd0547
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20809149 Change-Id: Ie3137618bfe38964f0ca6ccf2b10bf88f8220824 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -39,6 +39,17 @@ constructor(
|
|||||||
private val featureFlags: FeatureFlags,
|
private val featureFlags: FeatureFlags,
|
||||||
) : CoreStartable, StylusManager.StylusCallback, StylusManager.StylusBatteryCallback {
|
) : 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) {
|
override fun onStylusBluetoothConnected(deviceId: Int, btAddress: String) {
|
||||||
stylusUsiPowerUi.refresh()
|
stylusUsiPowerUi.refresh()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,20 @@ class StylusUsiPowerStartableTest : SysuiTestCase() {
|
|||||||
verify(stylusUsiPowerUi, times(1)).init()
|
verify(stylusUsiPowerUi, times(1)).init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
fun onStylusBluetoothConnected_refreshesNotification() {
|
fun onStylusBluetoothConnected_refreshesNotification() {
|
||||||
startable.onStylusBluetoothConnected(STYLUS_DEVICE_ID, "ANY")
|
startable.onStylusBluetoothConnected(STYLUS_DEVICE_ID, "ANY")
|
||||||
|
|||||||
Reference in New Issue
Block a user