Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9248d1c7 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari Committed by Android (Google) Code Review
Browse files

Merge "Log KCM name instead of layout label in KeyboardConfiguration atom" into main

parents aaab1611 d99ac13e
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -1246,11 +1246,17 @@ class KeyboardLayoutManager implements InputManager.InputDeviceListener {
                        isFirstConfiguration);
        for (int i = 0; i < imeInfoList.size(); i++) {
            KeyboardLayoutInfo layoutInfo = layoutInfoList.get(i);
            boolean noLayoutFound = layoutInfo == null || layoutInfo.mDescriptor == null;
            configurationEventBuilder.addLayoutSelection(imeInfoList.get(i).mImeSubtype,
                    noLayoutFound ? null : getKeyboardLayout(layoutInfo.mDescriptor),
                    noLayoutFound ? LAYOUT_SELECTION_CRITERIA_DEFAULT
                            : layoutInfo.mSelectionCriteria);
            String layoutName = null;
            int layoutSelectionCriteria = LAYOUT_SELECTION_CRITERIA_DEFAULT;
            if (layoutInfo != null && layoutInfo.mDescriptor != null) {
                layoutSelectionCriteria = layoutInfo.mSelectionCriteria;
                KeyboardLayoutDescriptor d = KeyboardLayoutDescriptor.parse(layoutInfo.mDescriptor);
                if (d != null) {
                    layoutName = d.keyboardLayoutName;
                }
            }
            configurationEventBuilder.addLayoutSelection(imeInfoList.get(i).mImeSubtype, layoutName,
                    layoutSelectionCriteria);
        }
        KeyboardMetricsCollector.logKeyboardConfiguredAtom(configurationEventBuilder.build());
    }
