Add SensorManager support in inputflinger.
Add sensor device, sensor input mapper, sens event dispatcher support
into inputflinger.
Bug: 161634265
Test: atest inputflinger_tests
Change-Id: I2dcb2c35d9dccefc4cd8d939b79cf340931a9410
diff --git a/libs/input/tests/InputDevice_test.cpp b/libs/input/tests/InputDevice_test.cpp
index c174ae9..e2cf245 100644
--- a/libs/input/tests/InputDevice_test.cpp
+++ b/libs/input/tests/InputDevice_test.cpp
@@ -14,9 +14,12 @@
* limitations under the License.
*/
-
+#include <binder/Binder.h>
+#include <binder/Parcel.h>
#include <gtest/gtest.h>
#include <input/InputDevice.h>
+#include <input/KeyLayoutMap.h>
+#include <input/Keyboard.h>
namespace android {
@@ -31,4 +34,52 @@
ASSERT_EQ(std::string("deviceName-123_version_C_"), identifier.getCanonicalName());
}
+class InputDeviceKeyMapTest : public testing::Test {
+protected:
+ void loadKeyLayout(const char* name) {
+ std::string path =
+ getInputDeviceConfigurationFilePathByName(name,
+ InputDeviceConfigurationFileType::
+ KEY_LAYOUT);
+ ASSERT_FALSE(path.empty());
+ base::Result<std::shared_ptr<KeyLayoutMap>> ret = KeyLayoutMap::load(path);
+ ASSERT_TRUE(ret) << "Cannot load KeyLayout at " << path;
+ mKeyMap.keyLayoutMap = std::move(*ret);
+ mKeyMap.keyLayoutFile = path;
+ }
+
+ void loadKeyCharacterMap(const char* name) {
+ InputDeviceIdentifier identifier;
+ identifier.name = name;
+ std::string path =
+ getInputDeviceConfigurationFilePathByName(identifier.getCanonicalName(),
+ InputDeviceConfigurationFileType::
+ KEY_CHARACTER_MAP);
+ ASSERT_FALSE(path.empty()) << "KeyCharacterMap for " << name << " not found";
+ base::Result<std::shared_ptr<KeyCharacterMap>> ret =
+ KeyCharacterMap::load(path, KeyCharacterMap::Format::BASE);
+ ASSERT_TRUE(ret) << "Cannot load KeyCharacterMap at " << path;
+ mKeyMap.keyCharacterMap = *ret;
+ mKeyMap.keyCharacterMapFile = path;
+ }
+
+ virtual void SetUp() override {
+ loadKeyLayout("Generic");
+ loadKeyCharacterMap("Generic");
+ }
+
+ virtual void TearDown() override {}
+
+ KeyMap mKeyMap;
+};
+
+TEST_F(InputDeviceKeyMapTest, keyCharacterMapParcelingTest) {
+ Parcel parcel;
+ mKeyMap.keyCharacterMap->writeToParcel(&parcel);
+ parcel.setDataPosition(0);
+ std::shared_ptr<KeyCharacterMap> map = KeyCharacterMap::readFromParcel(&parcel);
+ // Verify the key character map is the same as original
+ ASSERT_EQ(*map, *mKeyMap.keyCharacterMap);
+}
+
} // namespace android
\ No newline at end of file