Loading src/com/android/settings/connecteddevice/stylus/StylusDeviceUpdater.java +8 −1 Original line number Diff line number Diff line Loading @@ -100,6 +100,8 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener, @Override public void onInputDeviceAdded(int deviceId) { InputDevice inputDevice = mInputManager.getInputDevice(deviceId); if (inputDevice == null) return; if (inputDevice.supportsSource(InputDevice.SOURCE_STYLUS) && !inputDevice.isExternal()) { try { Loading @@ -121,7 +123,10 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener, @Override public void onInputDeviceChanged(int deviceId) { if (mInputManager.getInputDevice(deviceId).supportsSource(InputDevice.SOURCE_STYLUS)) { InputDevice inputDevice = mInputManager.getInputDevice(deviceId); if (inputDevice == null) return; if (inputDevice.supportsSource(InputDevice.SOURCE_STYLUS)) { forceUpdate(); } } Loading Loading @@ -189,6 +194,8 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener, boolean hasConnectedBluetoothStylusDevice() { for (int deviceId : mInputManager.getInputDeviceIds()) { InputDevice device = mInputManager.getInputDevice(deviceId); if (device == null) continue; if (device.supportsSource(InputDevice.SOURCE_STYLUS) && mInputManager.getInputDeviceBluetoothAddress(deviceId) != null) { return true; Loading tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDeviceUpdaterTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import android.content.Context; import android.content.Intent; Loading Loading @@ -108,6 +109,15 @@ public class StylusDeviceUpdaterTest { any()); } @Test public void onInputDeviceAdded_null_doesNothing() { doReturn(null).when(mInputManager).getInputDevice(0); mStylusDeviceUpdater.onInputDeviceAdded(0); verify(mInputManager).getInputDevice(0); verifyNoMoreInteractions(mInputManager); } @Test public void onInputDeviceAdded_internalStylus_registersBatteryListener() { mStylusDeviceUpdater.onInputDeviceAdded(1); Loading @@ -124,6 +134,15 @@ public class StylusDeviceUpdaterTest { any()); } @Test public void onInputDeviceChanged_null_doesNothing() { doReturn(null).when(mInputManager).getInputDevice(0); mStylusDeviceUpdater.onInputDeviceChanged(0); verify(mInputManager).getInputDevice(0); verifyNoMoreInteractions(mInputManager); } @Test public void click_usiPreference_launchUsiDetailsPage() { doReturn(mSettingsActivity).when(mDashboardFragment).getContext(); Loading Loading
src/com/android/settings/connecteddevice/stylus/StylusDeviceUpdater.java +8 −1 Original line number Diff line number Diff line Loading @@ -100,6 +100,8 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener, @Override public void onInputDeviceAdded(int deviceId) { InputDevice inputDevice = mInputManager.getInputDevice(deviceId); if (inputDevice == null) return; if (inputDevice.supportsSource(InputDevice.SOURCE_STYLUS) && !inputDevice.isExternal()) { try { Loading @@ -121,7 +123,10 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener, @Override public void onInputDeviceChanged(int deviceId) { if (mInputManager.getInputDevice(deviceId).supportsSource(InputDevice.SOURCE_STYLUS)) { InputDevice inputDevice = mInputManager.getInputDevice(deviceId); if (inputDevice == null) return; if (inputDevice.supportsSource(InputDevice.SOURCE_STYLUS)) { forceUpdate(); } } Loading Loading @@ -189,6 +194,8 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener, boolean hasConnectedBluetoothStylusDevice() { for (int deviceId : mInputManager.getInputDeviceIds()) { InputDevice device = mInputManager.getInputDevice(deviceId); if (device == null) continue; if (device.supportsSource(InputDevice.SOURCE_STYLUS) && mInputManager.getInputDeviceBluetoothAddress(deviceId) != null) { return true; Loading
tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDeviceUpdaterTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import android.content.Context; import android.content.Intent; Loading Loading @@ -108,6 +109,15 @@ public class StylusDeviceUpdaterTest { any()); } @Test public void onInputDeviceAdded_null_doesNothing() { doReturn(null).when(mInputManager).getInputDevice(0); mStylusDeviceUpdater.onInputDeviceAdded(0); verify(mInputManager).getInputDevice(0); verifyNoMoreInteractions(mInputManager); } @Test public void onInputDeviceAdded_internalStylus_registersBatteryListener() { mStylusDeviceUpdater.onInputDeviceAdded(1); Loading @@ -124,6 +134,15 @@ public class StylusDeviceUpdaterTest { any()); } @Test public void onInputDeviceChanged_null_doesNothing() { doReturn(null).when(mInputManager).getInputDevice(0); mStylusDeviceUpdater.onInputDeviceChanged(0); verify(mInputManager).getInputDevice(0); verifyNoMoreInteractions(mInputManager); } @Test public void click_usiPreference_launchUsiDetailsPage() { doReturn(mSettingsActivity).when(mDashboardFragment).getContext(); Loading