+5 −6
Original line number Diff line number Diff line
@@ -491,7 +491,7 @@ public final class KeyboardMetricsCollector {
            private final InputDevice mInputDevice;
            private boolean mIsFirstConfiguration;
            private final List<InputMethodSubtype> mImeSubtypeList = new ArrayList<>();
            private final List<KeyboardLayout> mSelectedLayoutList = new ArrayList<>();
            private final List<String> mSelectedLayoutList = new ArrayList<>();
            private final List<Integer> mLayoutSelectionCriteriaList = new ArrayList<>();

            public Builder(@NonNull InputDevice inputDevice) {
@@ -511,7 +511,7 @@ public final class KeyboardMetricsCollector {
             * Adds keyboard layout configuration info for a particular IME subtype language
             */
            public Builder addLayoutSelection(@NonNull InputMethodSubtype imeSubtype,
                    @Nullable KeyboardLayout selectedLayout,
                    @Nullable String selectedLayout,
                    @LayoutSelectionCriteria int layoutSelectionCriteria) {
                Objects.requireNonNull(imeSubtype, "IME subtype provided should not be null");
                if (!isValidSelectionCriteria(layoutSelectionCriteria)) {
@@ -533,7 +533,6 @@ public final class KeyboardMetricsCollector {
                }
                List<LayoutConfiguration> configurationList = new ArrayList<>();
                for (int i = 0; i < size; i++) {
                    KeyboardLayout selectedLayout = mSelectedLayoutList.get(i);
                    @LayoutSelectionCriteria int layoutSelectionCriteria =
                            mLayoutSelectionCriteriaList.get(i);
                    InputMethodSubtype imeSubtype = mImeSubtypeList.get(i);
@@ -552,9 +551,9 @@ public final class KeyboardMetricsCollector {
                            imeSubtype.getPhysicalKeyboardHintLayoutType());

                    // Sanitize null values
                    String keyboardLayoutName =
                            selectedLayout == null ? DEFAULT_LAYOUT_NAME
                                    : selectedLayout.getLabel();
                    String keyboardLayoutName = mSelectedLayoutList.get(i) == null
                            ? DEFAULT_LAYOUT_NAME
                            : mSelectedLayoutList.get(i);

                    configurationList.add(
                            new LayoutConfiguration(keyboardLayoutType, keyboardLanguageTag,
+7 −5
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ class KeyboardLayoutManagerTests {
        const val RECEIVER_NAME = "DummyReceiver"
        private const val ENGLISH_US_LAYOUT_NAME = "keyboard_layout_english_us"
        private const val ENGLISH_UK_LAYOUT_NAME = "keyboard_layout_english_uk"
        private const val GERMAN_LAYOUT_NAME = "keyboard_layout_german"
        private const val VENDOR_SPECIFIC_LAYOUT_NAME = "keyboard_layout_vendorId:1,productId:1"
        const val LAYOUT_TYPE_QWERTZ = 2
        const val LAYOUT_TYPE_QWERTY = 1
@@ -108,6 +109,7 @@ class KeyboardLayoutManagerTests {

    private val ENGLISH_US_LAYOUT_DESCRIPTOR = createLayoutDescriptor(ENGLISH_US_LAYOUT_NAME)
    private val ENGLISH_UK_LAYOUT_DESCRIPTOR = createLayoutDescriptor(ENGLISH_UK_LAYOUT_NAME)
    private val GERMAN_LAYOUT_DESCRIPTOR = createLayoutDescriptor(GERMAN_LAYOUT_NAME)
    private val VENDOR_SPECIFIC_LAYOUT_DESCRIPTOR =
        createLayoutDescriptor(VENDOR_SPECIFIC_LAYOUT_NAME)

@@ -710,7 +712,7 @@ class KeyboardLayoutManagerTests {
            assertCorrectLayout(
                keyboardDevice,
                createImeSubtypeForLanguageTag("de"),
                createLayoutDescriptor("keyboard_layout_german")
                GERMAN_LAYOUT_DESCRIPTOR
            )
            assertCorrectLayout(
                keyboardDevice,
@@ -775,13 +777,13 @@ class KeyboardLayoutManagerTests {
            assertCorrectLayout(
                keyboardDevice,
                createImeSubtypeForLanguageTagAndLayoutType("de", "qwertz"),
                createLayoutDescriptor("keyboard_layout_german")
                GERMAN_LAYOUT_DESCRIPTOR
            )
            // Wrong layout type should match with language if provided layout type not available
            assertCorrectLayout(
                keyboardDevice,
                createImeSubtypeForLanguageTagAndLayoutType("de", "qwerty"),
                createLayoutDescriptor("keyboard_layout_german")
                GERMAN_LAYOUT_DESCRIPTOR
            )
            assertCorrectLayout(
                keyboardDevice,
@@ -856,7 +858,7 @@ class KeyboardLayoutManagerTests {
                        ArgumentMatchers.eq(createByteArray(
                                KeyboardMetricsCollector.DEFAULT_LANGUAGE_TAG,
                                LAYOUT_TYPE_DEFAULT,
                                "German",
                                GERMAN_LAYOUT_NAME,
                                KeyboardMetricsCollector.LAYOUT_SELECTION_CRITERIA_VIRTUAL_KEYBOARD,
                                "de-Latn",
                                LAYOUT_TYPE_QWERTZ))
@@ -882,7 +884,7 @@ class KeyboardLayoutManagerTests {
                        ArgumentMatchers.eq(createByteArray(
                                "en",
                                LAYOUT_TYPE_QWERTY,
                                "English (US)",
                                ENGLISH_US_LAYOUT_NAME,
                                KeyboardMetricsCollector.LAYOUT_SELECTION_CRITERIA_DEVICE,
                                "de-Latn",
                                LAYOUT_TYPE_QWERTZ))
+3 −3
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class KeyboardMetricsCollectorTests {
        )
        val event = builder.addLayoutSelection(
            createImeSubtype(1, ULocale.forLanguageTag("en-US"), "qwerty"),
            KeyboardLayout(null, "English(US)(Qwerty)", null, 0, null, 0, 0, 0),
            "English(US)(Qwerty)",
            KeyboardMetricsCollector.LAYOUT_SELECTION_CRITERIA_VIRTUAL_KEYBOARD
        ).addLayoutSelection(
            createImeSubtype(2, ULocale.forLanguageTag("en-US"), "azerty"),
@@ -121,7 +121,7 @@ class KeyboardMetricsCollectorTests {
            KeyboardMetricsCollector.LAYOUT_SELECTION_CRITERIA_USER
        ).addLayoutSelection(
            createImeSubtype(3, ULocale.forLanguageTag("en-US"), "qwerty"),
            KeyboardLayout(null, "German", null, 0, null, 0, 0, 0),
            "German",
            KeyboardMetricsCollector.LAYOUT_SELECTION_CRITERIA_DEVICE
        ).setIsFirstTimeConfiguration(true).build()

@@ -184,7 +184,7 @@ class KeyboardMetricsCollectorTests {
        )
        val event = builder.addLayoutSelection(
            createImeSubtype(4, null, "qwerty"), // Default language tag
            KeyboardLayout(null, "German", null, 0, null, 0, 0, 0),
            "German",
            KeyboardMetricsCollector.LAYOUT_SELECTION_CRITERIA_DEVICE
        ).build()