summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2013-12-16 11:27:55 -0800
committerRoboErik <epastern@google.com>2014-03-12 13:21:08 -0700
commitca9eef6203b7cfb0084f8305d4dcc5d70a7a25cd (patch)
treee1d23691fc25baa5271a075350eb93e01b6f1e9c /core/java/android/hardware
parentc1e0015ec3dfacc137cb500066020b25f18ecbb7 (diff)
downloadframeworks_base-ca9eef6203b7cfb0084f8305d4dcc5d70a7a25cd.zip
frameworks_base-ca9eef6203b7cfb0084f8305d4dcc5d70a7a25cd.tar.gz
frameworks_base-ca9eef6203b7cfb0084f8305d4dcc5d70a7a25cd.tar.bz2
b/12068020 Make kb layouts only unique to vendor/product. Do not merge
This is a cherry-pick of https://googleplex-android-review.git.corp.google.com/#/c/399886/ Instead of storing a kb layout per device descriptor (which is expected to be unique), store it for each vendor/product. This way we can keep a consistent layout between identical but physically different keyboards. There are some corner cases this is expected to fail on, namely devices that incorrectly have the same vendor/product id. Devices that don't define a vendor/product id will continue to use the descriptor to store layout files. Change-Id: I1f2508561992080459310d5a644dad65a9c24f1a
Diffstat (limited to 'core/java/android/hardware')
-rw-r--r--core/java/android/hardware/input/IInputManager.aidl11
-rw-r--r--core/java/android/hardware/input/InputDeviceIdentifier.aidl19
-rw-r--r--core/java/android/hardware/input/InputDeviceIdentifier.java82
-rw-r--r--core/java/android/hardware/input/InputManager.java84
4 files changed, 149 insertions, 47 deletions
diff --git a/core/java/android/hardware/input/IInputManager.aidl b/core/java/android/hardware/input/IInputManager.aidl
index 9b6f82a..f1e7e98 100644
--- a/core/java/android/hardware/input/IInputManager.aidl
+++ b/core/java/android/hardware/input/IInputManager.aidl
@@ -16,6 +16,7 @@
package android.hardware.input;
+import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.KeyboardLayout;
import android.hardware.input.IInputDevicesChangedListener;
import android.os.IBinder;
@@ -41,13 +42,13 @@ interface IInputManager {
// Keyboard layouts configuration.
KeyboardLayout[] getKeyboardLayouts();
KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor);
- String getCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor);
- void setCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ String getCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier);
+ void setCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor);
- String[] getKeyboardLayoutsForInputDevice(String inputDeviceDescriptor);
- void addKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ String[] getKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier);
+ void addKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor);
- void removeKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ void removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor);
// Registers an input devices changed listener.
diff --git a/core/java/android/hardware/input/InputDeviceIdentifier.aidl b/core/java/android/hardware/input/InputDeviceIdentifier.aidl
new file mode 100644
index 0000000..7234a91
--- /dev/null
+++ b/core/java/android/hardware/input/InputDeviceIdentifier.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.input;
+
+parcelable InputDeviceIdentifier;
diff --git a/core/java/android/hardware/input/InputDeviceIdentifier.java b/core/java/android/hardware/input/InputDeviceIdentifier.java
new file mode 100644
index 0000000..5e832e3
--- /dev/null
+++ b/core/java/android/hardware/input/InputDeviceIdentifier.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.input;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Wrapper for passing identifying information for input devices.
+ *
+ * @hide
+ */
+public final class InputDeviceIdentifier implements Parcelable {
+ private final String mDescriptor;
+ private final int mVendorId;
+ private final int mProductId;
+
+ public InputDeviceIdentifier(String descriptor, int vendorId, int productId) {
+ this.mDescriptor = descriptor;
+ this.mVendorId = vendorId;
+ this.mProductId = productId;
+ }
+
+ private InputDeviceIdentifier(Parcel src) {
+ mDescriptor = src.readString();
+ mVendorId = src.readInt();
+ mProductId = src.readInt();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mDescriptor);
+ dest.writeInt(mVendorId);
+ dest.writeInt(mProductId);
+ }
+
+ public String getDescriptor() {
+ return mDescriptor;
+ }
+
+ public int getVendorId() {
+ return mVendorId;
+ }
+
+ public int getProductId() {
+ return mProductId;
+ }
+
+ public static final Parcelable.Creator<InputDeviceIdentifier> CREATOR =
+ new Parcelable.Creator<InputDeviceIdentifier>() {
+
+ @Override
+ public InputDeviceIdentifier createFromParcel(Parcel source) {
+ return new InputDeviceIdentifier(source);
+ }
+
+ @Override
+ public InputDeviceIdentifier[] newArray(int size) {
+ return new InputDeviceIdentifier[size];
+ }
+
+ };
+}
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index 30e69a6..a2aeafb 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -26,6 +26,8 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.Vibrator;
@@ -373,20 +375,17 @@ public final class InputManager {
}
/**
- * Gets the current keyboard layout descriptor for the specified input device.
- *
- * @param inputDeviceDescriptor The input device descriptor.
- * @return The keyboard layout descriptor, or null if no keyboard layout has been set.
+ * Gets the current keyboard layout descriptor for the specified input
+ * device.
*
+ * @param identifier Identifier for the input device
+ * @return The keyboard layout descriptor, or null if no keyboard layout has
+ * been set.
* @hide
*/
- public String getCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor) {
- if (inputDeviceDescriptor == null) {
- throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
- }
-
+ public String getCurrentKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier) {
try {
- return mIm.getCurrentKeyboardLayoutForInputDevice(inputDeviceDescriptor);
+ return mIm.getCurrentKeyboardLayoutForInputDevice(identifier);
} catch (RemoteException ex) {
Log.w(TAG, "Could not get current keyboard layout for input device.", ex);
return null;
@@ -394,28 +393,29 @@ public final class InputManager {
}
/**
- * Sets the current keyboard layout descriptor for the specified input device.
+ * Sets the current keyboard layout descriptor for the specified input
+ * device.
* <p>
- * This method may have the side-effect of causing the input device in question
- * to be reconfigured.
+ * This method may have the side-effect of causing the input device in
+ * question to be reconfigured.
* </p>
*
- * @param inputDeviceDescriptor The input device descriptor.
- * @param keyboardLayoutDescriptor The keyboard layout descriptor to use, must not be null.
- *
+ * @param identifier The identifier for the input device.
+ * @param keyboardLayoutDescriptor The keyboard layout descriptor to use,
+ * must not be null.
* @hide
*/
- public void setCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ public void setCurrentKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor) {
- if (inputDeviceDescriptor == null) {
- throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
+ if (identifier == null) {
+ throw new IllegalArgumentException("identifier must not be null");
}
if (keyboardLayoutDescriptor == null) {
throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null");
}
try {
- mIm.setCurrentKeyboardLayoutForInputDevice(inputDeviceDescriptor,
+ mIm.setCurrentKeyboardLayoutForInputDevice(identifier,
keyboardLayoutDescriptor);
} catch (RemoteException ex) {
Log.w(TAG, "Could not set current keyboard layout for input device.", ex);
@@ -423,20 +423,20 @@ public final class InputManager {
}
/**
- * Gets all keyboard layout descriptors that are enabled for the specified input device.
+ * Gets all keyboard layout descriptors that are enabled for the specified
+ * input device.
*
- * @param inputDeviceDescriptor The input device descriptor.
+ * @param identifier The identifier for the input device.
* @return The keyboard layout descriptors.
- *
* @hide
*/
- public String[] getKeyboardLayoutsForInputDevice(String inputDeviceDescriptor) {
- if (inputDeviceDescriptor == null) {
+ public String[] getKeyboardLayoutsForInputDevice(InputDeviceIdentifier identifier) {
+ if (identifier == null) {
throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
}
try {
- return mIm.getKeyboardLayoutsForInputDevice(inputDeviceDescriptor);
+ return mIm.getKeyboardLayoutsForInputDevice(identifier);
} catch (RemoteException ex) {
Log.w(TAG, "Could not get keyboard layouts for input device.", ex);
return ArrayUtils.emptyArray(String.class);
@@ -446,18 +446,18 @@ public final class InputManager {
/**
* Adds the keyboard layout descriptor for the specified input device.
* <p>
- * This method may have the side-effect of causing the input device in question
- * to be reconfigured.
+ * This method may have the side-effect of causing the input device in
+ * question to be reconfigured.
* </p>
*
- * @param inputDeviceDescriptor The input device descriptor.
- * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to add.
- *
+ * @param identifier The identifier for the input device.
+ * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to
+ * add.
* @hide
*/
- public void addKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ public void addKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor) {
- if (inputDeviceDescriptor == null) {
+ if (identifier == null) {
throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
}
if (keyboardLayoutDescriptor == null) {
@@ -465,7 +465,7 @@ public final class InputManager {
}
try {
- mIm.addKeyboardLayoutForInputDevice(inputDeviceDescriptor, keyboardLayoutDescriptor);
+ mIm.addKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor);
} catch (RemoteException ex) {
Log.w(TAG, "Could not add keyboard layout for input device.", ex);
}
@@ -474,18 +474,18 @@ public final class InputManager {
/**
* Removes the keyboard layout descriptor for the specified input device.
* <p>
- * This method may have the side-effect of causing the input device in question
- * to be reconfigured.
+ * This method may have the side-effect of causing the input device in
+ * question to be reconfigured.
* </p>
*
- * @param inputDeviceDescriptor The input device descriptor.
- * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to remove.
- *
+ * @param identifier The identifier for the input device.
+ * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to
+ * remove.
* @hide
*/
- public void removeKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ public void removeKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor) {
- if (inputDeviceDescriptor == null) {
+ if (identifier == null) {
throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
}
if (keyboardLayoutDescriptor == null) {
@@ -493,7 +493,7 @@ public final class InputManager {
}
try {
- mIm.removeKeyboardLayoutForInputDevice(inputDeviceDescriptor, keyboardLayoutDescriptor);
+ mIm.removeKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor);
} catch (RemoteException ex) {
Log.w(TAG, "Could not remove keyboard layout for input device.", ex);
}