Merge "SF: do not wait for LastCompositeEventThread if it is not used" into main
diff --git a/include/ftl/details/hash.h b/include/ftl/details/hash.h
new file mode 100644
index 0000000..f9a7fa8
--- /dev/null
+++ b/include/ftl/details/hash.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2024 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 <cinttypes>
+#include <cstring>
+
+namespace android::ftl::details {
+
+// Based on CityHash64 v1.0.1 (http://code.google.com/p/cityhash/), but slightly
+// modernized and trimmed for cases with bounded lengths.
+
+template <typename T = std::uint64_t>
+inline T read_unaligned(const void* ptr) {
+ T v;
+ std::memcpy(&v, ptr, sizeof(T));
+ return v;
+}
+
+template <bool NonZeroShift = false>
+constexpr std::uint64_t rotate(std::uint64_t v, std::uint8_t shift) {
+ if constexpr (!NonZeroShift) {
+ if (shift == 0) return v;
+ }
+ return (v >> shift) | (v << (64 - shift));
+}
+
+constexpr std::uint64_t shift_mix(std::uint64_t v) {
+ return v ^ (v >> 47);
+}
+
+constexpr std::uint64_t hash_length_16(std::uint64_t u, std::uint64_t v) {
+ constexpr std::uint64_t kPrime = 0x9ddfea08eb382d69ull;
+ auto a = (u ^ v) * kPrime;
+ a ^= (a >> 47);
+ auto b = (v ^ a) * kPrime;
+ b ^= (b >> 47);
+ b *= kPrime;
+ return b;
+}
+
+constexpr std::uint64_t kPrime0 = 0xc3a5c85c97cb3127ull;
+constexpr std::uint64_t kPrime1 = 0xb492b66fbe98f273ull;
+constexpr std::uint64_t kPrime2 = 0x9ae16a3b2f90404full;
+constexpr std::uint64_t kPrime3 = 0xc949d7c7509e6557ull;
+
+inline std::uint64_t hash_length_0_to_16(const char* str, std::uint64_t length) {
+ if (length > 8) {
+ const auto a = read_unaligned(str);
+ const auto b = read_unaligned(str + length - 8);
+ return hash_length_16(a, rotate<true>(b + length, static_cast<std::uint8_t>(length))) ^ b;
+ }
+ if (length >= 4) {
+ const auto a = read_unaligned<std::uint32_t>(str);
+ const auto b = read_unaligned<std::uint32_t>(str + length - 4);
+ return hash_length_16(length + (a << 3), b);
+ }
+ if (length > 0) {
+ const auto a = static_cast<unsigned char>(str[0]);
+ const auto b = static_cast<unsigned char>(str[length >> 1]);
+ const auto c = static_cast<unsigned char>(str[length - 1]);
+ const auto y = static_cast<std::uint32_t>(a) + (static_cast<std::uint32_t>(b) << 8);
+ const auto z = static_cast<std::uint32_t>(length) + (static_cast<std::uint32_t>(c) << 2);
+ return shift_mix(y * kPrime2 ^ z * kPrime3) * kPrime2;
+ }
+ return kPrime2;
+}
+
+inline std::uint64_t hash_length_17_to_32(const char* str, std::uint64_t length) {
+ const auto a = read_unaligned(str) * kPrime1;
+ const auto b = read_unaligned(str + 8);
+ const auto c = read_unaligned(str + length - 8) * kPrime2;
+ const auto d = read_unaligned(str + length - 16) * kPrime0;
+ return hash_length_16(rotate(a - b, 43) + rotate(c, 30) + d,
+ a + rotate(b ^ kPrime3, 20) - c + length);
+}
+
+inline std::uint64_t hash_length_33_to_64(const char* str, std::uint64_t length) {
+ auto z = read_unaligned(str + 24);
+ auto a = read_unaligned(str) + (length + read_unaligned(str + length - 16)) * kPrime0;
+ auto b = rotate(a + z, 52);
+ auto c = rotate(a, 37);
+
+ a += read_unaligned(str + 8);
+ c += rotate(a, 7);
+ a += read_unaligned(str + 16);
+
+ const auto vf = a + z;
+ const auto vs = b + rotate(a, 31) + c;
+
+ a = read_unaligned(str + 16) + read_unaligned(str + length - 32);
+ z += read_unaligned(str + length - 8);
+ b = rotate(a + z, 52);
+ c = rotate(a, 37);
+ a += read_unaligned(str + length - 24);
+ c += rotate(a, 7);
+ a += read_unaligned(str + length - 16);
+
+ const auto wf = a + z;
+ const auto ws = b + rotate(a, 31) + c;
+ const auto r = shift_mix((vf + ws) * kPrime2 + (wf + vs) * kPrime0);
+ return shift_mix(r * kPrime0 + vs) * kPrime2;
+}
+
+} // namespace android::ftl::details
diff --git a/include/ftl/hash.h b/include/ftl/hash.h
new file mode 100644
index 0000000..29a6f71
--- /dev/null
+++ b/include/ftl/hash.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2024 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 <cinttypes>
+#include <optional>
+#include <string_view>
+
+#include <ftl/details/hash.h>
+
+namespace android::ftl {
+
+// Non-cryptographic hash function (namely CityHash64) for strings with at most 64 characters.
+// Unlike std::hash, which returns std::size_t and is only required to produce the same result
+// for the same input within a single execution of a program, this hash is stable.
+inline std::optional<std::uint64_t> stable_hash(std::string_view view) {
+ const auto length = view.length();
+ if (length <= 16) {
+ return details::hash_length_0_to_16(view.data(), length);
+ }
+ if (length <= 32) {
+ return details::hash_length_17_to_32(view.data(), length);
+ }
+ if (length <= 64) {
+ return details::hash_length_33_to_64(view.data(), length);
+ }
+ return {};
+}
+
+} // namespace android::ftl
diff --git a/libs/ftl/Android.bp b/libs/ftl/Android.bp
index 32b2b68..4b41152 100644
--- a/libs/ftl/Android.bp
+++ b/libs/ftl/Android.bp
@@ -24,6 +24,7 @@
"flags_test.cpp",
"function_test.cpp",
"future_test.cpp",
+ "hash_test.cpp",
"match_test.cpp",
"mixins_test.cpp",
"non_null_test.cpp",
diff --git a/libs/ftl/hash_test.cpp b/libs/ftl/hash_test.cpp
new file mode 100644
index 0000000..9c7b8c2
--- /dev/null
+++ b/libs/ftl/hash_test.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2024 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 <ftl/hash.h>
+#include <gtest/gtest.h>
+
+#include <numeric>
+#include <string>
+
+namespace android::test {
+
+TEST(Hash, StableHash) {
+ EXPECT_EQ(11160318154034397263ull, (ftl::stable_hash({})));
+
+ std::string string(64, '?');
+ std::iota(string.begin(), string.end(), 'A');
+
+ // Maximum length is 64 characters.
+ EXPECT_FALSE(ftl::stable_hash(string + '\n'));
+
+ EXPECT_EQ(6278090252846864564ull, ftl::stable_hash(std::string_view(string).substr(0, 8)));
+ EXPECT_EQ(1883356980931444616ull, ftl::stable_hash(std::string_view(string).substr(0, 16)));
+ EXPECT_EQ(8073093283835059304ull, ftl::stable_hash(std::string_view(string).substr(0, 32)));
+ EXPECT_EQ(18197365392429149980ull, ftl::stable_hash(string));
+}
+
+} // namespace android::test
diff --git a/libs/graphicsenv/GpuStatsInfo.cpp b/libs/graphicsenv/GpuStatsInfo.cpp
index 7b74214..33cebe3 100644
--- a/libs/graphicsenv/GpuStatsInfo.cpp
+++ b/libs/graphicsenv/GpuStatsInfo.cpp
@@ -96,6 +96,7 @@
if ((status = parcel->writeUint64(vulkanDeviceFeaturesEnabled)) != OK) return status;
if ((status = parcel->writeInt32Vector(vulkanInstanceExtensions)) != OK) return status;
if ((status = parcel->writeInt32Vector(vulkanDeviceExtensions)) != OK) return status;
+ if ((status = parcel->writeUtf8VectorAsUtf16Vector(vulkanEngineNames)) != OK) return status;
return OK;
}
@@ -118,6 +119,7 @@
if ((status = parcel->readUint64(&vulkanDeviceFeaturesEnabled)) != OK) return status;
if ((status = parcel->readInt32Vector(&vulkanInstanceExtensions)) != OK) return status;
if ((status = parcel->readInt32Vector(&vulkanDeviceExtensions)) != OK) return status;
+ if ((status = parcel->readUtf8VectorFromUtf16Vector(&vulkanEngineNames)) != OK) return status;
return OK;
}
@@ -161,6 +163,11 @@
StringAppendF(&result, " 0x%x", extension);
}
result.append("\n");
+ result.append("vulkanEngineNames:");
+ for (const std::string& engineName : vulkanEngineNames) {
+ StringAppendF(&result, " %s,", engineName.c_str());
+ }
+ result.append("\n");
return result;
}
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index 50c05f4..52383ac 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -445,6 +445,21 @@
extensionHashes, numStats);
}
+void GraphicsEnv::addVulkanEngineName(const char* engineName) {
+ ATRACE_CALL();
+ if (engineName == nullptr) {
+ return;
+ }
+ std::lock_guard<std::mutex> lock(mStatsLock);
+ if (!readyToSendGpuStatsLocked()) return;
+
+ const sp<IGpuService> gpuService = getGpuService();
+ if (gpuService) {
+ gpuService->addVulkanEngineName(mGpuStats.appPackageName, mGpuStats.driverVersionCode,
+ engineName);
+ }
+}
+
bool GraphicsEnv::readyToSendGpuStatsLocked() {
// Only send stats for processes having at least one activity launched and that process doesn't
// skip the GraphicsEnvironment setup.
diff --git a/libs/graphicsenv/IGpuService.cpp b/libs/graphicsenv/IGpuService.cpp
index 5dc195c..42e7c37 100644
--- a/libs/graphicsenv/IGpuService.cpp
+++ b/libs/graphicsenv/IGpuService.cpp
@@ -77,6 +77,19 @@
IBinder::FLAG_ONEWAY);
}
+ void addVulkanEngineName(const std::string& appPackageName, const uint64_t driverVersionCode,
+ const char* engineName) override {
+ Parcel data, reply;
+ data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());
+
+ data.writeUtf8AsUtf16(appPackageName);
+ data.writeUint64(driverVersionCode);
+ data.writeCString(engineName);
+
+ remote()->transact(BnGpuService::ADD_VULKAN_ENGINE_NAME, data, &reply,
+ IBinder::FLAG_ONEWAY);
+ }
+
void setUpdatableDriverPath(const std::string& driverPath) override {
Parcel data, reply;
data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());
@@ -197,6 +210,21 @@
return OK;
}
+ case ADD_VULKAN_ENGINE_NAME: {
+ CHECK_INTERFACE(IGpuService, data, reply);
+
+ std::string appPackageName;
+ if ((status = data.readUtf8FromUtf16(&appPackageName)) != OK) return status;
+
+ uint64_t driverVersionCode;
+ if ((status = data.readUint64(&driverVersionCode)) != OK) return status;
+
+ const char* engineName;
+ if ((engineName = data.readCString()) == nullptr) return BAD_VALUE;
+
+ addVulkanEngineName(appPackageName, driverVersionCode, engineName);
+ return OK;
+ }
case SET_UPDATABLE_DRIVER_PATH: {
CHECK_INTERFACE(IGpuService, data, reply);
diff --git a/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h b/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h
index 9ebaf16..23f583b 100644
--- a/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h
+++ b/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h
@@ -60,6 +60,10 @@
public:
// This limits the worst case number of extensions to be tracked.
static const uint32_t MAX_NUM_EXTENSIONS = 100;
+ // Max number of vulkan engine names for a single GpuStatsAppInfo
+ static const uint32_t MAX_VULKAN_ENGINE_NAMES = 16;
+ // Max length of a vulkan engine name string
+ static const size_t MAX_VULKAN_ENGINE_NAME_LENGTH = 50;
GpuStatsAppInfo() = default;
GpuStatsAppInfo(const GpuStatsAppInfo&) = default;
@@ -84,6 +88,7 @@
uint64_t vulkanDeviceFeaturesEnabled = 0;
std::vector<int32_t> vulkanInstanceExtensions = {};
std::vector<int32_t> vulkanDeviceExtensions = {};
+ std::vector<std::string> vulkanEngineNames = {};
std::chrono::time_point<std::chrono::system_clock> lastAccessTime;
};
diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
index 6cce3f6..b0ab0b9 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -89,6 +89,8 @@
// Set which device extensions are enabled for the app.
void setVulkanDeviceExtensions(uint32_t enabledExtensionCount,
const char* const* ppEnabledExtensionNames);
+ // Add the engine name passed in VkApplicationInfo during CreateInstance
+ void addVulkanEngineName(const char* engineName);
/*
* Api for Vk/GL layer injection. Presently, drivers enable certain
diff --git a/libs/graphicsenv/include/graphicsenv/IGpuService.h b/libs/graphicsenv/include/graphicsenv/IGpuService.h
index 45f05d6..a0d6e37 100644
--- a/libs/graphicsenv/include/graphicsenv/IGpuService.h
+++ b/libs/graphicsenv/include/graphicsenv/IGpuService.h
@@ -46,6 +46,8 @@
const uint64_t driverVersionCode,
const GpuStatsInfo::Stats stats, const uint64_t* values,
const uint32_t valueCount) = 0;
+ virtual void addVulkanEngineName(const std::string& appPackageName,
+ const uint64_t driverVersionCode, const char* engineName) = 0;
// setter and getter for updatable driver path.
virtual void setUpdatableDriverPath(const std::string& driverPath) = 0;
@@ -64,6 +66,7 @@
GET_UPDATABLE_DRIVER_PATH,
TOGGLE_ANGLE_AS_SYSTEM_DRIVER,
SET_TARGET_STATS_ARRAY,
+ ADD_VULKAN_ENGINE_NAME,
// Always append new enum to the end.
};
diff --git a/libs/gui/include/gui/WindowInfo.h b/libs/gui/include/gui/WindowInfo.h
index e4f1890..b73e497 100644
--- a/libs/gui/include/gui/WindowInfo.h
+++ b/libs/gui/include/gui/WindowInfo.h
@@ -178,8 +178,8 @@
static_cast<uint32_t>(os::InputConfig::CLONE),
GLOBAL_STYLUS_BLOCKS_TOUCH =
static_cast<uint32_t>(os::InputConfig::GLOBAL_STYLUS_BLOCKS_TOUCH),
- SENSITIVE_FOR_TRACING =
- static_cast<uint32_t>(os::InputConfig::SENSITIVE_FOR_TRACING),
+ SENSITIVE_FOR_PRIVACY =
+ static_cast<uint32_t>(os::InputConfig::SENSITIVE_FOR_PRIVACY),
// clang-format on
};
diff --git a/libs/input/android/os/InputConfig.aidl b/libs/input/android/os/InputConfig.aidl
index 6b97cbb..da62e03 100644
--- a/libs/input/android/os/InputConfig.aidl
+++ b/libs/input/android/os/InputConfig.aidl
@@ -159,10 +159,12 @@
GLOBAL_STYLUS_BLOCKS_TOUCH = 1 << 17,
/**
- * InputConfig used to indicate that this window is sensitive for tracing.
+ * InputConfig used to indicate that this window is privacy sensitive. This may be used to
+ * redact input interactions from tracing or screen mirroring.
+ *
* This must be set on windows that use {@link WindowManager.LayoutParams#FLAG_SECURE},
* but it may also be set without setting FLAG_SECURE. The tracing configuration will
* determine how these sensitive events are eventually traced.
*/
- SENSITIVE_FOR_TRACING = 1 << 18,
+ SENSITIVE_FOR_PRIVACY = 1 << 18,
}
diff --git a/libs/ui/DisplayIdentification.cpp b/libs/ui/DisplayIdentification.cpp
index 82e5427..0908ae8 100644
--- a/libs/ui/DisplayIdentification.cpp
+++ b/libs/ui/DisplayIdentification.cpp
@@ -23,67 +23,13 @@
#include <optional>
#include <span>
+#include <ftl/hash.h>
#include <log/log.h>
-
#include <ui/DisplayIdentification.h>
namespace android {
namespace {
-template <class T>
-inline T load(const void* p) {
- static_assert(std::is_integral<T>::value, "T must be integral");
-
- T r;
- std::memcpy(&r, p, sizeof(r));
- return r;
-}
-
-uint64_t rotateByAtLeast1(uint64_t val, uint8_t shift) {
- return (val >> shift) | (val << (64 - shift));
-}
-
-uint64_t shiftMix(uint64_t val) {
- return val ^ (val >> 47);
-}
-
-__attribute__((no_sanitize("unsigned-integer-overflow")))
-uint64_t hash64Len16(uint64_t u, uint64_t v) {
- constexpr uint64_t kMul = 0x9ddfea08eb382d69;
- uint64_t a = (u ^ v) * kMul;
- a ^= (a >> 47);
- uint64_t b = (v ^ a) * kMul;
- b ^= (b >> 47);
- b *= kMul;
- return b;
-}
-
-__attribute__((no_sanitize("unsigned-integer-overflow")))
-uint64_t hash64Len0To16(const char* s, uint64_t len) {
- constexpr uint64_t k2 = 0x9ae16a3b2f90404f;
- constexpr uint64_t k3 = 0xc949d7c7509e6557;
-
- if (len > 8) {
- const uint64_t a = load<uint64_t>(s);
- const uint64_t b = load<uint64_t>(s + len - 8);
- return hash64Len16(a, rotateByAtLeast1(b + len, static_cast<uint8_t>(len))) ^ b;
- }
- if (len >= 4) {
- const uint32_t a = load<uint32_t>(s);
- const uint32_t b = load<uint32_t>(s + len - 4);
- return hash64Len16(len + (a << 3), b);
- }
- if (len > 0) {
- const unsigned char a = static_cast<unsigned char>(s[0]);
- const unsigned char b = static_cast<unsigned char>(s[len >> 1]);
- const unsigned char c = static_cast<unsigned char>(s[len - 1]);
- const uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
- const uint32_t z = static_cast<uint32_t>(len) + (static_cast<uint32_t>(c) << 2);
- return shiftMix(y * k2 ^ z * k3) * k2;
- }
- return k2;
-}
-
using byte_view = std::span<const uint8_t>;
constexpr size_t kEdidBlockSize = 128;
@@ -320,7 +266,7 @@
// Hash model string instead of using product code or (integer) serial number, since the latter
// have been observed to change on some displays with multiple inputs. Use a stable hash instead
// of std::hash which is only required to be same within a single execution of a program.
- const uint32_t modelHash = static_cast<uint32_t>(cityHash64Len0To16(modelString));
+ const uint32_t modelHash = static_cast<uint32_t>(*ftl::stable_hash(modelString));
// Parse extension blocks.
std::optional<Cea861ExtensionBlock> cea861Block;
@@ -394,13 +340,4 @@
return PhysicalDisplayId::fromEdid(0, kVirtualEdidManufacturerId, id);
}
-uint64_t cityHash64Len0To16(std::string_view sv) {
- auto len = sv.length();
- if (len > 16) {
- ALOGE("%s called with length %zu. Only hashing the first 16 chars", __FUNCTION__, len);
- len = 16;
- }
- return hash64Len0To16(sv.data(), len);
-}
-
} // namespace android
diff --git a/libs/ui/include/ui/DisplayIdentification.h b/libs/ui/include/ui/DisplayIdentification.h
index fc9c0f4..8bc2017 100644
--- a/libs/ui/include/ui/DisplayIdentification.h
+++ b/libs/ui/include/ui/DisplayIdentification.h
@@ -80,7 +80,4 @@
PhysicalDisplayId getVirtualDisplayId(uint32_t id);
-// CityHash64 implementation that only hashes at most the first 16 characters of the given string.
-uint64_t cityHash64Len0To16(std::string_view sv);
-
} // namespace android
diff --git a/libs/ui/tests/DisplayIdentification_test.cpp b/libs/ui/tests/DisplayIdentification_test.cpp
index 736979a..721b466 100644
--- a/libs/ui/tests/DisplayIdentification_test.cpp
+++ b/libs/ui/tests/DisplayIdentification_test.cpp
@@ -21,9 +21,9 @@
#include <functional>
#include <string_view>
+#include <ftl/hash.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
-
#include <ui/DisplayIdentification.h>
using ::testing::ElementsAre;
@@ -135,7 +135,7 @@
}
uint32_t hash(const char* str) {
- return static_cast<uint32_t>(cityHash64Len0To16(str));
+ return static_cast<uint32_t>(*ftl::stable_hash(str));
}
} // namespace
@@ -188,6 +188,7 @@
EXPECT_STREQ("SEC", edid->pnpId.data());
// ASCII text should be used as fallback if display name and serial number are missing.
EXPECT_EQ(hash("121AT11-801"), edid->modelHash);
+ EXPECT_EQ(hash("121AT11-801"), 626564263);
EXPECT_TRUE(edid->displayName.empty());
EXPECT_EQ(12610, edid->productId);
EXPECT_EQ(21, edid->manufactureOrModelYear);
@@ -199,6 +200,7 @@
EXPECT_EQ(0x22f0u, edid->manufacturerId);
EXPECT_STREQ("HWP", edid->pnpId.data());
EXPECT_EQ(hash("HP ZR30w"), edid->modelHash);
+ EXPECT_EQ(hash("HP ZR30w"), 918492362);
EXPECT_EQ("HP ZR30w", edid->displayName);
EXPECT_EQ(10348, edid->productId);
EXPECT_EQ(22, edid->manufactureOrModelYear);
@@ -210,6 +212,7 @@
EXPECT_EQ(0x4c2du, edid->manufacturerId);
EXPECT_STREQ("SAM", edid->pnpId.data());
EXPECT_EQ(hash("SAMSUNG"), edid->modelHash);
+ EXPECT_EQ(hash("SAMSUNG"), 1201368132);
EXPECT_EQ("SAMSUNG", edid->displayName);
EXPECT_EQ(2302, edid->productId);
EXPECT_EQ(21, edid->manufactureOrModelYear);
@@ -227,6 +230,7 @@
EXPECT_EQ(13481, edid->manufacturerId);
EXPECT_STREQ("MEI", edid->pnpId.data());
EXPECT_EQ(hash("Panasonic-TV"), edid->modelHash);
+ EXPECT_EQ(hash("Panasonic-TV"), 3876373262);
EXPECT_EQ("Panasonic-TV", edid->displayName);
EXPECT_EQ(41622, edid->productId);
EXPECT_EQ(29, edid->manufactureOrModelYear);
@@ -244,6 +248,7 @@
EXPECT_EQ(8355, edid->manufacturerId);
EXPECT_STREQ("HEC", edid->pnpId.data());
EXPECT_EQ(hash("Hisense"), edid->modelHash);
+ EXPECT_EQ(hash("Hisense"), 2859844809);
EXPECT_EQ("Hisense", edid->displayName);
EXPECT_EQ(0, edid->productId);
EXPECT_EQ(29, edid->manufactureOrModelYear);
@@ -261,6 +266,7 @@
EXPECT_EQ(3724, edid->manufacturerId);
EXPECT_STREQ("CTL", edid->pnpId.data());
EXPECT_EQ(hash("LP2361"), edid->modelHash);
+ EXPECT_EQ(hash("LP2361"), 1523181158);
EXPECT_EQ("LP2361", edid->displayName);
EXPECT_EQ(9373, edid->productId);
EXPECT_EQ(23, edid->manufactureOrModelYear);
@@ -281,6 +287,7 @@
// Serial number should be used as fallback if display name is invalid.
const auto modelHash = hash("CN4202137Q");
EXPECT_EQ(modelHash, edid->modelHash);
+ EXPECT_EQ(modelHash, 3582951527);
EXPECT_TRUE(edid->displayName.empty());
// Parsing should succeed even if EDID is truncated.
diff --git a/services/gpuservice/GpuService.cpp b/services/gpuservice/GpuService.cpp
index a481c62..fadb1fd 100644
--- a/services/gpuservice/GpuService.cpp
+++ b/services/gpuservice/GpuService.cpp
@@ -100,6 +100,12 @@
mGpuStats->insertTargetStatsArray(appPackageName, driverVersionCode, stats, values, valueCount);
}
+void GpuService::addVulkanEngineName(const std::string& appPackageName,
+ const uint64_t driverVersionCode,
+ const char* engineName) {
+ mGpuStats->addVulkanEngineName(appPackageName, driverVersionCode, engineName);
+}
+
void GpuService::toggleAngleAsSystemDriver(bool enabled) {
IPCThreadState* ipc = IPCThreadState::self();
const int pid = ipc->getCallingPid();
diff --git a/services/gpuservice/gpustats/GpuStats.cpp b/services/gpuservice/gpustats/GpuStats.cpp
index 11b636d..6d758bc 100644
--- a/services/gpuservice/gpustats/GpuStats.cpp
+++ b/services/gpuservice/gpustats/GpuStats.cpp
@@ -181,6 +181,33 @@
return insertTargetStatsArray(appPackageName, driverVersionCode, stats, &value, 1);
}
+void GpuStats::addVulkanEngineName(const std::string& appPackageName,
+ const uint64_t driverVersionCode,
+ const char* engineNameCStr) {
+ ATRACE_CALL();
+
+ const std::string appStatsKey = appPackageName + std::to_string(driverVersionCode);
+ const size_t engineNameLen = std::min(strlen(engineNameCStr),
+ GpuStatsAppInfo::MAX_VULKAN_ENGINE_NAME_LENGTH);
+ const std::string engineName{engineNameCStr, engineNameLen};
+
+ std::lock_guard<std::mutex> lock(mLock);
+ registerStatsdCallbacksIfNeeded();
+
+ const auto foundApp = mAppStats.find(appStatsKey);
+ if (foundApp == mAppStats.end()) {
+ return;
+ }
+
+ // Storing in std::set<> is not efficient for serialization tasks. Use
+ // vector instead and filter out dups
+ std::vector<std::string>& engineNames = foundApp->second.vulkanEngineNames;
+ if (engineNames.size() < GpuStatsAppInfo::MAX_VULKAN_ENGINE_NAMES
+ && std::find(engineNames.cbegin(), engineNames.cend(), engineName) == engineNames.cend()) {
+ engineNames.push_back(engineName);
+ }
+}
+
void GpuStats::insertTargetStatsArray(const std::string& appPackageName,
const uint64_t driverVersionCode, const GpuStatsInfo::Stats stats,
const uint64_t* values, const uint32_t valueCount) {
@@ -389,6 +416,11 @@
std::string angleDriverBytes = int64VectorToProtoByteString(
ele.second.angleDriverLoadingTime);
+ std::vector<const char*> engineNames;
+ for (const std::string &engineName : ele.second.vulkanEngineNames) {
+ engineNames.push_back(engineName.c_str());
+ }
+
android::util::addAStatsEvent(
data,
android::util::GPU_STATS_APP_INFO,
@@ -410,7 +442,8 @@
ele.second.vulkanApiVersion,
ele.second.vulkanDeviceFeaturesEnabled,
ele.second.vulkanInstanceExtensions,
- ele.second.vulkanDeviceExtensions);
+ ele.second.vulkanDeviceExtensions,
+ engineNames);
}
}
diff --git a/services/gpuservice/gpustats/include/gpustats/GpuStats.h b/services/gpuservice/gpustats/include/gpustats/GpuStats.h
index 22c64db..961f011 100644
--- a/services/gpuservice/gpustats/include/gpustats/GpuStats.h
+++ b/services/gpuservice/gpustats/include/gpustats/GpuStats.h
@@ -44,6 +44,9 @@
void insertTargetStatsArray(const std::string& appPackageName,
const uint64_t driverVersionCode, const GpuStatsInfo::Stats stats,
const uint64_t* values, const uint32_t valueCount);
+ // Add the engine name passed in VkApplicationInfo during CreateInstance
+ void addVulkanEngineName(const std::string& appPackageName,
+ const uint64_t driverVersionCode, const char* engineName);
// dumpsys interface
void dump(const Vector<String16>& args, std::string* result);
diff --git a/services/gpuservice/include/gpuservice/GpuService.h b/services/gpuservice/include/gpuservice/GpuService.h
index 54f8f66..3072885 100644
--- a/services/gpuservice/include/gpuservice/GpuService.h
+++ b/services/gpuservice/include/gpuservice/GpuService.h
@@ -64,6 +64,8 @@
void setUpdatableDriverPath(const std::string& driverPath) override;
std::string getUpdatableDriverPath() override;
void toggleAngleAsSystemDriver(bool enabled) override;
+ void addVulkanEngineName(const std::string& appPackageName, const uint64_t driverVersionCode,
+ const char *engineName) override;
/*
* IBinder interface
diff --git a/services/gpuservice/tests/unittests/GpuStatsTest.cpp b/services/gpuservice/tests/unittests/GpuStatsTest.cpp
index 4ce533f..b367457 100644
--- a/services/gpuservice/tests/unittests/GpuStatsTest.cpp
+++ b/services/gpuservice/tests/unittests/GpuStatsTest.cpp
@@ -46,6 +46,8 @@
#define UPDATED_DRIVER_VER_CODE 1
#define UPDATED_DRIVER_BUILD_TIME 234
#define VULKAN_VERSION 345
+#define VULKAN_ENGINE_NAME_1 "testVulkanEngine1"
+#define VULKAN_ENGINE_NAME_2 "testVulkanEngine2"
#define APP_PKG_NAME_1 "testapp1"
#define APP_PKG_NAME_2 "testapp2"
#define DRIVER_LOADING_TIME_1 678
@@ -243,6 +245,8 @@
mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
GpuStatsInfo::Stats::VULKAN_DEVICE_EXTENSION,
VULKAN_DEVICE_EXTENSION_1);
+ mGpuStats->addVulkanEngineName(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
+ VULKAN_ENGINE_NAME_1);
EXPECT_TRUE(inputCommand(InputCommand::DUMP_APP).empty());
}
@@ -282,6 +286,8 @@
mGpuStats->insertTargetStats(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
GpuStatsInfo::Stats::VULKAN_DEVICE_EXTENSION,
VULKAN_DEVICE_EXTENSION_2);
+ mGpuStats->addVulkanEngineName(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
+ VULKAN_ENGINE_NAME_1);
EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("cpuVulkanInUse = 1"));
EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("falsePrerotation = 1"));
@@ -302,6 +308,64 @@
expectedResult.str("");
expectedResult << "vulkanDeviceExtensions: 0x" << std::hex << VULKAN_DEVICE_EXTENSION_1
<< " 0x" << std::hex << VULKAN_DEVICE_EXTENSION_2;
+ expectedResult.str("");
+ expectedResult << "vulkanEngineNames: " << VULKAN_ENGINE_NAME_1 << ",";
+
+ EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult.str()));
+}
+
+// Verify the vulkanEngineNames list behaves like a set and dedupes additions
+TEST_F(GpuStatsTest, vulkanEngineNamesBehavesLikeSet) {
+ mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME,
+ BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1,
+ VULKAN_VERSION, GpuStatsInfo::Driver::GL, true,
+ DRIVER_LOADING_TIME_1);
+ for (int i = 0; i < 4; i++) {
+ mGpuStats->addVulkanEngineName(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
+ VULKAN_ENGINE_NAME_1);
+ }
+
+ std::stringstream wrongResult, expectedResult;
+ wrongResult << "vulkanEngineNames: " << VULKAN_ENGINE_NAME_1 << ", " <<
+ VULKAN_ENGINE_NAME_1;
+ expectedResult << "vulkanEngineNames: " << VULKAN_ENGINE_NAME_1;
+
+ EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), Not(HasSubstr(wrongResult.str())));
+ EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult.str()));
+}
+
+TEST_F(GpuStatsTest, vulkanEngineNamesCheckEmptyEngineNameAlone) {
+ mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME,
+ BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1,
+ VULKAN_VERSION, GpuStatsInfo::Driver::GL, true,
+ DRIVER_LOADING_TIME_1);
+
+ mGpuStats->addVulkanEngineName(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
+ "");
+
+ std::stringstream expectedResult;
+ expectedResult << "vulkanEngineNames: ,";
+
+ EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult.str()));
+}
+
+TEST_F(GpuStatsTest, vulkanEngineNamesCheckEmptyEngineNameWithOthers) {
+ mGpuStats->insertDriverStats(BUILTIN_DRIVER_PKG_NAME, BUILTIN_DRIVER_VER_NAME,
+ BUILTIN_DRIVER_VER_CODE, BUILTIN_DRIVER_BUILD_TIME, APP_PKG_NAME_1,
+ VULKAN_VERSION, GpuStatsInfo::Driver::GL, true,
+ DRIVER_LOADING_TIME_1);
+
+ mGpuStats->addVulkanEngineName(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
+ VULKAN_ENGINE_NAME_1);
+ mGpuStats->addVulkanEngineName(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
+ "");
+ mGpuStats->addVulkanEngineName(APP_PKG_NAME_1, BUILTIN_DRIVER_VER_CODE,
+ VULKAN_ENGINE_NAME_2);
+
+ std::stringstream expectedResult;
+ expectedResult << "vulkanEngineNames: " << VULKAN_ENGINE_NAME_1 << ", "
+ << ", " << VULKAN_ENGINE_NAME_2;
+
EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult.str()));
}
@@ -350,6 +414,10 @@
mGpuStats->insertTargetStats(fullPkgName, BUILTIN_DRIVER_VER_CODE,
GpuStatsInfo::Stats::VULKAN_DEVICE_EXTENSION,
VULKAN_DEVICE_EXTENSION_2);
+ mGpuStats->addVulkanEngineName(fullPkgName, BUILTIN_DRIVER_VER_CODE,
+ VULKAN_ENGINE_NAME_1);
+ mGpuStats->addVulkanEngineName(fullPkgName, BUILTIN_DRIVER_VER_CODE,
+ VULKAN_ENGINE_NAME_2);
EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(fullPkgName.c_str()));
EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr("cpuVulkanInUse = 1"));
@@ -371,6 +439,9 @@
expectedResult.str("");
expectedResult << "vulkanDeviceExtensions: 0x" << std::hex << VULKAN_DEVICE_EXTENSION_1
<< " 0x" << std::hex << VULKAN_DEVICE_EXTENSION_2;
+ expectedResult.str("");
+ expectedResult << "vulkanEngineNames: " << VULKAN_ENGINE_NAME_1 << ", "
+ << VULKAN_ENGINE_NAME_2 << ",";
EXPECT_THAT(inputCommand(InputCommand::DUMP_APP), HasSubstr(expectedResult.str()));
}
diff --git a/services/inputflinger/Android.bp b/services/inputflinger/Android.bp
index a03055f..70801dc 100644
--- a/services/inputflinger/Android.bp
+++ b/services/inputflinger/Android.bp
@@ -56,6 +56,16 @@
host: {
sanitize: {
address: true,
+ diag: {
+ cfi: true,
+ integer_overflow: true,
+ memtag_heap: true,
+ undefined: true,
+ misc_undefined: [
+ "bounds",
+ "all",
+ ],
+ },
},
include_dirs: [
"bionic/libc/kernel/android/uapi/",
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index ae066c0..41e5247 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -41,7 +41,6 @@
const bool ENABLE_INPUT_DEVICE_USAGE_METRICS =
sysprop::InputProperties::enable_input_device_usage_metrics().value_or(true);
-const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer();
const bool ENABLE_INPUT_FILTER_RUST = input_flags::enable_input_filter_rust_impl();
int32_t exceptionCodeFromStatusT(status_t status) {
@@ -152,12 +151,10 @@
mTracingStages.emplace_back(
std::make_unique<TracedInputListener>("InputProcessor", *mProcessor));
- if (ENABLE_POINTER_CHOREOGRAPHER) {
- mChoreographer =
- std::make_unique<PointerChoreographer>(*mTracingStages.back(), choreographerPolicy);
- mTracingStages.emplace_back(
- std::make_unique<TracedInputListener>("PointerChoreographer", *mChoreographer));
- }
+ mChoreographer =
+ std::make_unique<PointerChoreographer>(*mTracingStages.back(), choreographerPolicy);
+ mTracingStages.emplace_back(
+ std::make_unique<TracedInputListener>("PointerChoreographer", *mChoreographer));
mBlocker = std::make_unique<UnwantedInteractionBlocker>(*mTracingStages.back());
mTracingStages.emplace_back(
@@ -245,10 +242,8 @@
dump += '\n';
mBlocker->dump(dump);
dump += '\n';
- if (ENABLE_POINTER_CHOREOGRAPHER) {
- mChoreographer->dump(dump);
- dump += '\n';
- }
+ mChoreographer->dump(dump);
+ dump += '\n';
mProcessor->dump(dump);
dump += '\n';
if (ENABLE_INPUT_DEVICE_USAGE_METRICS) {
diff --git a/services/inputflinger/PointerChoreographer.cpp b/services/inputflinger/PointerChoreographer.cpp
index 4dc2737..a3d0c2b 100644
--- a/services/inputflinger/PointerChoreographer.cpp
+++ b/services/inputflinger/PointerChoreographer.cpp
@@ -17,7 +17,12 @@
#define LOG_TAG "PointerChoreographer"
#include <android-base/logging.h>
+#include <com_android_input_flags.h>
+#if defined(__ANDROID__)
+#include <gui/SurfaceComposerClient.h>
+#endif
#include <input/PrintTools.h>
+#include <unordered_set>
#include "PointerChoreographer.h"
@@ -25,6 +30,10 @@
namespace android {
+namespace input_flags = com::android::input::flags;
+static const bool HIDE_TOUCH_INDICATORS_FOR_SECURE_WINDOWS =
+ input_flags::hide_pointer_indicators_for_secure_windows();
+
namespace {
bool isFromMouse(const NotifyMotionArgs& args) {
@@ -96,6 +105,14 @@
mShowTouchesEnabled(false),
mStylusPointerIconEnabled(false) {}
+PointerChoreographer::~PointerChoreographer() {
+ std::scoped_lock _l(mLock);
+ if (mWindowInfoListener == nullptr) {
+ return;
+ }
+ mWindowInfoListener->onPointerChoreographerDestroyed();
+}
+
void PointerChoreographer::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
PointerDisplayChange pointerDisplayChange;
@@ -231,6 +248,7 @@
auto [it, _] = mDrawingTabletPointersByDevice.try_emplace(args.deviceId,
getMouseControllerConstructor(
args.displayId));
+ // TODO (b/325252005): Add handing for drawing tablets mouse pointer controller
PointerControllerInterface& pc = *it->second;
@@ -268,7 +286,11 @@
}
// Get the touch pointer controller for the device, or create one if it doesn't exist.
- auto [it, _] = mTouchPointersByDevice.try_emplace(args.deviceId, mTouchControllerConstructor);
+ auto [it, controllerAdded] =
+ mTouchPointersByDevice.try_emplace(args.deviceId, mTouchControllerConstructor);
+ if (controllerAdded) {
+ onControllerAddedOrRemoved();
+ }
PointerControllerInterface& pc = *it->second;
@@ -306,6 +328,7 @@
auto [it, _] =
mStylusPointersByDevice.try_emplace(args.deviceId,
getStylusControllerConstructor(args.displayId));
+ // TODO (b/325252005): Add handing for stylus pointer controller
PointerControllerInterface& pc = *it->second;
@@ -345,6 +368,31 @@
mTouchPointersByDevice.erase(args.deviceId);
mStylusPointersByDevice.erase(args.deviceId);
mDrawingTabletPointersByDevice.erase(args.deviceId);
+ onControllerAddedOrRemoved();
+}
+
+void PointerChoreographer::onControllerAddedOrRemoved() {
+ if (!HIDE_TOUCH_INDICATORS_FOR_SECURE_WINDOWS) {
+ return;
+ }
+ bool requireListener = !mTouchPointersByDevice.empty();
+ // TODO (b/325252005): Update for other types of pointer controllers
+
+ if (requireListener && mWindowInfoListener == nullptr) {
+ mWindowInfoListener = sp<PointerChoreographerDisplayInfoListener>::make(this);
+ auto initialInfo = std::make_pair(std::vector<android::gui::WindowInfo>{},
+ std::vector<android::gui::DisplayInfo>{});
+#if defined(__ANDROID__)
+ SurfaceComposerClient::getDefault()->addWindowInfosListener(mWindowInfoListener,
+ &initialInfo);
+#endif
+ onWindowInfosChangedLocked(initialInfo.first);
+ } else if (!requireListener && mWindowInfoListener != nullptr) {
+#if defined(__ANDROID__)
+ SurfaceComposerClient::getDefault()->removeWindowInfosListener(mWindowInfoListener);
+#endif
+ mWindowInfoListener = nullptr;
+ }
}
void PointerChoreographer::notifyPointerCaptureChanged(
@@ -358,6 +406,12 @@
mNextListener.notify(args);
}
+void PointerChoreographer::onWindowInfosChanged(
+ const std::vector<android::gui::WindowInfo>& windowInfos) {
+ std::scoped_lock _l(mLock);
+ onWindowInfosChangedLocked(windowInfos);
+}
+
void PointerChoreographer::dump(std::string& dump) {
std::scoped_lock _l(mLock);
@@ -410,6 +464,7 @@
if (it == mMousePointersByDisplay.end()) {
it = mMousePointersByDisplay.emplace(displayId, getMouseControllerConstructor(displayId))
.first;
+ // TODO (b/325252005): Add handing for mouse pointer controller
}
return {displayId, *it->second};
@@ -450,6 +505,8 @@
auto [mousePointerIt, isNewMousePointer] =
mMousePointersByDisplay.try_emplace(displayId,
getMouseControllerConstructor(displayId));
+ // TODO (b/325252005): Add handing for mouse pointer controller
+
mMouseDevices.emplace(info.getId());
if ((!isKnownMouse || isNewMousePointer) && canUnfadeOnDisplay(displayId)) {
mousePointerIt->second->unfade(PointerControllerInterface::Transition::IMMEDIATE);
@@ -488,6 +545,8 @@
mInputDeviceInfos.end();
});
+ onControllerAddedOrRemoved();
+
// Check if we need to notify the policy if there's a change on the pointer display ID.
return calculatePointerDisplayChangeToNotify();
}
@@ -652,6 +711,31 @@
return false;
}
+void PointerChoreographer::onWindowInfosChangedLocked(
+ const std::vector<android::gui::WindowInfo>& windowInfos) {
+ // Mark all spot controllers secure on displays containing secure windows and
+ // remove secure flag from others if required
+ std::unordered_set<int32_t> privacySensitiveDisplays;
+ std::unordered_set<int32_t> allDisplayIds;
+ for (const auto& windowInfo : windowInfos) {
+ allDisplayIds.insert(windowInfo.displayId);
+ if (!windowInfo.inputConfig.test(gui::WindowInfo::InputConfig::NOT_VISIBLE) &&
+ windowInfo.inputConfig.test(gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY)) {
+ privacySensitiveDisplays.insert(windowInfo.displayId);
+ }
+ }
+
+ for (auto& it : mTouchPointersByDevice) {
+ auto& pc = it.second;
+ for (int32_t displayId : allDisplayIds) {
+ pc->setSkipScreenshot(displayId,
+ privacySensitiveDisplays.find(displayId) !=
+ privacySensitiveDisplays.end());
+ }
+ }
+ // TODO (b/325252005): update skip screenshot flag for other types of pointer controllers
+}
+
void PointerChoreographer::setPointerIconVisibility(int32_t displayId, bool visible) {
std::scoped_lock lock(mLock);
if (visible) {
@@ -702,4 +786,18 @@
return ConstructorDelegate(std::move(ctor));
}
+void PointerChoreographer::PointerChoreographerDisplayInfoListener::onWindowInfosChanged(
+ const gui::WindowInfosUpdate& windowInfosUpdate) {
+ std::scoped_lock _l(mListenerLock);
+ if (mPointerChoreographer != nullptr) {
+ mPointerChoreographer->onWindowInfosChanged(windowInfosUpdate.windowInfos);
+ }
+}
+
+void PointerChoreographer::PointerChoreographerDisplayInfoListener::
+ onPointerChoreographerDestroyed() {
+ std::scoped_lock _l(mListenerLock);
+ mPointerChoreographer = nullptr;
+}
+
} // namespace android
diff --git a/services/inputflinger/PointerChoreographer.h b/services/inputflinger/PointerChoreographer.h
index a3c210e..b29d9cd 100644
--- a/services/inputflinger/PointerChoreographer.h
+++ b/services/inputflinger/PointerChoreographer.h
@@ -21,6 +21,7 @@
#include "PointerChoreographerPolicyInterface.h"
#include <android-base/thread_annotations.h>
+#include <gui/WindowInfosListener.h>
#include <type_traits>
namespace android {
@@ -83,7 +84,7 @@
public:
explicit PointerChoreographer(InputListenerInterface& listener,
PointerChoreographerPolicyInterface&);
- ~PointerChoreographer() override = default;
+ ~PointerChoreographer() override;
void setDefaultMouseDisplayId(int32_t displayId) override;
void setDisplayViewports(const std::vector<DisplayViewport>& viewports) override;
@@ -106,6 +107,9 @@
void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
+ // Public because it's also used by tests to simulate the WindowInfosListener callback
+ void onWindowInfosChanged(const std::vector<android::gui::WindowInfo>& windowInfos);
+
void dump(std::string& dump) override;
private:
@@ -127,6 +131,22 @@
void processTouchscreenAndStylusEventLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
void processStylusHoverEventLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
void processDeviceReset(const NotifyDeviceResetArgs& args);
+ void onControllerAddedOrRemoved() REQUIRES(mLock);
+ void onWindowInfosChangedLocked(const std::vector<android::gui::WindowInfo>& windowInfos)
+ REQUIRES(mLock);
+
+ class PointerChoreographerDisplayInfoListener : public gui::WindowInfosListener {
+ public:
+ explicit PointerChoreographerDisplayInfoListener(PointerChoreographer* pc)
+ : mPointerChoreographer(pc){};
+ void onWindowInfosChanged(const gui::WindowInfosUpdate&) override;
+ void onPointerChoreographerDestroyed();
+
+ private:
+ std::mutex mListenerLock;
+ PointerChoreographer* mPointerChoreographer GUARDED_BY(mListenerLock);
+ };
+ sp<PointerChoreographerDisplayInfoListener> mWindowInfoListener GUARDED_BY(mLock);
using ControllerConstructor =
ConstructorDelegate<std::function<std::shared_ptr<PointerControllerInterface>()>>;
diff --git a/services/inputflinger/dispatcher/trace/InputTracer.cpp b/services/inputflinger/dispatcher/trace/InputTracer.cpp
index 4931a5f..a1a87af 100644
--- a/services/inputflinger/dispatcher/trace/InputTracer.cpp
+++ b/services/inputflinger/dispatcher/trace/InputTracer.cpp
@@ -88,7 +88,7 @@
}
const auto& info = *target.windowHandle->getInfo();
const bool isSensitiveTarget =
- info.inputConfig.test(gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING);
+ info.inputConfig.test(gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY);
return {target.windowHandle->getInfo()->ownerUid, isSensitiveTarget};
}
diff --git a/services/inputflinger/include/PointerControllerInterface.h b/services/inputflinger/include/PointerControllerInterface.h
index c44486f..6b26e81 100644
--- a/services/inputflinger/include/PointerControllerInterface.h
+++ b/services/inputflinger/include/PointerControllerInterface.h
@@ -143,6 +143,11 @@
/* Sets the custom pointer icon for mice or styluses. */
virtual void setCustomPointerIcon(const SpriteIcon& icon) = 0;
+
+ /* Sets the flag to skip screenshot of the pointer indicators on the display matching the
+ * provided displayId.
+ */
+ virtual void setSkipScreenshot(int32_t displayId, bool skip) = 0;
};
} // namespace android
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
index c8cc5dc..ede2d72 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
@@ -40,8 +40,6 @@
// The default velocity control parameters that has no effect.
static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{};
-static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer();
-
// --- CursorMotionAccumulator ---
CursorMotionAccumulator::CursorMotionAccumulator() {
@@ -78,22 +76,10 @@
CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext,
const InputReaderConfiguration& readerConfig)
- : CursorInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {}
-
-CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext,
- const InputReaderConfiguration& readerConfig,
- bool enablePointerChoreographer)
: InputMapper(deviceContext, readerConfig),
mLastEventTime(std::numeric_limits<nsecs_t>::min()),
- mEnablePointerChoreographer(enablePointerChoreographer),
mEnableNewMousePointerBallistics(input_flags::enable_new_mouse_pointer_ballistics()) {}
-CursorInputMapper::~CursorInputMapper() {
- if (mPointerController != nullptr) {
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
- }
-}
-
uint32_t CursorInputMapper::getSources() const {
return mSource;
}
@@ -304,22 +290,6 @@
float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
if (mSource == AINPUT_SOURCE_MOUSE) {
- if (!mEnablePointerChoreographer) {
- if (moved || scrolled || buttonsChanged) {
- mPointerController->setPresentation(
- PointerControllerInterface::Presentation::POINTER);
-
- if (moved) {
- mPointerController->move(deltaX, deltaY);
- }
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
- }
-
- std::tie(xCursorPosition, yCursorPosition) = mPointerController->getPosition();
-
- pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
- }
pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY);
} else {
@@ -470,7 +440,6 @@
mYPrecision = 1.0f;
mXScale = 1.0f;
mYScale = 1.0f;
- mPointerController = getContext()->getPointerController(getDeviceId());
break;
case Parameters::Mode::NAVIGATION:
mSource = AINPUT_SOURCE_TRACKBALL;
@@ -490,8 +459,6 @@
if (mParameters.mode == Parameters::Mode::POINTER) {
mParameters.mode = Parameters::Mode::POINTER_RELATIVE;
mSource = AINPUT_SOURCE_MOUSE_RELATIVE;
- // Keep PointerController around in order to preserve the pointer position.
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
} else {
ALOGE("Cannot request pointer capture, device is not in MODE_POINTER");
}
@@ -540,38 +507,17 @@
mDisplayId = ADISPLAY_ID_NONE;
std::optional<DisplayViewport> resolvedViewport;
- bool isBoundsSet = false;
if (auto assocViewport = mDeviceContext.getAssociatedViewport(); assocViewport) {
// This InputDevice is associated with a viewport.
// Only generate events for the associated display.
mDisplayId = assocViewport->displayId;
resolvedViewport = *assocViewport;
- if (!mEnablePointerChoreographer) {
- const bool mismatchedPointerDisplay =
- isPointer && (assocViewport->displayId != mPointerController->getDisplayId());
- if (mismatchedPointerDisplay) {
- // This device's associated display doesn't match PointerController's current
- // display. Do not associate it with any display.
- mDisplayId.reset();
- }
- }
} else if (isPointer) {
// The InputDevice is not associated with a viewport, but it controls the mouse pointer.
- if (mEnablePointerChoreographer) {
- // Always use DISPLAY_ID_NONE for mouse events.
- // PointerChoreographer will make it target the correct the displayId later.
- resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
- mDisplayId = resolvedViewport ? std::make_optional(ADISPLAY_ID_NONE) : std::nullopt;
- } else {
- mDisplayId = mPointerController->getDisplayId();
- if (auto v = config.getDisplayViewportById(*mDisplayId); v) {
- resolvedViewport = *v;
- }
- if (auto bounds = mPointerController->getBounds(); bounds) {
- mBoundsInLogicalDisplay = *bounds;
- isBoundsSet = true;
- }
- }
+ // Always use DISPLAY_ID_NONE for mouse events.
+ // PointerChoreographer will make it target the correct the displayId later.
+ resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
+ mDisplayId = resolvedViewport ? std::make_optional(ADISPLAY_ID_NONE) : std::nullopt;
}
mOrientation = (mParameters.orientationAware && mParameters.hasAssociatedDisplay) ||
@@ -579,14 +525,12 @@
? ui::ROTATION_0
: getInverseRotation(resolvedViewport->orientation);
- if (!isBoundsSet) {
- mBoundsInLogicalDisplay = resolvedViewport
- ? FloatRect{static_cast<float>(resolvedViewport->logicalLeft),
- static_cast<float>(resolvedViewport->logicalTop),
- static_cast<float>(resolvedViewport->logicalRight - 1),
- static_cast<float>(resolvedViewport->logicalBottom - 1)}
- : FloatRect{0, 0, 0, 0};
- }
+ mBoundsInLogicalDisplay = resolvedViewport
+ ? FloatRect{static_cast<float>(resolvedViewport->logicalLeft),
+ static_cast<float>(resolvedViewport->logicalTop),
+ static_cast<float>(resolvedViewport->logicalRight - 1),
+ static_cast<float>(resolvedViewport->logicalBottom - 1)}
+ : FloatRect{0, 0, 0, 0};
bumpGeneration();
}
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.h b/services/inputflinger/reader/mapper/CursorInputMapper.h
index ca541d9..3daae2f 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.h
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.h
@@ -20,14 +20,11 @@
#include "CursorScrollAccumulator.h"
#include "InputMapper.h"
-#include <PointerControllerInterface.h>
#include <input/VelocityControl.h>
#include <ui/Rotation.h>
namespace android {
-class PointerControllerInterface;
-
class CursorButtonAccumulator;
class CursorScrollAccumulator;
@@ -56,7 +53,7 @@
friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
const InputReaderConfiguration& readerConfig,
Args... args);
- virtual ~CursorInputMapper();
+ virtual ~CursorInputMapper() = default;
virtual uint32_t getSources() const override;
virtual void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
@@ -122,21 +119,14 @@
ui::Rotation mOrientation{ui::ROTATION_0};
FloatRect mBoundsInLogicalDisplay{};
- std::shared_ptr<PointerControllerInterface> mPointerController;
-
int32_t mButtonState;
nsecs_t mDownTime;
nsecs_t mLastEventTime;
- const bool mEnablePointerChoreographer;
const bool mEnableNewMousePointerBallistics;
explicit CursorInputMapper(InputDeviceContext& deviceContext,
const InputReaderConfiguration& readerConfig);
- // Constructor for testing.
- explicit CursorInputMapper(InputDeviceContext& deviceContext,
- const InputReaderConfiguration& readerConfig,
- bool enablePointerChoreographer);
void dumpParameters(std::string& dump);
void configureBasicParams();
void configureOnPointerCapture(const InputReaderConfiguration& config);
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 81449d1..cf07506 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -336,7 +336,6 @@
changes.any(InputReaderConfiguration::Change::DISPLAY_INFO |
InputReaderConfiguration::Change::POINTER_CAPTURE |
InputReaderConfiguration::Change::POINTER_GESTURE_ENABLEMENT |
- InputReaderConfiguration::Change::SHOW_TOUCHES |
InputReaderConfiguration::Change::EXTERNAL_STYLUS_PRESENCE |
InputReaderConfiguration::Change::DEVICE_TYPE)) {
// Configure device sources, display dimensions, orientation and
@@ -1042,32 +1041,6 @@
mOrientedRanges.clear();
}
- // Create and preserve the pointer controller in the following cases:
- const bool isPointerControllerNeeded =
- // - when the device is in pointer mode, to show the mouse cursor;
- (mDeviceMode == DeviceMode::POINTER) ||
- // - when pointer capture is enabled, to preserve the mouse cursor position;
- (mParameters.deviceType == Parameters::DeviceType::POINTER &&
- mConfig.pointerCaptureRequest.isEnable()) ||
- // - when we should be showing touches;
- (mDeviceMode == DeviceMode::DIRECT && mConfig.showTouches) ||
- // - when we should be showing a pointer icon for direct styluses.
- (mDeviceMode == DeviceMode::DIRECT && mConfig.stylusPointerIconEnabled && hasStylus());
- if (isPointerControllerNeeded) {
- if (mPointerController == nullptr) {
- mPointerController = getContext()->getPointerController(getDeviceId());
- }
- if (mConfig.pointerCaptureRequest.isEnable()) {
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
- }
- } else {
- if (mPointerController != nullptr && mDeviceMode == DeviceMode::DIRECT &&
- !mConfig.showTouches) {
- mPointerController->clearSpots();
- }
- mPointerController.reset();
- }
-
if ((viewportChanged && !skipViewportUpdate) || deviceModeChanged) {
ALOGI("Device reconfigured: id=%d, name='%s', size %s, orientation %s, mode %s, "
"display id %d",
@@ -1400,7 +1373,6 @@
std::list<NotifyArgs> TouchInputMapper::reset(nsecs_t when) {
std::list<NotifyArgs> out = cancelTouch(when, when);
- updateTouchSpots();
mCursorButtonAccumulator.reset(getDeviceContext());
mCursorScrollAccumulator.reset(getDeviceContext());
@@ -1427,11 +1399,6 @@
mPointerSimple.reset();
resetExternalStylus();
- if (mPointerController != nullptr) {
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
- mPointerController->clearSpots();
- }
-
return out += InputMapper::reset(when);
}
@@ -1586,11 +1553,6 @@
uint32_t policyFlags = 0;
bool buttonsPressed = mCurrentRawState.buttonState & ~mLastRawState.buttonState;
if (initialDown || buttonsPressed) {
- // If this is a touch screen, hide the pointer on an initial down.
- if (mDeviceMode == DeviceMode::DIRECT) {
- getContext()->fadePointer();
- }
-
if (mParameters.wake) {
policyFlags |= POLICY_FLAG_WAKE;
}
@@ -1658,7 +1620,6 @@
out += dispatchPointerUsage(when, readTime, policyFlags, pointerUsage);
} else {
if (!mCurrentMotionAborted) {
- updateTouchSpots();
out += dispatchButtonRelease(when, readTime, policyFlags);
out += dispatchHoverExit(when, readTime, policyFlags);
out += dispatchTouches(when, readTime, policyFlags);
@@ -1690,28 +1651,6 @@
return out;
}
-void TouchInputMapper::updateTouchSpots() {
- if (!mConfig.showTouches || mPointerController == nullptr) {
- return;
- }
-
- // Update touch spots when this is a touchscreen even when it's not enabled so that we can
- // clear touch spots.
- if (mDeviceMode != DeviceMode::DIRECT &&
- (mDeviceMode != DeviceMode::DISABLED || !isTouchScreen())) {
- return;
- }
-
- mPointerController->setPresentation(PointerControllerInterface::Presentation::SPOT);
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
-
- mPointerController->setSpots(mCurrentCookedState.cookedPointerData.pointerCoords.cbegin(),
- mCurrentCookedState.cookedPointerData.idToIndex.cbegin(),
- mCurrentCookedState.cookedPointerData.touchingIdBits |
- mCurrentCookedState.cookedPointerData.hoveringIdBits,
- mViewport.displayId);
-}
-
bool TouchInputMapper::isTouchScreen() {
return mParameters.deviceType == Parameters::DeviceType::TOUCH_SCREEN &&
mParameters.hasAssociatedDisplay;
@@ -2560,54 +2499,6 @@
cancelPreviousGesture = false;
}
- // Update the pointer presentation and spots.
- if (mParameters.gestureMode == Parameters::GestureMode::MULTI_TOUCH) {
- mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
- if (finishPreviousGesture || cancelPreviousGesture) {
- mPointerController->clearSpots();
- }
-
- if (mPointerGesture.currentGestureMode == PointerGesture::Mode::FREEFORM) {
- mPointerController->setSpots(mPointerGesture.currentGestureCoords.cbegin(),
- mPointerGesture.currentGestureIdToIndex.cbegin(),
- mPointerGesture.currentGestureIdBits,
- mPointerController->getDisplayId());
- }
- } else {
- mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
- }
-
- // Show or hide the pointer if needed.
- switch (mPointerGesture.currentGestureMode) {
- case PointerGesture::Mode::NEUTRAL:
- case PointerGesture::Mode::QUIET:
- if (mParameters.gestureMode == Parameters::GestureMode::MULTI_TOUCH &&
- mPointerGesture.lastGestureMode == PointerGesture::Mode::FREEFORM) {
- // Remind the user of where the pointer is after finishing a gesture with spots.
- mPointerController->unfade(PointerControllerInterface::Transition::GRADUAL);
- }
- break;
- case PointerGesture::Mode::TAP:
- case PointerGesture::Mode::TAP_DRAG:
- case PointerGesture::Mode::BUTTON_CLICK_OR_DRAG:
- case PointerGesture::Mode::HOVER:
- case PointerGesture::Mode::PRESS:
- case PointerGesture::Mode::SWIPE:
- // Unfade the pointer when the current gesture manipulates the
- // area directly under the pointer.
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
- break;
- case PointerGesture::Mode::FREEFORM:
- // Fade the pointer when the current gesture manipulates a different
- // area and there are spots to guide the user experience.
- if (mParameters.gestureMode == Parameters::GestureMode::MULTI_TOUCH) {
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
- } else {
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
- }
- break;
- }
-
// Send events!
int32_t metaState = getContext()->getGlobalMetaState();
int32_t buttonState = mCurrentCookedState.buttonState;
@@ -2746,7 +2637,6 @@
// the pointer is hovering again even if the user is not currently touching
// the touch pad. This ensures that a view will receive a fresh hover enter
// event after a tap.
- const auto [x, y] = mPointerController->getPosition();
PointerProperties pointerProperties;
pointerProperties.clear();
@@ -2755,16 +2645,12 @@
PointerCoords pointerCoords;
pointerCoords.clear();
- pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
- pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
-
- const int32_t displayId = mPointerController->getDisplayId();
out.push_back(NotifyMotionArgs(getContext()->getNextId(), when, readTime, getDeviceId(),
- mSource, displayId, policyFlags,
+ mSource, ADISPLAY_ID_NONE, policyFlags,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, flags, metaState,
buttonState, MotionClassification::NONE,
AMOTION_EVENT_EDGE_FLAG_NONE, 1, &pointerProperties,
- &pointerCoords, 0, 0, x, y, mPointerGesture.downTime,
+ &pointerCoords, 0, 0, 0.f, 0.f, mPointerGesture.downTime,
/*videoFrames=*/{}));
}
@@ -2810,12 +2696,6 @@
// Reset the current pointer gesture.
mPointerGesture.reset();
mPointerVelocityControl.reset();
-
- // Remove any current spots.
- if (mPointerController != nullptr) {
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
- mPointerController->clearSpots();
- }
return out;
}
@@ -2951,8 +2831,6 @@
mPointerVelocityControl.reset();
}
- const auto [x, y] = mPointerController->getPosition();
-
mPointerGesture.currentGestureMode = PointerGesture::Mode::BUTTON_CLICK_OR_DRAG;
mPointerGesture.currentGestureIdBits.clear();
mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId);
@@ -2961,8 +2839,6 @@
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
- mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
- mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
} else if (currentFingerCount == 0) {
// Case 3. No fingers down and button is not pressed. (NEUTRAL)
@@ -2977,9 +2853,8 @@
mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP_DRAG) &&
lastFingerCount == 1) {
if (when <= mPointerGesture.tapDownTime + mConfig.pointerGestureTapInterval) {
- const auto [x, y] = mPointerController->getPosition();
- if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop &&
- fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
+ if (fabs(0.f - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop &&
+ fabs(0.f - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
ALOGD_IF(DEBUG_GESTURES, "Gestures: TAP");
mPointerGesture.tapUpTime = when;
@@ -3006,7 +2881,7 @@
tapped = true;
} else {
ALOGD_IF(DEBUG_GESTURES, "Gestures: Not a TAP, deltaX=%f, deltaY=%f",
- x - mPointerGesture.tapX, y - mPointerGesture.tapY);
+ 0.f - mPointerGesture.tapX, 0.f - mPointerGesture.tapY);
}
} else {
if (DEBUG_GESTURES) {
@@ -3038,13 +2913,12 @@
mPointerGesture.currentGestureMode = PointerGesture::Mode::HOVER;
if (mPointerGesture.lastGestureMode == PointerGesture::Mode::TAP) {
if (when <= mPointerGesture.tapUpTime + mConfig.pointerGestureTapDragInterval) {
- const auto [x, y] = mPointerController->getPosition();
- if (fabs(x - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop &&
- fabs(y - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
+ if (fabs(0.f - mPointerGesture.tapX) <= mConfig.pointerGestureTapSlop &&
+ fabs(0.f - mPointerGesture.tapY) <= mConfig.pointerGestureTapSlop) {
mPointerGesture.currentGestureMode = PointerGesture::Mode::TAP_DRAG;
} else {
ALOGD_IF(DEBUG_GESTURES, "Gestures: Not a TAP_DRAG, deltaX=%f, deltaY=%f",
- x - mPointerGesture.tapX, y - mPointerGesture.tapY);
+ 0.f - mPointerGesture.tapX, 0.f - mPointerGesture.tapY);
}
} else {
ALOGD_IF(DEBUG_GESTURES, "Gestures: Not a TAP_DRAG, %0.3fms time since up",
@@ -3074,8 +2948,6 @@
down = false;
}
- const auto [x, y] = mPointerController->getPosition();
-
mPointerGesture.currentGestureIdBits.clear();
mPointerGesture.currentGestureIdBits.markBit(mPointerGesture.activeGestureId);
mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
@@ -3083,16 +2955,14 @@
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
- mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
- mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
down ? 1.0f : 0.0f);
if (lastFingerCount == 0 && currentFingerCount != 0) {
mPointerGesture.resetTap();
mPointerGesture.tapDownTime = when;
- mPointerGesture.tapX = x;
- mPointerGesture.tapY = y;
+ mPointerGesture.tapX = 0.f;
+ mPointerGesture.tapY = 0.f;
}
} else {
// Case 5. At least two fingers down, button is not pressed. (PRESS, SWIPE or FREEFORM)
@@ -3243,8 +3113,8 @@
mCurrentRawState.rawPointerData
.getCentroidOfTouchingPointers(&mPointerGesture.referenceTouchX,
&mPointerGesture.referenceTouchY);
- std::tie(mPointerGesture.referenceGestureX, mPointerGesture.referenceGestureY) =
- mPointerController->getPosition();
+ mPointerGesture.referenceGestureX = 0.f;
+ mPointerGesture.referenceGestureY = 0.f;
}
// Clear the reference deltas for fingers not yet included in the reference calculation.
@@ -3539,8 +3409,6 @@
rotateDelta(mInputDeviceOrientation, &deltaX, &deltaY);
mPointerVelocityControl.move(when, &deltaX, &deltaY);
-
- mPointerController->move(deltaX, deltaY);
}
std::list<NotifyArgs> TouchInputMapper::dispatchPointerStylus(nsecs_t when, nsecs_t readTime,
@@ -3557,13 +3425,6 @@
float x = mCurrentCookedState.cookedPointerData.pointerCoords[index].getX();
float y = mCurrentCookedState.cookedPointerData.pointerCoords[index].getY();
- // Styluses are configured specifically for one display. We only update the
- // PointerController for this stylus if the PointerController is configured for
- // the same display as this stylus,
- if (getAssociatedDisplayId() == mViewport.displayId) {
- mPointerController->setPosition(x, y);
- std::tie(x, y) = mPointerController->getPosition();
- }
mPointerSimple.currentCoords = mCurrentCookedState.cookedPointerData.pointerCoords[index];
mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
@@ -3601,12 +3462,9 @@
down = isPointerDown(mCurrentRawState.buttonState);
hovering = !down;
- const auto [x, y] = mPointerController->getPosition();
const uint32_t currentIndex = mCurrentRawState.rawPointerData.idToIndex[id];
mPointerSimple.currentCoords =
mCurrentCookedState.cookedPointerData.pointerCoords[currentIndex];
- mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
- mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
hovering ? 0.0f : 1.0f);
mPointerSimple.currentProperties.id = 0;
@@ -3619,8 +3477,7 @@
hovering = false;
}
- const int32_t displayId = mPointerController->getDisplayId();
- return dispatchPointerSimple(when, readTime, policyFlags, down, hovering, displayId);
+ return dispatchPointerSimple(when, readTime, policyFlags, down, hovering, ADISPLAY_ID_NONE);
}
std::list<NotifyArgs> TouchInputMapper::abortPointerMouse(nsecs_t when, nsecs_t readTime,
@@ -3641,17 +3498,6 @@
int32_t metaState = getContext()->getGlobalMetaState();
auto cursorPosition = mPointerSimple.currentCoords.getXYValue();
- if (displayId == mPointerController->getDisplayId()) {
- std::tie(cursorPosition.x, cursorPosition.y) = mPointerController->getPosition();
- if (down || hovering) {
- mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
- mPointerController->clearSpots();
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
- } else if (!down && !hovering && (mPointerSimple.down || mPointerSimple.hovering)) {
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
- }
- }
-
if (mPointerSimple.down && !down) {
mPointerSimple.down = false;
@@ -3787,9 +3633,6 @@
mPointerSimple.lastCursorX, mPointerSimple.lastCursorY,
mPointerSimple.downTime,
/*videoFrames=*/{}));
- if (mPointerController != nullptr) {
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
- }
}
mPointerSimple.reset();
return out;
@@ -3841,32 +3684,11 @@
}
const int32_t displayId = getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE);
- const bool showDirectStylusPointer = mConfig.stylusPointerIconEnabled &&
- mDeviceMode == DeviceMode::DIRECT && isStylusEvent(source, pointerProperties) &&
- mPointerController && displayId != ADISPLAY_ID_NONE &&
- displayId == mPointerController->getDisplayId();
- if (showDirectStylusPointer) {
- switch (action & AMOTION_EVENT_ACTION_MASK) {
- case AMOTION_EVENT_ACTION_HOVER_ENTER:
- case AMOTION_EVENT_ACTION_HOVER_MOVE:
- mPointerController->setPresentation(
- PointerControllerInterface::Presentation::STYLUS_HOVER);
- mPointerController
- ->setPosition(mCurrentCookedState.cookedPointerData.pointerCoords[0].getX(),
- mCurrentCookedState.cookedPointerData.pointerCoords[0]
- .getY());
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
- break;
- case AMOTION_EVENT_ACTION_HOVER_EXIT:
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
- break;
- }
- }
float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
if (mDeviceMode == DeviceMode::POINTER) {
- std::tie(xCursorPosition, yCursorPosition) = mPointerController->getPosition();
+ xCursorPosition = yCursorPosition = 0.f;
}
const int32_t deviceId = getDeviceId();
std::vector<TouchVideoFrame> frames = getDeviceContext().getVideoFrames();
@@ -4138,7 +3960,7 @@
std::optional<int32_t> TouchInputMapper::getAssociatedDisplayId() {
if (mParameters.hasAssociatedDisplay) {
if (mDeviceMode == DeviceMode::POINTER) {
- return std::make_optional(mPointerController->getDisplayId());
+ return ADISPLAY_ID_NONE;
} else {
return std::make_optional(mViewport.displayId);
}
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index 9b7fe93..6485ab2 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -46,7 +46,6 @@
#include "InputMapper.h"
#include "InputReaderBase.h"
#include "NotifyArgs.h"
-#include "PointerControllerInterface.h"
#include "StylusState.h"
#include "TouchButtonAccumulator.h"
@@ -392,9 +391,6 @@
// The time the primary pointer last went down.
nsecs_t mDownTime{0};
- // The pointer controller, or null if the device is not a pointer.
- std::shared_ptr<PointerControllerInterface> mPointerController;
-
std::vector<VirtualKey> mVirtualKeys;
explicit TouchInputMapper(InputDeviceContext& deviceContext,
@@ -837,9 +833,6 @@
// Returns if this touch device is a touch screen with an associated display.
bool isTouchScreen();
- // Updates touch spots if they are enabled. Should only be used when this device is a
- // touchscreen.
- void updateTouchSpots();
bool isPointInsidePhysicalFrame(int32_t x, int32_t y) const;
const VirtualKey* findVirtualKeyHit(int32_t x, int32_t y);
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index f558ba1..6a38aa7 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -47,8 +47,6 @@
namespace {
-static const bool ENABLE_POINTER_CHOREOGRAPHER = input_flags::enable_pointer_choreographer();
-
/**
* Log details of each gesture output by the gestures library.
* Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires
@@ -237,20 +235,13 @@
TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
const InputReaderConfiguration& readerConfig)
- : TouchpadInputMapper(deviceContext, readerConfig, ENABLE_POINTER_CHOREOGRAPHER) {}
-
-TouchpadInputMapper::TouchpadInputMapper(InputDeviceContext& deviceContext,
- const InputReaderConfiguration& readerConfig,
- bool enablePointerChoreographer)
: InputMapper(deviceContext, readerConfig),
mGestureInterpreter(NewGestureInterpreter(), DeleteGestureInterpreter),
- mPointerController(getContext()->getPointerController(getDeviceId())),
mTimerProvider(*getContext()),
mStateConverter(deviceContext, mMotionAccumulator),
mGestureConverter(*getContext(), deviceContext, getDeviceId()),
mCapturedEventConverter(*getContext(), deviceContext, mMotionAccumulator, getDeviceId()),
- mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())),
- mEnablePointerChoreographer(enablePointerChoreographer) {
+ mMetricsId(metricsIdFromInputDeviceIdentifier(deviceContext.getDeviceIdentifier())) {
RawAbsoluteAxisInfo slotAxisInfo;
deviceContext.getAbsoluteAxisInfo(ABS_MT_SLOT, &slotAxisInfo);
if (!slotAxisInfo.valid || slotAxisInfo.maxValue <= 0) {
@@ -277,10 +268,6 @@
}
TouchpadInputMapper::~TouchpadInputMapper() {
- if (mPointerController != nullptr) {
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
- }
-
// The gesture interpreter's destructor will try to free its property and timer providers,
// calling PropertyProvider::freeProperty and TimerProvider::freeTimer using a raw pointers.
// Depending on the declaration order in TouchpadInputMapper.h, those providers may have already
@@ -342,33 +329,12 @@
// Only generate events for the associated display.
mDisplayId = assocViewport->displayId;
resolvedViewport = *assocViewport;
- if (!mEnablePointerChoreographer) {
- const bool mismatchedPointerDisplay =
- (assocViewport->displayId != mPointerController->getDisplayId());
- if (mismatchedPointerDisplay) {
- ALOGW("Touchpad \"%s\" associated viewport display does not match pointer "
- "controller",
- mDeviceContext.getName().c_str());
- mDisplayId.reset();
- }
- }
} else {
// The InputDevice is not associated with a viewport, but it controls the mouse pointer.
- if (mEnablePointerChoreographer) {
- // Always use DISPLAY_ID_NONE for touchpad events.
- // PointerChoreographer will make it target the correct the displayId later.
- resolvedViewport =
- getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
- mDisplayId = resolvedViewport ? std::make_optional(ADISPLAY_ID_NONE) : std::nullopt;
- } else {
- mDisplayId = mPointerController->getDisplayId();
- if (auto v = config.getDisplayViewportById(*mDisplayId); v) {
- resolvedViewport = *v;
- }
- if (auto bounds = mPointerController->getBounds(); bounds) {
- boundsInLogicalDisplay = *bounds;
- }
- }
+ // Always use DISPLAY_ID_NONE for touchpad events.
+ // PointerChoreographer will make it target the correct the displayId later.
+ resolvedViewport = getContext()->getPolicy()->getPointerViewportForAssociatedDisplay();
+ mDisplayId = resolvedViewport ? std::make_optional(ADISPLAY_ID_NONE) : std::nullopt;
}
mGestureConverter.setDisplayId(mDisplayId);
@@ -422,7 +388,6 @@
// The touchpad is being captured, so we need to tidy up any fake fingers etc. that are
// still being reported for a gesture in progress.
out += reset(when);
- mPointerController->fade(PointerControllerInterface::Transition::IMMEDIATE);
} else {
// We're transitioning from captured to uncaptured.
mCapturedEventConverter.reset();
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
index 9f272cf..9f685ec 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
@@ -72,10 +72,6 @@
void resetGestureInterpreter(nsecs_t when);
explicit TouchpadInputMapper(InputDeviceContext& deviceContext,
const InputReaderConfiguration& readerConfig);
- // Constructor for testing.
- explicit TouchpadInputMapper(InputDeviceContext& deviceContext,
- const InputReaderConfiguration& readerConfig,
- bool enablePointerChoreographer);
void updatePalmDetectionMetrics();
[[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime,
SelfContainedHardwareState schs);
@@ -83,7 +79,6 @@
std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)>
mGestureInterpreter;
- std::shared_ptr<PointerControllerInterface> mPointerController;
PropertyProvider mPropertyProvider;
TimerProvider mTimerProvider;
@@ -111,8 +106,6 @@
// Tracking IDs for touches that have at some point been reported as palms by the touchpad.
std::set<int32_t> mPalmTrackingIds;
- const bool mEnablePointerChoreographer;
-
// The display that events generated by this mapper should target. This can be set to
// ADISPLAY_ID_NONE to target the focused display. If there is no display target (i.e.
// std::nullopt), all events will be ignored.
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index 39a88e5..ff95857 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -66,7 +66,6 @@
const InputDeviceContext& deviceContext, int32_t deviceId)
: mDeviceId(deviceId),
mReaderContext(readerContext),
- mPointerController(readerContext.getPointerController(deviceId)),
mEnableFlingStop(input_flags::enable_touchpad_fling_stop()) {
deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_X, &mXAxisInfo);
deviceContext.getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &mYAxisInfo);
@@ -174,7 +173,6 @@
const Gesture& gesture) {
float deltaX = gesture.details.move.dx;
float deltaY = gesture.details.move.dy;
- const auto [oldXCursorPosition, oldYCursorPosition] = mPointerController->getPosition();
if (ENABLE_TOUCHPAD_PALM_REJECTION_V2) {
bool wasHoverCancelled = mIsHoverCancelled;
// Gesture will be cancelled if it started before the user started typing and
@@ -185,8 +183,7 @@
if (!wasHoverCancelled && mIsHoverCancelled) {
// This is the first event of the cancelled gesture, we won't return because we need to
// generate a HOVER_EXIT event
- mPointerController->fade(PointerControllerInterface::Transition::GRADUAL);
- return exitHover(when, readTime, oldXCursorPosition, oldYCursorPosition);
+ return exitHover(when, readTime);
} else if (mIsHoverCancelled) {
return {};
}
@@ -202,30 +199,23 @@
(std::abs(deltaX) > 0 || std::abs(deltaY) > 0)) {
enableTapToClick(when);
}
- mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
- mPointerController->move(deltaX, deltaY);
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
}
std::list<NotifyArgs> out;
const bool down = isPointerDown(mButtonState);
if (!down) {
- out += enterHover(when, readTime, oldXCursorPosition, oldYCursorPosition);
+ out += enterHover(when, readTime);
}
- const auto [newXCursorPosition, newYCursorPosition] = mPointerController->getPosition();
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, newXCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, newYCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, down ? 1.0f : 0.0f);
const int32_t action = down ? AMOTION_EVENT_ACTION_MOVE : AMOTION_EVENT_ACTION_HOVER_MOVE;
out.push_back(makeMotionArgs(when, readTime, action, /*actionButton=*/0, mButtonState,
- /*pointerCount=*/1, &coords, newXCursorPosition,
- newYCursorPosition));
+ /*pointerCount=*/1, &coords));
return out;
}
@@ -233,15 +223,8 @@
const Gesture& gesture) {
std::list<NotifyArgs> out = {};
- mPointerController->setPresentation(PointerControllerInterface::Presentation::POINTER);
- mPointerController->unfade(PointerControllerInterface::Transition::IMMEDIATE);
-
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
-
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
@@ -274,16 +257,15 @@
newButtonState |= actionButton;
pressEvents.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_BUTTON_PRESS,
actionButton, newButtonState,
- /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
+ /*pointerCount=*/1, &coords));
}
}
if (!isPointerDown(mButtonState) && isPointerDown(newButtonState)) {
mDownTime = when;
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/* actionButton= */ 0, newButtonState, /* pointerCount= */ 1,
- &coords, xCursorPosition, yCursorPosition));
+ &coords));
}
out.splice(out.end(), pressEvents);
@@ -299,16 +281,15 @@
newButtonState &= ~actionButton;
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_BUTTON_RELEASE,
actionButton, newButtonState, /* pointerCount= */ 1,
- &coords, xCursorPosition, yCursorPosition));
+ &coords));
}
}
if (isPointerDown(mButtonState) && !isPointerDown(newButtonState)) {
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.0f);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0,
- newButtonState, /* pointerCount= */ 1, &coords,
- xCursorPosition, yCursorPosition));
+ newButtonState, /* pointerCount= */ 1, &coords));
mButtonState = newButtonState;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
}
mButtonState = newButtonState;
return out;
@@ -316,12 +297,9 @@
std::list<NotifyArgs> GestureConverter::releaseAllButtons(nsecs_t when, nsecs_t readTime) {
std::list<NotifyArgs> out;
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
const bool pointerDown = isPointerDown(mButtonState);
@@ -332,17 +310,15 @@
if (mButtonState & button) {
newButtonState &= ~button;
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_BUTTON_RELEASE,
- button, newButtonState, /*pointerCount=*/1, &coords,
- xCursorPosition, yCursorPosition));
+ button, newButtonState, /*pointerCount=*/1, &coords));
}
}
mButtonState = 0;
if (pointerDown) {
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.0f);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /*actionButton=*/0,
- mButtonState, /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ mButtonState, /*pointerCount=*/1, &coords));
+ out += enterHover(when, readTime);
}
return out;
}
@@ -351,19 +327,15 @@
const Gesture& gesture) {
std::list<NotifyArgs> out;
PointerCoords& coords = mFakeFingerCoords[0];
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
if (mCurrentClassification != MotionClassification::TWO_FINGER_SWIPE) {
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE;
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
mDownTime = when;
NotifyMotionArgs args =
makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition);
+ mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data());
args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
out.push_back(args);
}
@@ -378,8 +350,7 @@
coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, -gesture.details.scroll.dy);
NotifyMotionArgs args =
makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition);
+ mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data());
args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
out.push_back(args);
return out;
@@ -409,28 +380,22 @@
// avoid side effects (e.g. activation of UI elements).
// TODO(b/326056750): add an API for fling stops.
mFlingMayBeInProgress = false;
- const auto [xCursorPosition, yCursorPosition] =
- mPointerController->getPosition();
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
std::list<NotifyArgs> out;
mDownTime = when;
mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE;
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/*actionButton=*/0, /*buttonState=*/0,
- /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
+ /*pointerCount=*/1, &coords));
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_CANCEL,
/*actionButton=*/0, /*buttonState=*/0,
- /*pointerCount=*/1, &coords, xCursorPosition,
- yCursorPosition));
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ /*pointerCount=*/1, &coords));
+ out += enterHover(when, readTime);
mCurrentClassification = MotionClassification::NONE;
return out;
} else {
@@ -455,17 +420,15 @@
std::list<NotifyArgs> GestureConverter::endScroll(nsecs_t when, nsecs_t readTime) {
std::list<NotifyArgs> out;
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, 0);
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, 0);
NotifyMotionArgs args =
makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition);
+ mButtonState, /* pointerCount= */ 1, mFakeFingerCoords.data());
args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE;
out.push_back(args);
mCurrentClassification = MotionClassification::NONE;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
return out;
}
@@ -475,26 +438,26 @@
float dx, float dy) {
std::list<NotifyArgs> out = {};
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) {
// If the user changes the number of fingers mid-way through a swipe (e.g. they start with
// three and then put a fourth finger down), the gesture library will treat it as two
// separate swipes with an appropriate lift event between them, so we don't have to worry
// about the finger count changing mid-swipe.
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::MULTI_FINGER_SWIPE;
mSwipeFingerCount = fingerCount;
constexpr float FAKE_FINGER_SPACING = 100;
- float xCoord = xCursorPosition - FAKE_FINGER_SPACING * (mSwipeFingerCount - 1) / 2;
+ float xCoord = 0.f - FAKE_FINGER_SPACING * (mSwipeFingerCount - 1) / 2;
for (size_t i = 0; i < mSwipeFingerCount; i++) {
PointerCoords& coords = mFakeFingerCoords[i];
coords.clear();
+ // PointerChoreographer will add the cursor position to these pointers.
coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCoord);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
xCoord += FAKE_FINGER_SPACING;
}
@@ -504,14 +467,13 @@
fingerCount);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 1,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
for (size_t i = 1; i < mSwipeFingerCount; i++) {
out.push_back(makeMotionArgs(when, readTime,
AMOTION_EVENT_ACTION_POINTER_DOWN |
(i << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
/* actionButton= */ 0, mButtonState,
- /* pointerCount= */ i + 1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition));
+ /* pointerCount= */ i + 1, mFakeFingerCoords.data()));
}
}
float rotatedDeltaX = dx, rotatedDeltaY = -dy;
@@ -529,7 +491,7 @@
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, yOffset);
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0,
mButtonState, /* pointerCount= */ mSwipeFingerCount,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
return out;
}
@@ -539,7 +501,6 @@
if (mCurrentClassification != MotionClassification::MULTI_FINGER_SWIPE) {
return out;
}
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_X_OFFSET, 0);
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, 0);
@@ -548,22 +509,20 @@
AMOTION_EVENT_ACTION_POINTER_UP |
((i - 1) << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
/* actionButton= */ 0, mButtonState, /* pointerCount= */ i,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
}
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 1,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SWIPE_FINGER_COUNT, 0);
mCurrentClassification = MotionClassification::NONE;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
mSwipeFingerCount = 0;
return out;
}
[[nodiscard]] std::list<NotifyArgs> GestureConverter::handlePinch(nsecs_t when, nsecs_t readTime,
const Gesture& gesture) {
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
-
// Pinch gesture phases are reported a little differently from others, in that the same details
// struct is used for all phases of the gesture, just with different zoom_state values. When
// zoom_state is START or END, dz will always be 1, so we don't need to move the pointers in
@@ -575,28 +534,27 @@
gesture.details.pinch.zoom_state);
std::list<NotifyArgs> out;
- out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += exitHover(when, readTime);
mCurrentClassification = MotionClassification::PINCH;
mPinchFingerSeparation = INITIAL_PINCH_SEPARATION_PX;
+ // PointerChoreographer will add the cursor position to these pointers.
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 1.0);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition - mPinchFingerSeparation / 2);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f - mPinchFingerSeparation / 2);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition + mPinchFingerSeparation / 2);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f + mPinchFingerSeparation / 2);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
mDownTime = when;
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 1,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
out.push_back(makeMotionArgs(when, readTime,
AMOTION_EVENT_ACTION_POINTER_DOWN |
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 2,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
return out;
}
@@ -605,77 +563,65 @@
}
mPinchFingerSeparation *= gesture.details.pinch.dz;
+ // PointerChoreographer will add the cursor position to these pointers.
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR,
gesture.details.pinch.dz);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition - mPinchFingerSeparation / 2);
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X,
- xCursorPosition + mPinchFingerSeparation / 2);
- mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f - mPinchFingerSeparation / 2);
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X, 0.f + mPinchFingerSeparation / 2);
+ mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, 0.f);
return {makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /*actionButton=*/0,
- mButtonState, /*pointerCount=*/2, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition)};
+ mButtonState, /*pointerCount=*/2, mFakeFingerCoords.data())};
}
std::list<NotifyArgs> GestureConverter::endPinch(nsecs_t when, nsecs_t readTime) {
std::list<NotifyArgs> out;
- const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 1.0);
out.push_back(makeMotionArgs(when, readTime,
AMOTION_EVENT_ACTION_POINTER_UP |
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT,
/*actionButton=*/0, mButtonState, /*pointerCount=*/2,
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mFakeFingerCoords.data()));
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /*actionButton=*/0,
- mButtonState, /*pointerCount=*/1, mFakeFingerCoords.data(),
- xCursorPosition, yCursorPosition));
+ mButtonState, /*pointerCount=*/1, mFakeFingerCoords.data()));
mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 0);
mCurrentClassification = MotionClassification::NONE;
- out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ out += enterHover(when, readTime);
return out;
}
-std::list<NotifyArgs> GestureConverter::enterHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition) {
+std::list<NotifyArgs> GestureConverter::enterHover(nsecs_t when, nsecs_t readTime) {
if (!mIsHovering) {
mIsHovering = true;
- return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_ENTER, xCursorPosition,
- yCursorPosition)};
+ return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_ENTER)};
} else {
return {};
}
}
-std::list<NotifyArgs> GestureConverter::exitHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition) {
+std::list<NotifyArgs> GestureConverter::exitHover(nsecs_t when, nsecs_t readTime) {
if (mIsHovering) {
mIsHovering = false;
- return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_EXIT, xCursorPosition,
- yCursorPosition)};
+ return {makeHoverEvent(when, readTime, AMOTION_EVENT_ACTION_HOVER_EXIT)};
} else {
return {};
}
}
-NotifyMotionArgs GestureConverter::makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action,
- float xCursorPosition, float yCursorPosition) {
+NotifyMotionArgs GestureConverter::makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action) {
PointerCoords coords;
coords.clear();
- coords.setAxisValue(AMOTION_EVENT_AXIS_X, xCursorPosition);
- coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, 0);
coords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, 0);
return makeMotionArgs(when, readTime, action, /*actionButton=*/0, mButtonState,
- /*pointerCount=*/1, &coords, xCursorPosition, yCursorPosition);
+ /*pointerCount=*/1, &coords);
}
NotifyMotionArgs GestureConverter::makeMotionArgs(nsecs_t when, nsecs_t readTime, int32_t action,
int32_t actionButton, int32_t buttonState,
uint32_t pointerCount,
- const PointerCoords* pointerCoords,
- float xCursorPosition, float yCursorPosition) {
+ const PointerCoords* pointerCoords) {
return {mReaderContext.getNextId(),
when,
readTime,
@@ -695,8 +641,8 @@
pointerCoords,
/* xPrecision= */ 1.0f,
/* yPrecision= */ 1.0f,
- xCursorPosition,
- yCursorPosition,
+ /* xCursorPosition= */ 0.f,
+ /* yCursorPosition= */ 0.f,
/* downTime= */ mDownTime,
/* videoFrames= */ {}};
}
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.h b/services/inputflinger/reader/mapper/gestures/GestureConverter.h
index c8f437e..e6ced0f 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.h
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.h
@@ -20,7 +20,6 @@
#include <list>
#include <memory>
-#include <PointerControllerInterface.h>
#include <android/input.h>
#include <utils/Timers.h>
@@ -41,8 +40,7 @@
*/
constexpr std::chrono::nanoseconds TAP_ENABLE_DELAY_NANOS = 400ms;
-// Converts Gesture structs from the gestures library into NotifyArgs and the appropriate
-// PointerController calls.
+// Converts Gesture structs from the gestures library into NotifyArgs.
class GestureConverter {
public:
GestureConverter(InputReaderContext& readerContext, const InputDeviceContext& deviceContext,
@@ -85,18 +83,14 @@
const Gesture& gesture);
[[nodiscard]] std::list<NotifyArgs> endPinch(nsecs_t when, nsecs_t readTime);
- [[nodiscard]] std::list<NotifyArgs> enterHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition);
- [[nodiscard]] std::list<NotifyArgs> exitHover(nsecs_t when, nsecs_t readTime,
- float xCursorPosition, float yCursorPosition);
+ [[nodiscard]] std::list<NotifyArgs> enterHover(nsecs_t when, nsecs_t readTime);
+ [[nodiscard]] std::list<NotifyArgs> exitHover(nsecs_t when, nsecs_t readTime);
- NotifyMotionArgs makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action,
- float xCursorPosition, float yCursorPosition);
+ NotifyMotionArgs makeHoverEvent(nsecs_t when, nsecs_t readTime, int32_t action);
NotifyMotionArgs makeMotionArgs(nsecs_t when, nsecs_t readTime, int32_t action,
int32_t actionButton, int32_t buttonState,
- uint32_t pointerCount, const PointerCoords* pointerCoords,
- float xCursorPosition, float yCursorPosition);
+ uint32_t pointerCount, const PointerCoords* pointerCoords);
void enableTapToClick(nsecs_t when);
bool mIsHoverCancelled{false};
@@ -104,7 +98,6 @@
const int32_t mDeviceId;
InputReaderContext& mReaderContext;
- std::shared_ptr<PointerControllerInterface> mPointerController;
const bool mEnableFlingStop;
std::optional<int32_t> mDisplayId;
diff --git a/services/inputflinger/tests/CursorInputMapper_test.cpp b/services/inputflinger/tests/CursorInputMapper_test.cpp
index c44f880..c237fb6 100644
--- a/services/inputflinger/tests/CursorInputMapper_test.cpp
+++ b/services/inputflinger/tests/CursorInputMapper_test.cpp
@@ -29,7 +29,6 @@
#include <linux/input.h>
#include <utils/Timers.h>
-#include "FakePointerController.h"
#include "InputMapperTest.h"
#include "InputReaderBase.h"
#include "InterfaceMocks.h"
@@ -157,12 +156,9 @@
mFakePolicy->addDisplayViewport(createPrimaryViewport(ui::Rotation::Rotation0));
}
- virtual bool isPointerChoreographerEnabled() { return false; }
-
void createMapper() {
createDevice();
- mMapper = createInputMapper<CursorInputMapper>(*mDeviceContext, mReaderConfiguration,
- isPointerChoreographerEnabled());
+ mMapper = createInputMapper<CursorInputMapper>(*mDeviceContext, mReaderConfiguration);
}
void setPointerCapture(bool enabled) {
@@ -200,8 +196,6 @@
input_flags::enable_new_mouse_pointer_ballistics(false);
CursorInputMapperUnitTestBase::SetUp();
}
-
- bool isPointerChoreographerEnabled() override { return false; }
};
TEST_F(CursorInputMapperUnitTest, GetSourcesReturnsMouseInPointerMode) {
@@ -325,12 +319,9 @@
// Disable pointer capture. Afterwards, events should be generated the usual way.
setPointerCapture(false);
- const auto expectedCoords = CursorInputMapperUnitTest::isPointerChoreographerEnabled()
- ? WithCoords(0, 0)
- : WithCoords(INITIAL_CURSOR_X + 10.0f, INITIAL_CURSOR_Y + 20.0f);
- const auto expectedCursorPosition = CursorInputMapperUnitTest::isPointerChoreographerEnabled()
- ? WithCursorPosition(INVALID_CURSOR_POSITION, INVALID_CURSOR_POSITION)
- : WithCursorPosition(INITIAL_CURSOR_X + 10.0f, INITIAL_CURSOR_Y + 20.0f);
+ const auto expectedCoords = WithCoords(0, 0);
+ const auto expectedCursorPosition =
+ WithCursorPosition(INVALID_CURSOR_POSITION, INVALID_CURSOR_POSITION);
args.clear();
args += process(EV_REL, REL_X, 10);
args += process(EV_REL, REL_Y, 20);
@@ -342,42 +333,6 @@
WithRelativeMotion(10.0f, 20.0f)))));
}
-TEST_F(CursorInputMapperUnitTest,
- PopulateDeviceInfoReturnsRangeFromPointerControllerInPointerMode) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- mFakePolicy->clearViewports();
- mFakePointerController->clearBounds();
- createMapper();
-
- InputDeviceInfo info;
- mMapper->populateDeviceInfo(info);
-
- // Initially there should not be a valid motion range because there's no viewport or pointer
- // bounds.
- ASSERT_EQ(nullptr, info.getMotionRange(AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_MOUSE));
- ASSERT_EQ(nullptr, info.getMotionRange(AINPUT_MOTION_RANGE_Y, AINPUT_SOURCE_MOUSE));
- ASSERT_NO_FATAL_FAILURE(assertMotionRange(info, AINPUT_MOTION_RANGE_PRESSURE,
- AINPUT_SOURCE_MOUSE, 0.0f, 1.0f, 0.0f, 0.0f));
-
- // When the bounds are set, then there should be a valid motion range.
- mFakePointerController->setBounds(1, 2, 800 - 1, 480 - 1);
- mFakePolicy->addDisplayViewport(createPrimaryViewport(ui::Rotation::Rotation0));
- std::list<NotifyArgs> args =
- mMapper->reconfigure(systemTime(), mReaderConfiguration,
- InputReaderConfiguration::Change::DISPLAY_INFO);
- ASSERT_THAT(args, testing::IsEmpty());
-
- InputDeviceInfo info2;
- mMapper->populateDeviceInfo(info2);
-
- ASSERT_NO_FATAL_FAILURE(assertMotionRange(info2, AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_MOUSE, 1,
- 800 - 1, 0.0f, 0.0f));
- ASSERT_NO_FATAL_FAILURE(assertMotionRange(info2, AINPUT_MOTION_RANGE_Y, AINPUT_SOURCE_MOUSE, 2,
- 480 - 1, 0.0f, 0.0f));
- ASSERT_NO_FATAL_FAILURE(assertMotionRange(info2, AINPUT_MOTION_RANGE_PRESSURE,
- AINPUT_SOURCE_MOUSE, 0.0f, 1.0f, 0.0f, 0.0f));
-}
-
TEST_F(CursorInputMapperUnitTest, PopulateDeviceInfoReturnsScaledRangeInNavigationMode) {
mPropertyMap.addProperty("cursor.mode", "navigation");
createMapper();
@@ -649,334 +604,9 @@
ASSERT_NO_FATAL_FAILURE(testMotionRotation(-1, 1, 1, 1));
}
-TEST_F(CursorInputMapperUnitTest, PointerCaptureDisablesOrientationChanges) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- DisplayViewport viewport = createPrimaryViewport(ui::Rotation::Rotation90);
- mFakePointerController->setDisplayViewport(viewport);
- mReaderConfiguration.setDisplayViewports({viewport});
- createMapper();
-
- // Verify that the coordinates are rotated.
- std::list<NotifyArgs> args;
- args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE),
- WithRelativeMotion(-20.0f, 10.0f)))));
-
- // Enable Pointer Capture.
- setPointerCapture(true);
-
- // Move and verify rotation is not applied.
- args = process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(ACTION_MOVE),
- WithSource(AINPUT_SOURCE_MOUSE_RELATIVE),
- WithCoords(10.0f, 20.0f)))));
-}
-
-TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdNoAssociatedViewport) {
- DisplayViewport primaryViewport = createPrimaryViewport(ui::Rotation::Rotation90);
- DisplayViewport secondaryViewport = createSecondaryViewport();
- mReaderConfiguration.setDisplayViewports({primaryViewport, secondaryViewport});
- // Set up the secondary display as the display on which the pointer should be shown. The
- // InputDevice is not associated with any display.
- mFakePointerController->setDisplayViewport(secondaryViewport);
- mFakePointerController->setPosition(100, 200);
- createMapper();
-
- // Ensure input events are generated for the secondary display.
- std::list<NotifyArgs> args;
- args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE),
- WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))));
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(110.0f, 220.0f));
-}
-
-TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdWithAssociatedViewport) {
- DisplayViewport primaryViewport = createPrimaryViewport(ui::Rotation::Rotation90);
- DisplayViewport secondaryViewport = createSecondaryViewport();
- mReaderConfiguration.setDisplayViewports({primaryViewport, secondaryViewport});
- // Set up the secondary display as the display on which the pointer should be shown.
- mFakePointerController->setDisplayViewport(secondaryViewport);
- mFakePointerController->setPosition(100, 200);
- createDevice();
- // Associate the InputDevice with the secondary display.
- ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport);
- mMapper = createInputMapper<
- CursorInputMapper>(deviceContext, mReaderConfiguration,
- CursorInputMapperUnitTest::isPointerChoreographerEnabled());
-
- // Ensure input events are generated for the secondary display.
- std::list<NotifyArgs> args;
- args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(HOVER_MOVE), WithSource(AINPUT_SOURCE_MOUSE),
- WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(110.0f, 220.0f)))));
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(110.0f, 220.0f));
-}
-
-TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdIgnoresEventsForMismatchedPointerDisplay) {
- DisplayViewport primaryViewport = createPrimaryViewport(ui::Rotation::Rotation90);
- DisplayViewport secondaryViewport = createSecondaryViewport();
- mReaderConfiguration.setDisplayViewports({primaryViewport, secondaryViewport});
- // Set up the primary display as the display on which the pointer should be shown.
- mFakePointerController->setDisplayViewport(primaryViewport);
- createDevice();
- // Associate the InputDevice with the secondary display.
- ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport);
- mMapper = createInputMapper<
- CursorInputMapper>(deviceContext, mReaderConfiguration,
- CursorInputMapperUnitTest::isPointerChoreographerEnabled());
-
- // The mapper should not generate any events because it is associated with a display that is
- // different from the pointer display.
- std::list<NotifyArgs> args;
- args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args, testing::IsEmpty());
-}
-
-TEST_F(CursorInputMapperUnitTest, ProcessShouldHandleAllButtons) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- createMapper();
-
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(100, 200);
-
- std::list<NotifyArgs> args;
-
- // press BTN_LEFT, release BTN_LEFT
- args += process(ARBITRARY_TIME, EV_KEY, BTN_LEFT, 1);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithCoords(100.0f, 200.0f), WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithCoords(100.0f, 200.0f), WithPressure(1.0f)))));
- args.clear();
-
- args += process(ARBITRARY_TIME, EV_KEY, BTN_LEFT, 0);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithButtonState(0), WithCoords(100.0f, 200.0f),
- WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithButtonState(0), WithCoords(100.0f, 200.0f),
- WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithButtonState(0), WithCoords(100.0f, 200.0f),
- WithPressure(0.0f)))));
- args.clear();
-
- // press BTN_RIGHT + BTN_MIDDLE, release BTN_RIGHT, release BTN_MIDDLE
- args += process(ARBITRARY_TIME, EV_KEY, BTN_RIGHT, 1);
- args += process(ARBITRARY_TIME, EV_KEY, BTN_MIDDLE, 1);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY |
- AMOTION_EVENT_BUTTON_TERTIARY),
- WithCoords(100.0f, 200.0f), WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithButtonState(AMOTION_EVENT_BUTTON_TERTIARY),
- WithCoords(100.0f, 200.0f), WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY |
- AMOTION_EVENT_BUTTON_TERTIARY),
- WithCoords(100.0f, 200.0f), WithPressure(1.0f)))));
- args.clear();
-
- args += process(ARBITRARY_TIME, EV_KEY, BTN_RIGHT, 0);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithButtonState(AMOTION_EVENT_BUTTON_TERTIARY),
- WithCoords(100.0f, 200.0f), WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithButtonState(AMOTION_EVENT_BUTTON_TERTIARY),
- WithCoords(100.0f, 200.0f), WithPressure(1.0f)))));
- args.clear();
-
- args += process(ARBITRARY_TIME, EV_KEY, BTN_MIDDLE, 0);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithButtonState(0), WithCoords(100.0f, 200.0f),
- WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithButtonState(0),
- WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithCoords(100.0f, 200.0f), WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithButtonState(0),
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithCoords(100.0f, 200.0f), WithPressure(0.0f)))));
-}
-
-class CursorInputMapperButtonKeyTest
- : public CursorInputMapperUnitTest,
- public testing::WithParamInterface<
- std::tuple<int32_t /*evdevCode*/, int32_t /*expectedButtonState*/,
- int32_t /*expectedKeyCode*/>> {
- virtual bool isPointerChoreographerEnabled() override { return false; }
-};
-
-TEST_P(CursorInputMapperButtonKeyTest, ProcessShouldHandleButtonKey) {
- auto [evdevCode, expectedButtonState, expectedKeyCode] = GetParam();
- mPropertyMap.addProperty("cursor.mode", "pointer");
- createMapper();
-
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(100, 200);
-
- std::list<NotifyArgs> args;
-
- args += process(ARBITRARY_TIME, EV_KEY, evdevCode, 1);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyKeyArgs>(AllOf(WithKeyAction(AKEY_EVENT_ACTION_DOWN),
- WithKeyCode(expectedKeyCode))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithButtonState(expectedButtonState),
- WithCoords(100.0f, 200.0f), WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithButtonState(expectedButtonState),
- WithCoords(100.0f, 200.0f), WithPressure(0.0f)))));
- args.clear();
-
- args += process(ARBITRARY_TIME, EV_KEY, evdevCode, 0);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithButtonState(0), WithCoords(100.0f, 200.0f),
- WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithButtonState(0), WithCoords(100.0f, 200.0f),
- WithPressure(0.0f))),
- VariantWith<NotifyKeyArgs>(AllOf(WithKeyAction(AKEY_EVENT_ACTION_UP),
- WithKeyCode(expectedKeyCode)))));
-}
-
-INSTANTIATE_TEST_SUITE_P(
- SideExtraBackAndForward, CursorInputMapperButtonKeyTest,
- testing::Values(std::make_tuple(BTN_SIDE, AMOTION_EVENT_BUTTON_BACK, AKEYCODE_BACK),
- std::make_tuple(BTN_EXTRA, AMOTION_EVENT_BUTTON_FORWARD, AKEYCODE_FORWARD),
- std::make_tuple(BTN_BACK, AMOTION_EVENT_BUTTON_BACK, AKEYCODE_BACK),
- std::make_tuple(BTN_FORWARD, AMOTION_EVENT_BUTTON_FORWARD,
- AKEYCODE_FORWARD)));
-
-TEST_F(CursorInputMapperUnitTest, ProcessShouldMoveThePointerAroundInPointerMode) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- createMapper();
-
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(100, 200);
-
- std::list<NotifyArgs> args;
-
- args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithSource(AINPUT_SOURCE_MOUSE),
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithCoords(110.0f, 220.0f), WithPressure(0.0f), WithSize(0.0f),
- WithTouchDimensions(0.0f, 0.0f), WithToolDimensions(0.0f, 0.0f),
- WithOrientation(0.0f), WithDistance(0.0f)))));
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(110.0f, 220.0f));
-}
-
-/**
- * When Pointer Capture is enabled, we expect to report unprocessed relative movements, so any
- * pointer acceleration or speed processing should not be applied.
- */
-TEST_F(CursorInputMapperUnitTest, PointerCaptureDisablesVelocityProcessing) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- const VelocityControlParameters testParams(/*scale=*/5.f, /*lowThreshold=*/0.f,
- /*highThreshold=*/100.f, /*acceleration=*/10.f);
- mReaderConfiguration.pointerVelocityControlParameters = testParams;
- mFakePolicy->setVelocityControlParams(testParams);
- createMapper();
-
- std::list<NotifyArgs> args;
-
- // Move and verify scale is applied.
- args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithSource(AINPUT_SOURCE_MOUSE),
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE)))));
- NotifyMotionArgs motionArgs = std::get<NotifyMotionArgs>(args.front());
- const float relX = motionArgs.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
- const float relY = motionArgs.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
- ASSERT_GT(relX, 10);
- ASSERT_GT(relY, 20);
- args.clear();
-
- // Enable Pointer Capture
- setPointerCapture(true);
-
- // Move and verify scale is not applied.
- args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
- args += process(ARBITRARY_TIME, EV_REL, REL_Y, 20);
- args += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithSource(AINPUT_SOURCE_MOUSE_RELATIVE),
- WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(10, 20)))));
-}
-
-// TODO(b/311416205): De-duplicate the test cases after the refactoring is complete and the flagging
-// logic can be removed.
-class CursorInputMapperUnitTestWithChoreographer : public CursorInputMapperUnitTestBase {
-protected:
- void SetUp() override {
- input_flags::enable_new_mouse_pointer_ballistics(false);
- CursorInputMapperUnitTestBase::SetUp();
- }
-
- bool isPointerChoreographerEnabled() override { return true; }
-};
-
-TEST_F(CursorInputMapperUnitTestWithChoreographer, PopulateDeviceInfoReturnsRangeFromPolicy) {
+TEST_F(CursorInputMapperUnitTest, PopulateDeviceInfoReturnsRangeFromPolicy) {
mPropertyMap.addProperty("cursor.mode", "pointer");
mFakePolicy->clearViewports();
- mFakePointerController->clearBounds();
createMapper();
InputDeviceInfo info;
@@ -1009,14 +639,12 @@
AINPUT_SOURCE_MOUSE, 0.0f, 1.0f, 0.0f, 0.0f));
}
-TEST_F(CursorInputMapperUnitTestWithChoreographer, ConfigureDisplayIdWithAssociatedViewport) {
+TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdWithAssociatedViewport) {
DisplayViewport primaryViewport = createPrimaryViewport(ui::Rotation::Rotation90);
DisplayViewport secondaryViewport = createSecondaryViewport();
mReaderConfiguration.setDisplayViewports({primaryViewport, secondaryViewport});
// Set up the secondary display as the display on which the pointer should be shown.
// The InputDevice is not associated with any display.
- mFakePointerController->setDisplayViewport(secondaryViewport);
- mFakePointerController->setPosition(100, 200);
createDevice();
ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport);
mMapper = createInputMapper<CursorInputMapper>(deviceContext, mReaderConfiguration);
@@ -1032,13 +660,12 @@
WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(0.0f, 0.0f)))));
}
-TEST_F(CursorInputMapperUnitTestWithChoreographer,
+TEST_F(CursorInputMapperUnitTest,
ConfigureDisplayIdShouldGenerateEventForMismatchedPointerDisplay) {
DisplayViewport primaryViewport = createPrimaryViewport(ui::Rotation::Rotation90);
DisplayViewport secondaryViewport = createSecondaryViewport();
mReaderConfiguration.setDisplayViewports({primaryViewport, secondaryViewport});
// Set up the primary display as the display on which the pointer should be shown.
- mFakePointerController->setDisplayViewport(primaryViewport);
createDevice();
// Associate the InputDevice with the secondary display.
ViewportFakingInputDeviceContext deviceContext(*mDevice, EVENTHUB_ID, secondaryViewport);
@@ -1057,13 +684,10 @@
WithDisplayId(SECONDARY_DISPLAY_ID), WithCoords(0.0f, 0.0f)))));
}
-TEST_F(CursorInputMapperUnitTestWithChoreographer, ProcessShouldHandleAllButtonsWithZeroCoords) {
+TEST_F(CursorInputMapperUnitTest, ProcessShouldHandleAllButtonsWithZeroCoords) {
mPropertyMap.addProperty("cursor.mode", "pointer");
createMapper();
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(100, 200);
-
std::list<NotifyArgs> args;
// press BTN_LEFT, release BTN_LEFT
@@ -1147,21 +771,17 @@
WithCoords(0.0f, 0.0f), WithPressure(0.0f)))));
}
-class CursorInputMapperButtonKeyTestWithChoreographer
- : public CursorInputMapperUnitTestWithChoreographer,
+class CursorInputMapperButtonKeyTest
+ : public CursorInputMapperUnitTest,
public testing::WithParamInterface<
std::tuple<int32_t /*evdevCode*/, int32_t /*expectedButtonState*/,
int32_t /*expectedKeyCode*/>> {};
-TEST_P(CursorInputMapperButtonKeyTestWithChoreographer,
- ProcessShouldHandleButtonKeyWithZeroCoords) {
+TEST_P(CursorInputMapperButtonKeyTest, ProcessShouldHandleButtonKeyWithZeroCoords) {
auto [evdevCode, expectedButtonState, expectedKeyCode] = GetParam();
mPropertyMap.addProperty("cursor.mode", "pointer");
createMapper();
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(100, 200);
-
std::list<NotifyArgs> args;
args += process(ARBITRARY_TIME, EV_KEY, evdevCode, 1);
@@ -1195,20 +815,17 @@
}
INSTANTIATE_TEST_SUITE_P(
- SideExtraBackAndForward, CursorInputMapperButtonKeyTestWithChoreographer,
+ SideExtraBackAndForward, CursorInputMapperButtonKeyTest,
testing::Values(std::make_tuple(BTN_SIDE, AMOTION_EVENT_BUTTON_BACK, AKEYCODE_BACK),
std::make_tuple(BTN_EXTRA, AMOTION_EVENT_BUTTON_FORWARD, AKEYCODE_FORWARD),
std::make_tuple(BTN_BACK, AMOTION_EVENT_BUTTON_BACK, AKEYCODE_BACK),
std::make_tuple(BTN_FORWARD, AMOTION_EVENT_BUTTON_FORWARD,
AKEYCODE_FORWARD)));
-TEST_F(CursorInputMapperUnitTestWithChoreographer, ProcessWhenModeIsPointerShouldKeepZeroCoords) {
+TEST_F(CursorInputMapperUnitTest, ProcessWhenModeIsPointerShouldKeepZeroCoords) {
mPropertyMap.addProperty("cursor.mode", "pointer");
createMapper();
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(100, 200);
-
std::list<NotifyArgs> args;
args += process(ARBITRARY_TIME, EV_REL, REL_X, 10);
@@ -1223,7 +840,11 @@
WithOrientation(0.0f), WithDistance(0.0f)))));
}
-TEST_F(CursorInputMapperUnitTestWithChoreographer, PointerCaptureDisablesVelocityProcessing) {
+/**
+ * When Pointer Capture is enabled, we expect to report unprocessed relative movements, so any
+ * pointer acceleration or speed processing should not be applied.
+ */
+TEST_F(CursorInputMapperUnitTest, PointerCaptureDisablesVelocityProcessing) {
mPropertyMap.addProperty("cursor.mode", "pointer");
const VelocityControlParameters testParams(/*scale=*/5.f, /*lowThreshold=*/0.f,
/*highThreshold=*/100.f, /*acceleration=*/10.f);
@@ -1267,7 +888,7 @@
ASSERT_EQ(20, relY2);
}
-TEST_F(CursorInputMapperUnitTestWithChoreographer, ConfigureDisplayIdNoAssociatedViewport) {
+TEST_F(CursorInputMapperUnitTest, ConfigureDisplayIdNoAssociatedViewport) {
// Set up the default display.
mFakePolicy->clearViewports();
mFakePolicy->addDisplayViewport(createPrimaryViewport(ui::Rotation::Rotation0));
@@ -1279,9 +900,6 @@
createMapper();
- mFakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
- mFakePointerController->setPosition(100, 200);
-
// Ensure input events are generated without display ID or coords, because they will be decided
// later by PointerChoreographer.
std::list<NotifyArgs> args;
@@ -1302,8 +920,6 @@
input_flags::enable_new_mouse_pointer_ballistics(true);
CursorInputMapperUnitTestBase::SetUp();
}
-
- bool isPointerChoreographerEnabled() override { return true; }
};
TEST_F(CursorInputMapperUnitTestWithNewBallistics, PointerCaptureDisablesVelocityProcessing) {
@@ -1422,14 +1038,11 @@
} // namespace
+// --- BluetoothCursorInputMapperUnitTest ---
+
class BluetoothCursorInputMapperUnitTest : public CursorInputMapperUnitTestBase {
protected:
- void SetUp() override {
- SetUpWithBus(BUS_BLUETOOTH);
-
- mFakePointerController = std::make_shared<FakePointerController>();
- mFakePolicy->setPointerController(mFakePointerController);
- }
+ void SetUp() override { SetUpWithBus(BUS_BLUETOOTH); }
};
TEST_F(BluetoothCursorInputMapperUnitTest, TimestampSmoothening) {
@@ -1537,123 +1150,4 @@
argsList.clear();
}
-// --- BluetoothCursorInputMapperUnitTestWithChoreographer ---
-
-class BluetoothCursorInputMapperUnitTestWithChoreographer : public CursorInputMapperUnitTestBase {
-protected:
- void SetUp() override {
- SetUpWithBus(BUS_BLUETOOTH);
-
- mFakePointerController = std::make_shared<FakePointerController>();
- mFakePolicy->setPointerController(mFakePointerController);
- }
-
- bool isPointerChoreographerEnabled() override { return true; }
-};
-
-TEST_F(BluetoothCursorInputMapperUnitTestWithChoreographer, TimestampSmoothening) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- createMapper();
- std::list<NotifyArgs> argsList;
-
- nsecs_t kernelEventTime = ARBITRARY_TIME;
- nsecs_t expectedEventTime = ARBITRARY_TIME;
- argsList += process(kernelEventTime, EV_REL, REL_X, 1);
- argsList += process(kernelEventTime, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(argsList,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithEventTime(expectedEventTime)))));
- argsList.clear();
-
- // Process several events that come in quick succession, according to their timestamps.
- for (int i = 0; i < 3; i++) {
- constexpr static nsecs_t delta = ms2ns(1);
- static_assert(delta < MIN_BLUETOOTH_TIMESTAMP_DELTA);
- kernelEventTime += delta;
- expectedEventTime += MIN_BLUETOOTH_TIMESTAMP_DELTA;
-
- argsList += process(kernelEventTime, EV_REL, REL_X, 1);
- argsList += process(kernelEventTime, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(argsList,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithEventTime(expectedEventTime)))));
- argsList.clear();
- }
-}
-
-TEST_F(BluetoothCursorInputMapperUnitTestWithChoreographer, TimestampSmootheningIsCapped) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- createMapper();
- std::list<NotifyArgs> argsList;
-
- nsecs_t expectedEventTime = ARBITRARY_TIME;
- argsList += process(ARBITRARY_TIME, EV_REL, REL_X, 1);
- argsList += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(argsList,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithEventTime(expectedEventTime)))));
- argsList.clear();
-
- // Process several events with the same timestamp from the kernel.
- // Ensure that we do not generate events too far into the future.
- constexpr static int32_t numEvents =
- MAX_BLUETOOTH_SMOOTHING_DELTA / MIN_BLUETOOTH_TIMESTAMP_DELTA;
- for (int i = 0; i < numEvents; i++) {
- expectedEventTime += MIN_BLUETOOTH_TIMESTAMP_DELTA;
-
- argsList += process(ARBITRARY_TIME, EV_REL, REL_X, 1);
- argsList += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(argsList,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithEventTime(expectedEventTime)))));
- argsList.clear();
- }
-
- // By processing more events with the same timestamp, we should not generate events with a
- // timestamp that is more than the specified max time delta from the timestamp at its injection.
- const nsecs_t cappedEventTime = ARBITRARY_TIME + MAX_BLUETOOTH_SMOOTHING_DELTA;
- for (int i = 0; i < 3; i++) {
- argsList += process(ARBITRARY_TIME, EV_REL, REL_X, 1);
- argsList += process(ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(argsList,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithEventTime(cappedEventTime)))));
- argsList.clear();
- }
-}
-
-TEST_F(BluetoothCursorInputMapperUnitTestWithChoreographer, TimestampSmootheningNotUsed) {
- mPropertyMap.addProperty("cursor.mode", "pointer");
- createMapper();
- std::list<NotifyArgs> argsList;
-
- nsecs_t kernelEventTime = ARBITRARY_TIME;
- nsecs_t expectedEventTime = ARBITRARY_TIME;
- argsList += process(kernelEventTime, EV_REL, REL_X, 1);
- argsList += process(kernelEventTime, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(argsList,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithEventTime(expectedEventTime)))));
- argsList.clear();
-
- // If the next event has a timestamp that is sufficiently spaced out so that Bluetooth timestamp
- // smoothening is not needed, its timestamp is not affected.
- kernelEventTime += MAX_BLUETOOTH_SMOOTHING_DELTA + ms2ns(1);
- expectedEventTime = kernelEventTime;
-
- argsList += process(kernelEventTime, EV_REL, REL_X, 1);
- argsList += process(kernelEventTime, EV_SYN, SYN_REPORT, 0);
- EXPECT_THAT(argsList,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithEventTime(expectedEventTime)))));
- argsList.clear();
-}
-
} // namespace android
diff --git a/services/inputflinger/tests/FakePointerController.cpp b/services/inputflinger/tests/FakePointerController.cpp
index dc199e2..28d4b67 100644
--- a/services/inputflinger/tests/FakePointerController.cpp
+++ b/services/inputflinger/tests/FakePointerController.cpp
@@ -76,6 +76,14 @@
mCustomIconStyle = icon.style;
}
+void FakePointerController::setSkipScreenshot(int32_t displayId, bool skip) {
+ if (skip) {
+ mDisplaysToSkipScreenshot.insert(displayId);
+ } else {
+ mDisplaysToSkipScreenshot.erase(displayId);
+ }
+};
+
void FakePointerController::assertViewportSet(int32_t displayId) {
ASSERT_TRUE(mDisplayId);
ASSERT_EQ(displayId, mDisplayId);
@@ -117,6 +125,14 @@
ASSERT_EQ(std::nullopt, mCustomIconStyle);
}
+void FakePointerController::assertIsHiddenOnMirroredDisplays(int32_t displayId, bool isHidden) {
+ if (isHidden) {
+ ASSERT_TRUE(mDisplaysToSkipScreenshot.find(displayId) != mDisplaysToSkipScreenshot.end());
+ } else {
+ ASSERT_TRUE(mDisplaysToSkipScreenshot.find(displayId) == mDisplaysToSkipScreenshot.end());
+ }
+}
+
bool FakePointerController::isPointerShown() {
return mIsPointerShown;
}
diff --git a/services/inputflinger/tests/FakePointerController.h b/services/inputflinger/tests/FakePointerController.h
index 536b447..b5b982e 100644
--- a/services/inputflinger/tests/FakePointerController.h
+++ b/services/inputflinger/tests/FakePointerController.h
@@ -21,6 +21,7 @@
#include <input/DisplayViewport.h>
#include <input/Input.h>
#include <utils/BitSet.h>
+#include <unordered_set>
namespace android {
@@ -45,6 +46,7 @@
void setDisplayViewport(const DisplayViewport& viewport) override;
void updatePointerIcon(PointerIconStyle iconId) override;
void setCustomPointerIcon(const SpriteIcon& icon) override;
+ void setSkipScreenshot(int32_t displayId, bool skip) override;
void fade(Transition) override;
void assertViewportSet(int32_t displayId);
@@ -55,6 +57,7 @@
void assertPointerIconNotSet();
void assertCustomPointerIconSet(PointerIconStyle iconId);
void assertCustomPointerIconNotSet();
+ void assertIsHiddenOnMirroredDisplays(int32_t displayId, bool isHidden);
bool isPointerShown();
private:
@@ -77,6 +80,7 @@
std::optional<PointerIconStyle> mCustomIconStyle;
std::map<int32_t, std::vector<int32_t>> mSpotsByDisplay;
+ std::unordered_set<int32_t> mDisplaysToSkipScreenshot;
};
} // namespace android
diff --git a/services/inputflinger/tests/FakeWindows.h b/services/inputflinger/tests/FakeWindows.h
index 26c2b4b..6cd76b2 100644
--- a/services/inputflinger/tests/FakeWindows.h
+++ b/services/inputflinger/tests/FakeWindows.h
@@ -164,7 +164,7 @@
using namespace ftl::flag_operators;
mInfo.layoutParamsFlags &= ~gui::WindowInfo::Flag::SECURE;
}
- mInfo.setInputConfig(InputConfig::SENSITIVE_FOR_TRACING, secure);
+ mInfo.setInputConfig(InputConfig::SENSITIVE_FOR_PRIVACY, secure);
}
inline void setInterceptsStylus(bool interceptsStylus) {
diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp
index 6a009b2..f50f517 100644
--- a/services/inputflinger/tests/GestureConverter_test.cpp
+++ b/services/inputflinger/tests/GestureConverter_test.cpp
@@ -51,13 +51,11 @@
using testing::ElementsAre;
using testing::VariantWith;
-class GestureConverterTestBase : public testing::Test {
+class GestureConverterTest : public testing::Test {
protected:
static constexpr int32_t DEVICE_ID = END_RESERVED_ID + 1000;
static constexpr int32_t EVENTHUB_ID = 1;
static constexpr stime_t ARBITRARY_GESTURE_TIME = 1.2;
- static constexpr float POINTER_X = 500;
- static constexpr float POINTER_Y = 200;
void SetUp() {
mFakeEventHub = std::make_unique<FakeEventHub>();
@@ -68,12 +66,6 @@
mDevice = newDevice();
mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_MT_POSITION_X, -500, 500, 0, 0, 20);
mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_MT_POSITION_Y, -500, 500, 0, 0, 20);
-
- mFakePointerController = std::make_shared<FakePointerController>(
- /*enabled=*/!input_flags::enable_pointer_choreographer());
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(POINTER_X, POINTER_Y);
- mFakePolicy->setPointerController(mFakePointerController);
}
std::shared_ptr<InputDevice> newDevice() {
@@ -96,15 +88,6 @@
std::unique_ptr<TestInputListener> mFakeListener;
std::unique_ptr<InstrumentedInputReader> mReader;
std::shared_ptr<InputDevice> mDevice;
- std::shared_ptr<FakePointerController> mFakePointerController;
-};
-
-class GestureConverterTest : public GestureConverterTestBase {
-protected:
- void SetUp() override {
- input_flags::enable_pointer_choreographer(false);
- GestureConverterTestBase::SetUp();
- }
};
TEST_F(GestureConverterTest, Move) {
@@ -118,31 +101,24 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
WithRelativeMotion(0, 0))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithCoords(POINTER_X - 5, POINTER_Y + 10),
WithRelativeMotion(-5, 10), WithButtonState(0),
WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
+ WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X - 5, POINTER_Y + 10));
-
- // The same gesture again should only repeat the HOVER_MOVE and cursor position change, not the
- // HOVER_ENTER.
+ // The same gesture again should only repeat the HOVER_MOVE, not the HOVER_ENTER.
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithCoords(POINTER_X - 10, POINTER_Y + 20),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithCoords(0, 0),
WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER),
WithButtonState(0), WithPressure(0.0f),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X - 10, POINTER_Y + 20));
}
TEST_F(GestureConverterTest, Move_Rotated) {
@@ -157,18 +133,15 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
WithRelativeMotion(0, 0))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithCoords(POINTER_X + 10, POINTER_Y + 5),
WithRelativeMotion(10, 5), WithButtonState(0),
WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
+ WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X + 10, POINTER_Y + 5));
}
TEST_F(GestureConverterTest, ButtonsChange) {
@@ -197,7 +170,7 @@
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY |
AMOTION_EVENT_BUTTON_SECONDARY)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
@@ -210,8 +183,8 @@
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY),
- WithCoords(POINTER_X, POINTER_Y), WithToolType(ToolType::FINGER),
+ WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY), WithCoords(0, 0),
+ WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
// Finally release the right button
@@ -228,8 +201,7 @@
VariantWith<NotifyMotionArgs>(
WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0),
- WithCoords(POINTER_X, POINTER_Y),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
}
@@ -250,8 +222,8 @@
ASSERT_THAT(args.front(),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), WithButtonState(0),
- WithCoords(POINTER_X - 5, POINTER_Y + 10),
- WithToolType(ToolType::FINGER), WithDisplayId(ADISPLAY_ID_DEFAULT))));
+ WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ADISPLAY_ID_DEFAULT))));
}
TEST_F(GestureConverterTest, DragWithButton) {
@@ -274,7 +246,7 @@
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
@@ -283,14 +255,11 @@
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithCoords(POINTER_X - 5, POINTER_Y + 10), WithRelativeMotion(-5, 10),
- WithToolType(ToolType::FINGER),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, 0),
+ WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X - 5, POINTER_Y + 10));
-
// Release the button
Gesture upGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* down= */ GESTURES_BUTTON_NONE, /* up= */ GESTURES_BUTTON_LEFT,
@@ -305,8 +274,7 @@
VariantWith<NotifyMotionArgs>(
WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0),
- WithCoords(POINTER_X - 5, POINTER_Y + 10),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
}
@@ -323,12 +291,12 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithGestureScrollDistance(0, 0, EPSILON),
WithDownTime(downTime))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithCoords(POINTER_X, POINTER_Y - 10),
+ WithCoords(0, -10),
WithGestureScrollDistance(0, 10, EPSILON)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(
@@ -341,8 +309,7 @@
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithCoords(POINTER_X, POINTER_Y - 15),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, -15),
WithGestureScrollDistance(0, 5, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithToolType(ToolType::FINGER),
@@ -355,14 +322,14 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithCoords(POINTER_X, POINTER_Y - 15),
+ WithCoords(0, -15),
WithGestureScrollDistance(0, 0, EPSILON),
WithMotionClassification(
MotionClassification::TWO_FINGER_SWIPE),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
@@ -382,12 +349,12 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithGestureScrollDistance(0, 0, EPSILON),
WithDownTime(downTime))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithCoords(POINTER_X - 10, POINTER_Y),
+ WithCoords(-10, 0),
WithGestureScrollDistance(0, 10, EPSILON)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(
@@ -399,25 +366,25 @@
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithCoords(POINTER_X - 15, POINTER_Y),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(-15, 0),
WithGestureScrollDistance(0, 5, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
GESTURES_FLING_START);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithCoords(POINTER_X - 15, POINTER_Y),
+ WithCoords(-15, 0),
WithGestureScrollDistance(0, 0, EPSILON),
WithMotionClassification(
MotionClassification::TWO_FINGER_SWIPE))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
@@ -619,7 +586,7 @@
WithPointerCount(1u))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
@@ -706,7 +673,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
WithGestureOffset(0, 0, EPSILON), WithPointerCount(1u))),
VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))));
ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ADISPLAY_ID_DEFAULT))));
}
@@ -828,7 +795,7 @@
WithPointerCount(1u))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
@@ -847,14 +814,12 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(POINTER_X - 100, POINTER_Y),
- WithPointerCount(1u))),
+ WithCoords(-100, 0), WithPointerCount(1u))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(
AMOTION_EVENT_ACTION_POINTER_DOWN |
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithPointerCoords(1, POINTER_X + 100, POINTER_Y),
- WithPointerCount(2u)))));
+ WithPointerCoords(1, 100, 0), WithPointerCount(2u)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionClassification(MotionClassification::PINCH),
@@ -870,73 +835,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(0.8f, EPSILON),
- WithPointerCoords(0, POINTER_X - 80, POINTER_Y),
- WithPointerCoords(1, POINTER_X + 80, POINTER_Y), WithPointerCount(2u),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
- GESTURES_ZOOM_END);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTest, Pinch_Outwards) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
- GESTURES_ZOOM_START);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(POINTER_X - 100, POINTER_Y),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_DOWN |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithPointerCoords(1, POINTER_X + 100, POINTER_Y),
- WithPointerCount(2u)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* dz= */ 1.2, GESTURES_ZOOM_UPDATE);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.2f, EPSILON),
- WithPointerCoords(0, POINTER_X - 120, POINTER_Y),
- WithPointerCoords(1, POINTER_X + 120, POINTER_Y),
+ WithPointerCoords(0, -80, 0), WithPointerCoords(1, 80, 0),
WithPointerCount(2u), WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
@@ -958,7 +857,69 @@
WithPointerCount(1u))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
+ WithMotionClassification(MotionClassification::NONE)))));
+ ASSERT_THAT(args,
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
+ WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+}
+
+TEST_F(GestureConverterTest, Pinch_Outwards) {
+ InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
+ GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
+ converter.setDisplayId(ADISPLAY_ID_DEFAULT);
+
+ Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
+ GESTURES_ZOOM_START);
+ std::list<NotifyArgs> args =
+ converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
+ ASSERT_THAT(args,
+ ElementsAre(VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
+ WithCoords(-100, 0), WithPointerCount(1u))),
+ VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(
+ AMOTION_EVENT_ACTION_POINTER_DOWN |
+ 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+ WithPointerCoords(1, 100, 0), WithPointerCount(2u)))));
+ ASSERT_THAT(args,
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionClassification(MotionClassification::PINCH),
+ WithGesturePinchScaleFactor(1.0f, EPSILON),
+ WithToolType(ToolType::FINGER),
+ WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+
+ Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
+ /* dz= */ 1.1, GESTURES_ZOOM_UPDATE);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture);
+ ASSERT_THAT(args,
+ ElementsAre(VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
+ WithMotionClassification(MotionClassification::PINCH),
+ WithGesturePinchScaleFactor(1.1f, EPSILON),
+ WithPointerCoords(0, -110, 0), WithPointerCoords(1, 110, 0),
+ WithPointerCount(2u), WithToolType(ToolType::FINGER),
+ WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+
+ Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
+ GESTURES_ZOOM_END);
+ args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture);
+ ASSERT_THAT(args,
+ ElementsAre(VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(
+ AMOTION_EVENT_ACTION_POINTER_UP |
+ 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+ WithMotionClassification(MotionClassification::PINCH),
+ WithGesturePinchScaleFactor(1.0f, EPSILON),
+ WithPointerCount(2u))),
+ VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
+ WithMotionClassification(MotionClassification::PINCH),
+ WithGesturePinchScaleFactor(1.0f, EPSILON),
+ WithPointerCount(1u))),
+ VariantWith<NotifyMotionArgs>(
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
+ WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
@@ -1044,7 +1005,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithButtonState(0)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
}
@@ -1061,14 +1022,14 @@
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithCoords(POINTER_X, POINTER_Y - 10),
+ WithCoords(0, -10),
WithGestureScrollDistance(0, 0, EPSILON),
WithMotionClassification(
MotionClassification::TWO_FINGER_SWIPE),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
@@ -1141,7 +1102,7 @@
WithPointerCount(1u))),
VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y),
+ WithCoords(0, 0),
WithMotionClassification(MotionClassification::NONE)))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
@@ -1159,13 +1120,9 @@
converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, tapDownGesture);
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(POINTER_X, POINTER_Y), WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER), WithButtonState(0), WithPressure(0.0f),
- WithDisplayId(ADISPLAY_ID_DEFAULT)));
-
- ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X, POINTER_Y));
- ASSERT_TRUE(mFakePointerController->isPointerShown());
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithCoords(0, 0),
+ WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER),
+ WithButtonState(0), WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT)));
}
TEST_F(GestureConverterTest, FlingTapDownAfterScrollStopsFling) {
@@ -1195,7 +1152,7 @@
WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
ASSERT_THAT(args,
Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithCoords(POINTER_X, POINTER_Y), WithToolType(ToolType::FINGER),
+ AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE)))));
}
@@ -1241,7 +1198,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithButtonState(0), WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
WithRelativeMotion(0.f, 0.f),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
@@ -1278,7 +1235,7 @@
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
WithPressure(1.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
WithRelativeMotion(0.f, 0.f),
WithToolType(ToolType::FINGER),
WithDisplayId(ADISPLAY_ID_DEFAULT)))));
@@ -1287,6 +1244,7 @@
/* down= */ GESTURES_BUTTON_NONE,
/* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ false);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonUpGesture);
+
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
@@ -1299,10 +1257,10 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithPressure(0.0f)))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithButtonState(0), WithCoords(POINTER_X, POINTER_Y),
- WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
+ WithRelativeMotion(0.f, 0.f),
+ WithToolType(ToolType::FINGER),
+ WithDisplayId(ADISPLAY_ID_DEFAULT)))));
}
TEST_F_WITH_FLAGS(GestureConverterTest, TapWithTapToClickDisabled,
@@ -1438,1428 +1396,6 @@
/* down= */ GESTURES_BUTTON_LEFT,
/* up= */ GESTURES_BUTTON_NONE, /* is_tap= */ false);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonDownGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT),
- WithButtonState(0), WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithPressure(1.0f)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_NONE,
- /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonUpGesture);
-
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(0), WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithButtonState(0), WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithButtonState(0), WithPressure(0.0f)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // Future taps should be re-enabled
- ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
-}
-
-TEST_F_WITH_FLAGS(GestureConverterTest, MoveEnablesTapToClick,
- REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) {
- // initially disable tap-to-click
- mReader->getContext()->setPreventingTouchpadTaps(true);
-
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- // We don't need to check args here, since it's covered by the Move test.
-
- // Future taps should be re-enabled
- ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
-}
-
-TEST_F_WITH_FLAGS(GestureConverterTest, KeypressCancelsHoverMove,
- REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION_V2)) {
- const nsecs_t gestureStartTime = 1000;
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- // Start a move gesture at gestureStartTime
- Gesture moveGesture(kGestureMove, gestureStartTime, gestureStartTime, -5, 10);
- std::list<NotifyArgs> args =
- converter.handleGesture(gestureStartTime, READ_TIME, gestureStartTime, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE))));
-
- // Key presses with IME connection should cancel ongoing move gesture
- nsecs_t currentTime = gestureStartTime + 100;
- mFakePolicy->setIsInputMethodConnectionActive(true);
- mReader->getContext()->setLastKeyDownTimestamp(currentTime);
- moveGesture = Gesture(kGestureMove, currentTime, currentTime, -5, 10);
- args = converter.handleGesture(currentTime, READ_TIME, gestureStartTime, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT))));
-
- // any updates in existing move gesture should be ignored
- moveGesture = Gesture(kGestureMove, currentTime, currentTime, -5, 10);
- args = converter.handleGesture(currentTime, READ_TIME, gestureStartTime, moveGesture);
- ASSERT_EQ(0u, args.size());
-
- // New gesture should not be affected
- currentTime += 100;
- moveGesture = Gesture(kGestureMove, currentTime, currentTime, -5, 10);
- args = converter.handleGesture(currentTime, READ_TIME, currentTime, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE))));
-}
-
-// TODO(b/311416205): De-duplicate the test cases after the refactoring is complete and the flagging
-// logic can be removed.
-class GestureConverterTestWithChoreographer : public GestureConverterTestBase {
-protected:
- void SetUp() override {
- input_flags::enable_pointer_choreographer(true);
- GestureConverterTestBase::SetUp();
- }
-};
-
-TEST_F(GestureConverterTestWithChoreographer, Move) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithRelativeMotion(0, 0))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithRelativeMotion(-5, 10), WithButtonState(0),
- WithPressure(0.0f)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // The same gesture again should only repeat the HOVER_MOVE, not the HOVER_ENTER.
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithCoords(0, 0),
- WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER),
- WithButtonState(0), WithPressure(0.0f),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Move_Rotated) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setOrientation(ui::ROTATION_90);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithRelativeMotion(0, 0))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
- WithRelativeMotion(10, 5), WithButtonState(0),
- WithPressure(0.0f)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ButtonsChange) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- // Press left and right buttons at once
- Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_LEFT | GESTURES_BUTTON_RIGHT,
- /* up= */ GESTURES_BUTTON_NONE, /* is_tap= */ false);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY |
- AMOTION_EVENT_BUTTON_SECONDARY))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY |
- AMOTION_EVENT_BUTTON_SECONDARY)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // Then release the left button
- Gesture leftUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_NONE, /* up= */ GESTURES_BUTTON_LEFT,
- /* is_tap= */ false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, leftUpGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY), WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // Finally release the right button
- Gesture rightUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_NONE, /* up= */ GESTURES_BUTTON_RIGHT,
- /* is_tap= */ false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, rightUpGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY))),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_UP)),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ButtonDownAfterMoveExitsHover) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
-
- Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /*down=*/GESTURES_BUTTON_LEFT, /*up=*/GESTURES_BUTTON_NONE,
- /*is_tap=*/false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture);
- ASSERT_THAT(args.front(),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT), WithButtonState(0),
- WithCoords(0, 0), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, DragWithButton) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- // Press the button
- Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_LEFT, /* up= */ GESTURES_BUTTON_NONE,
- /* is_tap= */ false);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // Move
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, 0),
- WithRelativeMotion(-5, 10), WithToolType(ToolType::FINGER),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // Release the button
- Gesture upGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_NONE, /* up= */ GESTURES_BUTTON_LEFT,
- /* is_tap= */ false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, upGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY))),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_UP)),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Scroll) {
- const nsecs_t downTime = 12345;
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
- std::list<NotifyArgs> args =
- converter.handleGesture(downTime, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(0, 0),
- WithGestureScrollDistance(0, 0, EPSILON),
- WithDownTime(downTime))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithCoords(0, -10),
- WithGestureScrollDistance(0, 10, EPSILON)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(0, -15),
- WithGestureScrollDistance(0, 5, EPSILON),
- WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(ToolType::FINGER),
- WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
- GESTURES_FLING_START);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithCoords(0, -15),
- WithGestureScrollDistance(0, 0, EPSILON),
- WithMotionClassification(
- MotionClassification::TWO_FINGER_SWIPE),
- WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Scroll_Rotated) {
- const nsecs_t downTime = 12345;
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setOrientation(ui::ROTATION_90);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
- std::list<NotifyArgs> args =
- converter.handleGesture(downTime, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(0, 0),
- WithGestureScrollDistance(0, 0, EPSILON),
- WithDownTime(downTime))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithCoords(-10, 0),
- WithGestureScrollDistance(0, 10, EPSILON)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(-15, 0),
- WithGestureScrollDistance(0, 5, EPSILON),
- WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
- GESTURES_FLING_START);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithCoords(-15, 0),
- WithGestureScrollDistance(0, 0, EPSILON),
- WithMotionClassification(
- MotionClassification::TWO_FINGER_SWIPE))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Scroll_ClearsClassificationAfterGesture) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
-
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
- GESTURES_FLING_START);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
-
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::NONE),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Scroll_ClearsScrollDistanceAfterGesture) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
-
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
- GESTURES_FLING_START);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
-
- // Move gestures don't use the fake finger array, so to test that gesture axes are cleared we
- // need to use another gesture type, like pinch.
- Gesture pinchGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
- GESTURES_ZOOM_START);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, pinchGesture);
- ASSERT_FALSE(args.empty());
- EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()), WithGestureScrollDistance(0, 0, EPSILON));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ThreeFingerSwipe_ClearsClassificationAfterGesture) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0,
- /*dy=*/0);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture);
-
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/-5,
- /*dy=*/10);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- WithMotionClassification(MotionClassification::NONE))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ThreeFingerSwipe_ClearsGestureAxesAfterGesture) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/5,
- /*dy=*/5);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture);
-
- // Move gestures don't use the fake finger array, so to test that gesture axes are cleared we
- // need to use another gesture type, like pinch.
- Gesture pinchGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
- GESTURES_ZOOM_START);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, pinchGesture);
- ASSERT_FALSE(args.empty());
- EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
- AllOf(WithGestureOffset(0, 0, EPSILON), WithGestureSwipeFingerCount(0)));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ThreeFingerSwipe_Vertical) {
- // The gestures library will "lock" a swipe into the dimension it starts in. For example, if you
- // start swiping up and then start moving left or right, it'll return gesture events with only Y
- // deltas until you lift your fingers and start swiping again. That's why each of these tests
- // only checks movement in one dimension.
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0,
- /* dy= */ 10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_EQ(4u, args.size());
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithGestureSwipeFingerCount(3), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // Three fake fingers should be created. We don't actually care where they are, so long as they
- // move appropriately.
- NotifyMotionArgs arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON),
- WithPointerCount(1u)));
- PointerCoords finger0Start = arg.pointerCoords[0];
- args.pop_front();
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u)));
- PointerCoords finger1Start = arg.pointerCoords[1];
- args.pop_front();
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
- 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u)));
- PointerCoords finger2Start = arg.pointerCoords[2];
- args.pop_front();
-
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithGestureOffset(0, -0.01, EPSILON), WithPointerCount(3u)));
- EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX());
- EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX());
- EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX());
- EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY() - 10);
- EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY() - 10);
- EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY() - 10);
-
- Gesture continueGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* dx= */ 0, /* dy= */ 5);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
- ASSERT_EQ(1u, args.size());
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithGestureOffset(0, -0.005, EPSILON), WithGestureSwipeFingerCount(3),
- WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)));
- EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX());
- EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX());
- EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX());
- EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY() - 15);
- EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY() - 15);
- EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY() - 15);
-
- Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON),
- WithGestureSwipeFingerCount(3),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON),
- WithGestureSwipeFingerCount(3),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithGestureOffset(0, 0, EPSILON),
- WithGestureSwipeFingerCount(3),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ThreeFingerSwipe_Rotated) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setOrientation(ui::ROTATION_90);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dx= */ 0,
- /* dy= */ 10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_EQ(4u, args.size());
- ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ADISPLAY_ID_DEFAULT))));
-
- // Three fake fingers should be created. We don't actually care where they are, so long as they
- // move appropriately.
- NotifyMotionArgs arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON),
- WithPointerCount(1u)));
- PointerCoords finger0Start = arg.pointerCoords[0];
- args.pop_front();
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u)));
- PointerCoords finger1Start = arg.pointerCoords[1];
- args.pop_front();
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
- 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u)));
- PointerCoords finger2Start = arg.pointerCoords[2];
- args.pop_front();
-
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithGestureOffset(0, -0.01, EPSILON), WithPointerCount(3u)));
- EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() - 10);
- EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() - 10);
- EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() - 10);
- EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY());
- EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY());
- EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY());
-
- Gesture continueGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* dx= */ 0, /* dy= */ 5);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
- ASSERT_EQ(1u, args.size());
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithGestureOffset(0, -0.005, EPSILON), WithPointerCount(3u),
- WithDisplayId(ADISPLAY_ID_DEFAULT)));
- EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() - 15);
- EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() - 15);
- EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() - 15);
- EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY());
- EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY());
- EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY());
-
- Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER)))));
- ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithDisplayId(ADISPLAY_ID_DEFAULT))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, FourFingerSwipe_Horizontal) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureFourFingerSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* dx= */ 10, /* dy= */ 0);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_EQ(5u, args.size());
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithGestureSwipeFingerCount(4), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- // Four fake fingers should be created. We don't actually care where they are, so long as they
- // move appropriately.
- NotifyMotionArgs arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON),
- WithPointerCount(1u)));
- PointerCoords finger0Start = arg.pointerCoords[0];
- args.pop_front();
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(2u)));
- PointerCoords finger1Start = arg.pointerCoords[1];
- args.pop_front();
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
- 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(3u)));
- PointerCoords finger2Start = arg.pointerCoords[2];
- args.pop_front();
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
- 3 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON), WithPointerCount(4u)));
- PointerCoords finger3Start = arg.pointerCoords[3];
- args.pop_front();
-
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithGestureOffset(0.01, 0, EPSILON), WithPointerCount(4u)));
- EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() + 10);
- EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() + 10);
- EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() + 10);
- EXPECT_EQ(arg.pointerCoords[3].getX(), finger3Start.getX() + 10);
- EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY());
- EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY());
- EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY());
- EXPECT_EQ(arg.pointerCoords[3].getY(), finger3Start.getY());
-
- Gesture continueGesture(kGestureFourFingerSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* dx= */ 5, /* dy= */ 0);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, continueGesture);
- ASSERT_EQ(1u, args.size());
- arg = std::get<NotifyMotionArgs>(args.front());
- ASSERT_THAT(arg,
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithGestureOffset(0.005, 0, EPSILON), WithGestureSwipeFingerCount(4),
- WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(4u), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)));
- EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX() + 15);
- EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX() + 15);
- EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX() + 15);
- EXPECT_EQ(arg.pointerCoords[3].getX(), finger3Start.getX() + 15);
- EXPECT_EQ(arg.pointerCoords[0].getY(), finger0Start.getY());
- EXPECT_EQ(arg.pointerCoords[1].getY(), finger1Start.getY());
- EXPECT_EQ(arg.pointerCoords[2].getY(), finger2Start.getY());
- EXPECT_EQ(arg.pointerCoords[3].getY(), finger3Start.getY());
-
- Gesture liftGesture(kGestureSwipeLift, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, liftGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 3 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON),
- WithGestureSwipeFingerCount(4),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(4u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON),
- WithGestureSwipeFingerCount(4),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON),
- WithGestureSwipeFingerCount(4),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithGestureOffset(0, 0, EPSILON),
- WithGestureSwipeFingerCount(4),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Pinch_Inwards) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
- GESTURES_ZOOM_START);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(-100, 0), WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_DOWN |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithPointerCoords(1, 100, 0), WithPointerCount(2u)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* dz= */ 0.8, GESTURES_ZOOM_UPDATE);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(0.8f, EPSILON),
- WithPointerCoords(0, -80, 0), WithPointerCoords(1, 80, 0),
- WithPointerCount(2u), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
- GESTURES_ZOOM_END);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Pinch_Outwards) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
- GESTURES_ZOOM_START);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithCoords(-100, 0), WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_DOWN |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithPointerCoords(1, 100, 0), WithPointerCount(2u)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* dz= */ 1.1, GESTURES_ZOOM_UPDATE);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.1f, EPSILON),
- WithPointerCoords(0, -110, 0), WithPointerCoords(1, 110, 0),
- WithPointerCount(2u), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
- GESTURES_ZOOM_END);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Pinch_ClearsClassificationAfterGesture) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
- GESTURES_ZOOM_START);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /*dz=*/1.2, GESTURES_ZOOM_UPDATE);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture);
-
- Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
- GESTURES_ZOOM_END);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture);
-
- Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, moveGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- WithMotionClassification(MotionClassification::NONE))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Pinch_ClearsScaleFactorAfterGesture) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
- GESTURES_ZOOM_START);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /*dz=*/1.2, GESTURES_ZOOM_UPDATE);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, updateGesture);
-
- Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
- GESTURES_ZOOM_END);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, endGesture);
-
- // Move gestures don't use the fake finger array, so to test that gesture axes are cleared we
- // need to use another gesture type, like scroll.
- Gesture scrollGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/1,
- /*dy=*/0);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, scrollGesture);
- ASSERT_FALSE(args.empty());
- EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()), WithGesturePinchScaleFactor(0, EPSILON));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ResetWithButtonPressed) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture downGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /*down=*/GESTURES_BUTTON_LEFT | GESTURES_BUTTON_RIGHT,
- /*up=*/GESTURES_BUTTON_NONE, /*is_tap=*/false);
- (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, downGesture);
-
- std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY),
- WithButtonState(0))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithButtonState(0))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithButtonState(0)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ResetDuringScroll) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
- (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithCoords(0, -10),
- WithGestureScrollDistance(0, 0, EPSILON),
- WithMotionClassification(
- MotionClassification::TWO_FINGER_SWIPE),
- WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ResetDuringThreeFingerSwipe) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0,
- /*dy=*/10);
- (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithGestureOffset(0, 0, EPSILON),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithGestureOffset(0, 0, EPSILON),
- WithMotionClassification(
- MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, ResetDuringPinch) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
- GESTURES_ZOOM_START);
- (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, startGesture);
-
- std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(
- AMOTION_EVENT_ACTION_POINTER_UP |
- 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(2u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithMotionClassification(MotionClassification::PINCH),
- WithGesturePinchScaleFactor(1.0f, EPSILON),
- WithPointerCount(1u))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithCoords(0, 0),
- WithMotionClassification(MotionClassification::NONE)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, FlingTapDown) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture tapDownGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /*vx=*/0.f, /*vy=*/0.f, GESTURES_FLING_TAP_DOWN);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, tapDownGesture);
-
- ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER), WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f), WithToolType(ToolType::FINGER),
- WithButtonState(0), WithPressure(0.0f), WithDisplayId(ADISPLAY_ID_DEFAULT)));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, FlingTapDownAfterScrollStopsFling) {
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- input_flags::enable_touchpad_fling_stop(true);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture scrollGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, scrollGesture);
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
- GESTURES_FLING_START);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
-
- Gesture tapDownGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /*vx=*/0.f, /*vy=*/0.f, GESTURES_FLING_TAP_DOWN);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, tapDownGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT)),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_DOWN)),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_CANCEL)),
- VariantWith<NotifyMotionArgs>(
- WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(
- AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT),
- WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Tap) {
- // Tap should produce button press/release events
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0,
- /* vy= */ 0, GESTURES_FLING_TAP_DOWN);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
- // We don't need to check args here, since it's covered by the FlingTapDown test.
-
- Gesture tapGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_LEFT,
- /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, tapGesture);
-
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT),
- WithButtonState(0), WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(0), WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithButtonState(0), WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithButtonState(0), WithPressure(0.0f)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F(GestureConverterTestWithChoreographer, Click) {
- // Click should produce button press/release events
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0,
- /* vy= */ 0, GESTURES_FLING_TAP_DOWN);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
- // We don't need to check args here, since it's covered by the FlingTapDown test.
-
- Gesture buttonDownGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_LEFT,
- /* up= */ GESTURES_BUTTON_NONE, /* is_tap= */ false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonDownGesture);
-
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT),
- WithButtonState(0), WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
- WithPressure(1.0f)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-
- Gesture buttonUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_NONE,
- /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonUpGesture);
-
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithPressure(1.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithPressure(0.0f))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithPressure(0.0f)))));
- ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithButtonState(0), WithCoords(0, 0),
- WithRelativeMotion(0.f, 0.f),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
-}
-
-TEST_F_WITH_FLAGS(GestureConverterTestWithChoreographer, TapWithTapToClickDisabled,
- REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION),
- REQUIRES_FLAGS_DISABLED(TOUCHPAD_PALM_REJECTION_V2)) {
- nsecs_t currentTime = ARBITRARY_GESTURE_TIME;
-
- // Tap should be ignored when disabled
- mReader->getContext()->setPreventingTouchpadTaps(true);
-
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0,
- /* vy= */ 0, GESTURES_FLING_TAP_DOWN);
- std::list<NotifyArgs> args =
- converter.handleGesture(currentTime, currentTime, currentTime, flingGesture);
- // We don't need to check args here, since it's covered by the FlingTapDown test.
-
- Gesture tapGesture(kGestureButtonsChange, currentTime, currentTime,
- /* down= */ GESTURES_BUTTON_LEFT,
- /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true);
- args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture);
-
- // no events should be generated
- ASSERT_EQ(0u, args.size());
-
- // Future taps should be re-enabled
- ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
-}
-
-TEST_F_WITH_FLAGS(GestureConverterTestWithChoreographer, TapWithTapToClickDisabledWithDelay,
- REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION_V2)) {
- nsecs_t currentTime = ARBITRARY_GESTURE_TIME;
-
- // Tap should be ignored when disabled
- mReader->getContext()->setPreventingTouchpadTaps(true);
-
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture flingGesture(kGestureFling, currentTime, currentTime, /* vx= */ 0,
- /* vy= */ 0, GESTURES_FLING_TAP_DOWN);
- std::list<NotifyArgs> args =
- converter.handleGesture(currentTime, currentTime, currentTime, flingGesture);
- // We don't need to check args here, since it's covered by the FlingTapDown test.
-
- Gesture tapGesture(kGestureButtonsChange, currentTime, currentTime,
- /* down= */ GESTURES_BUTTON_LEFT,
- /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true);
- args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture);
-
- // no events should be generated
- ASSERT_EQ(0u, args.size());
-
- // Future taps should be re-enabled
- ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
-
- // taps before the threshold should still be ignored
- currentTime += TAP_ENABLE_DELAY_NANOS.count();
- flingGesture = Gesture(kGestureFling, currentTime, currentTime, /* vx= */ 0,
- /* vy= */ 0, GESTURES_FLING_TAP_DOWN);
- args = converter.handleGesture(currentTime, currentTime, currentTime, flingGesture);
-
- ASSERT_EQ(1u, args.size());
- ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithRelativeMotion(0, 0)));
-
- tapGesture = Gesture(kGestureButtonsChange, currentTime, currentTime,
- /* down= */ GESTURES_BUTTON_LEFT,
- /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true);
- args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture);
-
- // no events should be generated
- ASSERT_EQ(0u, args.size());
-
- // taps after the threshold should be recognised
- currentTime += 1;
- flingGesture = Gesture(kGestureFling, currentTime, currentTime, /* vx= */ 0,
- /* vy= */ 0, GESTURES_FLING_TAP_DOWN);
- args = converter.handleGesture(currentTime, currentTime, currentTime, flingGesture);
-
- ASSERT_EQ(1u, args.size());
- ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE), WithRelativeMotion(0, 0)));
-
- tapGesture = Gesture(kGestureButtonsChange, currentTime, currentTime,
- /* down= */ GESTURES_BUTTON_LEFT,
- /* up= */ GESTURES_BUTTON_LEFT, /* is_tap= */ true);
- args = converter.handleGesture(currentTime, currentTime, currentTime, tapGesture);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT),
- WithButtonState(0))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
- WithButtonState(0))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithButtonState(0))),
- VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithButtonState(0)))));
- ASSERT_THAT(args, Each(VariantWith<NotifyMotionArgs>(WithRelativeMotion(0.f, 0.f))));
-}
-
-TEST_F_WITH_FLAGS(GestureConverterTestWithChoreographer, ClickWithTapToClickDisabled,
- REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) {
- // Click should still produce button press/release events
- mReader->getContext()->setPreventingTouchpadTaps(true);
-
- InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
- GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
- converter.setDisplayId(ADISPLAY_ID_DEFAULT);
-
- Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* vx= */ 0,
- /* vy= */ 0, GESTURES_FLING_TAP_DOWN);
- std::list<NotifyArgs> args =
- converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, flingGesture);
- // We don't need to check args here, since it's covered by the FlingTapDown test.
-
- Gesture buttonDownGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
- /* down= */ GESTURES_BUTTON_LEFT,
- /* up= */ GESTURES_BUTTON_NONE, /* is_tap= */ false);
- args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, ARBITRARY_TIME, buttonDownGesture);
ASSERT_THAT(args,
ElementsAre(VariantWith<NotifyMotionArgs>(
@@ -2909,7 +1445,7 @@
ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
}
-TEST_F_WITH_FLAGS(GestureConverterTestWithChoreographer, MoveEnablesTapToClick,
+TEST_F_WITH_FLAGS(GestureConverterTest, MoveEnablesTapToClick,
REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION)) {
// initially disable tap-to-click
mReader->getContext()->setPreventingTouchpadTaps(true);
@@ -2927,7 +1463,7 @@
ASSERT_FALSE(mReader->getContext()->isPreventingTouchpadTaps());
}
-TEST_F_WITH_FLAGS(GestureConverterTestWithChoreographer, KeypressCancelsHoverMove,
+TEST_F_WITH_FLAGS(GestureConverterTest, KeypressCancelsHoverMove,
REQUIRES_FLAGS_ENABLED(TOUCHPAD_PALM_REJECTION_V2)) {
const nsecs_t gestureStartTime = 1000;
InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
diff --git a/services/inputflinger/tests/InputMapperTest.cpp b/services/inputflinger/tests/InputMapperTest.cpp
index 2aecab9..ae6c849 100644
--- a/services/inputflinger/tests/InputMapperTest.cpp
+++ b/services/inputflinger/tests/InputMapperTest.cpp
@@ -29,14 +29,8 @@
using testing::Return;
void InputMapperUnitTest::SetUpWithBus(int bus) {
- mFakePointerController = std::make_shared<FakePointerController>();
- mFakePointerController->setBounds(0, 0, 800 - 1, 480 - 1);
- mFakePointerController->setPosition(INITIAL_CURSOR_X, INITIAL_CURSOR_Y);
mFakePolicy = sp<FakeInputReaderPolicy>::make();
- EXPECT_CALL(mMockInputReaderContext, getPointerController(DEVICE_ID))
- .WillRepeatedly(Return(mFakePointerController));
-
EXPECT_CALL(mMockInputReaderContext, getPolicy()).WillRepeatedly(Return(mFakePolicy.get()));
EXPECT_CALL(mMockInputReaderContext, getEventHub()).WillRepeatedly(Return(&mMockEventHub));
diff --git a/services/inputflinger/tests/InputMapperTest.h b/services/inputflinger/tests/InputMapperTest.h
index e176a65..509a593 100644
--- a/services/inputflinger/tests/InputMapperTest.h
+++ b/services/inputflinger/tests/InputMapperTest.h
@@ -40,8 +40,6 @@
protected:
static constexpr int32_t EVENTHUB_ID = 1;
static constexpr int32_t DEVICE_ID = END_RESERVED_ID + 1000;
- static constexpr float INITIAL_CURSOR_X = 400;
- static constexpr float INITIAL_CURSOR_Y = 240;
virtual void SetUp() override { SetUpWithBus(0); }
virtual void SetUpWithBus(int bus);
@@ -66,7 +64,6 @@
InputDeviceIdentifier mIdentifier;
MockEventHubInterface mMockEventHub;
sp<FakeInputReaderPolicy> mFakePolicy;
- std::shared_ptr<FakePointerController> mFakePointerController;
MockInputReaderContext mMockInputReaderContext;
std::unique_ptr<InputDevice> mDevice;
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index e5d929d..e1b46fa 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -5344,10 +5344,6 @@
}
TEST_F(SingleTouchInputMapperTest, Process_DoesntCheckPhysicalFrameForTouchpads) {
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- mFakePolicy->setPointerController(fakePointerController);
-
addConfigurationProperty("touch.deviceType", "pointer");
prepareAxes(POSITION);
prepareDisplay(ui::ROTATION_0);
@@ -6192,52 +6188,6 @@
ASSERT_EQ(AINPUT_SOURCE_TOUCH_NAVIGATION, mapper.getSources());
}
-TEST_F(SingleTouchInputMapperTest, Process_WhenConfigEnabled_ShouldShowDirectStylusPointer) {
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- addConfigurationProperty("touch.deviceType", "touchScreen");
- prepareDisplay(ui::ROTATION_0);
- prepareButtons();
- prepareAxes(POSITION);
- mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_PEN, 0, AKEYCODE_UNKNOWN, 0);
- mFakePolicy->setPointerController(fakePointerController);
- mFakePolicy->setStylusPointerIconEnabled(true);
- SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
-
- processKey(mapper, BTN_TOOL_PEN, 1);
- processMove(mapper, 100, 200);
- processSync(mapper);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(ToolType::STYLUS),
- WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
- ASSERT_TRUE(fakePointerController->isPointerShown());
- ASSERT_NO_FATAL_FAILURE(
- fakePointerController->assertPosition(toDisplayX(100), toDisplayY(200)));
-}
-
-TEST_F(SingleTouchInputMapperTest, Process_WhenConfigDisabled_ShouldNotShowDirectStylusPointer) {
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- addConfigurationProperty("touch.deviceType", "touchScreen");
- prepareDisplay(ui::ROTATION_0);
- prepareButtons();
- prepareAxes(POSITION);
- mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_PEN, 0, AKEYCODE_UNKNOWN, 0);
- mFakePolicy->setPointerController(fakePointerController);
- mFakePolicy->setStylusPointerIconEnabled(false);
- SingleTouchInputMapper& mapper = constructAndAddMapper<SingleTouchInputMapper>();
-
- processKey(mapper, BTN_TOOL_PEN, 1);
- processMove(mapper, 100, 200);
- processSync(mapper);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(ToolType::STYLUS),
- WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
- ASSERT_FALSE(fakePointerController->isPointerShown());
-}
-
TEST_F(SingleTouchInputMapperTest, WhenDeviceTypeIsChangedToTouchNavigation_updatesDeviceType) {
// Initialize the device without setting device source to touch navigation.
addConfigurationProperty("touch.deviceType", "touchScreen");
@@ -8717,21 +8667,12 @@
}
TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShouldHandleDisplayId) {
- // Setup for second display.
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- fakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
- fakePointerController->setPosition(100, 200);
- mFakePolicy->setPointerController(fakePointerController);
-
- mFakePolicy->setDefaultPointerDisplayId(SECONDARY_DISPLAY_ID);
prepareSecondaryDisplay(ViewportType::EXTERNAL);
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION);
MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
- // Check source is mouse that would obtain the PointerController.
ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper.getSources());
NotifyMotionArgs motionArgs;
@@ -8740,7 +8681,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
- ASSERT_EQ(SECONDARY_DISPLAY_ID, motionArgs.displayId);
+ ASSERT_EQ(ADISPLAY_ID_NONE, motionArgs.displayId);
}
/**
@@ -8920,97 +8861,6 @@
WithMotionAction(AMOTION_EVENT_ACTION_MOVE)));
}
-TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShowTouches) {
- // Setup the first touch screen device.
- prepareAxes(POSITION | ID | SLOT);
- addConfigurationProperty("touch.deviceType", "touchScreen");
- MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
-
- // Create the second touch screen device, and enable multi fingers.
- const std::string USB2 = "USB2";
- const std::string DEVICE_NAME2 = "TOUCHSCREEN2";
- constexpr int32_t SECOND_DEVICE_ID = DEVICE_ID + 1;
- constexpr int32_t SECOND_EVENTHUB_ID = EVENTHUB_ID + 1;
- std::shared_ptr<InputDevice> device2 =
- newDevice(SECOND_DEVICE_ID, DEVICE_NAME2, USB2, SECOND_EVENTHUB_ID,
- ftl::Flags<InputDeviceClass>(0));
-
- mFakeEventHub->addAbsoluteAxis(SECOND_EVENTHUB_ID, ABS_MT_POSITION_X, RAW_X_MIN, RAW_X_MAX,
- /*flat=*/0, /*fuzz=*/0);
- mFakeEventHub->addAbsoluteAxis(SECOND_EVENTHUB_ID, ABS_MT_POSITION_Y, RAW_Y_MIN, RAW_Y_MAX,
- /*flat=*/0, /*fuzz=*/0);
- mFakeEventHub->addAbsoluteAxis(SECOND_EVENTHUB_ID, ABS_MT_TRACKING_ID, RAW_ID_MIN, RAW_ID_MAX,
- /*flat=*/0, /*fuzz=*/0);
- mFakeEventHub->addAbsoluteAxis(SECOND_EVENTHUB_ID, ABS_MT_SLOT, RAW_SLOT_MIN, RAW_SLOT_MAX,
- /*flat=*/0, /*fuzz=*/0);
- mFakeEventHub->setAbsoluteAxisValue(SECOND_EVENTHUB_ID, ABS_MT_SLOT, /*value=*/0);
- mFakeEventHub->addConfigurationProperty(SECOND_EVENTHUB_ID, String8("touch.deviceType"),
- String8("touchScreen"));
-
- // Setup the second touch screen device.
- device2->addEmptyEventHubDevice(SECOND_EVENTHUB_ID);
- MultiTouchInputMapper& mapper2 = device2->constructAndAddMapper<
- MultiTouchInputMapper>(SECOND_EVENTHUB_ID, mFakePolicy->getReaderConfiguration());
- std::list<NotifyArgs> unused =
- device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- /*changes=*/{});
- unused += device2->reset(ARBITRARY_TIME);
-
- // Setup PointerController.
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- mFakePolicy->setPointerController(fakePointerController);
-
- // Setup policy for associated displays and show touches.
- const uint8_t hdmi1 = 0;
- const uint8_t hdmi2 = 1;
- mFakePolicy->addInputPortAssociation(DEVICE_LOCATION, hdmi1);
- mFakePolicy->addInputPortAssociation(USB2, hdmi2);
- mFakePolicy->setShowTouches(true);
-
- // Create displays.
- prepareDisplay(ui::ROTATION_0, hdmi1);
- prepareSecondaryDisplay(ViewportType::EXTERNAL, hdmi2);
-
- // Default device will reconfigure above, need additional reconfiguration for another device.
- unused += device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::Change::DISPLAY_INFO |
- InputReaderConfiguration::Change::SHOW_TOUCHES);
-
- // Two fingers down at default display.
- int32_t x1 = 100, y1 = 125, x2 = 300, y2 = 500;
- processPosition(mapper, x1, y1);
- processId(mapper, 1);
- processSlot(mapper, 1);
- processPosition(mapper, x2, y2);
- processId(mapper, 2);
- processSync(mapper);
-
- std::map<int32_t, std::vector<int32_t>>::const_iterator iter =
- fakePointerController->getSpots().find(DISPLAY_ID);
- ASSERT_TRUE(iter != fakePointerController->getSpots().end());
- ASSERT_EQ(size_t(2), iter->second.size());
-
- // Two fingers down at second display.
- processPosition(mapper2, x1, y1);
- processId(mapper2, 1);
- processSlot(mapper2, 1);
- processPosition(mapper2, x2, y2);
- processId(mapper2, 2);
- processSync(mapper2);
-
- iter = fakePointerController->getSpots().find(SECONDARY_DISPLAY_ID);
- ASSERT_TRUE(iter != fakePointerController->getSpots().end());
- ASSERT_EQ(size_t(2), iter->second.size());
-
- // Disable the show touches configuration and ensure the spots are cleared.
- mFakePolicy->setShowTouches(false);
- unused += device2->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
- InputReaderConfiguration::Change::SHOW_TOUCHES);
-
- ASSERT_TRUE(fakePointerController->getSpots().empty());
-}
-
TEST_F(MultiTouchInputMapperTest, VideoFrames_ReceivedByListener) {
prepareAxes(POSITION);
addConfigurationProperty("touch.deviceType", "touchScreen");
@@ -9703,58 +9553,6 @@
WithToolType(ToolType::STYLUS))));
}
-TEST_F(MultiTouchInputMapperTest, Process_WhenConfigEnabled_ShouldShowDirectStylusPointer) {
- addConfigurationProperty("touch.deviceType", "touchScreen");
- prepareDisplay(ui::ROTATION_0);
- prepareAxes(POSITION | ID | SLOT | TOOL_TYPE | PRESSURE);
- // Add BTN_TOOL_PEN to statically show stylus support, since using ABS_MT_TOOL_TYPE can only
- // indicate stylus presence dynamically.
- mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_PEN, 0, AKEYCODE_UNKNOWN, 0);
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- mFakePolicy->setPointerController(fakePointerController);
- mFakePolicy->setStylusPointerIconEnabled(true);
- MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
-
- processId(mapper, FIRST_TRACKING_ID);
- processPressure(mapper, RAW_PRESSURE_MIN);
- processPosition(mapper, 100, 200);
- processToolType(mapper, MT_TOOL_PEN);
- processSync(mapper);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(ToolType::STYLUS),
- WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
- ASSERT_TRUE(fakePointerController->isPointerShown());
- ASSERT_NO_FATAL_FAILURE(
- fakePointerController->assertPosition(toDisplayX(100), toDisplayY(200)));
-}
-
-TEST_F(MultiTouchInputMapperTest, Process_WhenConfigDisabled_ShouldNotShowDirectStylusPointer) {
- addConfigurationProperty("touch.deviceType", "touchScreen");
- prepareDisplay(ui::ROTATION_0);
- prepareAxes(POSITION | ID | SLOT | TOOL_TYPE | PRESSURE);
- // Add BTN_TOOL_PEN to statically show stylus support, since using ABS_MT_TOOL_TYPE can only
- // indicate stylus presence dynamically.
- mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOOL_PEN, 0, AKEYCODE_UNKNOWN, 0);
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- mFakePolicy->setPointerController(fakePointerController);
- mFakePolicy->setStylusPointerIconEnabled(false);
- MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
-
- processId(mapper, FIRST_TRACKING_ID);
- processPressure(mapper, RAW_PRESSURE_MIN);
- processPosition(mapper, 100, 200);
- processToolType(mapper, MT_TOOL_PEN);
- processSync(mapper);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(ToolType::STYLUS),
- WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
- ASSERT_FALSE(fakePointerController->isPointerShown());
-}
-
// --- MultiTouchInputMapperTest_ExternalDevice ---
class MultiTouchInputMapperTest_ExternalDevice : public MultiTouchInputMapperTest {
@@ -9790,18 +9588,15 @@
ASSERT_EQ(SECONDARY_DISPLAY_ID, motionArgs.displayId);
}
-TEST_F(MultiTouchInputMapperTest, Process_TouchpadPointer) {
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- fakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
- fakePointerController->setPosition(0, 0);
-
+// TODO(b/281840344): Remove the test when the old touchpad stack is removed. It is currently
+// unclear what the behavior of the touchpad logic in TouchInputMapper should do after the
+// PointerChoreographer refactor.
+TEST_F(MultiTouchInputMapperTest, DISABLED_Process_TouchpadPointer) {
// prepare device
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT);
mFakeEventHub->addKey(EVENTHUB_ID, BTN_LEFT, 0, AKEYCODE_UNKNOWN, 0);
mFakeEventHub->addKey(EVENTHUB_ID, BTN_TOUCH, 0, AKEYCODE_UNKNOWN, 0);
- mFakePolicy->setPointerController(fakePointerController);
MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
// run uncaptured pointer tests - pushes out generic events
// FINGER 0 DOWN
@@ -9855,13 +9650,9 @@
}
TEST_F(MultiTouchInputMapperTest, Touchpad_GetSources) {
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
-
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION | ID | SLOT);
mFakeEventHub->addKey(EVENTHUB_ID, BTN_LEFT, 0, AKEYCODE_UNKNOWN, 0);
- mFakePolicy->setPointerController(fakePointerController);
mFakePolicy->setPointerCapture(/*window=*/nullptr);
MultiTouchInputMapper& mapper = constructAndAddMapper<MultiTouchInputMapper>();
@@ -9925,10 +9716,6 @@
float mPointerXZoomScale;
void preparePointerMode(int xAxisResolution, int yAxisResolution) {
addConfigurationProperty("touch.deviceType", "pointer");
- std::shared_ptr<FakePointerController> fakePointerController =
- std::make_shared<FakePointerController>();
- fakePointerController->setBounds(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1);
- fakePointerController->setPosition(0, 0);
prepareDisplay(ui::ROTATION_0);
prepareAxes(POSITION);
@@ -9937,7 +9724,6 @@
// needs to be disabled, and the pointer gesture needs to be enabled.
mFakePolicy->setPointerCapture(/*window=*/nullptr);
mFakePolicy->setPointerGestureEnabled(true);
- mFakePolicy->setPointerController(fakePointerController);
float rawDiagonal = hypotf(RAW_X_MAX - RAW_X_MIN, RAW_Y_MAX - RAW_Y_MIN);
float displayDiagonal = hypotf(DISPLAY_WIDTH, DISPLAY_HEIGHT);
diff --git a/services/inputflinger/tests/PointerChoreographer_test.cpp b/services/inputflinger/tests/PointerChoreographer_test.cpp
index 11c6b7e..d81f8a0 100644
--- a/services/inputflinger/tests/PointerChoreographer_test.cpp
+++ b/services/inputflinger/tests/PointerChoreographer_test.cpp
@@ -15,7 +15,8 @@
*/
#include "../PointerChoreographer.h"
-
+#include <com_android_input_flags.h>
+#include <flag_macros.h>
#include <gtest/gtest.h>
#include <deque>
#include <vector>
@@ -27,6 +28,8 @@
namespace android {
+namespace input_flags = com::android::input::flags;
+
using ControllerType = PointerControllerInterface::ControllerType;
using testing::AllOf;
@@ -1587,6 +1590,76 @@
firstMousePc->assertPointerIconNotSet();
}
+TEST_F_WITH_FLAGS(PointerChoreographerTest, HidesTouchSpotsOnMirroredDisplaysForSecureWindow,
+ REQUIRES_FLAGS_ENABLED(
+ ACONFIG_FLAG(input_flags, hide_pointer_indicators_for_secure_windows))) {
+ // Add a touch device and enable show touches.
+ mChoreographer.notifyInputDevicesChanged(
+ {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, DISPLAY_ID)}});
+ mChoreographer.setShowTouchesEnabled(true);
+
+ // Emit touch events to create PointerController
+ mChoreographer.notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .pointer(FIRST_TOUCH_POINTER)
+ .deviceId(DEVICE_ID)
+ .displayId(DISPLAY_ID)
+ .build());
+
+ // By default touch indicators should not be hidden
+ auto pc = assertPointerControllerCreated(ControllerType::TOUCH);
+ pc->assertIsHiddenOnMirroredDisplays(DISPLAY_ID, /*isHidden=*/false);
+ pc->assertIsHiddenOnMirroredDisplays(ANOTHER_DISPLAY_ID, /*isHidden=*/false);
+
+ // adding secure window on display should set flag to hide pointer indicators on corresponding
+ // mirrored display
+ gui::WindowInfo windowInfo;
+ windowInfo.displayId = DISPLAY_ID;
+ windowInfo.inputConfig |= gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY;
+ mChoreographer.onWindowInfosChanged({windowInfo});
+ pc->assertIsHiddenOnMirroredDisplays(DISPLAY_ID, /*isHidden=*/true);
+ pc->assertIsHiddenOnMirroredDisplays(ANOTHER_DISPLAY_ID, /*isHidden=*/false);
+
+ // removing the secure window should reset the state
+ windowInfo.inputConfig.clear(gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY);
+ mChoreographer.onWindowInfosChanged({windowInfo});
+ pc->assertIsHiddenOnMirroredDisplays(DISPLAY_ID, /*isHidden=*/false);
+ pc->assertIsHiddenOnMirroredDisplays(ANOTHER_DISPLAY_ID, /*isHidden=*/false);
+}
+
+TEST_F_WITH_FLAGS(PointerChoreographerTest,
+ DoesNotHidesTouchSpotsOnMirroredDisplaysForInvisibleWindow,
+ REQUIRES_FLAGS_ENABLED(
+ ACONFIG_FLAG(input_flags, hide_pointer_indicators_for_secure_windows))) {
+ // Add a touch device and enable show touches.
+ mChoreographer.notifyInputDevicesChanged(
+ {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN, DISPLAY_ID)}});
+ mChoreographer.setShowTouchesEnabled(true);
+
+ // Emit touch events to create PointerController
+ mChoreographer.notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .pointer(FIRST_TOUCH_POINTER)
+ .deviceId(DEVICE_ID)
+ .displayId(DISPLAY_ID)
+ .build());
+
+ // By default touch indicators should not be hidden
+ auto pc = assertPointerControllerCreated(ControllerType::TOUCH);
+ pc->assertIsHiddenOnMirroredDisplays(DISPLAY_ID, /*isHidden=*/false);
+ pc->assertIsHiddenOnMirroredDisplays(ANOTHER_DISPLAY_ID, /*isHidden=*/false);
+
+ // adding secure but hidden window on display should still not set flag to hide pointer
+ // indicators
+ gui::WindowInfo windowInfo;
+ windowInfo.displayId = DISPLAY_ID;
+ windowInfo.inputConfig |= gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY;
+ windowInfo.inputConfig |= gui::WindowInfo::InputConfig::NOT_VISIBLE;
+ mChoreographer.onWindowInfosChanged({windowInfo});
+ pc->assertIsHiddenOnMirroredDisplays(DISPLAY_ID, /*isHidden=*/false);
+ pc->assertIsHiddenOnMirroredDisplays(ANOTHER_DISPLAY_ID, /*isHidden=*/false);
+}
+
TEST_P(StylusTestFixture, SetsPointerIconForStylus) {
const auto& [name, source, controllerType] = GetParam();
diff --git a/services/inputflinger/tests/TouchpadInputMapper_test.cpp b/services/inputflinger/tests/TouchpadInputMapper_test.cpp
index a92dce5..402654c 100644
--- a/services/inputflinger/tests/TouchpadInputMapper_test.cpp
+++ b/services/inputflinger/tests/TouchpadInputMapper_test.cpp
@@ -19,9 +19,7 @@
#include <android-base/logging.h>
#include <gtest/gtest.h>
-#include <com_android_input_flags.h>
#include <thread>
-#include "FakePointerController.h"
#include "InputMapperTest.h"
#include "InterfaceMocks.h"
#include "TestEventMatchers.h"
@@ -44,12 +42,10 @@
constexpr int32_t DISPLAY_HEIGHT = 800;
constexpr std::optional<uint8_t> NO_PORT = std::nullopt; // no physical port is specified
-namespace input_flags = com::android::input::flags;
-
/**
* Unit tests for TouchpadInputMapper.
*/
-class TouchpadInputMapperTestBase : public InputMapperUnitTest {
+class TouchpadInputMapperTest : public InputMapperUnitTest {
protected:
void SetUp() override {
InputMapperUnitTest::SetUp();
@@ -117,18 +113,7 @@
return base::ResultError("Axis not supported", NAME_NOT_FOUND);
});
createDevice();
- mMapper = createInputMapper<TouchpadInputMapper>(*mDeviceContext, mReaderConfiguration,
- isPointerChoreographerEnabled());
- }
-
- virtual bool isPointerChoreographerEnabled() { return false; }
-};
-
-class TouchpadInputMapperTest : public TouchpadInputMapperTestBase {
-protected:
- void SetUp() override {
- input_flags::enable_pointer_choreographer(false);
- TouchpadInputMapperTestBase::SetUp();
+ mMapper = createInputMapper<TouchpadInputMapper>(*mDeviceContext, mReaderConfiguration);
}
};
@@ -139,66 +124,6 @@
* but only after the button is released.
*/
TEST_F(TouchpadInputMapperTest, HoverAndLeftButtonPress) {
- std::list<NotifyArgs> args;
-
- args += process(EV_ABS, ABS_MT_TRACKING_ID, 1);
- args += process(EV_KEY, BTN_TOUCH, 1);
- setScanCodeState(KeyState::DOWN, {BTN_TOOL_FINGER});
- args += process(EV_KEY, BTN_TOOL_FINGER, 1);
- args += process(EV_ABS, ABS_MT_POSITION_X, 50);
- args += process(EV_ABS, ABS_MT_POSITION_Y, 50);
- args += process(EV_ABS, ABS_MT_PRESSURE, 1);
- args += process(EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args, testing::IsEmpty());
-
- // Without this sleep, the test fails.
- // TODO(b/284133337): Figure out whether this can be removed
- std::this_thread::sleep_for(std::chrono::milliseconds(20));
-
- args += process(EV_KEY, BTN_LEFT, 1);
- setScanCodeState(KeyState::DOWN, {BTN_LEFT});
- args += process(EV_SYN, SYN_REPORT, 0);
-
- args += process(EV_KEY, BTN_LEFT, 0);
- setScanCodeState(KeyState::UP, {BTN_LEFT});
- args += process(EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args,
- ElementsAre(VariantWith<NotifyMotionArgs>(WithMotionAction(HOVER_ENTER)),
- VariantWith<NotifyMotionArgs>(WithMotionAction(HOVER_MOVE)),
- VariantWith<NotifyMotionArgs>(WithMotionAction(HOVER_EXIT)),
- VariantWith<NotifyMotionArgs>(WithMotionAction(ACTION_DOWN)),
- VariantWith<NotifyMotionArgs>(WithMotionAction(BUTTON_PRESS)),
- VariantWith<NotifyMotionArgs>(WithMotionAction(BUTTON_RELEASE)),
- VariantWith<NotifyMotionArgs>(WithMotionAction(ACTION_UP)),
- VariantWith<NotifyMotionArgs>(WithMotionAction(HOVER_ENTER))));
-
- // Liftoff
- args.clear();
- args += process(EV_ABS, ABS_MT_PRESSURE, 0);
- args += process(EV_ABS, ABS_MT_TRACKING_ID, -1);
- args += process(EV_KEY, BTN_TOUCH, 0);
- setScanCodeState(KeyState::UP, {BTN_TOOL_FINGER});
- args += process(EV_KEY, BTN_TOOL_FINGER, 0);
- args += process(EV_SYN, SYN_REPORT, 0);
- ASSERT_THAT(args, testing::IsEmpty());
-}
-
-class TouchpadInputMapperTestWithChoreographer : public TouchpadInputMapperTestBase {
-protected:
- void SetUp() override { TouchpadInputMapperTestBase::SetUp(); }
-
- bool isPointerChoreographerEnabled() override { return true; }
-};
-
-// TODO(b/311416205): De-duplicate the test cases after the refactoring is complete and the flagging
-// logic can be removed.
-/**
- * Start moving the finger and then click the left touchpad button. Check whether HOVER_EXIT is
- * generated when hovering stops. Currently, it is not.
- * In the current implementation, HOVER_MOVE and ACTION_DOWN events are not sent out right away,
- * but only after the button is released.
- */
-TEST_F(TouchpadInputMapperTestWithChoreographer, HoverAndLeftButtonPress) {
mFakePolicy->setDefaultPointerDisplayId(DISPLAY_ID);
mFakePolicy->addDisplayViewport(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, ui::ROTATION_0,
/*isActive=*/true, "local:0", NO_PORT, ViewportType::INTERNAL);
diff --git a/services/inputflinger/tests/fuzzers/MapperHelpers.h b/services/inputflinger/tests/fuzzers/MapperHelpers.h
index 7898126..2602ebb 100644
--- a/services/inputflinger/tests/fuzzers/MapperHelpers.h
+++ b/services/inputflinger/tests/fuzzers/MapperHelpers.h
@@ -289,6 +289,7 @@
void setDisplayViewport(const DisplayViewport& displayViewport) override {}
void updatePointerIcon(PointerIconStyle iconId) override {}
void setCustomPointerIcon(const SpriteIcon& icon) override {}
+ void setSkipScreenshot(int32_t displayId, bool skip) override{};
std::string dump() override { return ""; }
};
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index a2b5329..2ff0fac 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -1061,8 +1061,8 @@
}
if (snapshot.isSecure ||
- parentSnapshot.inputInfo.inputConfig.test(InputConfig::SENSITIVE_FOR_TRACING)) {
- snapshot.inputInfo.inputConfig |= InputConfig::SENSITIVE_FOR_TRACING;
+ parentSnapshot.inputInfo.inputConfig.test(InputConfig::SENSITIVE_FOR_PRIVACY)) {
+ snapshot.inputInfo.inputConfig |= InputConfig::SENSITIVE_FOR_PRIVACY;
}
updateVisibility(snapshot, snapshot.isVisible);
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 77e045d..2ec20ad 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -42,6 +42,7 @@
#include "DisplayRenderArea.h"
#include "FrontEnd/LayerCreationArgs.h"
#include "Layer.h"
+#include "RenderAreaBuilder.h"
#include "Scheduler/VsyncController.h"
#include "SurfaceFlinger.h"
@@ -279,8 +280,11 @@
constexpr bool kHintForSeamlessTransition = false;
SurfaceFlinger::RenderAreaFuture renderAreaFuture = ftl::defer([=] {
- return DisplayRenderArea::create(displayWeak, sampledBounds, sampledBounds.getSize(),
- ui::Dataspace::V0_SRGB, kHintForSeamlessTransition);
+ DisplayRenderAreaBuilder displayRenderArea(sampledBounds, sampledBounds.getSize(),
+ ui::Dataspace::V0_SRGB,
+ kHintForSeamlessTransition,
+ true /* captureSecureLayers */, displayWeak);
+ return displayRenderArea.build();
});
std::unordered_set<sp<IRegionSamplingListener>, SpHash<IRegionSamplingListener>> listeners;
diff --git a/services/surfaceflinger/RenderAreaBuilder.h b/services/surfaceflinger/RenderAreaBuilder.h
new file mode 100644
index 0000000..012acd2
--- /dev/null
+++ b/services/surfaceflinger/RenderAreaBuilder.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2024 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 "DisplayDevice.h"
+#include "DisplayRenderArea.h"
+#include "LayerRenderArea.h"
+#include "ui/Size.h"
+#include "ui/Transform.h"
+
+namespace android {
+/**
+ * A parameter object for creating a render area
+ */
+struct RenderAreaBuilder {
+ // Source crop of the render area
+ Rect crop;
+
+ // Size of the physical render area
+ ui::Size reqSize;
+
+ // Composition data space of the render area
+ ui::Dataspace reqDataSpace;
+
+ // If true, the secure layer would be blacked out or skipped
+ // when rendered to an insecure render area
+ bool allowSecureLayers;
+
+ // If true, the render result may be used for system animations
+ // that must preserve the exact colors of the display
+ bool hintForSeamlessTransition;
+
+ virtual std::unique_ptr<RenderArea> build() const = 0;
+
+ RenderAreaBuilder(Rect crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
+ bool allowSecureLayers, bool hintForSeamlessTransition)
+ : crop(crop),
+ reqSize(reqSize),
+ reqDataSpace(reqDataSpace),
+ allowSecureLayers(allowSecureLayers),
+ hintForSeamlessTransition(hintForSeamlessTransition) {}
+
+ virtual ~RenderAreaBuilder() = default;
+};
+
+struct DisplayRenderAreaBuilder : RenderAreaBuilder {
+ DisplayRenderAreaBuilder(Rect crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
+ bool allowSecureLayers, bool hintForSeamlessTransition,
+ wp<const DisplayDevice> displayWeak)
+ : RenderAreaBuilder(crop, reqSize, reqDataSpace, allowSecureLayers,
+ hintForSeamlessTransition),
+ displayWeak(displayWeak) {}
+
+ // Display that render area will be on
+ wp<const DisplayDevice> displayWeak;
+
+ std::unique_ptr<RenderArea> build() const override {
+ return DisplayRenderArea::create(displayWeak, crop, reqSize, reqDataSpace,
+ hintForSeamlessTransition, allowSecureLayers);
+ }
+};
+
+struct LayerRenderAreaBuilder : RenderAreaBuilder {
+ LayerRenderAreaBuilder(Rect crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
+ bool allowSecureLayers, bool hintForSeamlessTransition, sp<Layer> layer,
+ bool childrenOnly)
+ : RenderAreaBuilder(crop, reqSize, reqDataSpace, allowSecureLayers,
+ hintForSeamlessTransition),
+ layer(layer),
+ childrenOnly(childrenOnly) {}
+
+ // Layer that the render area will be on
+ sp<Layer> layer;
+
+ // Transform to be applied on the layers to transform them
+ // into the logical render area
+ ui::Transform layerTransform{ui::Transform()};
+
+ // Buffer bounds
+ Rect layerBufferSize{Rect()};
+
+ // If false, transform is inverted from the parent snapshot
+ bool childrenOnly;
+
+ // Uses parent snapshot to determine layer transform and buffer size
+ void setLayerInfo(const frontend::LayerSnapshot* parentSnapshot) {
+ if (!childrenOnly) {
+ layerTransform = parentSnapshot->localTransform.inverse();
+ }
+ layerBufferSize = parentSnapshot->bufferSize;
+ }
+
+ std::unique_ptr<RenderArea> build() const override {
+ return std::make_unique<LayerRenderArea>(layer, crop, reqSize, reqDataSpace,
+ allowSecureLayers, layerTransform, layerBufferSize,
+ hintForSeamlessTransition);
+ }
+};
+
+} // namespace android
\ No newline at end of file
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9d29c41..496185e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -148,6 +148,7 @@
#include "MutexUtils.h"
#include "NativeWindowSurface.h"
#include "RegionSamplingThread.h"
+#include "RenderAreaBuilder.h"
#include "Scheduler/EventThread.h"
#include "Scheduler/LayerHistory.h"
#include "Scheduler/Scheduler.h"
@@ -424,7 +425,8 @@
mInternalDisplayDensity(
getDensityFromProperty("ro.sf.lcd_density", !mEmulatedDisplayDensity)),
mPowerAdvisor(std::make_unique<Hwc2::impl::PowerAdvisor>(*this)),
- mWindowInfosListenerInvoker(sp<WindowInfosListenerInvoker>::make()) {
+ mWindowInfosListenerInvoker(sp<WindowInfosListenerInvoker>::make()),
+ mSkipPowerOnForQuiescent(base::GetBoolProperty("ro.boot.quiescent"s, false)) {
ALOGI("Using HWComposer service: %s", mHwcServiceName.c_str());
}
@@ -3882,7 +3884,9 @@
if (currentState.physical) {
const auto display = getDisplayDeviceLocked(displayToken);
- setPowerModeInternal(display, hal::PowerMode::ON);
+ if (!mSkipPowerOnForQuiescent) {
+ setPowerModeInternal(display, hal::PowerMode::ON);
+ }
// TODO(b/175678251) Call a listener instead.
if (currentState.physical->hwcDisplayId == getHwComposer().getPrimaryHwcDisplayId()) {
@@ -6101,8 +6105,11 @@
// Power on all displays. The primary display is first, so becomes the active display. Also,
// the DisplayCapability set of a display is populated on its first powering on. Do this now
// before responding to any Binder query from DisplayManager about display capabilities.
- for (const auto& [id, display] : mPhysicalDisplays) {
- setPowerModeInternal(getDisplayDeviceLocked(id), hal::PowerMode::ON);
+ // Additionally, do not turn on displays if the boot should be quiescent.
+ if (!mSkipPowerOnForQuiescent) {
+ for (const auto& [id, display] : mPhysicalDisplays) {
+ setPowerModeInternal(getDisplayDeviceLocked(id), hal::PowerMode::ON);
+ }
}
}
}
@@ -6261,6 +6268,7 @@
void SurfaceFlinger::setPowerMode(const sp<IBinder>& displayToken, int mode) {
auto future = mScheduler->schedule([=, this]() FTL_FAKE_GUARD(mStateLock) FTL_FAKE_GUARD(
kMainThreadContext) {
+ mSkipPowerOnForQuiescent = false;
const auto display = getDisplayDeviceLocked(displayToken);
if (!display) {
ALOGE("Attempt to set power mode %d for invalid display token %p", mode,
@@ -7892,8 +7900,10 @@
}
RenderAreaFuture renderAreaFuture = ftl::defer([=] {
- return DisplayRenderArea::create(displayWeak, args.sourceCrop, reqSize, args.dataspace,
- args.hintForSeamlessTransition, args.captureSecureLayers);
+ DisplayRenderAreaBuilder displayRenderArea(args.sourceCrop, reqSize, args.dataspace,
+ args.hintForSeamlessTransition,
+ args.captureSecureLayers, displayWeak);
+ return displayRenderArea.build();
});
GetLayerSnapshotsFunction getLayerSnapshots;
@@ -7946,9 +7956,10 @@
}
RenderAreaFuture renderAreaFuture = ftl::defer([=] {
- return DisplayRenderArea::create(displayWeak, Rect(), size, args.dataspace,
- args.hintForSeamlessTransition,
- false /* captureSecureLayers */);
+ DisplayRenderAreaBuilder displayRenderArea(Rect(), size, args.dataspace,
+ args.hintForSeamlessTransition,
+ false /* captureSecureLayers */, displayWeak);
+ return displayRenderArea.build();
});
GetLayerSnapshotsFunction getLayerSnapshots;
@@ -8053,25 +8064,22 @@
return;
}
- RenderAreaFuture renderAreaFuture = ftl::defer([=, this]() FTL_FAKE_GUARD(kMainThreadContext)
- -> std::unique_ptr<RenderArea> {
- ui::Transform layerTransform;
- Rect layerBufferSize;
- frontend::LayerSnapshot* snapshot =
- mLayerSnapshotBuilder.getSnapshot(parent->getSequence());
- if (!snapshot) {
- ALOGW("Couldn't find layer snapshot for %d", parent->getSequence());
- } else {
- if (!args.childrenOnly) {
- layerTransform = snapshot->localTransform.inverse();
- }
- layerBufferSize = snapshot->bufferSize;
- }
+ RenderAreaFuture renderAreaFuture = ftl::defer(
+ [=, this]() FTL_FAKE_GUARD(kMainThreadContext) -> std::unique_ptr<RenderArea> {
+ LayerRenderAreaBuilder layerRenderArea(crop, reqSize, dataspace,
+ args.captureSecureLayers,
+ args.hintForSeamlessTransition, parent,
+ args.childrenOnly);
- return std::make_unique<LayerRenderArea>(parent, crop, reqSize, dataspace,
- args.captureSecureLayers, layerTransform,
- layerBufferSize, args.hintForSeamlessTransition);
- });
+ frontend::LayerSnapshot* snapshot =
+ mLayerSnapshotBuilder.getSnapshot(parent->getSequence());
+ if (!snapshot) {
+ ALOGW("Couldn't find layer snapshot for %d", parent->getSequence());
+ } else {
+ layerRenderArea.setLayerInfo(snapshot);
+ }
+ return layerRenderArea.build();
+ });
GetLayerSnapshotsFunction getLayerSnapshots;
if (mLayerLifecycleManagerEnabled) {
std::optional<FloatRect> parentCrop = std::nullopt;
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index fc50fd9..2444424 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1491,6 +1491,8 @@
bool mPowerHintSessionEnabled;
bool mLayerLifecycleManagerEnabled = false;
+ // Whether a display should be turned on when initialized
+ bool mSkipPowerOnForQuiescent;
frontend::LayerLifecycleManager mLayerLifecycleManager GUARDED_BY(kMainThreadContext);
frontend::LayerHierarchyBuilder mLayerHierarchyBuilder GUARDED_BY(kMainThreadContext);
diff --git a/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp
index 2b1834d..4b3ad8a 100644
--- a/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp
+++ b/services/surfaceflinger/tests/LayerRenderTypeTransaction_test.cpp
@@ -154,8 +154,6 @@
switch (layerType) {
case ISurfaceComposerClient::eFXSurfaceBufferQueue:
- Transaction().setPosition(layerG, 16, 16).setRelativeLayer(layerG, layerR, 1).apply();
- break;
case ISurfaceComposerClient::eFXSurfaceBufferState:
Transaction().setPosition(layerG, 16, 16).setRelativeLayer(layerG, layerR, 1).apply();
break;
@@ -200,13 +198,6 @@
// layerR = 0, layerG = layerR + 3, layerB = 2
switch (layerType) {
case ISurfaceComposerClient::eFXSurfaceBufferQueue:
- Transaction()
- .setPosition(layerG, 8, 8)
- .setRelativeLayer(layerG, layerR, 3)
- .setPosition(layerB, 16, 16)
- .setLayer(layerB, mLayerZBase + 2)
- .apply();
- break;
case ISurfaceComposerClient::eFXSurfaceBufferState:
Transaction()
.setPosition(layerG, 8, 8)
@@ -413,13 +404,6 @@
switch (layerType) {
case ISurfaceComposerClient::eFXSurfaceBufferQueue:
- Transaction()
- .setAlpha(layer1, 0.25f)
- .setAlpha(layer2, 0.75f)
- .setPosition(layer2, 16, 0)
- .setLayer(layer2, mLayerZBase + 1)
- .apply();
- break;
case ISurfaceComposerClient::eFXSurfaceBufferState:
Transaction()
.setAlpha(layer1, 0.25f)
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index 7c6cff0..82adadc 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -1204,34 +1204,34 @@
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
EXPECT_TRUE(getSnapshot(11)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_TRUE(getSnapshot(111)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_FALSE(getSnapshot(1)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_FALSE(getSnapshot(12)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_FALSE(getSnapshot(2)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
}
TEST_F(LayerSnapshotTest, setSensitiveForTracingFromInputWindowHandle) {
setInputInfo(11, [](auto& inputInfo) {
- inputInfo.inputConfig |= gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING;
+ inputInfo.inputConfig |= gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY;
});
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
EXPECT_TRUE(getSnapshot(11)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_TRUE(getSnapshot(111)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_FALSE(getSnapshot(1)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_FALSE(getSnapshot(12)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
EXPECT_FALSE(getSnapshot(2)->inputInfo.inputConfig.test(
- gui::WindowInfo::InputConfig::SENSITIVE_FOR_TRACING));
+ gui::WindowInfo::InputConfig::SENSITIVE_FOR_PRIVACY));
}
// b/314350323
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index 81fd118..7ea98f5 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -1372,6 +1372,11 @@
android::GraphicsEnv::getInstance().setTargetStats(
android::GpuStatsInfo::Stats::CREATED_VULKAN_API_VERSION,
vulkanApiVersion);
+
+ if (pCreateInfo->pApplicationInfo->pEngineName) {
+ android::GraphicsEnv::getInstance().addVulkanEngineName(
+ pCreateInfo->pApplicationInfo->pEngineName);
+ }
}
// Update stats for the extensions requested