summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcore/java/android/view/InputDevice.java22
-rw-r--r--core/java/android/view/WindowManagerPolicy.java12
-rw-r--r--core/jni/android_view_InputDevice.cpp4
-rw-r--r--include/androidfw/Input.h31
-rw-r--r--include/androidfw/InputDevice.h4
-rw-r--r--libs/androidfw/InputDevice.cpp7
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java55
-rw-r--r--services/input/InputReader.cpp42
-rw-r--r--services/input/InputReader.h10
-rw-r--r--services/input/tests/InputReader_test.cpp90
-rw-r--r--services/java/com/android/server/PowerManagerService.java4
-rw-r--r--services/java/com/android/server/input/InputManagerService.java19
-rwxr-xr-xservices/java/com/android/server/wm/WindowManagerService.java44
-rw-r--r--services/jni/com_android_server_input_InputManagerService.cpp33
14 files changed, 117 insertions, 260 deletions
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index 85f435c..2ea0360 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) {
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 94762b9..5025a29 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -91,6 +91,11 @@ public interface WindowManagerPolicy {
public final static int FLAG_BRIGHT_HERE = 0x20000000;
public final static int FLAG_PASS_TO_USER = 0x40000000;
+ // Flags used for indicating whether the internal and/or external input devices
+ // of some type are available.
+ public final static int PRESENCE_INTERNAL = 1 << 0;
+ public final static int PRESENCE_EXTERNAL = 1 << 1;
+
public final static boolean WATCH_POINTER = false;
/**
@@ -516,8 +521,13 @@ public interface WindowManagerPolicy {
*
* @param config The Configuration being computed, for you to change as
* desired.
+ * @param keyboardPresence Flags that indicate whether internal or external
+ * keyboards are present.
+ * @param navigationPresence Flags that indicate whether internal or external
+ * navigation devices are present.
*/
- public void adjustConfigurationLw(Configuration config);
+ public void adjustConfigurationLw(Configuration config, int keyboardPresence,
+ int navigationPresence);
/**
* Assign a window type to a layer. Allows you to control how different
diff --git a/core/jni/android_view_InputDevice.cpp b/core/jni/android_view_InputDevice.cpp
index d1f0a6a..576f831 100644
--- a/core/jni/android_view_InputDevice.cpp
+++ b/core/jni/android_view_InputDevice.cpp
@@ -55,7 +55,7 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi
ScopedLocalRef<jobject> inputDeviceObj(env, env->NewObject(gInputDeviceClassInfo.clazz,
gInputDeviceClassInfo.ctor, deviceInfo.getId(), deviceInfo.getGeneration(),
- nameObj.get(), descriptorObj.get(),
+ nameObj.get(), descriptorObj.get(), deviceInfo.isExternal(),
deviceInfo.getSources(), deviceInfo.getKeyboardType(),
kcmObj.get(), deviceInfo.hasVibrator()));
@@ -87,7 +87,7 @@ int register_android_view_InputDevice(JNIEnv* env)
gInputDeviceClassInfo.clazz = jclass(env->NewGlobalRef(gInputDeviceClassInfo.clazz));
GET_METHOD_ID(gInputDeviceClassInfo.ctor, gInputDeviceClassInfo.clazz,
- "<init>", "(IILjava/lang/String;Ljava/lang/String;IILandroid/view/KeyCharacterMap;Z)V");
+ "<init>", "(IILjava/lang/String;Ljava/lang/String;ZIILandroid/view/KeyCharacterMap;Z)V");
GET_METHOD_ID(gInputDeviceClassInfo.addMotionRange, gInputDeviceClassInfo.clazz,
"addMotionRange", "(IIFFFF)V");
diff --git a/include/androidfw/Input.h b/include/androidfw/Input.h
index 044f2bf..601a169 100644
--- a/include/androidfw/Input.h
+++ b/include/androidfw/Input.h
@@ -157,37 +157,6 @@ enum {
};
/*
- * Describes the basic configuration of input devices that are present.
- */
-struct InputConfiguration {
- enum {
- TOUCHSCREEN_UNDEFINED = 0,
- TOUCHSCREEN_NOTOUCH = 1,
- TOUCHSCREEN_STYLUS = 2,
- TOUCHSCREEN_FINGER = 3
- };
-
- enum {
- KEYBOARD_UNDEFINED = 0,
- KEYBOARD_NOKEYS = 1,
- KEYBOARD_QWERTY = 2,
- KEYBOARD_12KEY = 3
- };
-
- enum {
- NAVIGATION_UNDEFINED = 0,
- NAVIGATION_NONAV = 1,
- NAVIGATION_DPAD = 2,
- NAVIGATION_TRACKBALL = 3,
- NAVIGATION_WHEEL = 4
- };
-
- int32_t touchScreen;
- int32_t keyboard;
- int32_t navigation;
-};
-
-/*
* Pointer coordinate data.
*/
struct PointerCoords {
diff --git a/include/androidfw/InputDevice.h b/include/androidfw/InputDevice.h
index d6ecbf0..1aecf80 100644
--- a/include/androidfw/InputDevice.h
+++ b/include/androidfw/InputDevice.h
@@ -67,7 +67,7 @@ public:
};
void initialize(int32_t id, int32_t generation, const InputDeviceIdentifier& identifier,
- const String8& alias);
+ const String8& alias, bool isExternal);
inline int32_t getId() const { return mId; }
inline int32_t getGeneration() const { return mGeneration; }
@@ -76,6 +76,7 @@ public:
inline const String8& getDisplayName() const {
return mAlias.isEmpty() ? mIdentifier.name : mAlias;
}
+ inline bool isExternal() const { return mIsExternal; }
inline uint32_t getSources() const { return mSources; }
const MotionRange* getMotionRange(int32_t axis, uint32_t source) const;
@@ -108,6 +109,7 @@ private:
int32_t mGeneration;
InputDeviceIdentifier mIdentifier;
String8 mAlias;
+ bool mIsExternal;
uint32_t mSources;
int32_t mKeyboardType;
sp<KeyCharacterMap> mKeyCharacterMap;
diff --git a/libs/androidfw/InputDevice.cpp b/libs/androidfw/InputDevice.cpp
index 928157f..fe891cb 100644
--- a/libs/androidfw/InputDevice.cpp
+++ b/libs/androidfw/InputDevice.cpp
@@ -127,12 +127,12 @@ String8 getInputDeviceConfigurationFilePathByName(
// --- InputDeviceInfo ---
InputDeviceInfo::InputDeviceInfo() {
- initialize(-1, -1, InputDeviceIdentifier(), String8());
+ initialize(-1, -1, InputDeviceIdentifier(), String8(), false);
}
InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) :
mId(other.mId), mGeneration(other.mGeneration), mIdentifier(other.mIdentifier),
- mAlias(other.mAlias), mSources(other.mSources),
+ mAlias(other.mAlias), mIsExternal(other.mIsExternal), mSources(other.mSources),
mKeyboardType(other.mKeyboardType),
mKeyCharacterMap(other.mKeyCharacterMap),
mHasVibrator(other.mHasVibrator),
@@ -143,11 +143,12 @@ InputDeviceInfo::~InputDeviceInfo() {
}
void InputDeviceInfo::initialize(int32_t id, int32_t generation,
- const InputDeviceIdentifier& identifier, const String8& alias) {
+ const InputDeviceIdentifier& identifier, const String8& alias, bool isExternal) {
mId = id;
mGeneration = generation;
mIdentifier = identifier;
mAlias = alias;
+ mIsExternal = isExternal;
mSources = 0;
mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE;
mHasVibrator = false;
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index c364a68..40acc61 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -38,6 +38,7 @@ import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.hardware.input.InputManager;
import android.media.AudioManager;
import android.media.IAudioService;
import android.os.BatteryManager;
@@ -332,6 +333,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int mRecentAppsDialogHeldModifiers;
int mLidState = LID_ABSENT;
+ boolean mHaveBuiltInKeyboard;
boolean mSystemReady;
boolean mSystemBooted;
@@ -1265,46 +1267,42 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mLidState = mWindowManagerFuncs.getLidState();
}
- private int determineHiddenState(int mode, int hiddenValue, int visibleValue) {
- if (mLidState != LID_ABSENT) {
- switch (mode) {
- case 1:
- return mLidState == LID_OPEN ? visibleValue : hiddenValue;
- case 2:
- return mLidState == LID_OPEN ? hiddenValue : visibleValue;
- }
+ private boolean isHidden(int accessibilityMode) {
+ switch (accessibilityMode) {
+ case 1:
+ return mLidState == LID_CLOSED;
+ case 2:
+ return mLidState == LID_OPEN;
+ default:
+ return false;
}
- return visibleValue;
}
- private boolean isKeyboardVisible() {
- return determineHiddenState(mLidKeyboardAccessibility, 0, 1) == 1
- || determineHiddenState(mLidNavigationAccessibility, 0, 1) == 1;
+ private boolean isBuiltInKeyboardVisible() {
+ return mHaveBuiltInKeyboard && !isHidden(mLidKeyboardAccessibility);
}
/** {@inheritDoc} */
- public void adjustConfigurationLw(Configuration config) {
+ public void adjustConfigurationLw(Configuration config, int keyboardPresence,
+ int navigationPresence) {
+ mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0;
+
readLidState();
applyLidSwitchState();
- if (config.keyboard == Configuration.KEYBOARD_NOKEYS) {
+ if (config.keyboard == Configuration.KEYBOARD_NOKEYS
+ || (keyboardPresence == PRESENCE_INTERNAL
+ && isHidden(mLidKeyboardAccessibility))) {
config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES;
- } else {
- config.hardKeyboardHidden = determineHiddenState(mLidKeyboardAccessibility,
- Configuration.HARDKEYBOARDHIDDEN_YES, Configuration.HARDKEYBOARDHIDDEN_NO);
+ if (!mHasSoftInput) {
+ config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES;
+ }
}
- if (config.navigation == Configuration.NAVIGATION_NONAV) {
+ if (config.navigation == Configuration.NAVIGATION_NONAV
+ || (navigationPresence == PRESENCE_INTERNAL
+ && isHidden(mLidNavigationAccessibility))) {
config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES;
- } else {
- config.navigationHidden = determineHiddenState(mLidNavigationAccessibility,
- Configuration.NAVIGATIONHIDDEN_YES, Configuration.NAVIGATIONHIDDEN_NO);
- }
-
- if (mHasSoftInput || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
- config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
- } else {
- config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES;
}
}
@@ -3932,7 +3930,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
private void applyLidSwitchState() {
- mPowerManager.setKeyboardVisibility(isKeyboardVisible());
+ mPowerManager.setKeyboardVisibility(isBuiltInKeyboardVisible());
+
if (mLidState == LID_CLOSED && mLidControlsSleep) {
mPowerManager.goToSleep(SystemClock.uptimeMillis());
}
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index c6b701f..cd6a2ec 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -250,7 +250,6 @@ InputReader::InputReader(const sp<EventHubInterface>& eventHub,
refreshConfigurationLocked(0);
updateGlobalMetaStateLocked();
- updateInputConfigurationLocked();
} // release lock
}
@@ -502,9 +501,6 @@ void InputReader::handleConfigurationChangedLocked(nsecs_t when) {
// Reset global meta state because it depends on the list of all configured devices.
updateGlobalMetaStateLocked();
- // Update input configuration.
- updateInputConfigurationLocked();
-
// Enqueue configuration changed.
NotifyConfigurationChangedArgs args(when);
mQueuedListener->notifyConfigurationChanged(&args);
@@ -542,36 +538,6 @@ int32_t InputReader::getGlobalMetaStateLocked() {
return mGlobalMetaState;
}
-void InputReader::updateInputConfigurationLocked() {
- int32_t touchScreenConfig = InputConfiguration::TOUCHSCREEN_NOTOUCH;
- int32_t keyboardConfig = InputConfiguration::KEYBOARD_NOKEYS;
- int32_t navigationConfig = InputConfiguration::NAVIGATION_NONAV;
- InputDeviceInfo deviceInfo;
- for (size_t i = 0; i < mDevices.size(); i++) {
- InputDevice* device = mDevices.valueAt(i);
- if (!(device->getClasses() & INPUT_DEVICE_CLASS_VIRTUAL)) {
- device->getDeviceInfo(& deviceInfo);
- uint32_t sources = deviceInfo.getSources();
-
- if ((sources & AINPUT_SOURCE_TOUCHSCREEN) == AINPUT_SOURCE_TOUCHSCREEN) {
- touchScreenConfig = InputConfiguration::TOUCHSCREEN_FINGER;
- }
- if ((sources & AINPUT_SOURCE_TRACKBALL) == AINPUT_SOURCE_TRACKBALL) {
- navigationConfig = InputConfiguration::NAVIGATION_TRACKBALL;
- } else if ((sources & AINPUT_SOURCE_DPAD) == AINPUT_SOURCE_DPAD) {
- navigationConfig = InputConfiguration::NAVIGATION_DPAD;
- }
- if (deviceInfo.getKeyboardType() == AINPUT_KEYBOARD_TYPE_ALPHABETIC) {
- keyboardConfig = InputConfiguration::KEYBOARD_QWERTY;
- }
- }
- }
-
- mInputConfiguration.touchScreen = touchScreenConfig;
- mInputConfiguration.keyboard = keyboardConfig;
- mInputConfiguration.navigation = navigationConfig;
-}
-
void InputReader::disableVirtualKeysUntilLocked(nsecs_t time) {
mDisableVirtualKeysTimeout = time;
}
@@ -608,12 +574,6 @@ int32_t InputReader::bumpGenerationLocked() {
return ++mGeneration;
}
-void InputReader::getInputConfiguration(InputConfiguration* outConfiguration) {
- AutoMutex _l(mLock);
-
- *outConfiguration = mInputConfiguration;
-}
-
void InputReader::getInputDevices(Vector<InputDeviceInfo>& outInputDevices) {
AutoMutex _l(mLock);
getInputDevicesLocked(outInputDevices);
@@ -1049,7 +1009,7 @@ void InputDevice::timeoutExpired(nsecs_t when) {
}
void InputDevice::getDeviceInfo(InputDeviceInfo* outDeviceInfo) {
- outDeviceInfo->initialize(mId, mGeneration, mIdentifier, mAlias);
+ outDeviceInfo->initialize(mId, mGeneration, mIdentifier, mAlias, mIsExternal);
size_t numMappers = mMappers.size();
for (size_t i = 0; i < numMappers; i++) {
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index 8257dbc..03198a6 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -259,12 +259,6 @@ public:
*/
virtual void loopOnce() = 0;
- /* Gets the current input device configuration.
- *
- * This method may be called on any thread (usually by the input manager).
- */
- virtual void getInputConfiguration(InputConfiguration* outConfiguration) = 0;
-
/* Gets information about all input devices.
*
* This method may be called on any thread (usually by the input manager).
@@ -344,7 +338,6 @@ public:
virtual void loopOnce();
- virtual void getInputConfiguration(InputConfiguration* outConfiguration);
virtual void getInputDevices(Vector<InputDeviceInfo>& outInputDevices);
virtual int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask,
@@ -425,9 +418,6 @@ private:
int32_t mGeneration;
int32_t bumpGenerationLocked();
- InputConfiguration mInputConfiguration;
- void updateInputConfigurationLocked();
-
void getInputDevicesLocked(Vector<InputDeviceInfo>& outInputDevices);
nsecs_t mDisableVirtualKeysTimeout;
diff --git a/services/input/tests/InputReader_test.cpp b/services/input/tests/InputReader_test.cpp
index 0f755ae..abda10b 100644
--- a/services/input/tests/InputReader_test.cpp
+++ b/services/input/tests/InputReader_test.cpp
@@ -984,96 +984,6 @@ protected:
}
};
-TEST_F(InputReaderTest, GetInputConfiguration_WhenNoDevices_ReturnsDefaults) {
- InputConfiguration config;
- mReader->getInputConfiguration(&config);
-
- ASSERT_EQ(InputConfiguration::KEYBOARD_NOKEYS, config.keyboard);
- ASSERT_EQ(InputConfiguration::NAVIGATION_NONAV, config.navigation);
- ASSERT_EQ(InputConfiguration::TOUCHSCREEN_NOTOUCH, config.touchScreen);
-}
-
-TEST_F(InputReaderTest, GetInputConfiguration_WhenAlphabeticKeyboardPresent_ReturnsQwertyKeyboard) {
- ASSERT_NO_FATAL_FAILURE(addDevice(0, String8("keyboard"),
- INPUT_DEVICE_CLASS_KEYBOARD | INPUT_DEVICE_CLASS_ALPHAKEY, NULL));
-
- InputConfiguration config;
- mReader->getInputConfiguration(&config);
-
- ASSERT_EQ(InputConfiguration::KEYBOARD_QWERTY, config.keyboard);
- ASSERT_EQ(InputConfiguration::NAVIGATION_NONAV, config.navigation);
- ASSERT_EQ(InputConfiguration::TOUCHSCREEN_NOTOUCH, config.touchScreen);
-}
-
-TEST_F(InputReaderTest, GetInputConfiguration_WhenTouchScreenPresent_ReturnsFingerTouchScreen) {
- PropertyMap configuration;
- configuration.addProperty(String8("touch.deviceType"), String8("touchScreen"));
- ASSERT_NO_FATAL_FAILURE(addDevice(0, String8("touchscreen"),
- INPUT_DEVICE_CLASS_TOUCH, &configuration));
-
- InputConfiguration config;
- mReader->getInputConfiguration(&config);
-
- ASSERT_EQ(InputConfiguration::KEYBOARD_NOKEYS, config.keyboard);
- ASSERT_EQ(InputConfiguration::NAVIGATION_NONAV, config.navigation);
- ASSERT_EQ(InputConfiguration::TOUCHSCREEN_FINGER, config.touchScreen);
-}
-
-TEST_F(InputReaderTest, GetInputConfiguration_WhenTouchPadPresent_ReturnsFingerNoTouch) {
- ASSERT_NO_FATAL_FAILURE(addDevice(0, String8("touchpad"),
- INPUT_DEVICE_CLASS_TOUCH, NULL));
-
- InputConfiguration config;
- mReader->getInputConfiguration(&config);
-
- ASSERT_EQ(InputConfiguration::KEYBOARD_NOKEYS, config.keyboard);
- ASSERT_EQ(InputConfiguration::NAVIGATION_NONAV, config.navigation);
- ASSERT_EQ(InputConfiguration::TOUCHSCREEN_NOTOUCH, config.touchScreen);
-}
-
-TEST_F(InputReaderTest, GetInputConfiguration_WhenMousePresent_ReturnsNoNavigation) {
- sp<FakePointerController> controller = new FakePointerController();
- mFakePolicy->setPointerController(0, controller);
-
- PropertyMap configuration;
- configuration.addProperty(String8("cursor.mode"), String8("pointer"));
- ASSERT_NO_FATAL_FAILURE(addDevice(0, String8("mouse"),
- INPUT_DEVICE_CLASS_CURSOR, &configuration));
-
- InputConfiguration config;
- mReader->getInputConfiguration(&config);
-
- ASSERT_EQ(InputConfiguration::KEYBOARD_NOKEYS, config.keyboard);
- ASSERT_EQ(InputConfiguration::NAVIGATION_NONAV, config.navigation);
- ASSERT_EQ(InputConfiguration::TOUCHSCREEN_NOTOUCH, config.touchScreen);
-}
-
-TEST_F(InputReaderTest, GetInputConfiguration_WhenTrackballPresent_ReturnsTrackballNavigation) {
- PropertyMap configuration;
- configuration.addProperty(String8("cursor.mode"), String8("navigation"));
- ASSERT_NO_FATAL_FAILURE(addDevice(0, String8("trackball"),
- INPUT_DEVICE_CLASS_CURSOR, &configuration));
-
- InputConfiguration config;
- mReader->getInputConfiguration(&config);
-
- ASSERT_EQ(InputConfiguration::KEYBOARD_NOKEYS, config.keyboard);
- ASSERT_EQ(InputConfiguration::NAVIGATION_TRACKBALL, config.navigation);
- ASSERT_EQ(InputConfiguration::TOUCHSCREEN_NOTOUCH, config.touchScreen);
-}
-
-TEST_F(InputReaderTest, GetInputConfiguration_WhenDPadPresent_ReturnsDPadNavigation) {
- ASSERT_NO_FATAL_FAILURE(addDevice(0, String8("dpad"),
- INPUT_DEVICE_CLASS_DPAD, NULL));
-
- InputConfiguration config;
- mReader->getInputConfiguration(&config);
-
- ASSERT_EQ(InputConfiguration::KEYBOARD_NOKEYS, config.keyboard);
- ASSERT_EQ(InputConfiguration::NAVIGATION_DPAD, config.navigation);
- ASSERT_EQ(InputConfiguration::TOUCHSCREEN_NOTOUCH, config.touchScreen);
-}
-
TEST_F(InputReaderTest, GetInputDevices) {
ASSERT_NO_FATAL_FAILURE(addDevice(1, String8("keyboard"),
INPUT_DEVICE_CLASS_KEYBOARD, NULL));
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index bd50e22..5ec1fa5 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -2521,8 +2521,8 @@ public class PowerManagerService extends IPowerManager.Stub
return val;
} catch (Exception e) {
// guard against null pointer or index out of bounds errors
- Slog.e(TAG, "Values array must be non-empty and must be the same length "
- + "as the auto-brightness levels array. Check config.xml.", e);
+ Slog.e(TAG, "Values array must be non-empty and must be one element longer than "
+ + "the auto-brightness levels array. Check config.xml.", e);
return 255;
}
}
diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java
index aece7d2..117e064 100644
--- a/services/java/com/android/server/input/InputManagerService.java
+++ b/services/java/com/android/server/input/InputManagerService.java
@@ -162,7 +162,6 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
private static native void nativeSetSystemUiVisibility(int ptr, int visibility);
private static native void nativeSetFocusedApplication(int ptr,
InputApplicationHandle application);
- private static native void nativeGetInputConfiguration(int ptr, Configuration configuration);
private static native boolean nativeTransferTouchFocus(int ptr,
InputChannel fromChannel, InputChannel toChannel);
private static native void nativeSetPointerSpeed(int ptr, int speed);
@@ -298,14 +297,6 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
}
nativeSetDisplayOrientation(mPtr, displayId, rotation);
}
-
- public void getInputConfiguration(Configuration config) {
- if (config == null) {
- throw new IllegalArgumentException("config must not be null.");
- }
-
- nativeGetInputConfiguration(mPtr, config);
- }
/**
* Gets the current state of a key or button by key code.
@@ -522,6 +513,16 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog.
}
}
+ /**
+ * Gets all input devices in the system.
+ * @return The array of input devices.
+ */
+ public InputDevice[] getInputDevices() {
+ synchronized (mInputDevicesLock) {
+ return mInputDevices;
+ }
+ }
+
@Override // Binder call
public void registerInputDevicesChangedListener(IInputDevicesChangedListener listener) {
if (listener == null) {
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 28fca69..70da61a 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -6284,8 +6284,6 @@ public class WindowManagerService extends IWindowManager.Stub
final int dh = mCurDisplayHeight;
if (config != null) {
- mInputManager.getInputConfiguration(config);
-
int orientation = Configuration.ORIENTATION_SQUARE;
if (dw < dh) {
orientation = Configuration.ORIENTATION_PORTRAIT;
@@ -6328,12 +6326,46 @@ public class WindowManagerService extends IWindowManager.Stub
config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale);
config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dm, dw, dh);
+ // Update the configuration based on available input devices, lid switch,
+ // and platform configuration.
+ config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH;
+ config.keyboard = Configuration.KEYBOARD_NOKEYS;
+ config.navigation = Configuration.NAVIGATION_NONAV;
+
+ int keyboardPresence = 0;
+ int navigationPresence = 0;
+ for (InputDevice device : mInputManager.getInputDevices()) {
+ if (!device.isVirtual()) {
+ final int sources = device.getSources();
+ final int presenceFlag = device.isExternal() ?
+ WindowManagerPolicy.PRESENCE_EXTERNAL :
+ WindowManagerPolicy.PRESENCE_INTERNAL;
+
+ if ((sources & InputDevice.SOURCE_TOUCHSCREEN) != 0) {
+ config.touchscreen = Configuration.TOUCHSCREEN_FINGER;
+ }
+
+ if ((sources & InputDevice.SOURCE_TRACKBALL) != 0) {
+ config.navigation = Configuration.NAVIGATION_TRACKBALL;
+ navigationPresence |= presenceFlag;
+ } else if ((sources & InputDevice.SOURCE_DPAD) != 0
+ && config.navigation == Configuration.NAVIGATION_NONAV) {
+ config.navigation = Configuration.NAVIGATION_DPAD;
+ navigationPresence |= presenceFlag;
+ }
+
+ if (device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) {
+ config.keyboard = Configuration.KEYBOARD_QWERTY;
+ keyboardPresence |= presenceFlag;
+ }
+ }
+ }
+
// Determine whether a hard keyboard is available and enabled.
boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS;
if (hardKeyboardAvailable != mHardKeyboardAvailable) {
mHardKeyboardAvailable = hardKeyboardAvailable;
mHardKeyboardEnabled = hardKeyboardAvailable;
-
mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
}
@@ -6341,13 +6373,11 @@ public class WindowManagerService extends IWindowManager.Stub
config.keyboard = Configuration.KEYBOARD_NOKEYS;
}
- // Update value of keyboardHidden, hardKeyboardHidden and navigationHidden
- // based on whether a hard or soft keyboard is present, whether navigation keys
- // are present and the lid switch state.
+ // Let the policy update hidden states.
config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO;
config.navigationHidden = Configuration.NAVIGATIONHIDDEN_NO;
- mPolicy.adjustConfigurationLw(config);
+ mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence);
}
return true;
diff --git a/services/jni/com_android_server_input_InputManagerService.cpp b/services/jni/com_android_server_input_InputManagerService.cpp
index b2a2429..b6378bf 100644
--- a/services/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/jni/com_android_server_input_InputManagerService.cpp
@@ -98,12 +98,6 @@ static struct {
jclass clazz;
} gMotionEventClassInfo;
-static struct {
- jfieldID touchscreen;
- jfieldID keyboard;
- jfieldID navigation;
-} gConfigurationClassInfo;
-
// --- Global functions ---
@@ -1228,18 +1222,6 @@ static void nativeSetSystemUiVisibility(JNIEnv* env,
im->setSystemUiVisibility(visibility);
}
-static void nativeGetInputConfiguration(JNIEnv* env,
- jclass clazz, jint ptr, jobject configObj) {
- NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
-
- InputConfiguration config;
- im->getInputManager()->getReader()->getInputConfiguration(& config);
-
- env->SetIntField(configObj, gConfigurationClassInfo.touchscreen, config.touchScreen);
- env->SetIntField(configObj, gConfigurationClassInfo.keyboard, config.keyboard);
- env->SetIntField(configObj, gConfigurationClassInfo.navigation, config.navigation);
-}
-
static jboolean nativeTransferTouchFocus(JNIEnv* env,
jclass clazz, jint ptr, jobject fromChannelObj, jobject toChannelObj) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1372,8 +1354,6 @@ static JNINativeMethod gInputManagerMethods[] = {
(void*) nativeSetInputDispatchMode },
{ "nativeSetSystemUiVisibility", "(II)V",
(void*) nativeSetSystemUiVisibility },
- { "nativeGetInputConfiguration", "(ILandroid/content/res/Configuration;)V",
- (void*) nativeGetInputConfiguration },
{ "nativeTransferTouchFocus", "(ILandroid/view/InputChannel;Landroid/view/InputChannel;)Z",
(void*) nativeTransferTouchFocus },
{ "nativeSetPointerSpeed", "(II)V",
@@ -1504,19 +1484,6 @@ int register_android_server_InputManager(JNIEnv* env) {
FIND_CLASS(gMotionEventClassInfo.clazz, "android/view/MotionEvent");
gMotionEventClassInfo.clazz = jclass(env->NewGlobalRef(gMotionEventClassInfo.clazz));
- // Configuration
-
- FIND_CLASS(clazz, "android/content/res/Configuration");
-
- GET_FIELD_ID(gConfigurationClassInfo.touchscreen, clazz,
- "touchscreen", "I");
-
- GET_FIELD_ID(gConfigurationClassInfo.keyboard, clazz,
- "keyboard", "I");
-
- GET_FIELD_ID(gConfigurationClassInfo.navigation, clazz,
- "navigation", "I");
-
return 0;
}