summaryrefslogtreecommitdiff
path: root/libs/input/KeyCharacterMap.cpp
AgeCommit message (Collapse)Author
2024-12-18libinput: avoid null segmentation fault Steven Moreland
readCString may return nullptr, and it's deprecated and old anyway. Please also consider converting this code to use AIDL-defined parcelables. go/aidl-it! Bug: 301519740 Test: w/ fuzzer Change-Id: I76050c3b7fe40964fd751e678688d2e1d97b9479
2024-10-17Copy KeyCharacterMap object when we fill InputDeviceInfo(1/n) Linnan Li
Currently, in InputDeviceInfo, we store the KeyCharacterMap object, which is actually the original KeyCharacterMap from the EventHub. This could potentially lead to issues where two threads operate on the same KeyCharacterMap object simultaneously, resulting in thread safety problems. To avoid potential risks in the future, we make a copy of the original KeyCharacterMap when generating InputDeviceInfo. This change should not introduce any behavioral changes. Bug: 373011069 Flag: EXEMPT refactor Test: presubmit Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com> (cherry picked from https://partner-android-review.googlesource.com/q/commit:1be9c1ce7400e38cf3f45921d7181e947929f91c) Merged-In: I0d0155133f95b0f1dc925422eda0da04c6f196ea Change-Id: I0d0155133f95b0f1dc925422eda0da04c6f196ea
2024-10-07hasKeycode API should take into account key remapping Vaibhav Devmurari
Keyboards can generate certain keycodes even if the keys are not present in the device HID descriptor, by using key remapping APIs Test: atest ModifierKeyRemappingTest Bug: 368397939 Flag: EXEMPT bugfix Change-Id: I30afda89f289eddc2b05fb124555aebfb182852e
2024-09-20Move key remapping to InputReader thread(1/n) Linnan Li
Currently, the key remapping operation occurs on a non-Reader thread, which leads to concurrent operations on the KCM object by this thread and the Reader, causing unpredictable concurrency issues. Here, we move this operation to the Reader thread, aligning it with most configuration refresh methods, which can resolve the aforementioned issues. Additionally, we are removing the device traversal method on the Java side because we actually intend for the key remapping operation to apply to all full-keyboard devices. This can be fully achieved during the InputReader refresh, so we are also removing the deviceId parameter from the remapping interface. There should be no behavioral changes. Bug: 358042225 Test: atest CtsInputTestCases Test: atest InputTests Test: atest inputflinger_tests Flag: EXEMPT refactor Change-Id: I6ab802b70dc1242c796f672ac30672d10e34857f Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
2024-05-14Move ADISPLAY_ID_ definitions into LogicalDisplayId Siarhei Vishniakou
These will eventually replace the existing definitions as follows: ADISPLAY_ID_NONE -->> LogicalDisplayId::INVALID ADISPLAY_ID_DEFAULT -->> LogicalDisplayId::DEFAULT We are keeping the old definitions for now, to reduce the merge conflicts. These will be removed in subsequent CLs, after the frameworks/base and other repository patches go in. The constant "NONE" was renamed to "INVALID" to make it consistent with the Java definitions. Bug: 339106983 Test: m checkinput Change-Id: I0274be345159c85cb51fcea743d8acd3d298cd07
2024-05-10Remove __linux__ ifdefs where not needed Siarhei Vishniakou
The downstream branches now know about Parcel and binder, so in some places, these #ifdef statements are not needed. This CL should help reduce the divergence with downstream efforts. See the merge conflict resolution CL as an example: https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/native/+/27201796/-2..3 Bug: 309829647 Test: presubmit Change-Id: Iec17cface5069ca79a565c205546db8ada8a07ee
2024-05-09Use a strongly typed LogicalDisplayId for displayId(2/n) Linnan Li
Currently, we use int32_t for displayId, which is not a safe type, and it may also lead to misdefinition of types. Here, we introduce LogicalDisplayId as a strong type for displayId and move all contents of constants.h into LogicalDisplayId.h. Bug: 339106983 Test: atest inputflinger_tests Test: atest InputTests Test: m checkinput Test: m libsurfaceflinger_unittest Test: presubmit Change-Id: If44e56f69553d095af5adb59b595e4a852ab32ce Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
2023-10-24Return unique_ptr from readFromParcel Siarhei Vishniakou
When KeyCharacterMap is read from parcel, there's no need to force the caller to store the object in a shared pointer. We can return a unique_ptr first, and let the caller decide on how exactly that lifetime should be managed. Bug: 274058082 Test: presubmit Change-Id: I8c5ec1e32a9304f6ad186bc0279f4c7bcbab77d8
2023-08-24Migrate from android::String isEmpty to empty Tomasz Wasilczyk
This empty method is different from the old one - it aligns with std::string definition. Bug: 295394788 Test: make checkbuild Change-Id: Id74502de0e51182aa9629db8dc70739be4483d12
2023-08-16Use String8/16 c_str [input] Tomasz Wasilczyk
Bug: 295394788 Test: make checkbuild Change-Id: Iffbcff6f58e30c0bd40e699ba6e1f917addc5ade
2023-04-24Use std::unordered_map in KeyCharacterMap Siarhei Vishniakou
Previously, KeyedVector was used in KeyCharacterMap. Convert this to the std::unordered_map. Bug: 278299254 Test: m checkinput Test: m libinput_tests && $ANDROID_HOST_OUT/nativetest64/libinput_tests/libinput_tests Change-Id: I643aa8cc8ae0c68ade4d11d02e34be64faf7f157
2023-04-18Convert Vector usage to std::vector Siarhei Vishniakou
Prefer std::vector implementation over the custom Vector data type. Bug: 278299254 Test: atest android.view.cts.KeyCharacterMapTest Change-Id: If5b4e270a5c89c56619ae0c576495024438bd651
2023-04-17Return Key* from getKey Siarhei Vishniakou
The call getKey can fail. Rather than returning a separate bool that the caller might ignore, return a pointer to simplify the code. Bug: 278299254 Test: m libinput_tests && $ANDROID_HOST_OUT/nativetest64/libinput_tests/libinput_tests Change-Id: I28c25bee8890bdc90ca7e069c803423a7420e6b4
2023-04-17Pass reference to finishKey Siarhei Vishniakou
Since the parameter is assumed to be non-null, pass it by reference. Bug: 274058082 Test: m libinput_tests && $ANDROID_HOST_OUT/nativetest64/libinput_tests/libinput_tests Change-Id: Iedf8970a57e4463e6addc8ee1013feb3ee60c009
2023-01-24Validate axes and led labels correctly Siarhei Vishniakou
Before this CL, a number of checks for kl file validity were incorrect. Some of the APIs were supposed to return an invalid value, but instead were always returning a valid value, no matter what the input was. Correct these values by switching to std::optional. Bug: 266400536 Test: m libinput_tests && adb sync data && adb shell -t /data/nativetest64/libinput_tests/libinput_tests Change-Id: I4ef45f3249dca4f4f033fb85e9fecbc2ad1f1395
2023-01-12Clear applied layout overlay if new layout overlay is null. Vaibhav Devmurari
Need to allow resetting of key character map by setting overlay map to null. This is required when moving from a IME setting that has a KCM to another IME setting that has none. Test: atest KeyboardLayoutChangeTest Bug: 20805588 Change-Id: I62dc65970b61628486aff698a8ab8ccb31c109d6
2022-12-06Add API to support key remappings on native side Vaibhav Devmurari
For adding support for modifier key remapping, we need to add native support save key remappings and send appropriate android key codes using KeyCharacterMap. Test: atest KeyboardLayoutChangeTest Bug: 252812993 Change-Id: Ib3efa866c6e6408dd11e97dfaf49feb92f48bc18
2022-08-08Use std::list to store Behavior objects Siarhei Vishniakou
There's a bug about behavior being null. It's not clear how it gets there, but before this CL, there was a custom implementation of linked list to store the behaviours. Instead of implementing a custom linked list, let's switch over to std::list to remove the possibility of this bug. Bug: 238626341 Test: atest libinput_tests inputflinger_tests KeyCharacterMapTest Change-Id: I98e20de7d40b74e4af085cdafb68f867e6ebfe19
2022-08-05Return pointer from getKeyBehavior Siarhei Vishniakou
This function returns bool and outPointer, which is redundant. Return pointer directly. Bug: 238626341 Test: atest libinput_tests inputflinger_tests Change-Id: I7b945cd3a485afbb3f0ef0aef489e87e8358f4a7
2022-08-05Remove unused variable outKey Siarhei Vishniakou
This output variable is never used, delete it. Bug: 238626341 Test: atest libinput_tests inputflinger_tests Change-Id: Ide7d91f83ae88b2273519eabe1e8cb58ce89a9e5
2021-12-31Fix KeyCharacterMap overlays by reloading base overlay before applying ↵ Philip Junker
another overlay. Add all fields to parcel (mLoadFileName, mLayoutOverlayApplied, mKeysByScanCode, mKeysByUsageCode). Add all fields to equality operator. Add tests to libinput_tests. Bug: 210090260 Test: Manually verified that layout changes correctly. Test: atest libinput_tests Change-Id: I1777b87e5c2ce8a0dbd42ad48748ea9e669c9139
2021-06-28Renamed and moved InputWindow and related files chaviw
In preparation for the hierarchy listener interface, moved the InputWindow structs into libgui and have libinput dependant on libgui. Also renamed InputWindow to exclude Input since it will be used for more generic purposes. Test: Builds and flashes Bug: 188792659 Change-Id: I24262cbc14d409c00273de0024a672394a959e5f
2020-12-21Add explicit Result::ok() checks where needed Bernie Innocenti
Test: m checkbuild continuous_instrumentation_tests continuous_instrumentation_tests_api_coverage continuous_native_tests device-tests platform_tests Exempt-From-Owner-Approval: mechanical mass refactoring Change-Id: I698a6843686810527d753d075f543f1d6e1eb1f4
2020-12-16Add SensorManager support in inputflinger. Chris Ye
Add sensor device, sensor input mapper, sens event dispatcher support into inputflinger. Bug: 161634265 Test: atest inputflinger_tests Change-Id: I2dcb2c35d9dccefc4cd8d939b79cf340931a9410
2020-11-05Merge "Fix libinput mac build, hopefully." TreeHugger Robot
2020-11-04Fix libinput mac build, hopefully. Brett Chabot
Restore the ifdefs removed in go/ag/12549959, but using ifdef __linux__ instead of __ANDROID__. Test: m libinput Bug: 172023026 Change-Id: Iafbf592e7b937b780e5ffc2df490a6c17f5f6cf5
2020-11-04Move KeyCharacterMap to enum class Michael Wright
Bug: 160010896 Test: compiles Change-Id: Ia8c0d976665acf817f083726dcac10db0cd91048
2020-10-28Build all of libinput for linux host. Brett Chabot
Including enabling parcel-related code in source already building for host. Test: m libandroid_runtime Change-Id: Ia569e5158ba6ead28486069036f6a3595662bbf8
2020-09-02Merge "Created libattestation" Chavi Weingarten
2020-08-28Move KeyCharacterMap from RefBase to shared_ptr. Chris Ye
Move KeyCharacterMap from RefBase and make it shared_ptr in EventHub device when loaded from file. A shared_ptr of KeyCharacterMap is returned by EventHub getKeyCharacterMap to be shared in InputdeviceInfo. Remove extra KeyCharacterMap in EventHub to save memory sapce. Bug: 160010896 Test: atest inputflinger, atest libinput_tests Change-Id: Ibb317ea0684e6af6e7a6d808f816fc4a05c7b421
2020-08-27Created libattestation chaviw
Move attestation logic from input into separate library. This way Input and SurfaceFlinger can leverage the same logic Test: inputflinger_test Test: attestation_tests Bug: 155825630 Change-Id: Ia4f65166da8a1c53a9570db59eab602190438696
2020-08-21Optimize memory usage of InputEvent lookup. Chris Ye
Move the declaration of look up map to cpp file from header file to avoid duplicate copies. Bug: 165527068 Bug: 165398580 Bug: 165035349 Test: atest libinput_tests, atest inputflinger_tests adb shell showmap <system_server pid> | grep input Check libinput.so and libinput_reader.so size to be 300 and 372KB. Change-Id: Ia80200b7889f16ce576637d746e64641f3f2a094
2020-02-21Add ID to native events. Garfield Tan
To separate this big work into pieces I introduced a placeholder in InputTransport used to initialize native input events received from InputFlinger until InputFlinger can generate random sequence numbers. The work in InputDispatcher wires up ID between events and notify args as well. Bug: 144889238 Test: Builds and some smoke tests. Test: atest libinput_tests Change-Id: I1ef7f243cc89a8b6e07ba9ba30a43c21eedb16ce
2020-01-24Add hmac to InputEvent and scale to MotionEvent Siarhei Vishniakou
We need to pass some additional data to the app to be able to construct the MotionEvent. For proper support of getRawX/getRawY, add the xScale and yScale to MotionEvent. For the verification of input events, add hmac to InputEvent. Bug: 134977432 Bug: 140786233 Test: atest libinput_tests inputflinger_tests Change-Id: Ia3400ebbd9698549aad4d97a3b789ab7e10f6b65
2018-09-05Prefer std::string over String8 Siarhei Vishniakou
String8 is deprecated, so use proper C++ std::string instead. Change DisplayViewport.uniqueId to std::string. The current usage of String8 in DisplayViewport hinders refactoring of the code to use viewport types inside the viewports themselves. Most of the dependency on String8 is now removed. Once the xml for properties patch is added, almost all String8 should be gone from the input system. Test: atest libinput_tests inputflinger_tests Bug: 111108021 Change-Id: I580dc27b0449e664a7c9db2cdec1a0c18bf71a09
2018-07-17[input] Modernize codebase by replacing NULL with nullptr Yi Kong
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I8882234efd2a0b3ef27472d3f5d4e9c69c6e7b37
2018-07-03Move displayid into InputEvent Siarhei Vishniakou
There are certain use cases where key events should be associated with a particular display. Refactor KeyEvent and MotionEvent to have an associated display id. Remove "hasAssociatedDisplay" variable from KeyboardInputMapper, it just used to mirror "isOrientationAware". If the keyboard is orientation aware (= it is physically attached to a display, and therefore rotates together with that display), then associate that keyboard with the internal viewport. Otherwise, the key events are not associated with any particular display. Remaining to do: - make mInternalDisplay, mExternalDisplay, mVirtualDisplays into a single vector with type (internal, external, virtual) - have getDisplayViewport return std::optional (will require deep changes) Bug: 64258305 Test: atest inputflinger_tests libinput_tests Change-Id: I4fe145e74cb59310efaa55bfc9dc3c2b3bd997e3
2018-02-21Move SPECIAL_FUNCTION from .kcm to .idc files Siarhei Vishniakou
Currently, the only use of device-specific .kcm files is to specify SPECIAL_FUNCTION flag (meaning that this keyboard is only used to perform system control functions and not for typing). Instead of adding a special .kcm file, use .idc files with se keyboard.specialFunction = 1 to achieve the same functionality. This allows the removal of all device-specific .kcm files. The .kcm functionality will remain in P (with a warning). The functionality will be removed in Q. Bug: 67718661 Test: tested the codepath on Android wear device via logging Change-Id: I1b4572456fa42caae1282dd8d3557820671b3610
2016-02-19Revert "Revert "Fix warnings in servicemanager and KeyCharacterMap"" Ian Pedowitz
This reverts commit b480269b0f8e933fa6fc6bd4c9e1e504e1b51508. Change-Id: If405c0786c5bdd02e3f2c3356d56a4200c6b9dfb
2016-02-19Revert "Fix warnings in servicemanager and KeyCharacterMap" Ian Pedowitz
This reverts commit d3b4c050f6bcdfd44bfb9c8ed885fd1c482c50bb. Change-Id: I961f89d4446ac23f0e267c6541b504c4ec6b3af1
2016-02-18Fix warnings in servicemanager and KeyCharacterMap Aurimas Liutikas
- Suppress unused parameter warnings. - Remove a few unused parameters. - Set the correct formatting for size_t log. Bug: 26936282 Change-Id: I2e2acb15d1bc05c6ba09563a87d5baceebe7ebd9
2015-10-22Limit the number of keys read by KeyCharacterMaps. Michael Wright
Apps can send us a KCM containing a ridiculous key count, which will cause us to crash when an allocation fails. Limit the key count so this doesn't happen. Bug: 24876135 Change-Id: I2bb4a5acabfc9184a867a406eef756c28c28f0ad
2015-10-08resolved conflicts for b9163905 to mnc-dr-dev-plus-aosp Dmitry Torokhov
Change-Id: I83afd79491533b1c7ae2aed50a927db175ba555f
2015-09-29Allow defining replacement key events in keymap Dmitry Torokhov
Currently keyboard maps allow to assign character sequences to key events and allow specifying a so-called "fallback" key events that are re-injected into input stream if target application indicates that it was not able to handle the original key event. Unfortunately there is no way to perform substitution before handing the event to applicationis. This change adds a new keymap keyword "replace" that allows users query "replacement" actions for key (if any), with the intent that such replacement happens early in the event handling process. Bug: 24504154 Change-Id: I3e6a2476c856524171df00ad22ff56f2018c1278
2015-08-12Lose HAVE_ANDROID_OS from frameworks/native. Elliott Hughes
Change-Id: I8e6af2a46a9d875192fc7957ada9b5f66d84bad6
2014-04-22Move key attribute information out of native. Michael Wright
Native doesn't ever actually care about the attributes of keys, so move all of it up into the managed layer and move all of the key names down so they're defined once. Change-Id: Ic8ded13ce050b2b98744735ff50d11e8d882d7d5
2013-07-01Move input library code from frameworks/base. Jeff Brown
Change-Id: I4983db61b53e28479fc90d9211fafff68f7f49a6