diff options
| author | Jeff Brown <jeffbrown@google.com> | 2012-05-01 15:54:03 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2012-05-01 16:34:20 -0700 |
| commit | daa3753a04699724d2cfe824ac1f5a266d643a05 (patch) | |
| tree | ddc33d395dd0f3d01a95775397356983fb28a076 /core/java/android/view/InputDevice.java | |
| parent | 32c8113510b2774f865e8ac763976b90d9db2706 (diff) | |
Improve handling of built-in keyboard.
The window manager policy made some incorrect assumptions about the
meaning of the Configuration.keyboard field. We need to be more
careful about distinguishing between built-in and external keyboards.
Most of this change is to move the determination of the parts of
the Configuration related to input devices into the WindowManagerService
leveraging new features of the InputManagerService to good effect.
Then we plumb through the flag that indicates whether a device
is internal or external so that we can be more particular about
how the lid switch effects changes to the Configuration.
Bug: 6424373
Change-Id: I36a1c22ade35e578955465a25940a33f227b9763
Diffstat (limited to 'core/java/android/view/InputDevice.java')
| -rwxr-xr-x | core/java/android/view/InputDevice.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java index 85f435c76116..2ea03604315d 100755 --- a/core/java/android/view/InputDevice.java +++ b/core/java/android/view/InputDevice.java @@ -46,6 +46,7 @@ public final class InputDevice implements Parcelable { private final int mGeneration; private final String mName; private final String mDescriptor; + private final boolean mIsExternal; private final int mSources; private final int mKeyboardType; private final KeyCharacterMap mKeyCharacterMap; @@ -322,12 +323,14 @@ public final class InputDevice implements Parcelable { }; // Called by native code. - private InputDevice(int id, int generation, String name, String descriptor, int sources, + private InputDevice(int id, int generation, String name, String descriptor, + boolean isExternal, int sources, int keyboardType, KeyCharacterMap keyCharacterMap, boolean hasVibrator) { mId = id; mGeneration = generation; mName = name; mDescriptor = descriptor; + mIsExternal = isExternal; mSources = sources; mKeyboardType = keyboardType; mKeyCharacterMap = keyCharacterMap; @@ -339,6 +342,7 @@ public final class InputDevice implements Parcelable { mGeneration = in.readInt(); mName = in.readString(); mDescriptor = in.readString(); + mIsExternal = in.readInt() != 0; mSources = in.readInt(); mKeyboardType = in.readInt(); mKeyCharacterMap = KeyCharacterMap.CREATOR.createFromParcel(in); @@ -414,7 +418,7 @@ public final class InputDevice implements Parcelable { * has a trackpad. Alternately, it may be that the input devices are simply * indistinguishable, such as two keyboards made by the same manufacturer. * </p><p> - * The input device descriptor returned by {@link #getDescriptor} should only bt + * The input device descriptor returned by {@link #getDescriptor} should only be * used when an application needs to remember settings associated with a particular * input device. For all other purposes when referring to a logical * {@link InputDevice} instance at runtime use the id returned by {@link #getId()}. @@ -443,6 +447,18 @@ public final class InputDevice implements Parcelable { } /** + * Returns true if the device is external (connected to USB or Bluetooth or some other + * peripheral bus), otherwise it is built-in. + * + * @return True if the device is external. + * + * @hide + */ + public boolean isExternal() { + return mIsExternal; + } + + /** * Gets the name of this input device. * @return The input device name. */ @@ -660,6 +676,7 @@ public final class InputDevice implements Parcelable { out.writeInt(mGeneration); out.writeString(mName); out.writeString(mDescriptor); + out.writeInt(mIsExternal ? 1 : 0); out.writeInt(mSources); out.writeInt(mKeyboardType); mKeyCharacterMap.writeToParcel(out, flags); @@ -689,6 +706,7 @@ public final class InputDevice implements Parcelable { description.append("Input Device ").append(mId).append(": ").append(mName).append("\n"); description.append(" Descriptor: ").append(mDescriptor).append("\n"); description.append(" Generation: ").append(mGeneration).append("\n"); + description.append(" Location: ").append(mIsExternal ? "external" : "built-in").append("\n"); description.append(" Keyboard Type: "); switch (mKeyboardType) { |
