diff options
author | Siarhei Vishniakou <svv@google.com> | 2022-03-04 15:12:16 -0800 |
---|---|---|
committer | Siarhei Vishniakou <svv@google.com> | 2022-03-30 22:01:41 +0000 |
commit | 814ace3f256109b59ee9dc1d881887c4cb8b17ae (patch) | |
tree | 7f9d95a973aced16b8c6069338572328e59132f5 /include/input | |
parent | e844e01f78f98d54676d07f3a44f46ae410b9b7b (diff) | |
download | native-814ace3f256109b59ee9dc1d881887c4cb8b17ae.tar.gz |
Add PreferStylusOverTouchBlocker and handle multiple devices
We removed PreferStylusOverTouchBlocker previously in order to avoid a
crash. In this CL, we are adding it back in, and handling the case of
input device having "SOURCE_STYLUS", but reporting "finger" tool type.
If there's a stylus event with one of the pointers labeled as 'finger',
let's assume that the device supports simultaneous touch and stylus. For
this situation, simply disable PreferStylusOverTouchBlocker going
forward for these devices, and pass through any events coming from there.
Currently, this happens on emulator. In their touch driver, they
configure stylus properties as well as touch properties, but most of the
events that they send are TOOL_TYPE_FINGER. Previously, this triggered a
crash in PreferStylusOverTouchBlocker.
Bug: 222531989
Test: atest inputflinger_tests
Change-Id: Ifbb08858a4dfebc95c30ca19d6e68533855db7e4
(cherry picked from commit a6a660fc0aa74ea4f5930b74523cf1893b2f9282)
Diffstat (limited to 'include/input')
-rw-r--r-- | include/input/PrintTools.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/input/PrintTools.h b/include/input/PrintTools.h new file mode 100644 index 0000000000..7c3b29b55f --- /dev/null +++ b/include/input/PrintTools.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include <map> +#include <set> +#include <string> + +namespace android { + +template <typename T> +std::string constToString(const T& v) { + return std::to_string(v); +} + +/** + * Convert a set of integral types to string. + */ +template <typename T> +std::string dumpSet(const std::set<T>& v, std::string (*toString)(const T&) = constToString) { + std::string out; + for (const T& entry : v) { + out += out.empty() ? "{" : ", "; + out += toString(entry); + } + return out.empty() ? "{}" : (out + "}"); +} + +/** + * Convert a map to string. Both keys and values of the map should be integral type. + */ +template <typename K, typename V> +std::string dumpMap(const std::map<K, V>& map, std::string (*keyToString)(const K&) = constToString, + std::string (*valueToString)(const V&) = constToString) { + std::string out; + for (const auto& [k, v] : map) { + if (!out.empty()) { + out += "\n"; + } + out += keyToString(k) + ":" + valueToString(v); + } + return out; +} + +const char* toString(bool value); + +} // namespace android
\ No newline at end of file |