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

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

Merge "Remove country code and use Language tag and Layout type instead."

parents 0f562c44 e4e102f9
Loading
Loading
Loading
Loading
+14 −32
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.hardware.BatteryState;
import android.hardware.SensorManager;
import android.hardware.input.InputDeviceCountryCode;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.lights.LightsManager;
@@ -75,8 +74,6 @@ public final class InputDevice implements Parcelable {
    private final int mSources;
    private final int mKeyboardType;
    private final KeyCharacterMap mKeyCharacterMap;
    @InputDeviceCountryCode
    private final int mCountryCode;
    @Nullable
    private final String mKeyboardLanguageTag;
    @Nullable
@@ -468,10 +465,9 @@ public final class InputDevice implements Parcelable {
     */
    private InputDevice(int id, int generation, int controllerNumber, String name, int vendorId,
            int productId, String descriptor, boolean isExternal, int sources, int keyboardType,
            KeyCharacterMap keyCharacterMap, @InputDeviceCountryCode int countryCode,
            @Nullable String keyboardLanguageTag, @Nullable String keyboardLayoutType,
            boolean hasVibrator, boolean hasMicrophone, boolean hasButtonUnderPad,
            boolean hasSensor, boolean hasBattery, boolean supportsUsi) {
            KeyCharacterMap keyCharacterMap, @Nullable String keyboardLanguageTag,
            @Nullable String keyboardLayoutType, boolean hasVibrator, boolean hasMicrophone,
            boolean hasButtonUnderPad, boolean hasSensor, boolean hasBattery, boolean supportsUsi) {
        mId = id;
        mGeneration = generation;
        mControllerNumber = controllerNumber;
@@ -483,7 +479,6 @@ public final class InputDevice implements Parcelable {
        mSources = sources;
        mKeyboardType = keyboardType;
        mKeyCharacterMap = keyCharacterMap;
        mCountryCode = countryCode;
        if (keyboardLanguageTag != null) {
            mKeyboardLanguageTag = ULocale
                    .createCanonical(ULocale.forLanguageTag(keyboardLanguageTag))
@@ -513,7 +508,6 @@ public final class InputDevice implements Parcelable {
        mIsExternal = in.readInt() != 0;
        mSources = in.readInt();
        mKeyboardType = in.readInt();
        mCountryCode = in.readInt();
        mKeyboardLanguageTag = in.readString8();
        mKeyboardLayoutType = in.readString8();
        mHasVibrator = in.readInt() != 0;
@@ -558,8 +552,6 @@ public final class InputDevice implements Parcelable {
        private boolean mHasButtonUnderPad = false;
        private boolean mHasSensor = false;
        private boolean mHasBattery = false;
        @InputDeviceCountryCode
        private int mCountryCode = InputDeviceCountryCode.INVALID;
        private String mKeyboardLanguageTag = null;
        private String mKeyboardLayoutType = null;
        private boolean mSupportsUsi = false;
@@ -660,12 +652,6 @@ public final class InputDevice implements Parcelable {
            return this;
        }

        /** @see InputDevice#getCountryCode() */
        public Builder setCountryCode(@InputDeviceCountryCode int countryCode) {
            mCountryCode = countryCode;
            return this;
        }

        /** @see InputDevice#getKeyboardLanguageTag() */
        public Builder setKeyboardLanguageTag(String keyboardLanguageTag) {
            mKeyboardLanguageTag = keyboardLanguageTag;
@@ -688,8 +674,8 @@ public final class InputDevice implements Parcelable {
        public InputDevice build() {
            return new InputDevice(mId, mGeneration, mControllerNumber, mName, mVendorId,
                    mProductId, mDescriptor, mIsExternal, mSources, mKeyboardType, mKeyCharacterMap,
                    mCountryCode, mKeyboardLanguageTag, mKeyboardLayoutType, mHasVibrator,
                    mHasMicrophone, mHasButtonUnderPad, mHasSensor, mHasBattery, mSupportsUsi);
                    mKeyboardLanguageTag, mKeyboardLayoutType, mHasVibrator, mHasMicrophone,
                    mHasButtonUnderPad, mHasSensor, mHasBattery, mSupportsUsi);
        }
    }

@@ -908,16 +894,6 @@ public final class InputDevice implements Parcelable {
        return mKeyCharacterMap;
    }

    /**
     * Gets Country code associated with the device
     *
     * @hide
     */
    @InputDeviceCountryCode
    public int getCountryCode() {
        return mCountryCode;
    }

    /**
     * Returns the keyboard language as an IETF
     * <a href="https://tools.ietf.org/html/bcp47">BCP-47</a>
@@ -1393,7 +1369,6 @@ public final class InputDevice implements Parcelable {
        out.writeInt(mIsExternal ? 1 : 0);
        out.writeInt(mSources);
        out.writeInt(mKeyboardType);
        out.writeInt(mCountryCode);
        out.writeString8(mKeyboardLanguageTag);
        out.writeString8(mKeyboardLayoutType);
        out.writeInt(mHasVibrator ? 1 : 0);
@@ -1445,8 +1420,6 @@ public final class InputDevice implements Parcelable {
        }
        description.append("\n");

        description.append("  Country Code: ").append(mCountryCode).append("\n");

        description.append("  Has Vibrator: ").append(mHasVibrator).append("\n");

        description.append("  Has Sensor: ").append(mHasSensor).append("\n");
@@ -1457,6 +1430,15 @@ public final class InputDevice implements Parcelable {

        description.append("  Supports USI: ").append(mSupportsUsi).append("\n");

        if (mKeyboardLanguageTag != null) {
            description.append(" Keyboard language tag: ").append(mKeyboardLanguageTag).append(
                    "\n");
        }

        if (mKeyboardLayoutType != null) {
            description.append(" Keyboard layout type: ").append(mKeyboardLayoutType).append("\n");
        }

        description.append("  Sources: 0x").append(Integer.toHexString(mSources)).append(" (");
        appendSourceDescriptionIfApplicable(description, SOURCE_KEYBOARD, "keyboard");
        appendSourceDescriptionIfApplicable(description, SOURCE_DPAD, "dpad");
+5 −6
Original line number Diff line number Diff line
@@ -78,11 +78,10 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi
                                          static_cast<int32_t>(ident.product), descriptorObj.get(),
                                          deviceInfo.isExternal(), deviceInfo.getSources(),
                                          deviceInfo.getKeyboardType(), kcmObj.get(),
                                          deviceInfo.getCountryCode(), keyboardLanguageTagObj.get(),
                                          keyboardLayoutTypeObj.get(), deviceInfo.hasVibrator(),
                                          deviceInfo.hasMic(), deviceInfo.hasButtonUnderPad(),
                                          deviceInfo.hasSensor(), deviceInfo.hasBattery(),
                                          deviceInfo.supportsUsi()));
                                          keyboardLanguageTagObj.get(), keyboardLayoutTypeObj.get(),
                                          deviceInfo.hasVibrator(), deviceInfo.hasMic(),
                                          deviceInfo.hasButtonUnderPad(), deviceInfo.hasSensor(),
                                          deviceInfo.hasBattery(), deviceInfo.supportsUsi()));
    // Note: We do not populate the Bluetooth address into the InputDevice object to avoid leaking
    // it to apps that do not have the Bluetooth permission.

@@ -106,7 +105,7 @@ int register_android_view_InputDevice(JNIEnv* env)

    gInputDeviceClassInfo.ctor = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "<init>",
                                                  "(IIILjava/lang/String;IILjava/lang/"
                                                  "String;ZIILandroid/view/KeyCharacterMap;ILjava/"
                                                  "String;ZIILandroid/view/KeyCharacterMap;Ljava/"
                                                  "lang/String;Ljava/lang/String;ZZZZZZ)V");

    gInputDeviceClassInfo.addMotionRange = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz,
+0 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package android.view;

import static org.junit.Assert.assertEquals;

import android.hardware.input.InputDeviceCountryCode;
import android.os.Parcel;

import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -55,7 +54,6 @@ public class InputDeviceTest {
        assertEquals(device.isExternal(), outDevice.isExternal());
        assertEquals(device.getSources(), outDevice.getSources());
        assertEquals(device.getKeyboardType(), outDevice.getKeyboardType());
        assertEquals(device.getCountryCode(), outDevice.getCountryCode());
        assertEquals(device.getKeyboardLanguageTag(), outDevice.getKeyboardLanguageTag());
        assertEquals(device.getKeyboardLayoutType(), outDevice.getKeyboardLayoutType());
        assertEquals(device.getMotionRanges().size(), outDevice.getMotionRanges().size());
@@ -88,7 +86,6 @@ public class InputDeviceTest {
                .setHasButtonUnderPad(true)
                .setHasSensor(true)
                .setHasBattery(true)
                .setCountryCode(InputDeviceCountryCode.INTERNATIONAL)
                .setKeyboardLanguageTag("en-US")
                .setKeyboardLayoutType("qwerty")
                .setSupportsUsi(true)