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 /services/input | |
parent | 32c8113510b2774f865e8ac763976b90d9db2706 (diff) | |
download | frameworks_base-daa3753a04699724d2cfe824ac1f5a266d643a05.zip frameworks_base-daa3753a04699724d2cfe824ac1f5a266d643a05.tar.gz frameworks_base-daa3753a04699724d2cfe824ac1f5a266d643a05.tar.bz2 |
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 'services/input')
-rw-r--r-- | services/input/InputReader.cpp | 42 | ||||
-rw-r--r-- | services/input/InputReader.h | 10 | ||||
-rw-r--r-- | services/input/tests/InputReader_test.cpp | 90 |
3 files changed, 1 insertions, 141 deletions
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)); |