summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Prabir Pradhan <prabirmsp@google.com> 2023-08-14 20:27:29 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-08-14 20:27:29 +0000
commit69dbffb14b64d27ac91edb6cbed06e768e3885ec (patch)
treed7632814f9b776b61f58be20a69ee54ff49f6370
parent659ff001b877a792472170c0a8ca469b83a6c60b (diff)
parentebd5ab192a9d14ab7dddb9ae7249c58818c180f8 (diff)
Merge "InputVerifier: Accept invalid utf-8 strings silently" into udc-qpr-dev am: b381a8bad3 am: ebd5ab192a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/24406329 Change-Id: Ieda961e446aacec819929b738d1790b9faf237de Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libs/input/InputVerifier.cpp2
-rw-r--r--libs/input/tests/Android.bp1
-rw-r--r--libs/input/tests/InputVerifier_test.cpp29
3 files changed, 31 insertions, 1 deletions
diff --git a/libs/input/InputVerifier.cpp b/libs/input/InputVerifier.cpp
index 341eb6f920..6c602e031d 100644
--- a/libs/input/InputVerifier.cpp
+++ b/libs/input/InputVerifier.cpp
@@ -31,7 +31,7 @@ namespace android {
// --- InputVerifier ---
InputVerifier::InputVerifier(const std::string& name)
- : mVerifier(android::input::verifier::create(name)){};
+ : mVerifier(android::input::verifier::create(rust::String::lossy(name))){};
Result<void> InputVerifier::processMovement(DeviceId deviceId, int32_t action,
uint32_t pointerCount,
diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp
index cadac88030..86b996b3b6 100644
--- a/libs/input/tests/Android.bp
+++ b/libs/input/tests/Android.bp
@@ -18,6 +18,7 @@ cc_test {
"InputDevice_test.cpp",
"InputEvent_test.cpp",
"InputPublisherAndConsumer_test.cpp",
+ "InputVerifier_test.cpp",
"MotionPredictor_test.cpp",
"RingBuffer_test.cpp",
"TfLiteMotionPredictor_test.cpp",
diff --git a/libs/input/tests/InputVerifier_test.cpp b/libs/input/tests/InputVerifier_test.cpp
new file mode 100644
index 0000000000..e24fa6ed0b
--- /dev/null
+++ b/libs/input/tests/InputVerifier_test.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2023 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.
+ */
+
+#include <gtest/gtest.h>
+#include <input/InputVerifier.h>
+#include <string>
+
+namespace android {
+
+TEST(InputVerifierTest, CreationWithInvalidUtfStringDoesNotCrash) {
+ constexpr char bytes[] = {static_cast<char>(0xC0), static_cast<char>(0x80)};
+ const std::string name(bytes, sizeof(bytes));
+ InputVerifier verifier(name);
+}
+
+} // namespace android