Loading packages/SystemUI/src/com/android/systemui/stylus/StylusManager.kt +3 −7 Original line number Diff line number Diff line Loading @@ -102,8 +102,7 @@ constructor( registerBatteryListener(deviceId) } // TODO(b/257936830): get address once input api available val btAddress: String? = null val btAddress: String? = device.bluetoothAddress inputDeviceAddressMap[deviceId] = btAddress executeStylusCallbacks { cb -> cb.onStylusAdded(deviceId) } Loading @@ -120,8 +119,7 @@ constructor( val device: InputDevice = inputManager.getInputDevice(deviceId) ?: return if (!device.supportsSource(InputDevice.SOURCE_STYLUS)) return // TODO(b/257936830): get address once input api available val currAddress: String? = null val currAddress: String? = device.bluetoothAddress val prevAddress: String? = inputDeviceAddressMap[deviceId] inputDeviceAddressMap[deviceId] = currAddress Loading Loading @@ -212,7 +210,6 @@ constructor( * physical stylus device has actually been used. */ private fun onStylusUsed() { if (true) return // TODO(b/261826950): remove on main if (!featureFlags.isEnabled(Flags.TRACK_STYLUS_EVER_USED)) return if (inputManager.isStylusEverUsed(context)) return Loading Loading @@ -250,8 +247,7 @@ constructor( for (deviceId: Int in inputManager.inputDeviceIds) { val device: InputDevice = inputManager.getInputDevice(deviceId) ?: continue if (device.supportsSource(InputDevice.SOURCE_STYLUS)) { // TODO(b/257936830): get address once input api available inputDeviceAddressMap[deviceId] = null inputDeviceAddressMap[deviceId] = device.bluetoothAddress if (!device.isExternal) { // TODO(b/263556967): add supportsUsi check once available // For most devices, an active (non-bluetooth) stylus is represented by an Loading packages/SystemUI/tests/src/com/android/systemui/stylus/StylusManagerTest.kt +5 −27 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.whenever import java.util.concurrent.Executor import org.junit.Before import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock Loading Loading @@ -82,8 +81,8 @@ class StylusManagerTest : SysuiTestCase() { whenever(stylusDevice.supportsSource(InputDevice.SOURCE_STYLUS)).thenReturn(true) whenever(btStylusDevice.supportsSource(InputDevice.SOURCE_STYLUS)).thenReturn(true) // whenever(stylusDevice.bluetoothAddress).thenReturn(null) // whenever(btStylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(stylusDevice.bluetoothAddress).thenReturn(null) whenever(btStylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(inputManager.getInputDevice(OTHER_DEVICE_ID)).thenReturn(otherDevice) whenever(inputManager.getInputDevice(STYLUS_DEVICE_ID)).thenReturn(stylusDevice) Loading Loading @@ -170,7 +169,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceAdded_btStylus_firstUsed_callsCallbacksOnStylusFirstUsed() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -178,7 +176,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceAdded_btStylus_firstUsed_setsFlag() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -186,7 +183,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceAdded_btStylus_callsCallbacksWithAddress() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading Loading @@ -215,10 +211,9 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_multipleRegisteredCallbacks_callsAll() { stylusManager.onInputDeviceAdded(STYLUS_DEVICE_ID) // whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) stylusManager.registerCallback(otherStylusCallback) stylusManager.onInputDeviceChanged(STYLUS_DEVICE_ID) Loading @@ -230,10 +225,9 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_stylusNewBtConnection_callsCallbacks() { stylusManager.onInputDeviceAdded(STYLUS_DEVICE_ID) // whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) stylusManager.onInputDeviceChanged(STYLUS_DEVICE_ID) Loading @@ -242,10 +236,9 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_stylusLostBtConnection_callsCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) // whenever(btStylusDevice.bluetoothAddress).thenReturn(null) whenever(btStylusDevice.bluetoothAddress).thenReturn(null) stylusManager.onInputDeviceChanged(BT_STYLUS_DEVICE_ID) Loading @@ -254,7 +247,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_btConnection_stylusAlreadyBtConnected_onlyCallsListenersOnce() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -265,7 +257,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_noBtConnection_stylusNeverBtConnected_doesNotCallCallbacks() { stylusManager.onInputDeviceAdded(STYLUS_DEVICE_ID) Loading Loading @@ -317,7 +308,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceRemoved_btStylus_callsCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -331,7 +321,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onStylusBluetoothConnected_registersMetadataListener() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -339,7 +328,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onStylusBluetoothConnected_noBluetoothDevice_doesNotRegisterMetadataListener() { whenever(bluetoothAdapter.getRemoteDevice(STYLUS_BT_ADDRESS)).thenReturn(null) Loading @@ -349,7 +337,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onStylusBluetoothDisconnected_unregistersMetadataListener() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -359,7 +346,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_multipleRegisteredBatteryCallbacks_executesAll() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) stylusManager.registerBatteryCallback(otherStylusBatteryCallback) Loading @@ -377,7 +363,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_chargingStateTrue_executesBatteryCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -392,7 +377,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_chargingStateFalse_executesBatteryCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -407,7 +391,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_chargingStateNoDevice_doesNotExecuteBatteryCallbacks() { stylusManager.onMetadataChanged( bluetoothDevice, Loading @@ -419,7 +402,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_notChargingState_doesNotExecuteBatteryCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -434,7 +416,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryPresent_stylusNeverUsed_updateEverUsedFlag() { whenever(batteryState.isPresent).thenReturn(true) Loading @@ -444,7 +425,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryPresent_stylusNeverUsed_executesStylusFirstUsed() { whenever(batteryState.isPresent).thenReturn(true) Loading @@ -454,7 +434,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryPresent_stylusUsed_doesNotUpdateEverUsedFlag() { whenever(inputManager.isStylusEverUsed(mContext)).thenReturn(true) whenever(batteryState.isPresent).thenReturn(true) Loading @@ -465,7 +444,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryNotPresent_doesNotUpdateEverUsedFlag() { whenever(batteryState.isPresent).thenReturn(false) Loading Loading
packages/SystemUI/src/com/android/systemui/stylus/StylusManager.kt +3 −7 Original line number Diff line number Diff line Loading @@ -102,8 +102,7 @@ constructor( registerBatteryListener(deviceId) } // TODO(b/257936830): get address once input api available val btAddress: String? = null val btAddress: String? = device.bluetoothAddress inputDeviceAddressMap[deviceId] = btAddress executeStylusCallbacks { cb -> cb.onStylusAdded(deviceId) } Loading @@ -120,8 +119,7 @@ constructor( val device: InputDevice = inputManager.getInputDevice(deviceId) ?: return if (!device.supportsSource(InputDevice.SOURCE_STYLUS)) return // TODO(b/257936830): get address once input api available val currAddress: String? = null val currAddress: String? = device.bluetoothAddress val prevAddress: String? = inputDeviceAddressMap[deviceId] inputDeviceAddressMap[deviceId] = currAddress Loading Loading @@ -212,7 +210,6 @@ constructor( * physical stylus device has actually been used. */ private fun onStylusUsed() { if (true) return // TODO(b/261826950): remove on main if (!featureFlags.isEnabled(Flags.TRACK_STYLUS_EVER_USED)) return if (inputManager.isStylusEverUsed(context)) return Loading Loading @@ -250,8 +247,7 @@ constructor( for (deviceId: Int in inputManager.inputDeviceIds) { val device: InputDevice = inputManager.getInputDevice(deviceId) ?: continue if (device.supportsSource(InputDevice.SOURCE_STYLUS)) { // TODO(b/257936830): get address once input api available inputDeviceAddressMap[deviceId] = null inputDeviceAddressMap[deviceId] = device.bluetoothAddress if (!device.isExternal) { // TODO(b/263556967): add supportsUsi check once available // For most devices, an active (non-bluetooth) stylus is represented by an Loading
packages/SystemUI/tests/src/com/android/systemui/stylus/StylusManagerTest.kt +5 −27 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.whenever import java.util.concurrent.Executor import org.junit.Before import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock Loading Loading @@ -82,8 +81,8 @@ class StylusManagerTest : SysuiTestCase() { whenever(stylusDevice.supportsSource(InputDevice.SOURCE_STYLUS)).thenReturn(true) whenever(btStylusDevice.supportsSource(InputDevice.SOURCE_STYLUS)).thenReturn(true) // whenever(stylusDevice.bluetoothAddress).thenReturn(null) // whenever(btStylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(stylusDevice.bluetoothAddress).thenReturn(null) whenever(btStylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(inputManager.getInputDevice(OTHER_DEVICE_ID)).thenReturn(otherDevice) whenever(inputManager.getInputDevice(STYLUS_DEVICE_ID)).thenReturn(stylusDevice) Loading Loading @@ -170,7 +169,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceAdded_btStylus_firstUsed_callsCallbacksOnStylusFirstUsed() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -178,7 +176,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceAdded_btStylus_firstUsed_setsFlag() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -186,7 +183,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceAdded_btStylus_callsCallbacksWithAddress() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading Loading @@ -215,10 +211,9 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_multipleRegisteredCallbacks_callsAll() { stylusManager.onInputDeviceAdded(STYLUS_DEVICE_ID) // whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) stylusManager.registerCallback(otherStylusCallback) stylusManager.onInputDeviceChanged(STYLUS_DEVICE_ID) Loading @@ -230,10 +225,9 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_stylusNewBtConnection_callsCallbacks() { stylusManager.onInputDeviceAdded(STYLUS_DEVICE_ID) // whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) whenever(stylusDevice.bluetoothAddress).thenReturn(STYLUS_BT_ADDRESS) stylusManager.onInputDeviceChanged(STYLUS_DEVICE_ID) Loading @@ -242,10 +236,9 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_stylusLostBtConnection_callsCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) // whenever(btStylusDevice.bluetoothAddress).thenReturn(null) whenever(btStylusDevice.bluetoothAddress).thenReturn(null) stylusManager.onInputDeviceChanged(BT_STYLUS_DEVICE_ID) Loading @@ -254,7 +247,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_btConnection_stylusAlreadyBtConnected_onlyCallsListenersOnce() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -265,7 +257,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceChanged_noBtConnection_stylusNeverBtConnected_doesNotCallCallbacks() { stylusManager.onInputDeviceAdded(STYLUS_DEVICE_ID) Loading Loading @@ -317,7 +308,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onInputDeviceRemoved_btStylus_callsCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -331,7 +321,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onStylusBluetoothConnected_registersMetadataListener() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -339,7 +328,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onStylusBluetoothConnected_noBluetoothDevice_doesNotRegisterMetadataListener() { whenever(bluetoothAdapter.getRemoteDevice(STYLUS_BT_ADDRESS)).thenReturn(null) Loading @@ -349,7 +337,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onStylusBluetoothDisconnected_unregistersMetadataListener() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -359,7 +346,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_multipleRegisteredBatteryCallbacks_executesAll() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) stylusManager.registerBatteryCallback(otherStylusBatteryCallback) Loading @@ -377,7 +363,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_chargingStateTrue_executesBatteryCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -392,7 +377,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_chargingStateFalse_executesBatteryCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -407,7 +391,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_chargingStateNoDevice_doesNotExecuteBatteryCallbacks() { stylusManager.onMetadataChanged( bluetoothDevice, Loading @@ -419,7 +402,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("b/257936830 until bt APIs") fun onMetadataChanged_notChargingState_doesNotExecuteBatteryCallbacks() { stylusManager.onInputDeviceAdded(BT_STYLUS_DEVICE_ID) Loading @@ -434,7 +416,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryPresent_stylusNeverUsed_updateEverUsedFlag() { whenever(batteryState.isPresent).thenReturn(true) Loading @@ -444,7 +425,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryPresent_stylusNeverUsed_executesStylusFirstUsed() { whenever(batteryState.isPresent).thenReturn(true) Loading @@ -454,7 +434,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryPresent_stylusUsed_doesNotUpdateEverUsedFlag() { whenever(inputManager.isStylusEverUsed(mContext)).thenReturn(true) whenever(batteryState.isPresent).thenReturn(true) Loading @@ -465,7 +444,6 @@ class StylusManagerTest : SysuiTestCase() { } @Test @Ignore("TODO(b/261826950): remove on main") fun onBatteryStateChanged_batteryNotPresent_doesNotUpdateEverUsedFlag() { whenever(batteryState.isPresent).thenReturn(false) Loading