Loading services/core/java/com/android/server/input/KeyboardMetricsCollector.java +9 −4 Original line number Diff line number Diff line Loading @@ -369,15 +369,15 @@ public final class KeyboardMetricsCollector { if (inputDevice == null || inputDevice.isVirtual() || !inputDevice.isFullKeyboard()) { return; } int vendorId = inputDevice.getVendorId(); int productId = inputDevice.getProductId(); if (keyboardSystemEvent == null) { Slog.w(TAG, "Invalid keyboard event logging, keycode = " + Arrays.toString(keyCodes) + ", modifier state = " + modifierState); return; } FrameworkStatsLog.write(FrameworkStatsLog.KEYBOARD_SYSTEMS_EVENT_REPORTED, vendorId, productId, keyboardSystemEvent.getIntValue(), keyCodes, modifierState); inputDevice.getVendorId(), inputDevice.getProductId(), keyboardSystemEvent.getIntValue(), keyCodes, modifierState, inputDevice.getDeviceBus()); if (DEBUG) { Slog.d(TAG, "Logging Keyboard system event: " + keyboardSystemEvent.mName); Loading @@ -402,7 +402,7 @@ public final class KeyboardMetricsCollector { // Push the atom to Statsd FrameworkStatsLog.write(FrameworkStatsLog.KEYBOARD_CONFIGURED, event.isFirstConfiguration(), event.getVendorId(), event.getProductId(), proto.getBytes()); proto.getBytes(), event.getDeviceBus()); if (DEBUG) { Slog.d(TAG, "Logging Keyboard configuration event: " + event); Loading Loading @@ -467,6 +467,10 @@ public final class KeyboardMetricsCollector { return mInputDevice.getProductId(); } public int getDeviceBus() { return mInputDevice.getDeviceBus(); } public boolean isFirstConfiguration() { return mIsFirstConfiguration; } Loading @@ -479,6 +483,7 @@ public final class KeyboardMetricsCollector { public String toString() { return "InputDevice = {VendorId = " + Integer.toHexString(getVendorId()) + ", ProductId = " + Integer.toHexString(getProductId()) + ", Device Bus = " + Integer.toHexString(getDeviceBus()) + "}, isFirstConfiguration = " + mIsFirstConfiguration + ", LayoutConfigurations = " + mLayoutConfigurations; } Loading services/tests/servicestests/src/com/android/server/input/KeyboardMetricsCollectorTests.kt +12 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ private fun createKeyboard( deviceId: Int, vendorId: Int, productId: Int, deviceBus: Int, languageTag: String?, layoutType: String? ): InputDevice = Loading @@ -42,6 +43,7 @@ private fun createKeyboard( .setExternal(true) .setVendorId(vendorId) .setProductId(productId) .setDeviceBus(deviceBus) .setKeyboardLanguageTag(languageTag) .setKeyboardLayoutType(layoutType) .build() Loading @@ -67,6 +69,7 @@ class KeyboardMetricsCollectorTests { const val DEVICE_ID = 1 const val DEFAULT_VENDOR_ID = 123 const val DEFAULT_PRODUCT_ID = 456 const val DEFAULT_DEVICE_BUS = 789 } @Test Loading @@ -77,6 +80,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, null, null ) Loading @@ -92,6 +96,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, null, null ) Loading @@ -107,6 +112,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, "de-CH", "qwertz" ) Loading Loading @@ -135,6 +141,11 @@ class KeyboardMetricsCollectorTests { DEFAULT_PRODUCT_ID, event.productId ) assertEquals( "KeyboardConfigurationEvent should pick device bus from provided InputDevice", DEFAULT_DEVICE_BUS, event.deviceBus ) assertTrue(event.isFirstConfiguration) assertEquals( Loading Loading @@ -178,6 +189,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, "und", // Undefined language tag "azerty" ) Loading services/tests/wmtests/src/com/android/server/policy/ShortcutLoggingTests.java +4 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ public class ShortcutLoggingTests extends ShortcutKeyTestBase { private static final int VENDOR_ID = 0x123; private static final int PRODUCT_ID = 0x456; private static final int DEVICE_BUS = 0x789; private static final int META_KEY = KeyEvent.KEYCODE_META_LEFT; private static final int META_ON = MODIFIER.get(KeyEvent.KEYCODE_META_LEFT); private static final int ALT_KEY = KeyEvent.KEYCODE_ALT_LEFT; Loading Loading @@ -224,7 +225,7 @@ public class ShortcutLoggingTests extends ShortcutKeyTestBase { @Override public void setUp() { super.setUp(); mPhoneWindowManager.overrideKeyEventSource(VENDOR_ID, PRODUCT_ID); mPhoneWindowManager.overrideKeyEventSource(VENDOR_ID, PRODUCT_ID, DEVICE_BUS); mPhoneWindowManager.overrideLaunchHome(); mPhoneWindowManager.overrideSearchKeyBehavior( PhoneWindowManager.SEARCH_BEHAVIOR_TARGET_ACTIVITY); Loading @@ -240,6 +241,7 @@ public class ShortcutLoggingTests extends ShortcutKeyTestBase { int expectedKey, int expectedModifierState) { sendKeyCombination(testKeys, 0); mPhoneWindowManager.assertShortcutLogged(VENDOR_ID, PRODUCT_ID, expectedLogEvent, expectedKey, expectedModifierState, "Failed while executing " + testName); expectedKey, expectedModifierState, DEVICE_BUS, "Failed while executing " + testName); } } services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java +11 −6 Original line number Diff line number Diff line Loading @@ -423,10 +423,15 @@ class TestPhoneWindowManager { doReturn(isShowing).when(mKeyguardServiceDelegate).isShowing(); } void overrideKeyEventSource(int vendorId, int productId) { InputDevice device = new InputDevice.Builder().setId(1).setVendorId(vendorId).setProductId( productId).setSources(InputDevice.SOURCE_KEYBOARD).setKeyboardType( InputDevice.KEYBOARD_TYPE_ALPHABETIC).build(); void overrideKeyEventSource(int vendorId, int productId, int deviceBus) { InputDevice device = new InputDevice.Builder() .setId(1) .setVendorId(vendorId) .setProductId(productId) .setDeviceBus(deviceBus) .setSources(InputDevice.SOURCE_KEYBOARD) .setKeyboardType(InputDevice.KEYBOARD_TYPE_ALPHABETIC) .build(); doReturn(mInputManager).when(mContext).getSystemService(eq(InputManager.class)); doReturn(device).when(mInputManager).getInputDevice(anyInt()); } Loading Loading @@ -604,10 +609,10 @@ class TestPhoneWindowManager { } void assertShortcutLogged(int vendorId, int productId, KeyboardLogEvent logEvent, int expectedKey, int expectedModifierState, String errorMsg) { int expectedKey, int expectedModifierState, int deviceBus, String errorMsg) { waitForIdle(); verify(() -> FrameworkStatsLog.write(FrameworkStatsLog.KEYBOARD_SYSTEMS_EVENT_REPORTED, vendorId, productId, logEvent.getIntValue(), new int[]{expectedKey}, expectedModifierState), description(errorMsg)); expectedModifierState, deviceBus), description(errorMsg)); } } Loading
services/core/java/com/android/server/input/KeyboardMetricsCollector.java +9 −4 Original line number Diff line number Diff line Loading @@ -369,15 +369,15 @@ public final class KeyboardMetricsCollector { if (inputDevice == null || inputDevice.isVirtual() || !inputDevice.isFullKeyboard()) { return; } int vendorId = inputDevice.getVendorId(); int productId = inputDevice.getProductId(); if (keyboardSystemEvent == null) { Slog.w(TAG, "Invalid keyboard event logging, keycode = " + Arrays.toString(keyCodes) + ", modifier state = " + modifierState); return; } FrameworkStatsLog.write(FrameworkStatsLog.KEYBOARD_SYSTEMS_EVENT_REPORTED, vendorId, productId, keyboardSystemEvent.getIntValue(), keyCodes, modifierState); inputDevice.getVendorId(), inputDevice.getProductId(), keyboardSystemEvent.getIntValue(), keyCodes, modifierState, inputDevice.getDeviceBus()); if (DEBUG) { Slog.d(TAG, "Logging Keyboard system event: " + keyboardSystemEvent.mName); Loading @@ -402,7 +402,7 @@ public final class KeyboardMetricsCollector { // Push the atom to Statsd FrameworkStatsLog.write(FrameworkStatsLog.KEYBOARD_CONFIGURED, event.isFirstConfiguration(), event.getVendorId(), event.getProductId(), proto.getBytes()); proto.getBytes(), event.getDeviceBus()); if (DEBUG) { Slog.d(TAG, "Logging Keyboard configuration event: " + event); Loading Loading @@ -467,6 +467,10 @@ public final class KeyboardMetricsCollector { return mInputDevice.getProductId(); } public int getDeviceBus() { return mInputDevice.getDeviceBus(); } public boolean isFirstConfiguration() { return mIsFirstConfiguration; } Loading @@ -479,6 +483,7 @@ public final class KeyboardMetricsCollector { public String toString() { return "InputDevice = {VendorId = " + Integer.toHexString(getVendorId()) + ", ProductId = " + Integer.toHexString(getProductId()) + ", Device Bus = " + Integer.toHexString(getDeviceBus()) + "}, isFirstConfiguration = " + mIsFirstConfiguration + ", LayoutConfigurations = " + mLayoutConfigurations; } Loading
services/tests/servicestests/src/com/android/server/input/KeyboardMetricsCollectorTests.kt +12 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ private fun createKeyboard( deviceId: Int, vendorId: Int, productId: Int, deviceBus: Int, languageTag: String?, layoutType: String? ): InputDevice = Loading @@ -42,6 +43,7 @@ private fun createKeyboard( .setExternal(true) .setVendorId(vendorId) .setProductId(productId) .setDeviceBus(deviceBus) .setKeyboardLanguageTag(languageTag) .setKeyboardLayoutType(layoutType) .build() Loading @@ -67,6 +69,7 @@ class KeyboardMetricsCollectorTests { const val DEVICE_ID = 1 const val DEFAULT_VENDOR_ID = 123 const val DEFAULT_PRODUCT_ID = 456 const val DEFAULT_DEVICE_BUS = 789 } @Test Loading @@ -77,6 +80,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, null, null ) Loading @@ -92,6 +96,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, null, null ) Loading @@ -107,6 +112,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, "de-CH", "qwertz" ) Loading Loading @@ -135,6 +141,11 @@ class KeyboardMetricsCollectorTests { DEFAULT_PRODUCT_ID, event.productId ) assertEquals( "KeyboardConfigurationEvent should pick device bus from provided InputDevice", DEFAULT_DEVICE_BUS, event.deviceBus ) assertTrue(event.isFirstConfiguration) assertEquals( Loading Loading @@ -178,6 +189,7 @@ class KeyboardMetricsCollectorTests { DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, DEFAULT_DEVICE_BUS, "und", // Undefined language tag "azerty" ) Loading
services/tests/wmtests/src/com/android/server/policy/ShortcutLoggingTests.java +4 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ public class ShortcutLoggingTests extends ShortcutKeyTestBase { private static final int VENDOR_ID = 0x123; private static final int PRODUCT_ID = 0x456; private static final int DEVICE_BUS = 0x789; private static final int META_KEY = KeyEvent.KEYCODE_META_LEFT; private static final int META_ON = MODIFIER.get(KeyEvent.KEYCODE_META_LEFT); private static final int ALT_KEY = KeyEvent.KEYCODE_ALT_LEFT; Loading Loading @@ -224,7 +225,7 @@ public class ShortcutLoggingTests extends ShortcutKeyTestBase { @Override public void setUp() { super.setUp(); mPhoneWindowManager.overrideKeyEventSource(VENDOR_ID, PRODUCT_ID); mPhoneWindowManager.overrideKeyEventSource(VENDOR_ID, PRODUCT_ID, DEVICE_BUS); mPhoneWindowManager.overrideLaunchHome(); mPhoneWindowManager.overrideSearchKeyBehavior( PhoneWindowManager.SEARCH_BEHAVIOR_TARGET_ACTIVITY); Loading @@ -240,6 +241,7 @@ public class ShortcutLoggingTests extends ShortcutKeyTestBase { int expectedKey, int expectedModifierState) { sendKeyCombination(testKeys, 0); mPhoneWindowManager.assertShortcutLogged(VENDOR_ID, PRODUCT_ID, expectedLogEvent, expectedKey, expectedModifierState, "Failed while executing " + testName); expectedKey, expectedModifierState, DEVICE_BUS, "Failed while executing " + testName); } }
services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java +11 −6 Original line number Diff line number Diff line Loading @@ -423,10 +423,15 @@ class TestPhoneWindowManager { doReturn(isShowing).when(mKeyguardServiceDelegate).isShowing(); } void overrideKeyEventSource(int vendorId, int productId) { InputDevice device = new InputDevice.Builder().setId(1).setVendorId(vendorId).setProductId( productId).setSources(InputDevice.SOURCE_KEYBOARD).setKeyboardType( InputDevice.KEYBOARD_TYPE_ALPHABETIC).build(); void overrideKeyEventSource(int vendorId, int productId, int deviceBus) { InputDevice device = new InputDevice.Builder() .setId(1) .setVendorId(vendorId) .setProductId(productId) .setDeviceBus(deviceBus) .setSources(InputDevice.SOURCE_KEYBOARD) .setKeyboardType(InputDevice.KEYBOARD_TYPE_ALPHABETIC) .build(); doReturn(mInputManager).when(mContext).getSystemService(eq(InputManager.class)); doReturn(device).when(mInputManager).getInputDevice(anyInt()); } Loading Loading @@ -604,10 +609,10 @@ class TestPhoneWindowManager { } void assertShortcutLogged(int vendorId, int productId, KeyboardLogEvent logEvent, int expectedKey, int expectedModifierState, String errorMsg) { int expectedKey, int expectedModifierState, int deviceBus, String errorMsg) { waitForIdle(); verify(() -> FrameworkStatsLog.write(FrameworkStatsLog.KEYBOARD_SYSTEMS_EVENT_REPORTED, vendorId, productId, logEvent.getIntValue(), new int[]{expectedKey}, expectedModifierState), description(errorMsg)); expectedModifierState, deviceBus), description(errorMsg)); } }