Merge "Revert "SF: throttle WindowInfosListener calls"" into udc-dev
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 097bc53..2ce3fb0 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -7,6 +7,7 @@
rustfmt = --config-path=rustfmt.toml
# Only turn on clang-format check for the following subfolders.
clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
+ cmds/dumpstate/
cmds/idlcli/
cmds/installd/
cmds/servicemanager/
diff --git a/cmds/cmd/fuzzer/Android.bp b/cmds/cmd/fuzzer/Android.bp
index a65f6de..faf461a 100644
--- a/cmds/cmd/fuzzer/Android.bp
+++ b/cmds/cmd/fuzzer/Android.bp
@@ -42,5 +42,13 @@
"android-media-fuzzing-reports@google.com",
],
componentid: 155276,
+ hotlists: [
+ "4593311",
+ ],
+ description: "The fuzzer targets the APIs of libcmd",
+ vector: "local_no_privileges_required",
+ service_privilege: "constrained",
+ users: "multi_user",
+ fuzzed_code_usage: "shipped",
},
}
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 6f84e7c..baf8e42 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -816,6 +816,8 @@
printf("Kernel: ");
DumpFileToFd(STDOUT_FILENO, "", "/proc/version");
printf("Command line: %s\n", strtok(cmdline_buf, "\n"));
+ printf("Bootconfig: ");
+ DumpFileToFd(STDOUT_FILENO, "", "/proc/bootconfig");
printf("Uptime: ");
RunCommandToFd(STDOUT_FILENO, "", {"uptime", "-p"},
CommandOptions::WithTimeout(1).Always().Build());
@@ -1254,7 +1256,8 @@
dumpsys.writeDumpHeader(STDOUT_FILENO, service, priority);
dumpsys.writeDumpFooter(STDOUT_FILENO, service, std::chrono::milliseconds(1));
} else {
- status_t status = dumpsys.startDumpThread(Dumpsys::TYPE_DUMP | Dumpsys::TYPE_PID,
+ status_t status = dumpsys.startDumpThread(Dumpsys::TYPE_DUMP | Dumpsys::TYPE_PID |
+ Dumpsys::TYPE_CLIENTS | Dumpsys::TYPE_THREAD,
service, args);
if (status == OK) {
dumpsys.writeDumpHeader(STDOUT_FILENO, service, priority);
@@ -1273,6 +1276,9 @@
dumpsys.writeDumpFooter(STDOUT_FILENO, service, elapsed_seconds);
bool dump_complete = (status == OK);
dumpsys.stopDumpThread(dump_complete);
+ } else {
+ MYLOGE("Failed to start dump thread for service: %s, status: %d",
+ String8(service).c_str(), status);
}
}
@@ -2066,6 +2072,8 @@
SEC_TO_MSEC(10));
RunDumpsys("DUMPSYS", {"telephony.registry"}, CommandOptions::WithTimeout(90).Build(),
SEC_TO_MSEC(10));
+ RunDumpsys("DUMPSYS", {"isub"}, CommandOptions::WithTimeout(90).Build(),
+ SEC_TO_MSEC(10));
RunDumpsys("DUMPSYS", {"telecom"}, CommandOptions::WithTimeout(90).Build(),
SEC_TO_MSEC(10));
if (include_sensitive_info) {
diff --git a/cmds/installd/tests/installd_dexopt_test.cpp b/cmds/installd/tests/installd_dexopt_test.cpp
index be4ca43..c4071c6 100644
--- a/cmds/installd/tests/installd_dexopt_test.cpp
+++ b/cmds/installd/tests/installd_dexopt_test.cpp
@@ -203,6 +203,10 @@
std::string secondary_dex_de_;
virtual void SetUp() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP() << "Skipping legacy dexopt tests when ART Service is enabled";
+ }
+
setenv("ANDROID_LOG_TAGS", "*:v", 1);
android::base::InitLogging(nullptr);
// Initialize the globals holding the file system main paths (/data/, /system/ etc..).
@@ -223,6 +227,10 @@
}
virtual void TearDown() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP();
+ }
+
if (!kDebug) {
service_->controlDexOptBlocking(false);
service_->destroyAppData(
@@ -966,6 +974,10 @@
class PrimaryDexReCompilationTest : public DexoptTest {
public:
virtual void SetUp() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP() << "Skipping legacy dexopt tests when ART Service is enabled";
+ }
+
DexoptTest::SetUp();
CompilePrimaryDexOk("verify",
DEXOPT_BOOTCOMPLETE | DEXOPT_PUBLIC,
@@ -980,6 +992,10 @@
}
virtual void TearDown() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP();
+ }
+
first_compilation_odex_fd_.reset(-1);
first_compilation_vdex_fd_.reset(-1);
DexoptTest::TearDown();
@@ -1002,6 +1018,10 @@
class ReconcileTest : public DexoptTest {
virtual void SetUp() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP() << "Skipping legacy dexopt tests when ART Service is enabled";
+ }
+
DexoptTest::SetUp();
CompileSecondaryDex(secondary_dex_ce_, DEXOPT_STORAGE_CE,
/*binder_ok*/ true, /*compile_ok*/ true);
@@ -1067,6 +1087,10 @@
static constexpr const char* kPrimaryProfile = "primary.prof";
virtual void SetUp() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP() << "Skipping legacy dexopt tests when ART Service is enabled";
+ }
+
DexoptTest::SetUp();
cur_profile_ = create_current_profile_path(
kTestUserId, package_name_, kPrimaryProfile, /*is_secondary_dex*/ false);
@@ -1440,6 +1464,9 @@
std::vector<int64_t> extra_ce_data_inodes_;
virtual void SetUp() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP() << "Skipping legacy dexopt tests when ART Service is enabled";
+ }
ProfileTest::SetUp();
intial_android_profiles_dir = android_profiles_dir;
@@ -1453,6 +1480,10 @@
}
virtual void TearDown() {
+ if (base::GetBoolProperty("dalvik.vm.useartservice", false)) {
+ GTEST_SKIP();
+ }
+
android_profiles_dir = intial_android_profiles_dir;
deleteAppProfilesForBootMerge();
ProfileTest::TearDown();
diff --git a/cmds/servicemanager/Android.bp b/cmds/servicemanager/Android.bp
index 1386660..d73a30b 100644
--- a/cmds/servicemanager/Android.bp
+++ b/cmds/servicemanager/Android.bp
@@ -72,6 +72,7 @@
cc_test {
name: "servicemanager_test",
+ host_supported: true,
test_suites: ["device-tests"],
defaults: ["servicemanager_defaults"],
srcs: [
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp
index 4da0cd6..cc8ac0a 100644
--- a/cmds/servicemanager/ServiceManager.cpp
+++ b/cmds/servicemanager/ServiceManager.cpp
@@ -337,34 +337,38 @@
auto ctx = mAccess->getCallingContext();
if (multiuser_get_app_id(ctx.uid) >= AID_APP) {
- return Status::fromExceptionCode(Status::EX_SECURITY, "App UIDs cannot add services");
+ return Status::fromExceptionCode(Status::EX_SECURITY, "App UIDs cannot add services.");
}
if (!mAccess->canAdd(ctx, name)) {
- return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denial");
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
if (binder == nullptr) {
- return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Null binder");
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Null binder.");
}
if (!isValidServiceName(name)) {
ALOGE("Invalid service name: %s", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Invalid service name");
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Invalid service name.");
}
#ifndef VENDORSERVICEMANAGER
if (!meetsDeclarationRequirements(binder, name)) {
// already logged
- return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "VINTF declaration error");
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "VINTF declaration error.");
}
#endif // !VENDORSERVICEMANAGER
+ if ((dumpPriority & DUMP_FLAG_PRIORITY_ALL) == 0) {
+ ALOGW("Dump flag priority is not set when adding %s", name.c_str());
+ }
+
// implicitly unlinked when the binder is removed
if (binder->remoteBinder() != nullptr &&
binder->linkToDeath(sp<ServiceManager>::fromExisting(this)) != OK) {
ALOGE("Could not linkToDeath when adding %s", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, "linkToDeath failure");
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, "Couldn't linkToDeath.");
}
auto it = mNameToService.find(name);
@@ -418,7 +422,7 @@
Status ServiceManager::listServices(int32_t dumpPriority, std::vector<std::string>* outList) {
if (!mAccess->canList(mAccess->getCallingContext())) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
size_t toReserve = 0;
@@ -462,18 +466,18 @@
if (!isValidServiceName(name)) {
ALOGE("Invalid service name: %s", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Invalid service name.");
}
if (callback == nullptr) {
- return Status::fromExceptionCode(Status::EX_NULL_POINTER);
+ return Status::fromExceptionCode(Status::EX_NULL_POINTER, "Null callback.");
}
if (OK !=
IInterface::asBinder(callback)->linkToDeath(
sp<ServiceManager>::fromExisting(this))) {
ALOGE("Could not linkToDeath when adding %s", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, "Couldn't link to death.");
}
mNameToRegistrationCallback[name].push_back(callback);
@@ -493,7 +497,7 @@
auto ctx = mAccess->getCallingContext();
if (!mAccess->canFind(ctx, name)) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
bool found = false;
@@ -505,7 +509,7 @@
if (!found) {
ALOGE("Trying to unregister callback, but none exists %s", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, "Nothing to unregister.");
}
return Status::ok();
@@ -515,7 +519,7 @@
auto ctx = mAccess->getCallingContext();
if (!mAccess->canFind(ctx, name)) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
*outReturn = false;
@@ -543,7 +547,7 @@
}
if (outReturn->size() == 0 && allInstances.size() != 0) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
return Status::ok();
@@ -554,7 +558,7 @@
auto ctx = mAccess->getCallingContext();
if (!mAccess->canFind(ctx, name)) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
*outReturn = std::nullopt;
@@ -583,7 +587,7 @@
}
if (outReturn->size() == 0 && apexUpdatableInstances.size() != 0) {
- return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denial");
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
return Status::ok();
@@ -594,7 +598,7 @@
auto ctx = mAccess->getCallingContext();
if (!mAccess->canFind(ctx, name)) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
*outReturn = std::nullopt;
@@ -663,36 +667,37 @@
Status ServiceManager::registerClientCallback(const std::string& name, const sp<IBinder>& service,
const sp<IClientCallback>& cb) {
if (cb == nullptr) {
- return Status::fromExceptionCode(Status::EX_NULL_POINTER);
+ return Status::fromExceptionCode(Status::EX_NULL_POINTER, "Callback null.");
}
auto ctx = mAccess->getCallingContext();
if (!mAccess->canAdd(ctx, name)) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
auto serviceIt = mNameToService.find(name);
if (serviceIt == mNameToService.end()) {
ALOGE("Could not add callback for nonexistent service: %s", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Service doesn't exist.");
}
if (serviceIt->second.ctx.debugPid != IPCThreadState::self()->getCallingPid()) {
ALOGW("Only a server can register for client callbacks (for %s)", name.c_str());
- return Status::fromExceptionCode(Status::EX_UNSUPPORTED_OPERATION);
+ return Status::fromExceptionCode(Status::EX_UNSUPPORTED_OPERATION,
+ "Only service can register client callback for itself.");
}
if (serviceIt->second.binder != service) {
ALOGW("Tried to register client callback for %s but a different service is registered "
"under this name.",
name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Service mismatch.");
}
if (OK !=
IInterface::asBinder(cb)->linkToDeath(sp<ServiceManager>::fromExisting(this))) {
ALOGE("Could not linkToDeath when adding client callback for %s", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, "Couldn't linkToDeath.");
}
mNameToClientCallback[name].push_back(cb);
@@ -806,24 +811,25 @@
Status ServiceManager::tryUnregisterService(const std::string& name, const sp<IBinder>& binder) {
if (binder == nullptr) {
- return Status::fromExceptionCode(Status::EX_NULL_POINTER);
+ return Status::fromExceptionCode(Status::EX_NULL_POINTER, "Null service.");
}
auto ctx = mAccess->getCallingContext();
if (!mAccess->canAdd(ctx, name)) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
auto serviceIt = mNameToService.find(name);
if (serviceIt == mNameToService.end()) {
ALOGW("Tried to unregister %s, but that service wasn't registered to begin with.",
name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, "Service not registered.");
}
if (serviceIt->second.ctx.debugPid != IPCThreadState::self()->getCallingPid()) {
ALOGW("Only a server can unregister itself (for %s)", name.c_str());
- return Status::fromExceptionCode(Status::EX_UNSUPPORTED_OPERATION);
+ return Status::fromExceptionCode(Status::EX_UNSUPPORTED_OPERATION,
+ "Service can only unregister itself.");
}
sp<IBinder> storedBinder = serviceIt->second.binder;
@@ -831,14 +837,16 @@
if (binder != storedBinder) {
ALOGW("Tried to unregister %s, but a different service is registered under this name.",
name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE,
+ "Different service registered under this name.");
}
// important because we don't have timer-based guarantees, we don't want to clear
// this
if (serviceIt->second.guaranteeClient) {
ALOGI("Tried to unregister %s, but there is about to be a client.", name.c_str());
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE,
+ "Can't unregister, pending client.");
}
// - kernel driver will hold onto one refcount (during this transaction)
@@ -853,7 +861,8 @@
// help reduce thrashing, but we should be able to remove it.
serviceIt->second.guaranteeClient = true;
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE,
+ "Can't unregister, known client.");
}
ALOGI("Unregistering %s", name.c_str());
@@ -864,7 +873,7 @@
Status ServiceManager::getServiceDebugInfo(std::vector<ServiceDebugInfo>* outReturn) {
if (!mAccess->canList(mAccess->getCallingContext())) {
- return Status::fromExceptionCode(Status::EX_SECURITY);
+ return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denied.");
}
outReturn->reserve(mNameToService.size());
diff --git a/data/etc/Android.bp b/data/etc/Android.bp
index bdd5172..754e7b2 100644
--- a/data/etc/Android.bp
+++ b/data/etc/Android.bp
@@ -77,6 +77,12 @@
}
prebuilt_etc {
+ name: "android.hardware.context_hub.prebuilt.xml",
+ src: "android.hardware.context_hub.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.ethernet.prebuilt.xml",
src: "android.hardware.ethernet.xml",
defaults: ["frameworks_native_data_etc_defaults"],
@@ -107,30 +113,102 @@
}
prebuilt_etc {
+ name: "android.hardware.sensor.accelerometer_limited_axes_uncalibrated.prebuilt.xml",
+ src: "android.hardware.sensor.accelerometer_limited_axes_uncalibrated.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.accelerometer_limited_axes.prebuilt.xml",
+ src: "android.hardware.sensor.accelerometer_limited_axes.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.accelerometer.prebuilt.xml",
+ src: "android.hardware.sensor.accelerometer.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.sensor.ambient_temperature.prebuilt.xml",
src: "android.hardware.sensor.ambient_temperature.xml",
defaults: ["frameworks_native_data_etc_defaults"],
}
prebuilt_etc {
+ name: "android.hardware.sensor.assist.prebuilt.xml",
+ src: "android.hardware.sensor.assist.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.sensor.barometer.prebuilt.xml",
src: "android.hardware.sensor.barometer.xml",
defaults: ["frameworks_native_data_etc_defaults"],
}
prebuilt_etc {
+ name: "android.hardware.sensor.compass.prebuilt.xml",
+ src: "android.hardware.sensor.compass.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.sensor.dynamic.head_tracker.prebuilt.xml",
src: "android.hardware.sensor.dynamic.head_tracker.xml",
defaults: ["frameworks_native_data_etc_defaults"],
}
prebuilt_etc {
+ name: "android.hardware.sensor.gyroscope_limited_axes_uncalibrated.prebuilt.xml",
+ src: "android.hardware.sensor.gyroscope_limited_axes_uncalibrated.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.gyroscope_limited_axes.prebuilt.xml",
+ src: "android.hardware.sensor.gyroscope_limited_axes.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.sensor.gyroscope.prebuilt.xml",
src: "android.hardware.sensor.gyroscope.xml",
defaults: ["frameworks_native_data_etc_defaults"],
}
prebuilt_etc {
+ name: "android.hardware.sensor.heading.prebuilt.xml",
+ src: "android.hardware.sensor.heading.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.heartrate.ecg.prebuilt.xml",
+ src: "android.hardware.sensor.heartrate.ecg.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.heartrate.fitness.prebuilt.xml",
+ src: "android.hardware.sensor.heartrate.fitness.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.heartrate.prebuilt.xml",
+ src: "android.hardware.sensor.heartrate.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.hifi_sensors.prebuilt.xml",
+ src: "android.hardware.sensor.hifi_sensors.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.sensor.hinge_angle.prebuilt.xml",
src: "android.hardware.sensor.hinge_angle.xml",
defaults: ["frameworks_native_data_etc_defaults"],
@@ -155,6 +233,18 @@
}
prebuilt_etc {
+ name: "android.hardware.sensor.stepcounter.prebuilt.xml",
+ src: "android.hardware.sensor.stepcounter.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
+ name: "android.hardware.sensor.stepdetector.prebuilt.xml",
+ src: "android.hardware.sensor.stepdetector.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.telephony.gsm.prebuilt.xml",
src: "android.hardware.telephony.gsm.xml",
defaults: ["frameworks_native_data_etc_defaults"],
@@ -167,6 +257,12 @@
}
prebuilt_etc {
+ name: "android.hardware.telephony.satellite.prebuilt.xml",
+ src: "android.hardware.telephony.satellite.xml",
+ defaults: ["frameworks_native_data_etc_defaults"],
+}
+
+prebuilt_etc {
name: "android.hardware.usb.accessory.prebuilt.xml",
src: "android.hardware.usb.accessory.xml",
defaults: ["frameworks_native_data_etc_defaults"],
diff --git a/data/etc/android.hardware.telephony.satellite.xml b/data/etc/android.hardware.telephony.satellite.xml
new file mode 100644
index 0000000..d36c958
--- /dev/null
+++ b/data/etc/android.hardware.telephony.satellite.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Feature for devices that support satellite communication via satellite vendor service APIs. -->
+<permissions>
+ <feature name="android.hardware.telephony.satellite" />
+</permissions>
diff --git a/include/android/keycodes.h b/include/android/keycodes.h
index d4ba321..f8fb256 100644
--- a/include/android/keycodes.h
+++ b/include/android/keycodes.h
@@ -831,6 +831,14 @@
AKEYCODE_STYLUS_BUTTON_TAIL = 311,
/** Key to open recent apps (a.k.a. Overview) */
AKEYCODE_RECENT_APPS = 312,
+ /** User customizable key #1. */
+ AKEYCODE_MACRO_1 = 313,
+ /** User customizable key #2. */
+ AKEYCODE_MACRO_2 = 314,
+ /** User customizable key #3. */
+ AKEYCODE_MACRO_3 = 315,
+ /** User customizable key #4. */
+ AKEYCODE_MACRO_4 = 316,
// NOTE: If you add a new keycode here you must also add it to several other files.
// Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
diff --git a/include/android/surface_control.h b/include/android/surface_control.h
index e4926a6..daeebec 100644
--- a/include/android/surface_control.h
+++ b/include/android/surface_control.h
@@ -555,6 +555,8 @@
* range in use.
*
* Must be finite && >= 1.0f
+ *
+ * Available since API level 34.
*/
void ASurfaceTransaction_setExtendedRangeBrightness(ASurfaceTransaction* transaction,
ASurfaceControl* surface_control,
diff --git a/include/input/Input.h b/include/input/Input.h
index e8af5f7..a033535 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -216,7 +216,21 @@
bool isFromSource(uint32_t source, uint32_t test);
-bool isStylusToolType(uint32_t toolType);
+/**
+ * The pointer tool type.
+ */
+enum class ToolType {
+ UNKNOWN = AMOTION_EVENT_TOOL_TYPE_UNKNOWN,
+ FINGER = AMOTION_EVENT_TOOL_TYPE_FINGER,
+ STYLUS = AMOTION_EVENT_TOOL_TYPE_STYLUS,
+ MOUSE = AMOTION_EVENT_TOOL_TYPE_MOUSE,
+ ERASER = AMOTION_EVENT_TOOL_TYPE_ERASER,
+ PALM = AMOTION_EVENT_TOOL_TYPE_PALM,
+ ftl_first = UNKNOWN,
+ ftl_last = PALM,
+};
+
+bool isStylusToolType(ToolType toolType);
/*
* Flags that flow alongside events in the input dispatch system to help with certain
@@ -320,8 +334,6 @@
*/
const char* motionClassificationToString(MotionClassification classification);
-const char* motionToolTypeToString(int32_t toolType);
-
/**
* Portion of FrameMetrics timeline of interest to input code.
*/
@@ -448,11 +460,11 @@
int32_t id;
// The pointer tool type.
- int32_t toolType;
+ ToolType toolType;
inline void clear() {
id = -1;
- toolType = 0;
+ toolType = ToolType::UNKNOWN;
}
bool operator==(const PointerProperties& other) const;
@@ -638,7 +650,7 @@
return mPointerProperties[pointerIndex].id;
}
- inline int32_t getToolType(size_t pointerIndex) const {
+ inline ToolType getToolType(size_t pointerIndex) const {
return mPointerProperties[pointerIndex].toolType;
}
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index a1be542..4f53c36 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -669,7 +669,6 @@
static void addSample(MotionEvent* event, const InputMessage* msg);
static bool canAddSample(const Batch& batch, const InputMessage* msg);
static ssize_t findSampleNoLaterThan(const Batch& batch, nsecs_t time);
- static bool shouldResampleTool(int32_t toolType);
static bool isTouchResamplingEnabled();
};
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index 3f19371..49dd9c7 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -355,6 +355,7 @@
cc_library_static {
name: "libbinder_rpc_no_kernel",
+ vendor_available: true,
defaults: [
"libbinder_common_defaults",
"libbinder_android_defaults",
@@ -407,6 +408,7 @@
cc_defaults {
name: "libbinder_tls_defaults",
defaults: ["libbinder_tls_shared_deps"],
+ vendor_available: true,
host_supported: true,
header_libs: [
@@ -433,7 +435,7 @@
defaults: ["libbinder_tls_defaults"],
}
-cc_library_shared {
+cc_library {
name: "libbinder_trusty",
vendor: true,
srcs: [
diff --git a/libs/binder/IActivityManager.cpp b/libs/binder/IActivityManager.cpp
index 08169f5..ebdaa4c 100644
--- a/libs/binder/IActivityManager.cpp
+++ b/libs/binder/IActivityManager.cpp
@@ -131,6 +131,53 @@
*outResult = reply.readInt32();
return NO_ERROR;
}
+
+ virtual status_t logFgsApiBegin(int32_t apiType, int32_t appUid, int32_t appPid) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor());
+ data.writeInt32(apiType);
+ data.writeInt32(appUid);
+ data.writeInt32(appPid);
+ status_t err = remote()->transact(LOG_FGS_API_BEGIN_TRANSACTION, data, &reply);
+ if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) {
+ ALOGD("FGS Logger Transaction failed");
+ ALOGD("%d", err);
+ return err;
+ }
+ return NO_ERROR;
+ }
+
+ virtual status_t logFgsApiEnd(int32_t apiType, int32_t appUid, int32_t appPid) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor());
+ data.writeInt32(apiType);
+ data.writeInt32(appUid);
+ data.writeInt32(appPid);
+ status_t err = remote()->transact(LOG_FGS_API_END_TRANSACTION, data, &reply);
+ if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) {
+ ALOGD("FGS Logger Transaction failed");
+ ALOGD("%d", err);
+ return err;
+ }
+ return NO_ERROR;
+ }
+
+ virtual status_t logFgsApiStateChanged(int32_t apiType, int32_t state, int32_t appUid,
+ int32_t appPid) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor());
+ data.writeInt32(apiType);
+ data.writeInt32(state);
+ data.writeInt32(appUid);
+ data.writeInt32(appPid);
+ status_t err = remote()->transact(LOG_FGS_API_BEGIN_TRANSACTION, data, &reply);
+ if (err != NO_ERROR || ((err = reply.readExceptionCode()) != NO_ERROR)) {
+ ALOGD("FGS Logger Transaction failed");
+ ALOGD("%d", err);
+ return err;
+ }
+ return NO_ERROR;
+ }
};
// ------------------------------------------------------------------------------------
diff --git a/libs/binder/RpcTransportTipcAndroid.cpp b/libs/binder/RpcTransportTipcAndroid.cpp
index 8b3ddfb..d5a6da2 100644
--- a/libs/binder/RpcTransportTipcAndroid.cpp
+++ b/libs/binder/RpcTransportTipcAndroid.cpp
@@ -54,7 +54,7 @@
}
LOG_RPC_DETAIL("RpcTransport poll(): %s", strerror(savedErrno));
- return -savedErrno;
+ return adjustStatus(-savedErrno);
}
if (pfd.revents & POLLNVAL) {
@@ -87,8 +87,10 @@
"File descriptors are not supported on Trusty yet");
return TEMP_FAILURE_RETRY(tipc_send(mSocket.fd.get(), iovs, niovs, nullptr, 0));
};
- return interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, writeFn, "tipc_send",
- POLLOUT, altPoll);
+
+ status_t status = interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, writeFn,
+ "tipc_send", POLLOUT, altPoll);
+ return adjustStatus(status);
}
status_t interruptableReadFully(
@@ -121,13 +123,26 @@
return processSize;
};
- return interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, readFn, "read", POLLIN,
- altPoll);
+
+ status_t status = interruptableReadOrWrite(mSocket, fdTrigger, iovs, niovs, readFn, "read",
+ POLLIN, altPoll);
+ return adjustStatus(status);
}
bool isWaiting() override { return mSocket.isInPollingState(); }
private:
+ status_t adjustStatus(status_t status) {
+ if (status == -ENOTCONN) {
+ // TIPC returns ENOTCONN on disconnect, but that's basically
+ // the same as DEAD_OBJECT and the latter is the common libbinder
+ // error code for dead connections
+ return DEAD_OBJECT;
+ }
+
+ return status;
+ }
+
status_t fillReadBuffer() {
if (mReadBufferPos < mReadBufferSize) {
return OK;
@@ -167,7 +182,7 @@
continue;
} else {
LOG_RPC_DETAIL("RpcTransport fillBuffer(): %s", strerror(savedErrno));
- return -savedErrno;
+ return adjustStatus(-savedErrno);
}
} else {
mReadBufferSize = static_cast<size_t>(processSize);
diff --git a/libs/binder/TEST_MAPPING b/libs/binder/TEST_MAPPING
index 07b38d7..41707d4 100644
--- a/libs/binder/TEST_MAPPING
+++ b/libs/binder/TEST_MAPPING
@@ -79,6 +79,12 @@
},
{
"name": "rustBinderSerializationTest"
+ },
+ {
+ "name": "libbinder_ndk_bindgen_test"
+ },
+ {
+ "name": "libbinder_rpc_unstable_bindgen_test"
}
],
"presubmit-large": [
diff --git a/libs/binder/include_activitymanager/binder/IActivityManager.h b/libs/binder/include_activitymanager/binder/IActivityManager.h
index 4632b2e..20d12ae 100644
--- a/libs/binder/include_activitymanager/binder/IActivityManager.h
+++ b/libs/binder/include_activitymanager/binder/IActivityManager.h
@@ -42,6 +42,10 @@
const pid_t pid,
const uid_t uid,
int32_t* outResult) = 0;
+ virtual status_t logFgsApiBegin(int32_t apiType, int32_t appUid, int32_t appPid) = 0;
+ virtual status_t logFgsApiEnd(int32_t apiType, int32_t appUid, int32_t appPid) = 0;
+ virtual status_t logFgsApiStateChanged(int32_t apiType, int32_t state, int32_t appUid,
+ int32_t appPid) = 0;
enum {
OPEN_CONTENT_URI_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
@@ -50,6 +54,9 @@
IS_UID_ACTIVE_TRANSACTION,
GET_UID_PROCESS_STATE_TRANSACTION,
CHECK_PERMISSION_TRANSACTION,
+ LOG_FGS_API_BEGIN_TRANSACTION,
+ LOG_FGS_API_END_TRANSACTION,
+ LOG_FGS_API_STATE_CHANGED_TRANSACTION
};
};
diff --git a/libs/binder/ndk/include_platform/android/binder_manager.h b/libs/binder/ndk/include_platform/android/binder_manager.h
index 43159d8..89fd7a3 100644
--- a/libs/binder/ndk/include_platform/android/binder_manager.h
+++ b/libs/binder/ndk/include_platform/android/binder_manager.h
@@ -56,12 +56,12 @@
*
* \param binder object to register globally with the service manager.
* \param instance identifier of the service. This will be used to lookup the service.
- * \param flag an AServiceManager_AddServiceFlag enum to denote how the service should be added.
+ * \param flags an AServiceManager_AddServiceFlag enum to denote how the service should be added.
*
* \return EX_NONE on success.
*/
-__attribute__((warn_unused_result)) binder_exception_t AServiceManager_addServiceWithFlag(
- AIBinder* binder, const char* instance, const AServiceManager_AddServiceFlag flag)
+__attribute__((warn_unused_result)) binder_exception_t AServiceManager_addServiceWithFlags(
+ AIBinder* binder, const char* instance, const AServiceManager_AddServiceFlag flags)
__INTRODUCED_IN(34);
/**
diff --git a/libs/binder/ndk/libbinder_ndk.map.txt b/libs/binder/ndk/libbinder_ndk.map.txt
index 1078fb2..1c5f79f 100644
--- a/libs/binder/ndk/libbinder_ndk.map.txt
+++ b/libs/binder/ndk/libbinder_ndk.map.txt
@@ -158,7 +158,7 @@
AServiceManager_getUpdatableApexName; # systemapi
AServiceManager_registerForServiceNotifications; # systemapi llndk
AServiceManager_NotificationRegistration_delete; # systemapi llndk
- AServiceManager_addServiceWithFlag; # systemapi llndk
+ AServiceManager_addServiceWithFlags; # systemapi llndk
};
LIBBINDER_NDK_PLATFORM {
diff --git a/libs/binder/ndk/service_manager.cpp b/libs/binder/ndk/service_manager.cpp
index 84da459..2977786 100644
--- a/libs/binder/ndk/service_manager.cpp
+++ b/libs/binder/ndk/service_manager.cpp
@@ -42,15 +42,15 @@
return PruneException(exception);
}
-binder_exception_t AServiceManager_addServiceWithFlag(AIBinder* binder, const char* instance,
- const AServiceManager_AddServiceFlag flag) {
+binder_exception_t AServiceManager_addServiceWithFlags(AIBinder* binder, const char* instance,
+ const AServiceManager_AddServiceFlag flags) {
if (binder == nullptr || instance == nullptr) {
return EX_ILLEGAL_ARGUMENT;
}
sp<IServiceManager> sm = defaultServiceManager();
- bool allowIsolated = flag & AServiceManager_AddServiceFlag::ADD_SERVICE_ALLOW_ISOLATED;
+ bool allowIsolated = flags & AServiceManager_AddServiceFlag::ADD_SERVICE_ALLOW_ISOLATED;
status_t exception = sm->addService(String16(instance), binder->getBinder(), allowIsolated);
return PruneException(exception);
}
diff --git a/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp b/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp
index 882f1d6..cefc42f 100644
--- a/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp
+++ b/libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp
@@ -51,6 +51,7 @@
constexpr char kLazyBinderNdkUnitTestService[] = "LazyBinderNdkUnitTest";
constexpr char kForcePersistNdkUnitTestService[] = "ForcePersistNdkUnitTestService";
constexpr char kActiveServicesNdkUnitTestService[] = "ActiveServicesNdkUnitTestService";
+constexpr char kBinderNdkUnitTestServiceFlagged[] = "BinderNdkUnitTestFlagged";
constexpr unsigned int kShutdownWaitTime = 11;
constexpr uint64_t kContextTestValue = 0xb4e42fb4d9a1d715;
@@ -158,6 +159,24 @@
return 1; // should not return
}
+int generatedFlaggedService(const AServiceManager_AddServiceFlag flags, const char* instance) {
+ ABinderProcess_setThreadPoolMaxThreadCount(0);
+
+ auto service = ndk::SharedRefBase::make<MyBinderNdkUnitTest>();
+ auto binder = service->asBinder();
+
+ binder_exception_t exception =
+ AServiceManager_addServiceWithFlags(binder.get(), instance, flags);
+
+ if (exception != EX_NONE) {
+ LOG(FATAL) << "Could not register: " << exception << " " << instance;
+ }
+
+ ABinderProcess_joinThreadPool();
+
+ return 1; // should not return
+}
+
// manually-written parceling class considered bad practice
class MyFoo : public IFoo {
binder_status_t doubleNumber(int32_t in, int32_t* out) override {
@@ -847,6 +866,12 @@
EXPECT_EQ("CMD", shellCmdToString(testService, {"C", "M", "D"}));
}
+TEST(NdkBinder, FlaggedServiceAccessible) {
+ static const sp<android::IServiceManager> sm(android::defaultServiceManager());
+ sp<IBinder> testService = sm->getService(String16(kBinderNdkUnitTestServiceFlagged));
+ ASSERT_NE(nullptr, testService);
+}
+
TEST(NdkBinder, GetClassInterfaceDescriptor) {
ASSERT_STREQ(IFoo::kIFooDescriptor, AIBinder_Class_getDescriptor(IFoo::kClass));
}
@@ -901,6 +926,13 @@
prctl(PR_SET_PDEATHSIG, SIGHUP);
return generatedService();
}
+ if (fork() == 0) {
+ prctl(PR_SET_PDEATHSIG, SIGHUP);
+ // We may want to change this flag to be more generic ones for the future
+ AServiceManager_AddServiceFlag test_flags =
+ AServiceManager_AddServiceFlag::ADD_SERVICE_ALLOW_ISOLATED;
+ return generatedFlaggedService(test_flags, kBinderNdkUnitTestServiceFlagged);
+ }
ABinderProcess_setThreadPoolMaxThreadCount(1); // to receive death notifications/callbacks
ABinderProcess_startThreadPool();
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
index 0f0d64a..61a047b 100644
--- a/libs/binder/tests/Android.bp
+++ b/libs/binder/tests/Android.bp
@@ -138,6 +138,7 @@
aidl_interface {
name: "binderRpcTestIface",
+ vendor_available: true,
host_supported: true,
unstable: true,
srcs: [
@@ -159,6 +160,7 @@
cc_library_static {
name: "libbinder_tls_test_utils",
host_supported: true,
+ vendor_available: true,
target: {
darwin: {
enabled: false,
@@ -441,6 +443,37 @@
}
cc_test {
+ name: "binderRpcToTrustyTest",
+ vendor: true,
+ host_supported: false,
+ defaults: [
+ "binderRpcTest_common_defaults",
+ "binderRpcTest_static_defaults",
+ ],
+
+ srcs: [
+ "binderRpcTest.cpp",
+ "binderRpcTestCommon.cpp",
+ "binderRpcUniversalTests.cpp",
+ ],
+
+ cflags: [
+ "-DBINDER_RPC_TO_TRUSTY_TEST",
+ ],
+
+ static_libs: [
+ // We want to link libbinder statically so we can push the binary
+ // to the device for testing independently of the library
+ "libbinder_rpc_no_kernel",
+ "libbinder_trusty",
+ "libtrusty",
+ ],
+
+ test_suites: ["device-tests"],
+ require_root: true,
+}
+
+cc_test {
name: "RpcTlsUtilsTest",
host_supported: true,
target: {
diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp
index 8b37ed8..504b3ce 100644
--- a/libs/binder/tests/binderRpcTest.cpp
+++ b/libs/binder/tests/binderRpcTest.cpp
@@ -28,10 +28,10 @@
#include <sys/prctl.h>
#include <sys/socket.h>
-#ifdef __ANDROID_VENDOR__
+#ifdef BINDER_RPC_TO_TRUSTY_TEST
#include <binder/RpcTransportTipcAndroid.h>
#include <trusty/tipc.h>
-#endif // __ANDROID_VENDOR__
+#endif // BINDER_RPC_TO_TRUSTY_TEST
#include "binderRpcTestCommon.h"
#include "binderRpcTestFixture.h"
@@ -50,7 +50,7 @@
constexpr bool kEnableSharedLibs = true;
#endif
-#ifdef __ANDROID_VENDOR__
+#ifdef BINDER_RPC_TO_TRUSTY_TEST
constexpr char kTrustyIpcDevice[] = "/dev/trusty-ipc-dev0";
#endif
@@ -214,6 +214,7 @@
return serverFd;
}
+#ifndef BINDER_RPC_TO_TRUSTY_TEST
static base::unique_fd connectToUnixBootstrap(const RpcTransportFd& transportFd) {
base::unique_fd sockClient, sockServer;
if (!base::Socketpair(SOCK_STREAM, &sockClient, &sockServer)) {
@@ -232,6 +233,7 @@
}
return std::move(sockClient);
}
+#endif // BINDER_RPC_TO_TRUSTY_TEST
std::unique_ptr<RpcTransportCtxFactory> BinderRpc::newFactory(RpcSecurity rpcSecurity) {
return newTlsFactory(rpcSecurity);
@@ -308,7 +310,7 @@
for (size_t i = 0; i < options.numSessions; i++) {
std::unique_ptr<RpcTransportCtxFactory> factory;
if (socketType == SocketType::TIPC) {
-#ifdef __ANDROID_VENDOR__
+#ifdef BINDER_RPC_TO_TRUSTY_TEST
factory = RpcTransportCtxFactoryTipcAndroid::make();
#else
LOG_ALWAYS_FATAL("TIPC socket type only supported on vendor");
@@ -378,11 +380,18 @@
break;
case SocketType::TIPC:
status = session->setupPreconnectedClient({}, [=]() {
-#ifdef __ANDROID_VENDOR__
+#ifdef BINDER_RPC_TO_TRUSTY_TEST
auto port = trustyIpcPort(serverVersion);
- int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str());
- return tipcFd >= 0 ? android::base::unique_fd(tipcFd)
- : android::base::unique_fd();
+ for (size_t i = 0; i < 5; i++) {
+ // Try to connect several times,
+ // in case the service is slow to start
+ int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str());
+ if (tipcFd >= 0) {
+ return android::base::unique_fd(tipcFd);
+ }
+ usleep(50000);
+ }
+ return android::base::unique_fd();
#else
LOG_ALWAYS_FATAL("Tried to connect to Trusty outside of vendor");
return android::base::unique_fd();
@@ -1102,6 +1111,15 @@
ASSERT_EQ(beforeFds, countFds()) << (system("ls -l /proc/self/fd/"), "fd leak?");
}
+#ifdef BINDER_RPC_TO_TRUSTY_TEST
+INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc,
+ ::testing::Combine(::testing::Values(SocketType::TIPC),
+ ::testing::Values(RpcSecurity::RAW),
+ ::testing::ValuesIn(testVersions()),
+ ::testing::ValuesIn(testVersions()),
+ ::testing::Values(true), ::testing::Values(true)),
+ BinderRpc::PrintParamInfo);
+#else // BINDER_RPC_TO_TRUSTY_TEST
static bool testSupportVsockLoopback() {
// We don't need to enable TLS to know if vsock is supported.
unsigned int vsockPort = allocateVsockPort();
@@ -1206,21 +1224,6 @@
return ret;
}
-static std::vector<SocketType> testTipcSocketTypes() {
-#ifdef __ANDROID_VENDOR__
- auto port = trustyIpcPort(RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL);
- int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str());
- if (tipcFd >= 0) {
- close(tipcFd);
- return {SocketType::TIPC};
- }
-#endif // __ANDROID_VENDOR__
-
- // TIPC is not supported on this device, most likely
- // because /dev/trusty-ipc-dev0 is missing
- return {};
-}
-
INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc,
::testing::Combine(::testing::ValuesIn(testSocketTypes()),
::testing::ValuesIn(RpcSecurityValues()),
@@ -1230,14 +1233,6 @@
::testing::Values(false, true)),
BinderRpc::PrintParamInfo);
-INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc,
- ::testing::Combine(::testing::ValuesIn(testTipcSocketTypes()),
- ::testing::Values(RpcSecurity::RAW),
- ::testing::ValuesIn(testVersions()),
- ::testing::ValuesIn(testVersions()),
- ::testing::Values(true), ::testing::Values(true)),
- BinderRpc::PrintParamInfo);
-
class BinderRpcServerRootObject
: public ::testing::TestWithParam<std::tuple<bool, bool, RpcSecurity>> {};
@@ -2006,6 +2001,7 @@
testing::Values(RpcKeyFormat::PEM, RpcKeyFormat::DER),
testing::ValuesIn(testVersions())),
RpcTransportTlsKeyTest::PrintParamInfo);
+#endif // BINDER_RPC_TO_TRUSTY_TEST
} // namespace android
diff --git a/libs/binder/tests/parcel_fuzzer/binder.cpp b/libs/binder/tests/parcel_fuzzer/binder.cpp
index 768fbe1..46d387c 100644
--- a/libs/binder/tests/parcel_fuzzer/binder.cpp
+++ b/libs/binder/tests/parcel_fuzzer/binder.cpp
@@ -367,13 +367,15 @@
FUZZ_LOG() << "about to call readFromParcel() with status for SingleDataParcelable";
parcelables::SingleDataParcelable singleDataParcelable;
status_t status = singleDataParcelable.readFromParcel(&p);
- FUZZ_LOG() <<" status: " << status;
+ FUZZ_LOG() << " status: " << status;
},
[] (const ::android::Parcel& p, FuzzedDataProvider& /*provider*/) {
FUZZ_LOG() << "about to call readFromParcel() with status for GenericDataParcelable";
parcelables::GenericDataParcelable genericDataParcelable;
status_t status = genericDataParcelable.readFromParcel(&p);
- FUZZ_LOG() <<" status: " << status;
+ FUZZ_LOG() << " status: " << status;
+ std::string toString = genericDataParcelable.toString();
+ FUZZ_LOG() << " toString() result: " << toString;
},
};
// clang-format on
diff --git a/libs/binder/tests/parcel_fuzzer/binder_ndk.cpp b/libs/binder/tests/parcel_fuzzer/binder_ndk.cpp
index 08eb27a..3a1471e 100644
--- a/libs/binder/tests/parcel_fuzzer/binder_ndk.cpp
+++ b/libs/binder/tests/parcel_fuzzer/binder_ndk.cpp
@@ -198,6 +198,8 @@
aidl::parcelables::GenericDataParcelable genericDataParcelable;
binder_status_t status = genericDataParcelable.readFromParcel(p.aParcel());
FUZZ_LOG() << "status: " << status;
+ std::string toString = genericDataParcelable.toString();
+ FUZZ_LOG() << "toString() result: " << toString;
},
[](const NdkParcelAdapter& p, FuzzedDataProvider& provider) {
FUZZ_LOG() << "about to marshal AParcel";
diff --git a/libs/binder/tests/parcel_fuzzer/parcelables/GenericDataParcelable.aidl b/libs/binder/tests/parcel_fuzzer/parcelables/GenericDataParcelable.aidl
index f1079e9..dd08f72 100644
--- a/libs/binder/tests/parcel_fuzzer/parcelables/GenericDataParcelable.aidl
+++ b/libs/binder/tests/parcel_fuzzer/parcelables/GenericDataParcelable.aidl
@@ -16,10 +16,23 @@
package parcelables;
parcelable GenericDataParcelable {
+ enum JustSomeEnum {
+ SOME_ENUMERATOR,
+ ANOTHER_ENUMERATOR,
+ MAYBE_ONE_MORE_ENUMERATOR,
+ }
+
+ const int COOL_CONSTANT = 0x1234;
+
int data;
float majorVersion;
float minorVersion;
IBinder binder;
ParcelFileDescriptor fileDescriptor;
int[] array;
-}
\ No newline at end of file
+ String greatString;
+ @utf8InCpp
+ String greaterString;
+ @nullable String nullableString;
+ JustSomeEnum gretEnum = JustSomeEnum.ANOTHER_ENUMERATOR;
+}
diff --git a/libs/binderdebug/BinderDebug.cpp b/libs/binderdebug/BinderDebug.cpp
index d086b49..a8f2cbf 100644
--- a/libs/binderdebug/BinderDebug.cpp
+++ b/libs/binderdebug/BinderDebug.cpp
@@ -48,14 +48,12 @@
return -errno;
}
}
- static const std::regex kContextLine("^context (\\w+)$");
bool isDesiredContext = false;
std::string line;
- std::smatch match;
while (getline(ifs, line)) {
- if (std::regex_search(line, match, kContextLine)) {
- isDesiredContext = match.str(1) == contextName;
+ if (base::StartsWith(line, "context")) {
+ isDesiredContext = base::Split(line, " ").back() == contextName;
continue;
}
if (!isDesiredContext) {
@@ -66,57 +64,72 @@
return OK;
}
+// Examples of what we are looking at:
+// node 66730: u00007590061890e0 c0000759036130950 pri 0:120 hs 1 hw 1 ls 0 lw 0 is 2 iw 2 tr 1 proc 2300 1790
+// thread 2999: l 00 need_return 1 tr 0
status_t getBinderPidInfo(BinderDebugContext context, pid_t pid, BinderPidInfo* pidInfo) {
std::smatch match;
static const std::regex kReferencePrefix("^\\s*node \\d+:\\s+u([0-9a-f]+)\\s+c([0-9a-f]+)\\s+");
static const std::regex kThreadPrefix("^\\s*thread \\d+:\\s+l\\s+(\\d)(\\d)");
std::string contextStr = contextToString(context);
status_t ret = scanBinderContext(pid, contextStr, [&](const std::string& line) {
- if (std::regex_search(line, match, kReferencePrefix)) {
- const std::string& ptrString = "0x" + match.str(2); // use number after c
- uint64_t ptr;
- if (!::android::base::ParseUint(ptrString.c_str(), &ptr)) {
- // Should not reach here, but just be tolerant.
- return;
- }
- const std::string proc = " proc ";
- auto pos = line.rfind(proc);
- if (pos != std::string::npos) {
- for (const std::string& pidStr : base::Split(line.substr(pos + proc.size()), " ")) {
- int32_t pid;
- if (!::android::base::ParseInt(pidStr, &pid)) {
+ if (base::StartsWith(line, " node")) {
+ std::vector<std::string> splitString = base::Tokenize(line, " ");
+ bool pids = false;
+ uint64_t ptr = 0;
+ for (const auto& token : splitString) {
+ if (base::StartsWith(token, "u")) {
+ const std::string ptrString = "0x" + token.substr(1);
+ if (!::android::base::ParseUint(ptrString.c_str(), &ptr)) {
+ LOG(ERROR) << "Failed to parse pointer: " << ptrString;
return;
}
- pidInfo->refPids[ptr].push_back(pid);
+ } else {
+ // The last numbers in the line after "proc" are all client PIDs
+ if (token == "proc") {
+ pids = true;
+ } else if (pids) {
+ int32_t pid;
+ if (!::android::base::ParseInt(token, &pid)) {
+ LOG(ERROR) << "Failed to parse pid int: " << token;
+ return;
+ }
+ if (ptr == 0) {
+ LOG(ERROR) << "We failed to parse the pointer, so we can't add the refPids";
+ return;
+ }
+ pidInfo->refPids[ptr].push_back(pid);
+ }
}
}
+ } else if (base::StartsWith(line, " thread")) {
+ auto pos = line.find("l ");
+ if (pos != std::string::npos) {
+ // "1" is waiting in binder driver
+ // "2" is poll. It's impossible to tell if these are in use.
+ // and HIDL default code doesn't use it.
+ bool isInUse = line.at(pos + 2) != '1';
+ // "0" is a thread that has called into binder
+ // "1" is looper thread
+ // "2" is main looper thread
+ bool isBinderThread = line.at(pos + 3) != '0';
+ if (!isBinderThread) {
+ return;
+ }
+ if (isInUse) {
+ pidInfo->threadUsage++;
+ }
- return;
- }
- if (std::regex_search(line, match, kThreadPrefix)) {
- // "1" is waiting in binder driver
- // "2" is poll. It's impossible to tell if these are in use.
- // and HIDL default code doesn't use it.
- bool isInUse = match.str(1) != "1";
- // "0" is a thread that has called into binder
- // "1" is looper thread
- // "2" is main looper thread
- bool isBinderThread = match.str(2) != "0";
- if (!isBinderThread) {
- return;
+ pidInfo->threadCount++;
}
- if (isInUse) {
- pidInfo->threadUsage++;
- }
-
- pidInfo->threadCount++;
- return;
}
- return;
});
return ret;
}
+// Examples of what we are looking at:
+// ref 52493: desc 910 node 52492 s 1 w 1 d 0000000000000000
+// node 29413: u00007803fc982e80 c000078042c982210 pri 0:139 hs 1 hw 1 ls 0 lw 0 is 2 iw 2 tr 1 proc 488 683
status_t getBinderClientPids(BinderDebugContext context, pid_t pid, pid_t servicePid,
int32_t handle, std::vector<pid_t>* pids) {
std::smatch match;
@@ -124,51 +137,64 @@
std::string contextStr = contextToString(context);
int32_t node;
status_t ret = scanBinderContext(pid, contextStr, [&](const std::string& line) {
- if (std::regex_search(line, match, kNodeNumber)) {
- const std::string& descString = match.str(1);
- int32_t desc;
- if (!::android::base::ParseInt(descString.c_str(), &desc)) {
- LOG(ERROR) << "Failed to parse desc int: " << descString;
- return;
- }
- if (handle != desc) {
- return;
- }
- const std::string& nodeString = match.str(2);
- if (!::android::base::ParseInt(nodeString.c_str(), &node)) {
- LOG(ERROR) << "Failed to parse node int: " << nodeString;
- return;
- }
+ if (!base::StartsWith(line, " ref")) return;
+
+ std::vector<std::string> splitString = base::Tokenize(line, " ");
+ if (splitString.size() < 12) {
+ LOG(ERROR) << "Failed to parse binder_logs ref entry. Expecting size greater than 11, but got: " << splitString.size();
return;
}
- return;
+ int32_t desc;
+ if (!::android::base::ParseInt(splitString[3].c_str(), &desc)) {
+ LOG(ERROR) << "Failed to parse desc int: " << splitString[3];
+ return;
+ }
+ if (handle != desc) {
+ return;
+ }
+ if (!::android::base::ParseInt(splitString[5].c_str(), &node)) {
+ LOG(ERROR) << "Failed to parse node int: " << splitString[5];
+ return;
+ }
+ LOG(INFO) << "Parsed the node: " << node;
});
if (ret != OK) {
return ret;
}
- static const std::regex kClients("^\\s+node\\s+(\\d+).*proc\\s+([\\d+\\s*]*)");
+
ret = scanBinderContext(servicePid, contextStr, [&](const std::string& line) {
- if (std::regex_search(line, match, kClients)) {
- const std::string nodeString = match.str(1);
- int32_t matchedNode;
- if (!::android::base::ParseInt(nodeString.c_str(), &matchedNode)) {
- LOG(ERROR) << "Failed to parse node int: " << nodeString;
- return;
- }
- if (node != matchedNode) {
- return;
- }
- const std::string clients = match.str(2);
- for (const std::string& pidStr : base::Split(clients, " ")) {
+ if (!base::StartsWith(line, " node")) return;
+
+ std::vector<std::string> splitString = base::Tokenize(line, " ");
+ if (splitString.size() < 21) {
+ LOG(ERROR) << "Failed to parse binder_logs node entry. Expecting size greater than 20, but got: " << splitString.size();
+ return;
+ }
+
+ // remove the colon
+ const std::string nodeString = splitString[1].substr(0, splitString[1].size() - 1);
+ int32_t matchedNode;
+ if (!::android::base::ParseInt(nodeString.c_str(), &matchedNode)) {
+ LOG(ERROR) << "Failed to parse node int: " << nodeString;
+ return;
+ }
+
+ if (node != matchedNode) {
+ return;
+ }
+ bool pidsSection = false;
+ for (const auto& token : splitString) {
+ if (token == "proc") {
+ pidsSection = true;
+ } else if (pidsSection == true) {
int32_t pid;
- if (!::android::base::ParseInt(pidStr, &pid)) {
+ if (!::android::base::ParseInt(token.c_str(), &pid)) {
+ LOG(ERROR) << "Failed to parse PID int: " << token;
return;
}
pids->push_back(pid);
}
- return;
}
- return;
});
return ret;
}
diff --git a/libs/binderthreadstate/include/binderthreadstate/CallerUtils.h b/libs/binderthreadstate/include/binderthreadstate/CallerUtils.h
index a3e5026..54259d2 100644
--- a/libs/binderthreadstate/include/binderthreadstate/CallerUtils.h
+++ b/libs/binderthreadstate/include/binderthreadstate/CallerUtils.h
@@ -36,8 +36,12 @@
// Based on where we are in recursion of nested binder/hwbinder calls, determine
// which one we are closer to.
inline static BinderCallType getCurrentServingCall() {
- const void* hwbinderSp = android::hardware::IPCThreadState::self()->getServingStackPointer();
- const void* binderSp = android::IPCThreadState::self()->getServingStackPointer();
+ auto* hwState = android::hardware::IPCThreadState::selfOrNull();
+ auto* state = android::IPCThreadState::selfOrNull();
+
+ // getServingStackPointer can also return nullptr
+ const void* hwbinderSp = hwState ? hwState->getServingStackPointer() : nullptr;
+ const void* binderSp = state ? state->getServingStackPointer() : nullptr;
if (hwbinderSp == nullptr && binderSp == nullptr) return BinderCallType::NONE;
if (hwbinderSp == nullptr) return BinderCallType::BINDER;
diff --git a/libs/binderthreadstate/test.cpp b/libs/binderthreadstate/test.cpp
index df1f35d..b5c4010 100644
--- a/libs/binderthreadstate/test.cpp
+++ b/libs/binderthreadstate/test.cpp
@@ -16,11 +16,16 @@
#include <BnAidlStuff.h>
#include <android-base/logging.h>
+#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binderthreadstate/CallerUtils.h>
#include <binderthreadstateutilstest/1.0/IHidlStuff.h>
#include <gtest/gtest.h>
#include <hidl/HidlTransportSupport.h>
+#include <hwbinder/IPCThreadState.h>
+
+#include <thread>
+
#include <linux/prctl.h>
#include <sys/prctl.h>
@@ -154,6 +159,20 @@
EXPECT_TRUE(server->callLocal().isOk());
}
+TEST(BinderThreadState, DoesntInitializeBinderDriver) {
+ // this is on another thread, because it's testing thread-specific
+ // state and we expect it not to be initialized.
+ std::thread([&] {
+ EXPECT_EQ(nullptr, android::IPCThreadState::selfOrNull());
+ EXPECT_EQ(nullptr, android::hardware::IPCThreadState::selfOrNull());
+
+ (void)getCurrentServingCall();
+
+ EXPECT_EQ(nullptr, android::IPCThreadState::selfOrNull());
+ EXPECT_EQ(nullptr, android::hardware::IPCThreadState::selfOrNull());
+ }).join();
+}
+
TEST(BindThreadState, RemoteHidlCall) {
auto stuff = IHidlStuff::getService(id2name(kP1Id));
ASSERT_NE(nullptr, stuff);
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index b391337..1969496 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -190,8 +190,8 @@
}
SAFE_PARCEL(output.writeParcelable, trustedPresentationThresholds);
SAFE_PARCEL(output.writeParcelable, trustedPresentationListener);
- SAFE_PARCEL(output.writeFloat, currentSdrHdrRatio);
- SAFE_PARCEL(output.writeFloat, desiredSdrHdrRatio);
+ SAFE_PARCEL(output.writeFloat, currentHdrSdrRatio);
+ SAFE_PARCEL(output.writeFloat, desiredHdrSdrRatio);
SAFE_PARCEL(output.writeInt32, static_cast<int32_t>(cachingHint))
return NO_ERROR;
}
@@ -335,9 +335,9 @@
SAFE_PARCEL(input.readParcelable, &trustedPresentationListener);
SAFE_PARCEL(input.readFloat, &tmpFloat);
- currentSdrHdrRatio = tmpFloat;
+ currentHdrSdrRatio = tmpFloat;
SAFE_PARCEL(input.readFloat, &tmpFloat);
- desiredSdrHdrRatio = tmpFloat;
+ desiredHdrSdrRatio = tmpFloat;
int32_t tmpInt32;
SAFE_PARCEL(input.readInt32, &tmpInt32);
@@ -592,8 +592,8 @@
}
if (other.what & eExtendedRangeBrightnessChanged) {
what |= eExtendedRangeBrightnessChanged;
- desiredSdrHdrRatio = other.desiredSdrHdrRatio;
- currentSdrHdrRatio = other.currentSdrHdrRatio;
+ desiredHdrSdrRatio = other.desiredHdrSdrRatio;
+ currentHdrSdrRatio = other.currentHdrSdrRatio;
}
if (other.what & eCachingHintChanged) {
what |= eCachingHintChanged;
@@ -747,8 +747,8 @@
CHECK_DIFF(diff, eCropChanged, other, crop);
if (other.what & eBufferChanged) diff |= eBufferChanged;
CHECK_DIFF(diff, eDataspaceChanged, other, dataspace);
- CHECK_DIFF2(diff, eExtendedRangeBrightnessChanged, other, currentSdrHdrRatio,
- desiredSdrHdrRatio);
+ CHECK_DIFF2(diff, eExtendedRangeBrightnessChanged, other, currentHdrSdrRatio,
+ desiredHdrSdrRatio);
CHECK_DIFF(diff, eCachingHintChanged, other, cachingHint);
CHECK_DIFF(diff, eHdrMetadataChanged, other, hdrMetadata);
if (other.what & eSurfaceDamageRegionChanged &&
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 2f5830d..7700aa4 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1723,8 +1723,8 @@
return *this;
}
s->what |= layer_state_t::eExtendedRangeBrightnessChanged;
- s->currentSdrHdrRatio = currentBufferRatio;
- s->desiredSdrHdrRatio = desiredRatio;
+ s->currentHdrSdrRatio = currentBufferRatio;
+ s->desiredHdrSdrRatio = desiredRatio;
registerSurfaceControlForCallback(sc);
return *this;
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 6e3be5c..5c88a07 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -389,8 +389,8 @@
gui::DropInputMode dropInputMode;
bool dimmingEnabled;
- float currentSdrHdrRatio = 1.f;
- float desiredSdrHdrRatio = 1.f;
+ float currentHdrSdrRatio = 1.f;
+ float desiredHdrSdrRatio = 1.f;
gui::CachingHint cachingHint = gui::CachingHint::Enabled;
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index 3344e0b..5f80c16 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -512,6 +512,22 @@
bgSurface->expectTap(1, 1);
}
+TEST_F(InputSurfacesTest, input_respects_surface_insets_with_replaceTouchableRegionWithCrop) {
+ std::unique_ptr<InputSurface> bgSurface = makeSurface(100, 100);
+ std::unique_ptr<InputSurface> fgSurface = makeSurface(100, 100);
+ bgSurface->showAt(100, 100);
+
+ fgSurface->mInputInfo.surfaceInset = 5;
+ fgSurface->mInputInfo.replaceTouchableRegionWithCrop = true;
+ fgSurface->showAt(100, 100);
+
+ injectTap(106, 106);
+ fgSurface->expectTap(1, 1);
+
+ injectTap(101, 101);
+ bgSurface->expectTap(1, 1);
+}
+
// Ensure a surface whose insets are cropped, handles the touch offset correctly. ref:b/120413463
TEST_F(InputSurfacesTest, input_respects_cropped_surface_insets) {
std::unique_ptr<InputSurface> parentSurface = makeSurface(100, 100);
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 53b22cb..4dbf575 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -79,25 +79,6 @@
}
}
-const char* motionToolTypeToString(int32_t toolType) {
- switch (toolType) {
- case AMOTION_EVENT_TOOL_TYPE_UNKNOWN:
- return "UNKNOWN";
- case AMOTION_EVENT_TOOL_TYPE_FINGER:
- return "FINGER";
- case AMOTION_EVENT_TOOL_TYPE_STYLUS:
- return "STYLUS";
- case AMOTION_EVENT_TOOL_TYPE_MOUSE:
- return "MOUSE";
- case AMOTION_EVENT_TOOL_TYPE_ERASER:
- return "ERASER";
- case AMOTION_EVENT_TOOL_TYPE_PALM:
- return "PALM";
- default:
- return "INVALID";
- }
-}
-
// --- IdGenerator ---
#if defined(__ANDROID__)
[[maybe_unused]]
@@ -256,8 +237,8 @@
return (source & test) == test;
}
-bool isStylusToolType(uint32_t toolType) {
- return toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS || toolType == AMOTION_EVENT_TOOL_TYPE_ERASER;
+bool isStylusToolType(ToolType toolType) {
+ return toolType == ToolType::STYLUS || toolType == ToolType::ERASER;
}
VerifiedKeyEvent verifiedKeyEventFromKeyEvent(const KeyEvent& event) {
@@ -810,7 +791,7 @@
mPointerProperties.push_back({});
PointerProperties& properties = mPointerProperties.back();
properties.id = parcel->readInt32();
- properties.toolType = parcel->readInt32();
+ properties.toolType = static_cast<ToolType>(parcel->readInt32());
}
while (sampleCount > 0) {
@@ -866,7 +847,7 @@
for (size_t i = 0; i < pointerCount; i++) {
const PointerProperties& properties = mPointerProperties[i];
parcel->writeInt32(properties.id);
- parcel->writeInt32(properties.toolType);
+ parcel->writeInt32(static_cast<int32_t>(properties.toolType));
}
const PointerCoords* pc = mSamplePointerCoords.data();
@@ -1030,9 +1011,9 @@
out << ", x[" << i << "]=" << x;
out << ", y[" << i << "]=" << y;
}
- int toolType = event.getToolType(i);
- if (toolType != AMOTION_EVENT_TOOL_TYPE_FINGER) {
- out << ", toolType[" << i << "]=" << toolType;
+ ToolType toolType = event.getToolType(i);
+ if (toolType != ToolType::FINGER) {
+ out << ", toolType[" << i << "]=" << ftl::enum_string(toolType);
}
}
if (event.getButtonState() != 0) {
diff --git a/libs/input/InputEventLabels.cpp b/libs/input/InputEventLabels.cpp
index 4a19227..f99a7d6 100644
--- a/libs/input/InputEventLabels.cpp
+++ b/libs/input/InputEventLabels.cpp
@@ -343,7 +343,11 @@
DEFINE_KEYCODE(STYLUS_BUTTON_SECONDARY), \
DEFINE_KEYCODE(STYLUS_BUTTON_TERTIARY), \
DEFINE_KEYCODE(STYLUS_BUTTON_TAIL), \
- DEFINE_KEYCODE(RECENT_APPS)
+ DEFINE_KEYCODE(RECENT_APPS), \
+ DEFINE_KEYCODE(MACRO_1), \
+ DEFINE_KEYCODE(MACRO_2), \
+ DEFINE_KEYCODE(MACRO_3), \
+ DEFINE_KEYCODE(MACRO_4)
// NOTE: If you add a new axis here you must also add it to several other files.
// Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 311b244..f6b4648 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -145,6 +145,10 @@
return value ? "true" : "false";
}
+static bool shouldResampleTool(ToolType toolType) {
+ return toolType == ToolType::FINGER || toolType == ToolType::UNKNOWN;
+}
+
// --- InputMessage ---
bool InputMessage::isValid(size_t actualSize) const {
@@ -1274,11 +1278,6 @@
event->addSample(sampleTime, touchState.lastResample.pointers);
}
-bool InputConsumer::shouldResampleTool(int32_t toolType) {
- return toolType == AMOTION_EVENT_TOOL_TYPE_FINGER
- || toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
-}
-
status_t InputConsumer::sendFinishedSignal(uint32_t seq, bool handled) {
ALOGD_IF(DEBUG_TRANSPORT_CONSUMER,
"channel '%s' consumer ~ sendFinishedSignal: seq=%u, handled=%s",
diff --git a/libs/input/MotionPredictor.cpp b/libs/input/MotionPredictor.cpp
index b4151c6..3037573 100644
--- a/libs/input/MotionPredictor.cpp
+++ b/libs/input/MotionPredictor.cpp
@@ -30,6 +30,7 @@
#include <log/log.h>
#include <attestation/HmacKeyManager.h>
+#include <ftl/enum.h>
#include <input/TfLiteMotionPredictor.h>
namespace android {
@@ -108,10 +109,10 @@
return {};
}
- const int32_t toolType = event.getPointerProperties(0)->toolType;
- if (toolType != AMOTION_EVENT_TOOL_TYPE_STYLUS) {
+ const ToolType toolType = event.getPointerProperties(0)->toolType;
+ if (toolType != ToolType::STYLUS) {
ALOGD_IF(isDebug(), "Prediction not supported for non-stylus tool: %s",
- motionToolTypeToString(toolType));
+ ftl::enum_string(toolType).c_str());
return {};
}
diff --git a/libs/input/tests/InputEvent_test.cpp b/libs/input/tests/InputEvent_test.cpp
index 2132dc1..59125dd 100644
--- a/libs/input/tests/InputEvent_test.cpp
+++ b/libs/input/tests/InputEvent_test.cpp
@@ -259,10 +259,10 @@
mPointerProperties[0].clear();
mPointerProperties[0].id = 1;
- mPointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerProperties[0].toolType = ToolType::FINGER;
mPointerProperties[1].clear();
mPointerProperties[1].id = 2;
- mPointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ mPointerProperties[1].toolType = ToolType::STYLUS;
mSamples[0].pointerCoords[0].clear();
mSamples[0].pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 10);
@@ -366,9 +366,9 @@
ASSERT_EQ(2U, event->getPointerCount());
ASSERT_EQ(1, event->getPointerId(0));
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, event->getToolType(0));
+ ASSERT_EQ(ToolType::FINGER, event->getToolType(0));
ASSERT_EQ(2, event->getPointerId(1));
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, event->getToolType(1));
+ ASSERT_EQ(ToolType::STYLUS, event->getToolType(1));
ASSERT_EQ(2U, event->getHistorySize());
@@ -692,7 +692,7 @@
MotionEvent createMotionEvent(int32_t source, uint32_t action, float x, float y, float dx, float dy,
const ui::Transform& transform, const ui::Transform& rawTransform) {
std::vector<PointerProperties> pointerProperties;
- pointerProperties.push_back(PointerProperties{/* id */ 0, AMOTION_EVENT_TOOL_TYPE_FINGER});
+ pointerProperties.push_back(PointerProperties{/*id=*/0, ToolType::FINGER});
std::vector<PointerCoords> pointerCoords;
pointerCoords.emplace_back().clear();
pointerCoords.back().setAxisValue(AMOTION_EVENT_AXIS_X, x);
diff --git a/libs/input/tests/InputPublisherAndConsumer_test.cpp b/libs/input/tests/InputPublisherAndConsumer_test.cpp
index 5d8b970..965fda7 100644
--- a/libs/input/tests/InputPublisherAndConsumer_test.cpp
+++ b/libs/input/tests/InputPublisherAndConsumer_test.cpp
@@ -172,7 +172,7 @@
for (size_t i = 0; i < pointerCount; i++) {
pointerProperties[i].clear();
pointerProperties[i].id = (i + 2) % pointerCount;
- pointerProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties[i].toolType = ToolType::FINGER;
pointerCoords[i].clear();
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, 100 * i);
diff --git a/libs/input/tests/MotionPredictor_test.cpp b/libs/input/tests/MotionPredictor_test.cpp
index c61efbf..7a62f5e 100644
--- a/libs/input/tests/MotionPredictor_test.cpp
+++ b/libs/input/tests/MotionPredictor_test.cpp
@@ -45,7 +45,7 @@
PointerProperties properties;
properties.clear();
properties.id = i;
- properties.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ properties.toolType = ToolType::STYLUS;
pointerProperties.push_back(properties);
PointerCoords coords;
coords.clear();
diff --git a/libs/input/tests/TouchResampling_test.cpp b/libs/input/tests/TouchResampling_test.cpp
index 7cb9526..655de80 100644
--- a/libs/input/tests/TouchResampling_test.cpp
+++ b/libs/input/tests/TouchResampling_test.cpp
@@ -99,7 +99,7 @@
properties.push_back({});
properties.back().clear();
properties.back().id = pointer.id;
- properties.back().toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ properties.back().toolType = ToolType::FINGER;
coords.push_back({});
coords.back().clear();
diff --git a/libs/input/tests/VelocityTracker_test.cpp b/libs/input/tests/VelocityTracker_test.cpp
index 0277579..ae72109 100644
--- a/libs/input/tests/VelocityTracker_test.cpp
+++ b/libs/input/tests/VelocityTracker_test.cpp
@@ -212,7 +212,7 @@
coords[pointerIndex].isResampled = position.isResampled;
properties[pointerIndex].id = pointerId;
- properties[pointerIndex].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ properties[pointerIndex].toolType = ToolType::FINGER;
pointerIndex++;
}
EXPECT_EQ(pointerIndex, pointerCount);
diff --git a/libs/jpegrecoverymap/Android.bp b/libs/jpegrecoverymap/Android.bp
index b470f35..a1b0e19 100644
--- a/libs/jpegrecoverymap/Android.bp
+++ b/libs/jpegrecoverymap/Android.bp
@@ -24,7 +24,7 @@
cc_library {
name: "libjpegrecoverymap",
host_supported: true,
-
+ vendor_available: true,
export_include_dirs: ["include"],
local_include_dirs: ["include"],
@@ -49,10 +49,12 @@
cc_library {
name: "libjpegencoder",
host_supported: true,
+ vendor_available: true,
shared_libs: [
"libjpeg",
"liblog",
+ "libutils",
],
export_include_dirs: ["include"],
@@ -65,10 +67,12 @@
cc_library {
name: "libjpegdecoder",
host_supported: true,
+ vendor_available: true,
shared_libs: [
"libjpeg",
"liblog",
+ "libutils",
],
export_include_dirs: ["include"],
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegr.h b/libs/jpegrecoverymap/include/jpegrecoverymap/jpegr.h
index e2023a6..1ab1dd7 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/jpegr.h
+++ b/libs/jpegrecoverymap/include/jpegrecoverymap/jpegr.h
@@ -206,13 +206,14 @@
*
* @param compressed_jpegr_image compressed JPEGR image.
* @param dest destination of the uncompressed JPEGR image.
+ * @param max_display_boost (optional) the maximum available boost supported by a display
* @param exif destination of the decoded EXIF metadata. The default value is NULL where the
decoder will do nothing about it. If configured not NULL the decoder will write
EXIF data into this structure. The format is defined in {@code jpegr_exif_struct}
* @param output_format flag for setting output color format. Its value configures the output
color format. The default value is {@code JPEGR_OUTPUT_HDR_LINEAR}.
----------------------------------------------------------------------
- | output_format | decoded color format to be written |
+ | output_format | decoded color format to be written |
----------------------------------------------------------------------
| JPEGR_OUTPUT_SDR | RGBA_8888 |
----------------------------------------------------------------------
@@ -234,6 +235,7 @@
*/
status_t decodeJPEGR(jr_compressed_ptr compressed_jpegr_image,
jr_uncompressed_ptr dest,
+ float max_display_boost = -1.0f,
jr_exif_ptr exif = nullptr,
jpegr_output_format output_format = JPEGR_OUTPUT_HDR_LINEAR,
jr_uncompressed_ptr recovery_map = nullptr,
@@ -281,6 +283,7 @@
* @param output_format flag for setting output color format. if set to
* {@code JPEGR_OUTPUT_SDR}, decoder will only decode the primary image
* which is SDR. Default value is JPEGR_OUTPUT_HDR_LINEAR.
+ * @param max_display_boost the maximum available boost supported by a display
* @param dest reconstructed HDR image
* @return NO_ERROR if calculation succeeds, error code if error occurs.
*/
@@ -288,6 +291,7 @@
jr_uncompressed_ptr uncompressed_recovery_map,
jr_metadata_ptr metadata,
jpegr_output_format output_format,
+ float max_display_boost,
jr_uncompressed_ptr dest);
private:
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymapmath.h b/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymapmath.h
index 8b5318f..67d2a6a 100644
--- a/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymapmath.h
+++ b/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymapmath.h
@@ -135,6 +135,16 @@
}
}
+ RecoveryLUT(jr_metadata_ptr metadata, float displayBoost) {
+ float boostFactor = displayBoost > 0 ? displayBoost / metadata->maxContentBoost : 1.0f;
+ for (int idx = 0; idx < kRecoveryFactorNumEntries; idx++) {
+ float value = static_cast<float>(idx) / static_cast<float>(kRecoveryFactorNumEntries - 1);
+ float logBoost = log2(metadata->minContentBoost) * (1.0f - value)
+ + log2(metadata->maxContentBoost) * value;
+ mRecoveryTable[idx] = exp2(logBoost * boostFactor);
+ }
+ }
+
~RecoveryLUT() {
}
@@ -357,6 +367,7 @@
* value, with the given hdr ratio, to the given sdr input in the range [0, 1].
*/
Color applyRecovery(Color e, float recovery, jr_metadata_ptr metadata);
+Color applyRecovery(Color e, float recovery, jr_metadata_ptr metadata, float displayBoost);
Color applyRecoveryLUT(Color e, float recovery, RecoveryLUT& recoveryLUT);
/*
diff --git a/libs/jpegrecoverymap/jpegr.cpp b/libs/jpegrecoverymap/jpegr.cpp
index e197bf0..e395d51 100644
--- a/libs/jpegrecoverymap/jpegr.cpp
+++ b/libs/jpegrecoverymap/jpegr.cpp
@@ -330,6 +330,7 @@
/* Decode API */
status_t JpegR::decodeJPEGR(jr_compressed_ptr compressed_jpegr_image,
jr_uncompressed_ptr dest,
+ float max_display_boost,
jr_exif_ptr exif,
jpegr_output_format output_format,
jr_uncompressed_ptr recovery_map,
@@ -431,7 +432,7 @@
uncompressed_yuv_420_image.height = jpeg_decoder.getDecompressedImageHeight();
JPEGR_CHECK(applyRecoveryMap(&uncompressed_yuv_420_image, &map, &jr_metadata, output_format,
- dest));
+ max_display_boost, dest));
return NO_ERROR;
}
@@ -667,6 +668,7 @@
jr_uncompressed_ptr uncompressed_recovery_map,
jr_metadata_ptr metadata,
jpegr_output_format output_format,
+ float max_display_boost,
jr_uncompressed_ptr dest) {
if (uncompressed_yuv_420_image == nullptr
|| uncompressed_recovery_map == nullptr
@@ -678,13 +680,15 @@
dest->width = uncompressed_yuv_420_image->width;
dest->height = uncompressed_yuv_420_image->height;
ShepardsIDW idwTable(kMapDimensionScaleFactor);
- RecoveryLUT recoveryLUT(metadata);
+ float display_boost = max_display_boost > 0 ?
+ std::min(max_display_boost, metadata->maxContentBoost)
+ : metadata->maxContentBoost;
+ RecoveryLUT recoveryLUT(metadata, display_boost);
JobQueue jobQueue;
std::function<void()> applyRecMap = [uncompressed_yuv_420_image, uncompressed_recovery_map,
metadata, dest, &jobQueue, &idwTable, output_format,
- &recoveryLUT]() -> void {
- const float hdr_ratio = metadata->maxContentBoost;
+ &recoveryLUT, display_boost]() -> void {
size_t width = uncompressed_yuv_420_image->width;
size_t height = uncompressed_yuv_420_image->height;
@@ -710,12 +714,13 @@
} else {
recovery = sampleMap(uncompressed_recovery_map, map_scale_factor, x, y, idwTable);
}
+
#if USE_APPLY_RECOVERY_LUT
Color rgb_hdr = applyRecoveryLUT(rgb_sdr, recovery, recoveryLUT);
#else
- Color rgb_hdr = applyRecovery(rgb_sdr, recovery, metadata);
+ Color rgb_hdr = applyRecovery(rgb_sdr, recovery, metadata, display_boost);
#endif
- rgb_hdr = rgb_hdr / metadata->maxContentBoost;
+ rgb_hdr = rgb_hdr / display_boost;
size_t pixel_idx = x + y * width;
switch (output_format) {
diff --git a/libs/jpegrecoverymap/recoverymapmath.cpp b/libs/jpegrecoverymap/recoverymapmath.cpp
index 20c32ed..2cffde3 100644
--- a/libs/jpegrecoverymap/recoverymapmath.cpp
+++ b/libs/jpegrecoverymap/recoverymapmath.cpp
@@ -463,6 +463,13 @@
return e * recoveryFactor;
}
+Color applyRecovery(Color e, float recovery, jr_metadata_ptr metadata, float displayBoost) {
+ float logBoost = log2(metadata->minContentBoost) * (1.0f - recovery)
+ + log2(metadata->maxContentBoost) * recovery;
+ float recoveryFactor = exp2(logBoost * displayBoost / metadata->maxContentBoost);
+ return e * recoveryFactor;
+}
+
Color applyRecoveryLUT(Color e, float recovery, RecoveryLUT& recoveryLUT) {
float recoveryFactor = recoveryLUT.getRecoveryFactor(recovery);
return e * recoveryFactor;
diff --git a/libs/jpegrecoverymap/tests/jpegr_test.cpp b/libs/jpegrecoverymap/tests/jpegr_test.cpp
index be4b972..df90f53 100644
--- a/libs/jpegrecoverymap/tests/jpegr_test.cpp
+++ b/libs/jpegrecoverymap/tests/jpegr_test.cpp
@@ -152,7 +152,8 @@
timerStart(&applyRecMapTime);
for (auto i = 0; i < kProfileCount; i++) {
- ASSERT_EQ(OK, applyRecoveryMap(yuv420Image, map, metadata, JPEGR_OUTPUT_HDR_HLG, dest));
+ ASSERT_EQ(OK, applyRecoveryMap(yuv420Image, map, metadata, JPEGR_OUTPUT_HDR_HLG,
+ metadata->maxContentBoost /* displayBoost */, dest));
}
timerStop(&applyRecMapTime);
@@ -170,7 +171,7 @@
jpegRCodec.encodeJPEGR(nullptr, nullptr, nullptr, static_cast<jpegr_transfer_function>(0),
nullptr);
jpegRCodec.encodeJPEGR(nullptr, nullptr, static_cast<jpegr_transfer_function>(0), nullptr);
- jpegRCodec.decodeJPEGR(nullptr, nullptr, nullptr);
+ jpegRCodec.decodeJPEGR(nullptr, nullptr);
}
TEST_F(JpegRTest, writeXmpThenRead) {
diff --git a/libs/jpegrecoverymap/tests/recoverymapmath_test.cpp b/libs/jpegrecoverymap/tests/recoverymapmath_test.cpp
index cf6a034..5ef79e9 100644
--- a/libs/jpegrecoverymap/tests/recoverymapmath_test.cpp
+++ b/libs/jpegrecoverymap/tests/recoverymapmath_test.cpp
@@ -557,6 +557,7 @@
jpegr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
.minContentBoost = 1.0f / static_cast<float>(boost) };
RecoveryLUT recoveryLUT(&metadata);
+ RecoveryLUT recoveryLUTWithBoost(&metadata, metadata.maxContentBoost);
for (int idx = 0; idx < kRecoveryFactorNumEntries; idx++) {
float value = static_cast<float>(idx) / static_cast<float>(kRecoveryFactorNumEntries - 1);
EXPECT_RGB_NEAR(applyRecovery(RgbBlack(), value, &metadata),
@@ -569,6 +570,16 @@
applyRecoveryLUT(RgbGreen(), value, recoveryLUT));
EXPECT_RGB_NEAR(applyRecovery(RgbBlue(), value, &metadata),
applyRecoveryLUT(RgbBlue(), value, recoveryLUT));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbBlack(), value, recoveryLUT),
+ applyRecoveryLUT(RgbBlack(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbWhite(), value, recoveryLUT),
+ applyRecoveryLUT(RgbWhite(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbRed(), value, recoveryLUT),
+ applyRecoveryLUT(RgbRed(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbGreen(), value, recoveryLUT),
+ applyRecoveryLUT(RgbGreen(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbBlue(), value, recoveryLUT),
+ applyRecoveryLUT(RgbBlue(), value, recoveryLUTWithBoost));
}
}
@@ -576,6 +587,7 @@
jpegr_metadata_struct metadata = { .maxContentBoost = static_cast<float>(boost),
.minContentBoost = 1.0f };
RecoveryLUT recoveryLUT(&metadata);
+ RecoveryLUT recoveryLUTWithBoost(&metadata, metadata.maxContentBoost);
for (int idx = 0; idx < kRecoveryFactorNumEntries; idx++) {
float value = static_cast<float>(idx) / static_cast<float>(kRecoveryFactorNumEntries - 1);
EXPECT_RGB_NEAR(applyRecovery(RgbBlack(), value, &metadata),
@@ -588,6 +600,16 @@
applyRecoveryLUT(RgbGreen(), value, recoveryLUT));
EXPECT_RGB_NEAR(applyRecovery(RgbBlue(), value, &metadata),
applyRecoveryLUT(RgbBlue(), value, recoveryLUT));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbBlack(), value, recoveryLUT),
+ applyRecoveryLUT(RgbBlack(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbWhite(), value, recoveryLUT),
+ applyRecoveryLUT(RgbWhite(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbRed(), value, recoveryLUT),
+ applyRecoveryLUT(RgbRed(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbGreen(), value, recoveryLUT),
+ applyRecoveryLUT(RgbGreen(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbBlue(), value, recoveryLUT),
+ applyRecoveryLUT(RgbBlue(), value, recoveryLUTWithBoost));
}
}
@@ -596,6 +618,7 @@
.minContentBoost = 1.0f / pow(static_cast<float>(boost),
1.0f / 3.0f) };
RecoveryLUT recoveryLUT(&metadata);
+ RecoveryLUT recoveryLUTWithBoost(&metadata, metadata.maxContentBoost);
for (int idx = 0; idx < kRecoveryFactorNumEntries; idx++) {
float value = static_cast<float>(idx) / static_cast<float>(kRecoveryFactorNumEntries - 1);
EXPECT_RGB_NEAR(applyRecovery(RgbBlack(), value, &metadata),
@@ -608,6 +631,16 @@
applyRecoveryLUT(RgbGreen(), value, recoveryLUT));
EXPECT_RGB_NEAR(applyRecovery(RgbBlue(), value, &metadata),
applyRecoveryLUT(RgbBlue(), value, recoveryLUT));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbBlack(), value, recoveryLUT),
+ applyRecoveryLUT(RgbBlack(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbWhite(), value, recoveryLUT),
+ applyRecoveryLUT(RgbWhite(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbRed(), value, recoveryLUT),
+ applyRecoveryLUT(RgbRed(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbGreen(), value, recoveryLUT),
+ applyRecoveryLUT(RgbGreen(), value, recoveryLUTWithBoost));
+ EXPECT_RGB_EQ(applyRecoveryLUT(RgbBlue(), value, recoveryLUT),
+ applyRecoveryLUT(RgbBlue(), value, recoveryLUTWithBoost));
}
}
}
@@ -719,6 +752,7 @@
TEST_F(RecoveryMapMathTest, ApplyRecovery) {
jpegr_metadata_struct metadata = { .maxContentBoost = 4.0f,
.minContentBoost = 1.0f / 4.0f };
+ float displayBoost = metadata.maxContentBoost;
EXPECT_RGB_NEAR(applyRecovery(RgbBlack(), 0.0f, &metadata), RgbBlack());
EXPECT_RGB_NEAR(applyRecovery(RgbBlack(), 0.5f, &metadata), RgbBlack());
@@ -774,6 +808,19 @@
EXPECT_RGB_NEAR(applyRecovery(e, 0.5f, &metadata), e);
EXPECT_RGB_NEAR(applyRecovery(e, 0.75f, &metadata), e * 2.0f);
EXPECT_RGB_NEAR(applyRecovery(e, 1.0f, &metadata), e * 4.0f);
+
+ EXPECT_RGB_EQ(applyRecovery(RgbBlack(), 1.0f, &metadata),
+ applyRecovery(RgbBlack(), 1.0f, &metadata, displayBoost));
+ EXPECT_RGB_EQ(applyRecovery(RgbWhite(), 1.0f, &metadata),
+ applyRecovery(RgbWhite(), 1.0f, &metadata, displayBoost));
+ EXPECT_RGB_EQ(applyRecovery(RgbRed(), 1.0f, &metadata),
+ applyRecovery(RgbRed(), 1.0f, &metadata, displayBoost));
+ EXPECT_RGB_EQ(applyRecovery(RgbGreen(), 1.0f, &metadata),
+ applyRecovery(RgbGreen(), 1.0f, &metadata, displayBoost));
+ EXPECT_RGB_EQ(applyRecovery(RgbBlue(), 1.0f, &metadata),
+ applyRecovery(RgbBlue(), 1.0f, &metadata, displayBoost));
+ EXPECT_RGB_EQ(applyRecovery(e, 1.0f, &metadata),
+ applyRecovery(e, 1.0f, &metadata, displayBoost));
}
TEST_F(RecoveryMapMathTest, GetYuv420Pixel) {
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp
index cf927db..8060705 100644
--- a/libs/nativewindow/AHardwareBuffer.cpp
+++ b/libs/nativewindow/AHardwareBuffer.cpp
@@ -18,6 +18,7 @@
#include <android/hardware_buffer.h>
#include <android/hardware_buffer_aidl.h>
+#include <android/binder_libbinder.h>
#include <vndk/hardware_buffer.h>
#include <errno.h>
@@ -34,9 +35,6 @@
#include <android/hardware/graphics/common/1.1/types.h>
#include <aidl/android/hardware/graphics/common/PixelFormat.h>
-// TODO: Better way to handle this
-#include "../binder/ndk/parcel_internal.h"
-
static constexpr int kFdBufferSize = 128 * sizeof(int); // 128 ints
using namespace android;
@@ -421,7 +419,7 @@
AHardwareBuffer* _Nullable* _Nonnull outBuffer) {
if (!parcel || !outBuffer) return STATUS_BAD_VALUE;
auto buffer = sp<GraphicBuffer>::make();
- status_t status = parcel->get()->read(*buffer);
+ status_t status = AParcel_viewPlatformParcel(parcel)->read(*buffer);
if (status != STATUS_OK) return status;
*outBuffer = AHardwareBuffer_from_GraphicBuffer(buffer.get());
AHardwareBuffer_acquire(*outBuffer);
@@ -433,7 +431,7 @@
const GraphicBuffer* gb = AHardwareBuffer_to_GraphicBuffer(buffer);
if (!gb) return STATUS_BAD_VALUE;
if (!parcel) return STATUS_BAD_VALUE;
- return parcel->get()->write(*gb);
+ return AParcel_viewPlatformParcel(parcel)->write(*gb);
}
// ----------------------------------------------------------------------------
diff --git a/libs/nativewindow/include/android/hardware_buffer.h b/libs/nativewindow/include/android/hardware_buffer.h
index 85a5249..21798d0 100644
--- a/libs/nativewindow/include/android/hardware_buffer.h
+++ b/libs/nativewindow/include/android/hardware_buffer.h
@@ -177,14 +177,14 @@
/**
* Corresponding formats:
* Vulkan: VK_FORMAT_R16_UINT
- * OpenGL ES: GR_GL_R16UI
+ * OpenGL ES: GL_R16UI
*/
AHARDWAREBUFFER_FORMAT_R16_UINT = 0x39,
/**
* Corresponding formats:
* Vulkan: VK_FORMAT_R16G16_UINT
- * OpenGL ES: GR_GL_RG16UI
+ * OpenGL ES: GL_RG16UI
*/
AHARDWAREBUFFER_FORMAT_R16G16_UINT = 0x3a,
diff --git a/libs/ui/Gralloc4.cpp b/libs/ui/Gralloc4.cpp
index c3af996..b6274ab 100644
--- a/libs/ui/Gralloc4.cpp
+++ b/libs/ui/Gralloc4.cpp
@@ -766,162 +766,6 @@
gralloc4::encodeSmpte2094_10);
}
-template <class T>
-status_t Gralloc4Mapper::getDefault(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- const MetadataType& metadataType,
- DecodeFunction<T> decodeFunction, T* outMetadata) const {
- if (!outMetadata) {
- return BAD_VALUE;
- }
-
- IMapper::BufferDescriptorInfo descriptorInfo;
- if (auto error = sBufferDescriptorInfo("getDefault", width, height, format, layerCount, usage,
- &descriptorInfo) != OK) {
- return error;
- }
-
- hidl_vec<uint8_t> vec;
- Error error;
- auto ret = mMapper->getFromBufferDescriptorInfo(descriptorInfo, metadataType,
- [&](const auto& tmpError,
- const hidl_vec<uint8_t>& tmpVec) {
- error = tmpError;
- vec = tmpVec;
- });
-
- if (!ret.isOk()) {
- error = kTransactionError;
- }
-
- if (error != Error::NONE) {
- ALOGE("getDefault(%s, %" PRIu64 ", ...) failed with %d", metadataType.name.c_str(),
- metadataType.value, error);
- return static_cast<status_t>(error);
- }
-
- return decodeFunction(vec, outMetadata);
-}
-
-status_t Gralloc4Mapper::getDefaultPixelFormatFourCC(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint32_t* outPixelFormatFourCC) const {
- return getDefault(width, height, format, layerCount, usage,
- gralloc4::MetadataType_PixelFormatFourCC, gralloc4::decodePixelFormatFourCC,
- outPixelFormatFourCC);
-}
-
-status_t Gralloc4Mapper::getDefaultPixelFormatModifier(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t* outPixelFormatModifier) const {
- return getDefault(width, height, format, layerCount, usage,
- gralloc4::MetadataType_PixelFormatModifier,
- gralloc4::decodePixelFormatModifier, outPixelFormatModifier);
-}
-
-status_t Gralloc4Mapper::getDefaultAllocationSize(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t* outAllocationSize) const {
- return getDefault(width, height, format, layerCount, usage,
- gralloc4::MetadataType_AllocationSize, gralloc4::decodeAllocationSize,
- outAllocationSize);
-}
-
-status_t Gralloc4Mapper::getDefaultProtectedContent(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t* outProtectedContent) const {
- return getDefault(width, height, format, layerCount, usage,
- gralloc4::MetadataType_ProtectedContent, gralloc4::decodeProtectedContent,
- outProtectedContent);
-}
-
-status_t Gralloc4Mapper::getDefaultCompression(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ExtendableType* outCompression) const {
- return getDefault(width, height, format, layerCount, usage, gralloc4::MetadataType_Compression,
- gralloc4::decodeCompression, outCompression);
-}
-
-status_t Gralloc4Mapper::getDefaultCompression(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::Compression* outCompression) const {
- if (!outCompression) {
- return BAD_VALUE;
- }
- ExtendableType compression;
- status_t error = getDefaultCompression(width, height, format, layerCount, usage, &compression);
- if (error) {
- return error;
- }
- if (!gralloc4::isStandardCompression(compression)) {
- return BAD_TYPE;
- }
- *outCompression = gralloc4::getStandardCompressionValue(compression);
- return NO_ERROR;
-}
-
-status_t Gralloc4Mapper::getDefaultInterlaced(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ExtendableType* outInterlaced) const {
- return getDefault(width, height, format, layerCount, usage, gralloc4::MetadataType_Interlaced,
- gralloc4::decodeInterlaced, outInterlaced);
-}
-
-status_t Gralloc4Mapper::getDefaultInterlaced(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::Interlaced* outInterlaced) const {
- if (!outInterlaced) {
- return BAD_VALUE;
- }
- ExtendableType interlaced;
- status_t error = getDefaultInterlaced(width, height, format, layerCount, usage, &interlaced);
- if (error) {
- return error;
- }
- if (!gralloc4::isStandardInterlaced(interlaced)) {
- return BAD_TYPE;
- }
- *outInterlaced = gralloc4::getStandardInterlacedValue(interlaced);
- return NO_ERROR;
-}
-
-status_t Gralloc4Mapper::getDefaultChromaSiting(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ExtendableType* outChromaSiting) const {
- return getDefault(width, height, format, layerCount, usage, gralloc4::MetadataType_ChromaSiting,
- gralloc4::decodeChromaSiting, outChromaSiting);
-}
-
-status_t Gralloc4Mapper::getDefaultChromaSiting(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::ChromaSiting* outChromaSiting) const {
- if (!outChromaSiting) {
- return BAD_VALUE;
- }
- ExtendableType chromaSiting;
- status_t error =
- getDefaultChromaSiting(width, height, format, layerCount, usage, &chromaSiting);
- if (error) {
- return error;
- }
- if (!gralloc4::isStandardChromaSiting(chromaSiting)) {
- return BAD_TYPE;
- }
- *outChromaSiting = gralloc4::getStandardChromaSitingValue(chromaSiting);
- return NO_ERROR;
-}
-
-status_t Gralloc4Mapper::getDefaultPlaneLayouts(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage,
- std::vector<ui::PlaneLayout>* outPlaneLayouts) const {
- return getDefault(width, height, format, layerCount, usage, gralloc4::MetadataType_PlaneLayouts,
- gralloc4::decodePlaneLayouts, outPlaneLayouts);
-}
-
std::vector<MetadataTypeDescription> Gralloc4Mapper::listSupportedMetadataTypes() const {
hidl_vec<MetadataTypeDescription> descriptions;
Error error;
diff --git a/libs/ui/Gralloc5.cpp b/libs/ui/Gralloc5.cpp
index 6f196b8..2106839 100644
--- a/libs/ui/Gralloc5.cpp
+++ b/libs/ui/Gralloc5.cpp
@@ -352,14 +352,12 @@
}
}
{
- (void)stride;
- // TODO(b/261856851): Add StandardMetadataType::STRIDE && enable this
- // auto value = getStandardMetadata<StandardMetadataType::STRIDE>(mMapper,
- // bufferHandle); if (static_cast<BufferUsage>(usage) != value) {
- // ALOGW("Layer count didn't match, expected %" PRIu64 " got %" PRId64, usage,
- // static_cast<int64_t>(value.value_or(BufferUsage::CPU_READ_NEVER)));
- // return BAD_VALUE;
- // }
+ auto value = getStandardMetadata<StandardMetadataType::STRIDE>(mMapper, bufferHandle);
+ if (stride != value) {
+ ALOGW("Stride didn't match, expected %" PRIu32 " got %" PRId32, stride,
+ value.value_or(-1));
+ return BAD_VALUE;
+ }
}
return OK;
}
@@ -831,73 +829,4 @@
smpte2094_10);
}
-status_t Gralloc5Mapper::getDefaultPixelFormatFourCC(uint32_t, uint32_t, PixelFormat, uint32_t,
- uint64_t, uint32_t *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultPixelFormatModifier(uint32_t, uint32_t, PixelFormat, uint32_t,
- uint64_t, uint64_t *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultAllocationSize(uint32_t, uint32_t, PixelFormat, uint32_t,
- uint64_t, uint64_t *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultProtectedContent(uint32_t, uint32_t, PixelFormat, uint32_t,
- uint64_t, uint64_t *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultCompression(
- uint32_t, uint32_t, PixelFormat, uint32_t, uint64_t,
- aidl::android::hardware::graphics::common::ExtendableType *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultCompression(uint32_t, uint32_t, PixelFormat, uint32_t, uint64_t,
- ui::Compression *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultInterlaced(
- uint32_t, uint32_t, PixelFormat, uint32_t, uint64_t,
- aidl::android::hardware::graphics::common::ExtendableType *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultInterlaced(uint32_t, uint32_t, PixelFormat, uint32_t, uint64_t,
- ui::Interlaced *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultChromaSiting(
- uint32_t, uint32_t, PixelFormat, uint32_t, uint64_t,
- aidl::android::hardware::graphics::common::ExtendableType *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultChromaSiting(uint32_t, uint32_t, PixelFormat, uint32_t, uint64_t,
- ui::ChromaSiting *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
-status_t Gralloc5Mapper::getDefaultPlaneLayouts(uint32_t, uint32_t, PixelFormat, uint32_t, uint64_t,
- std::vector<ui::PlaneLayout> *) const {
- // TODO(b/261857910): Remove
- return UNKNOWN_TRANSACTION;
-}
-
} // namespace android
\ No newline at end of file
diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp
index 6002a6d..7086e04 100644
--- a/libs/ui/GraphicBufferMapper.cpp
+++ b/libs/ui/GraphicBufferMapper.cpp
@@ -341,84 +341,5 @@
return mMapper->setSmpte2094_10(bufferHandle, smpte2094_10);
}
-status_t GraphicBufferMapper::getDefaultPixelFormatFourCC(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint32_t* outPixelFormatFourCC) {
- return mMapper->getDefaultPixelFormatFourCC(width, height, format, layerCount, usage,
- outPixelFormatFourCC);
-}
-
-status_t GraphicBufferMapper::getDefaultPixelFormatModifier(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t* outPixelFormatModifier) {
- return mMapper->getDefaultPixelFormatModifier(width, height, format, layerCount, usage,
- outPixelFormatModifier);
-}
-
-status_t GraphicBufferMapper::getDefaultAllocationSize(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t* outAllocationSize) {
- return mMapper->getDefaultAllocationSize(width, height, format, layerCount, usage,
- outAllocationSize);
-}
-
-status_t GraphicBufferMapper::getDefaultProtectedContent(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t* outProtectedContent) {
- return mMapper->getDefaultProtectedContent(width, height, format, layerCount, usage,
- outProtectedContent);
-}
-
-status_t GraphicBufferMapper::getDefaultCompression(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType* outCompression) {
- return mMapper->getDefaultCompression(width, height, format, layerCount, usage, outCompression);
-}
-
-status_t GraphicBufferMapper::getDefaultCompression(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- ui::Compression* outCompression) {
- return mMapper->getDefaultCompression(width, height, format, layerCount, usage, outCompression);
-}
-
-status_t GraphicBufferMapper::getDefaultInterlaced(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType* outInterlaced) {
- return mMapper->getDefaultInterlaced(width, height, format, layerCount, usage, outInterlaced);
-}
-
-status_t GraphicBufferMapper::getDefaultInterlaced(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage, ui::Interlaced* outInterlaced) {
- return mMapper->getDefaultInterlaced(width, height, format, layerCount, usage, outInterlaced);
-}
-
-status_t GraphicBufferMapper::getDefaultChromaSiting(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType* outChromaSiting) {
- return mMapper->getDefaultChromaSiting(width, height, format, layerCount, usage,
- outChromaSiting);
-}
-
-status_t GraphicBufferMapper::getDefaultChromaSiting(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- ui::ChromaSiting* outChromaSiting) {
- return mMapper->getDefaultChromaSiting(width, height, format, layerCount, usage,
- outChromaSiting);
-}
-
-status_t GraphicBufferMapper::getDefaultPlaneLayouts(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage,
- std::vector<ui::PlaneLayout>* outPlaneLayouts) {
- return mMapper->getDefaultPlaneLayouts(width, height, format, layerCount, usage,
- outPlaneLayouts);
-}
-
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/libs/ui/include/ui/Gralloc.h b/libs/ui/include/ui/Gralloc.h
index b494cbe..496ba57 100644
--- a/libs/ui/include/ui/Gralloc.h
+++ b/libs/ui/include/ui/Gralloc.h
@@ -200,72 +200,6 @@
std::optional<std::vector<uint8_t>> /*smpte2094_10*/) const {
return INVALID_OPERATION;
}
- virtual status_t getDefaultPixelFormatFourCC(uint32_t /*width*/, uint32_t /*height*/,
- PixelFormat /*format*/, uint32_t /*layerCount*/,
- uint64_t /*usage*/,
- uint32_t* /*outPixelFormatFourCC*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultPixelFormatModifier(uint32_t /*width*/, uint32_t /*height*/,
- PixelFormat /*format*/, uint32_t /*layerCount*/,
- uint64_t /*usage*/,
- uint64_t* /*outPixelFormatModifier*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultAllocationSize(uint32_t /*width*/, uint32_t /*height*/,
- PixelFormat /*format*/, uint32_t /*layerCount*/,
- uint64_t /*usage*/,
- uint64_t* /*outAllocationSize*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultProtectedContent(uint32_t /*width*/, uint32_t /*height*/,
- PixelFormat /*format*/, uint32_t /*layerCount*/,
- uint64_t /*usage*/,
- uint64_t* /*outProtectedContent*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultCompression(
- uint32_t /*width*/, uint32_t /*height*/, PixelFormat /*format*/,
- uint32_t /*layerCount*/, uint64_t /*usage*/,
- aidl::android::hardware::graphics::common::ExtendableType* /*outCompression*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultCompression(uint32_t /*width*/, uint32_t /*height*/,
- PixelFormat /*format*/, uint32_t /*layerCount*/,
- uint64_t /*usage*/,
- ui::Compression* /*outCompression*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultInterlaced(
- uint32_t /*width*/, uint32_t /*height*/, PixelFormat /*format*/,
- uint32_t /*layerCount*/, uint64_t /*usage*/,
- aidl::android::hardware::graphics::common::ExtendableType* /*outInterlaced*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultInterlaced(uint32_t /*width*/, uint32_t /*height*/,
- PixelFormat /*format*/, uint32_t /*layerCount*/,
- uint64_t /*usage*/,
- ui::Interlaced* /*outInterlaced*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultChromaSiting(
- uint32_t /*width*/, uint32_t /*height*/, PixelFormat /*format*/,
- uint32_t /*layerCount*/, uint64_t /*usage*/,
- aidl::android::hardware::graphics::common::ExtendableType* /*outChromaSiting*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultChromaSiting(uint32_t /*width*/, uint32_t /*height*/,
- PixelFormat /*format*/, uint32_t /*layerCount*/,
- uint64_t /*usage*/,
- ui::ChromaSiting* /*outChromaSiting*/) const {
- return INVALID_OPERATION;
- }
- virtual status_t getDefaultPlaneLayouts(
- uint32_t /*width*/, uint32_t /*height*/, PixelFormat /*format*/,
- uint32_t /*layerCount*/, uint64_t /*usage*/,
- std::vector<ui::PlaneLayout>* /*outPlaneLayouts*/) const {
- return INVALID_OPERATION;
- }
};
// A wrapper to IAllocator
diff --git a/libs/ui/include/ui/Gralloc4.h b/libs/ui/include/ui/Gralloc4.h
index 6bc5ce5..df43be8 100644
--- a/libs/ui/include/ui/Gralloc4.h
+++ b/libs/ui/include/ui/Gralloc4.h
@@ -120,42 +120,6 @@
std::optional<std::vector<uint8_t>>* outSmpte2094_10) const override;
status_t setSmpte2094_10(buffer_handle_t bufferHandle,
std::optional<std::vector<uint8_t>> smpte2094_10) const override;
- status_t getDefaultPixelFormatFourCC(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint32_t* outPixelFormatFourCC) const override;
- status_t getDefaultPixelFormatModifier(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint64_t* outPixelFormatModifier) const override;
- status_t getDefaultAllocationSize(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint64_t* outAllocationSize) const override;
- status_t getDefaultProtectedContent(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint64_t* outProtectedContent) const override;
- status_t getDefaultCompression(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType*
- outCompression) const override;
- status_t getDefaultCompression(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::Compression* outCompression) const override;
- status_t getDefaultInterlaced(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType*
- outInterlaced) const override;
- status_t getDefaultInterlaced(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::Interlaced* outInterlaced) const override;
- status_t getDefaultChromaSiting(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType*
- outChromaSiting) const override;
- status_t getDefaultChromaSiting(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::ChromaSiting* outChromaSiting) const override;
- status_t getDefaultPlaneLayouts(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- std::vector<ui::PlaneLayout>* outPlaneLayouts) const override;
std::vector<android::hardware::graphics::mapper::V4_0::IMapper::MetadataTypeDescription>
listSupportedMetadataTypes() const;
diff --git a/libs/ui/include/ui/Gralloc5.h b/libs/ui/include/ui/Gralloc5.h
index bc10169..44b97d1 100644
--- a/libs/ui/include/ui/Gralloc5.h
+++ b/libs/ui/include/ui/Gralloc5.h
@@ -156,60 +156,6 @@
buffer_handle_t bufferHandle,
std::optional<std::vector<uint8_t>> smpte2094_10) const override;
- [[nodiscard]] status_t getDefaultPixelFormatFourCC(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage, uint32_t *outPixelFormatFourCC) const override;
-
- [[nodiscard]] status_t getDefaultPixelFormatModifier(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage, uint64_t *outPixelFormatModifier) const override;
-
- [[nodiscard]] status_t getDefaultAllocationSize(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t *outAllocationSize) const override;
-
- [[nodiscard]] status_t getDefaultProtectedContent(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- uint64_t *outProtectedContent) const override;
-
- [[nodiscard]] status_t getDefaultCompression(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType *outCompression)
- const override;
-
- [[nodiscard]] status_t getDefaultCompression(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- ui::Compression *outCompression) const override;
-
- [[nodiscard]] status_t getDefaultInterlaced(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType *outInterlaced)
- const override;
-
- [[nodiscard]] status_t getDefaultInterlaced(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::Interlaced *outInterlaced) const override;
-
- [[nodiscard]] status_t getDefaultChromaSiting(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType *outChromaSiting)
- const override;
-
- [[nodiscard]] status_t getDefaultChromaSiting(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- ui::ChromaSiting *outChromaSiting) const override;
-
- [[nodiscard]] status_t getDefaultPlaneLayouts(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage, std::vector<ui::PlaneLayout> *outPlaneLayouts) const override;
-
private:
void unlockBlocking(buffer_handle_t bufferHandle) const;
diff --git a/libs/ui/include/ui/GraphicBufferMapper.h b/libs/ui/include/ui/GraphicBufferMapper.h
index 51c6e92..3a5167a 100644
--- a/libs/ui/include/ui/GraphicBufferMapper.h
+++ b/libs/ui/include/ui/GraphicBufferMapper.h
@@ -138,48 +138,6 @@
status_t setSmpte2094_10(buffer_handle_t bufferHandle,
std::optional<std::vector<uint8_t>> smpte2094_10);
- /**
- * Gets the default metadata for a gralloc buffer allocated with the given parameters.
- *
- * These functions are supported by gralloc 4.0+.
- */
- status_t getDefaultPixelFormatFourCC(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint32_t* outPixelFormatFourCC);
- status_t getDefaultPixelFormatModifier(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint64_t* outPixelFormatModifier);
- status_t getDefaultAllocationSize(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint64_t* outAllocationSize);
- status_t getDefaultProtectedContent(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- uint64_t* outProtectedContent);
- status_t getDefaultCompression(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType* outCompression);
- status_t getDefaultCompression(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::Compression* outCompression);
- status_t getDefaultInterlaced(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType* outInterlaced);
- status_t getDefaultInterlaced(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::Interlaced* outInterlaced);
- status_t getDefaultChromaSiting(
- uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount,
- uint64_t usage,
- aidl::android::hardware::graphics::common::ExtendableType* outChromaSiting);
- status_t getDefaultChromaSiting(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- ui::ChromaSiting* outChromaSiting);
- status_t getDefaultPlaneLayouts(uint32_t width, uint32_t height, PixelFormat format,
- uint32_t layerCount, uint64_t usage,
- std::vector<ui::PlaneLayout>* outPlaneLayouts);
-
const GrallocMapper& getGrallocMapper() const {
return reinterpret_cast<const GrallocMapper&>(*mMapper);
}
diff --git a/services/gpuservice/vts/Android.bp b/services/gpuservice/vts/Android.bp
index 83a40e7..a24822a 100644
--- a/services/gpuservice/vts/Android.bp
+++ b/services/gpuservice/vts/Android.bp
@@ -21,7 +21,7 @@
srcs: ["src/**/*.java"],
libs: [
"tradefed",
- "vts-core-tradefed-harness",
+ "compatibility-host-util",
],
test_suites: [
"general-tests",
diff --git a/services/gpuservice/vts/src/com/android/tests/gpuservice/GpuWorkTracepointTest.java b/services/gpuservice/vts/src/com/android/tests/gpuservice/GpuWorkTracepointTest.java
index 9fa9016..6c16335 100644
--- a/services/gpuservice/vts/src/com/android/tests/gpuservice/GpuWorkTracepointTest.java
+++ b/services/gpuservice/vts/src/com/android/tests/gpuservice/GpuWorkTracepointTest.java
@@ -19,11 +19,16 @@
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
+import android.platform.test.annotations.RestrictedBuildTest;
+
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
import com.android.tradefed.util.CommandResult;
import com.android.tradefed.util.CommandStatus;
+import com.android.compatibility.common.util.PropertyUtil;
+import com.android.compatibility.common.util.VsrTest;
+
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,15 +62,23 @@
commandResult.getStatus(), CommandStatus.SUCCESS);
}
+ @VsrTest(requirements={"VSR-3.3-004"})
+ @RestrictedBuildTest
@Test
public void testGpuWorkPeriodTracepointFormat() throws Exception {
CommandResult commandResult = getDevice().executeShellV2Command(
String.format("cat %s", GPU_WORK_PERIOD_TRACEPOINT_FORMAT_PATH));
// If we failed to cat the tracepoint format then the test ends here.
- assumeTrue(String.format("Failed to cat the gpu_work_period tracepoint format at %s",
- GPU_WORK_PERIOD_TRACEPOINT_FORMAT_PATH),
- commandResult.getStatus().equals(CommandStatus.SUCCESS));
+ if (!commandResult.getStatus().equals(CommandStatus.SUCCESS)) {
+ String message = String.format(
+ "Failed to cat the gpu_work_period tracepoint format at %s\n",
+ GPU_WORK_PERIOD_TRACEPOINT_FORMAT_PATH);
+
+ // Tracepoint MUST exist on devices released with Android 14 or later
+ assumeTrue(message, PropertyUtil.getVsrApiLevel(getDevice()) >= 34);
+ fail(message);
+ }
// Otherwise, we check that the fields match the expected fields.
String actualFields = Arrays.stream(
diff --git a/services/inputflinger/InputCommonConverter.cpp b/services/inputflinger/InputCommonConverter.cpp
index 0c93f5c..2437d0f 100644
--- a/services/inputflinger/InputCommonConverter.cpp
+++ b/services/inputflinger/InputCommonConverter.cpp
@@ -200,17 +200,12 @@
return static_cast<common::Button>(buttonState);
}
-static common::ToolType getToolType(int32_t toolType) {
- static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_UNKNOWN) ==
- common::ToolType::UNKNOWN);
- static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_FINGER) ==
- common::ToolType::FINGER);
- static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_STYLUS) ==
- common::ToolType::STYLUS);
- static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_MOUSE) ==
- common::ToolType::MOUSE);
- static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_ERASER) ==
- common::ToolType::ERASER);
+static common::ToolType getToolType(ToolType toolType) {
+ static_assert(static_cast<common::ToolType>(ToolType::UNKNOWN) == common::ToolType::UNKNOWN);
+ static_assert(static_cast<common::ToolType>(ToolType::FINGER) == common::ToolType::FINGER);
+ static_assert(static_cast<common::ToolType>(ToolType::STYLUS) == common::ToolType::STYLUS);
+ static_assert(static_cast<common::ToolType>(ToolType::MOUSE) == common::ToolType::MOUSE);
+ static_assert(static_cast<common::ToolType>(ToolType::ERASER) == common::ToolType::ERASER);
return static_cast<common::ToolType>(toolType);
}
diff --git a/services/inputflinger/NotifyArgs.cpp b/services/inputflinger/NotifyArgs.cpp
index b192ad7..5f2a22f 100644
--- a/services/inputflinger/NotifyArgs.cpp
+++ b/services/inputflinger/NotifyArgs.cpp
@@ -161,9 +161,9 @@
StringPrintf("id=%" PRIu32 " x=%.1f y=%.1f pressure=%.1f", pointerProperties[i].id,
pointerCoords[i].getX(), pointerCoords[i].getY(),
pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
- const int32_t toolType = pointerProperties[i].toolType;
- if (toolType != AMOTION_EVENT_TOOL_TYPE_FINGER) {
- coords += StringPrintf(" toolType=%s", motionToolTypeToString(toolType));
+ const ToolType toolType = pointerProperties[i].toolType;
+ if (toolType != ToolType::FINGER) {
+ coords += StringPrintf(" toolType=%s", ftl::enum_string(toolType).c_str());
}
const float major = pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR);
const float minor = pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR);
diff --git a/services/inputflinger/PreferStylusOverTouchBlocker.cpp b/services/inputflinger/PreferStylusOverTouchBlocker.cpp
index ddd5146..fbd296c 100644
--- a/services/inputflinger/PreferStylusOverTouchBlocker.cpp
+++ b/services/inputflinger/PreferStylusOverTouchBlocker.cpp
@@ -24,11 +24,11 @@
bool hasTouch = false;
for (size_t i = 0; i < args.pointerCount; i++) {
// Make sure we are canceling stylus pointers
- const int32_t toolType = args.pointerProperties[i].toolType;
+ const ToolType toolType = args.pointerProperties[i].toolType;
if (isStylusToolType(toolType)) {
hasStylus = true;
}
- if (toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) {
+ if (toolType == ToolType::FINGER) {
hasTouch = true;
}
}
diff --git a/services/inputflinger/UnwantedInteractionBlocker.cpp b/services/inputflinger/UnwantedInteractionBlocker.cpp
index c170b81..ae20f86 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.cpp
+++ b/services/inputflinger/UnwantedInteractionBlocker.cpp
@@ -18,6 +18,7 @@
#include "UnwantedInteractionBlocker.h"
#include <android-base/stringprintf.h>
+#include <ftl/enum.h>
#include <input/PrintTools.h>
#include <inttypes.h>
#include <linux/input-event-codes.h>
@@ -98,18 +99,21 @@
return false;
}
-static int getLinuxToolCode(int toolType) {
+static int getLinuxToolCode(ToolType toolType) {
switch (toolType) {
- case AMOTION_EVENT_TOOL_TYPE_STYLUS:
+ case ToolType::STYLUS:
return BTN_TOOL_PEN;
- case AMOTION_EVENT_TOOL_TYPE_ERASER:
+ case ToolType::ERASER:
return BTN_TOOL_RUBBER;
- case AMOTION_EVENT_TOOL_TYPE_FINGER:
+ case ToolType::FINGER:
return BTN_TOOL_FINGER;
- default:
- ALOGW("Got tool type %" PRId32 ", converting to BTN_TOOL_FINGER", toolType);
- return BTN_TOOL_FINGER;
+ case ToolType::UNKNOWN:
+ case ToolType::MOUSE:
+ case ToolType::PALM:
+ break;
}
+ ALOGW("Got tool type %s, converting to BTN_TOOL_FINGER", ftl::enum_string(toolType).c_str());
+ return BTN_TOOL_FINGER;
}
static int32_t getActionUpForPointerId(const NotifyMotionArgs& args, int32_t pointerId) {
diff --git a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
index f03c837..58324c4 100644
--- a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
+++ b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
@@ -207,7 +207,7 @@
pointerProperties[0].clear();
pointerProperties[0].id = 0;
- pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties[0].toolType = ToolType::FINGER;
pointerCoords[0].clear();
pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 100);
@@ -235,7 +235,7 @@
pointerProperties[0].clear();
pointerProperties[0].id = 0;
- pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties[0].toolType = ToolType::FINGER;
pointerCoords[0].clear();
pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, 100);
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index cd427f0..0f7991a 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -1862,11 +1862,12 @@
entry.yPrecision, entry.downTime);
for (uint32_t i = 0; i < entry.pointerCount; i++) {
- ALOGD(" Pointer %d: id=%d, toolType=%d, "
+ ALOGD(" Pointer %d: id=%d, toolType=%s, "
"x=%f, y=%f, pressure=%f, size=%f, "
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
"orientation=%f",
- i, entry.pointerProperties[i].id, entry.pointerProperties[i].toolType,
+ i, entry.pointerProperties[i].id,
+ ftl::enum_string(entry.pointerProperties[i].toolType).c_str(),
entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
entry.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
@@ -4178,7 +4179,7 @@
ALOGD(" Pointer %d: id=%d, toolType=%s, x=%f, y=%f, pressure=%f, size=%f, "
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, orientation=%f",
i, args->pointerProperties[i].id,
- motionToolTypeToString(args->pointerProperties[i].toolType),
+ ftl::enum_string(args->pointerProperties[i].toolType).c_str(),
args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index 69363b6..ddf6c87 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -465,7 +465,7 @@
mHasMic, getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE));
for_each_mapper(
- [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(&outDeviceInfo); });
+ [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); });
if (mController) {
mController->populateDeviceInfo(&outDeviceInfo);
diff --git a/services/inputflinger/reader/include/StylusState.h b/services/inputflinger/reader/include/StylusState.h
index ff15e0c..d042784 100644
--- a/services/inputflinger/reader/include/StylusState.h
+++ b/services/inputflinger/reader/include/StylusState.h
@@ -33,8 +33,8 @@
std::optional<float> pressure{};
/* The state of the stylus buttons as a bitfield (e.g. AMOTION_EVENT_BUTTON_SECONDARY). */
uint32_t buttons{};
- /* Which tool type the stylus is currently using (e.g. AMOTION_EVENT_TOOL_TYPE_ERASER). */
- int32_t toolType{AMOTION_EVENT_TOOL_TYPE_UNKNOWN};
+ /* Which tool type the stylus is currently using (e.g. ToolType::ERASER). */
+ ToolType toolType{ToolType::UNKNOWN};
void clear() { *this = StylusState{}; }
};
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
index b27f70c..a3fdcdf 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
@@ -81,31 +81,31 @@
return mSource;
}
-void CursorInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void CursorInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
if (mParameters.mode == Parameters::Mode::POINTER) {
if (const auto bounds = mPointerController->getBounds(); bounds) {
- info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, bounds->left, bounds->right, 0.0f,
- 0.0f, 0.0f);
- info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, bounds->top, bounds->bottom, 0.0f,
- 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_X, mSource, bounds->left, bounds->right, 0.0f,
+ 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, bounds->top, bounds->bottom, 0.0f,
+ 0.0f, 0.0f);
}
} else {
- info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, -1.0f, 1.0f, 0.0f, mXScale, 0.0f);
- info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, -1.0f, 1.0f, 0.0f, mYScale, 0.0f);
- info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -1.0f, 1.0f, 0.0f, mXScale,
- 0.0f);
- info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -1.0f, 1.0f, 0.0f, mYScale,
- 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_X, mSource, -1.0f, 1.0f, 0.0f, mXScale, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, -1.0f, 1.0f, 0.0f, mYScale, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -1.0f, 1.0f, 0.0f, mXScale,
+ 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -1.0f, 1.0f, 0.0f, mYScale,
+ 0.0f);
}
- info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, mSource, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, mSource, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
if (mCursorScrollAccumulator.haveRelativeVWheel()) {
- info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
}
if (mCursorScrollAccumulator.haveRelativeHWheel()) {
- info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
}
}
@@ -350,7 +350,7 @@
PointerProperties pointerProperties;
pointerProperties.clear();
pointerProperties.id = 0;
- pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_MOUSE;
+ pointerProperties.toolType = ToolType::MOUSE;
PointerCoords pointerCoords;
pointerCoords.clear();
diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.h b/services/inputflinger/reader/mapper/CursorInputMapper.h
index 939cceb..5f02203 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.h
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.h
@@ -57,7 +57,7 @@
virtual ~CursorInputMapper();
virtual uint32_t getSources() const override;
- virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ virtual void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
virtual void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
diff --git a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp
index 2809939..99e6cf9 100644
--- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.cpp
@@ -30,11 +30,11 @@
return AINPUT_SOURCE_STYLUS;
}
-void ExternalStylusInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void ExternalStylusInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
if (mRawPressureAxis.valid) {
- info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, AINPUT_SOURCE_STYLUS, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, AINPUT_SOURCE_STYLUS, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f);
}
}
@@ -77,8 +77,8 @@
mStylusState.when = when;
mStylusState.toolType = mTouchButtonAccumulator.getToolType();
- if (mStylusState.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
- mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ if (mStylusState.toolType == ToolType::UNKNOWN) {
+ mStylusState.toolType = ToolType::STYLUS;
}
if (mRawPressureAxis.valid) {
diff --git a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h
index b6c9055..11b5315 100644
--- a/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h
+++ b/services/inputflinger/reader/mapper/ExternalStylusInputMapper.h
@@ -30,7 +30,7 @@
virtual ~ExternalStylusInputMapper() = default;
uint32_t getSources() const override;
- void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
diff --git a/services/inputflinger/reader/mapper/InputMapper.cpp b/services/inputflinger/reader/mapper/InputMapper.cpp
index ba2ea99..9cf3696 100644
--- a/services/inputflinger/reader/mapper/InputMapper.cpp
+++ b/services/inputflinger/reader/mapper/InputMapper.cpp
@@ -29,8 +29,8 @@
InputMapper::~InputMapper() {}
-void InputMapper::populateDeviceInfo(InputDeviceInfo* info) {
- info->addSource(getSources());
+void InputMapper::populateDeviceInfo(InputDeviceInfo& info) {
+ info.addSource(getSources());
}
void InputMapper::dump(std::string& dump) {}
diff --git a/services/inputflinger/reader/mapper/InputMapper.h b/services/inputflinger/reader/mapper/InputMapper.h
index 104305b..2722edd 100644
--- a/services/inputflinger/reader/mapper/InputMapper.h
+++ b/services/inputflinger/reader/mapper/InputMapper.h
@@ -51,7 +51,7 @@
inline InputReaderPolicyInterface* getPolicy() { return getContext()->getPolicy(); }
virtual uint32_t getSources() const = 0;
- virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
+ virtual void populateDeviceInfo(InputDeviceInfo& deviceInfo);
virtual void dump(std::string& dump);
[[nodiscard]] virtual std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
index d7f8b17..f65cdcb 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
@@ -29,7 +29,7 @@
return AINPUT_SOURCE_JOYSTICK;
}
-void JoystickInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void JoystickInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
for (const auto& [_, axis] : mAxes) {
@@ -41,16 +41,16 @@
}
}
-void JoystickInputMapper::addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo* info) {
- info->addMotionRange(axisId, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat, axis.fuzz,
- axis.resolution);
+void JoystickInputMapper::addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo& info) {
+ info.addMotionRange(axisId, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat, axis.fuzz,
+ axis.resolution);
/* In order to ease the transition for developers from using the old axes
* to the newer, more semantically correct axes, we'll continue to register
* the old axes as duplicates of their corresponding new ones. */
int32_t compatAxis = getCompatAxis(axisId);
if (compatAxis >= 0) {
- info->addMotionRange(compatAxis, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat,
- axis.fuzz, axis.resolution);
+ info.addMotionRange(compatAxis, AINPUT_SOURCE_JOYSTICK, axis.min, axis.max, axis.flat,
+ axis.fuzz, axis.resolution);
}
}
@@ -321,7 +321,7 @@
PointerProperties pointerProperties;
pointerProperties.clear();
pointerProperties.id = 0;
- pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+ pointerProperties.toolType = ToolType::UNKNOWN;
PointerCoords pointerCoords;
pointerCoords.clear();
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.h b/services/inputflinger/reader/mapper/JoystickInputMapper.h
index 72b8a52..9ca4176 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.h
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.h
@@ -26,7 +26,7 @@
virtual ~JoystickInputMapper();
virtual uint32_t getSources() const override;
- virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ virtual void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
virtual void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
@@ -106,7 +106,7 @@
static bool isCenteredAxis(int32_t axis);
static int32_t getCompatAxis(int32_t axis);
- static void addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo* info);
+ static void addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo& info);
static void setPointerCoordsAxisValue(PointerCoords* pointerCoords, int32_t axis, float value);
};
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
index f39e004..269c106 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.cpp
@@ -85,18 +85,18 @@
return ADISPLAY_ID_NONE;
}
-void KeyboardInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void KeyboardInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
- info->setKeyboardType(mKeyboardType);
- info->setKeyCharacterMap(getDeviceContext().getKeyCharacterMap());
+ info.setKeyboardType(mKeyboardType);
+ info.setKeyCharacterMap(getDeviceContext().getKeyCharacterMap());
if (mKeyboardLayoutInfo) {
- info->setKeyboardLayoutInfo(*mKeyboardLayoutInfo);
+ info.setKeyboardLayoutInfo(*mKeyboardLayoutInfo);
} else {
std::optional<RawLayoutInfo> layoutInfo = getDeviceContext().getRawLayoutInfo();
if (layoutInfo) {
- info->setKeyboardLayoutInfo(
+ info.setKeyboardLayoutInfo(
KeyboardLayoutInfo(layoutInfo->languageTag, layoutInfo->layoutType));
}
}
diff --git a/services/inputflinger/reader/mapper/KeyboardInputMapper.h b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
index da5b8ee..2fc82c3 100644
--- a/services/inputflinger/reader/mapper/KeyboardInputMapper.h
+++ b/services/inputflinger/reader/mapper/KeyboardInputMapper.h
@@ -27,7 +27,7 @@
~KeyboardInputMapper() override = default;
uint32_t getSources() const override;
- void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
diff --git a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
index 33e72c7..e871288 100644
--- a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
@@ -77,7 +77,7 @@
continue;
}
- if (inSlot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM) {
+ if (inSlot.getToolType() == ToolType::PALM) {
std::optional<int32_t> id = getActiveBitId(inSlot);
if (id) {
outState->rawPointerData.canceledIdBits.markBit(id.value());
@@ -112,12 +112,12 @@
outPointer.tiltY = 0;
outPointer.toolType = inSlot.getToolType();
- if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+ if (outPointer.toolType == ToolType::UNKNOWN) {
outPointer.toolType = mTouchButtonAccumulator.getToolType();
- if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
- outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ if (outPointer.toolType == ToolType::UNKNOWN) {
+ outPointer.toolType = ToolType::FINGER;
}
- } else if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS && !mStylusMtToolSeen) {
+ } else if (outPointer.toolType == ToolType::STYLUS && !mStylusMtToolSeen) {
mStylusMtToolSeen = true;
// The multi-touch device produced a stylus event with MT_TOOL_PEN. Dynamically
// re-configure this input device so that we add SOURCE_STYLUS if we haven't already.
@@ -130,12 +130,11 @@
bumpGeneration();
}
}
- if (shouldSimulateStylusWithTouch() &&
- outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) {
- outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ if (shouldSimulateStylusWithTouch() && outPointer.toolType == ToolType::FINGER) {
+ outPointer.toolType = ToolType::STYLUS;
}
- bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE &&
+ bool isHovering = mTouchButtonAccumulator.getToolType() != ToolType::MOUSE &&
(mTouchButtonAccumulator.isHovering() ||
(mRawPointerAxes.pressure.valid && inSlot.getPressure() <= 0));
outPointer.isHovering = isHovering;
diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
index 2ff26ed..c0a35b1 100644
--- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.cpp
@@ -37,7 +37,7 @@
return mSource;
}
-void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) {
@@ -52,8 +52,8 @@
"default to 1.0!\n");
}
mScalingFactor = scalingFactor.value_or(1.0f);
- info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
- res.value_or(0.0f) * mScalingFactor);
+ info.addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
+ res.value_or(0.0f) * mScalingFactor);
}
}
@@ -121,7 +121,7 @@
PointerProperties pointerProperties;
pointerProperties.clear();
pointerProperties.id = 0;
- pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+ pointerProperties.toolType = ToolType::UNKNOWN;
uint32_t policyFlags = 0;
if (getDeviceContext().isExternal()) {
diff --git a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h
index cb5fd88..a0516c4 100644
--- a/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h
+++ b/services/inputflinger/reader/mapper/RotaryEncoderInputMapper.h
@@ -29,7 +29,7 @@
virtual ~RotaryEncoderInputMapper();
virtual uint32_t getSources() const override;
- virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ virtual void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
virtual void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
diff --git a/services/inputflinger/reader/mapper/SensorInputMapper.cpp b/services/inputflinger/reader/mapper/SensorInputMapper.cpp
index ba08823..60e6727 100644
--- a/services/inputflinger/reader/mapper/SensorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/SensorInputMapper.cpp
@@ -73,12 +73,12 @@
}
}
-void SensorInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void SensorInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
for (const auto& [sensorType, sensor] : mSensors) {
- info->addSensorInfo(sensor.sensorInfo);
- info->setHasSensor(true);
+ info.addSensorInfo(sensor.sensorInfo);
+ info.setHasSensor(true);
}
}
diff --git a/services/inputflinger/reader/mapper/SensorInputMapper.h b/services/inputflinger/reader/mapper/SensorInputMapper.h
index 043a895..7f47df7 100644
--- a/services/inputflinger/reader/mapper/SensorInputMapper.h
+++ b/services/inputflinger/reader/mapper/SensorInputMapper.h
@@ -31,7 +31,7 @@
~SensorInputMapper() override;
uint32_t getSources() const override;
- void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
diff --git a/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp b/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp
index 13ad224..f13417a 100644
--- a/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/SingleTouchInputMapper.cpp
@@ -41,7 +41,7 @@
outState->rawPointerData.pointerCount = 1;
outState->rawPointerData.idToIndex[0] = 0;
- bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE &&
+ bool isHovering = mTouchButtonAccumulator.getToolType() != ToolType::MOUSE &&
(mTouchButtonAccumulator.isHovering() ||
(mRawPointerAxes.pressure.valid &&
mSingleTouchMotionAccumulator.getAbsolutePressure() <= 0));
@@ -61,8 +61,8 @@
outPointer.tiltX = mSingleTouchMotionAccumulator.getAbsoluteTiltX();
outPointer.tiltY = mSingleTouchMotionAccumulator.getAbsoluteTiltY();
outPointer.toolType = mTouchButtonAccumulator.getToolType();
- if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
- outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ if (outPointer.toolType == ToolType::UNKNOWN) {
+ outPointer.toolType = ToolType::FINGER;
}
outPointer.isHovering = isHovering;
}
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 34a4e93..073c18b 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -134,16 +134,16 @@
return mSource;
}
-void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void TouchInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
if (mDeviceMode == DeviceMode::DISABLED) {
return;
}
- info->addMotionRange(mOrientedRanges.x);
- info->addMotionRange(mOrientedRanges.y);
- info->addMotionRange(mOrientedRanges.pressure);
+ info.addMotionRange(mOrientedRanges.x);
+ info.addMotionRange(mOrientedRanges.y);
+ info.addMotionRange(mOrientedRanges.pressure);
if (mDeviceMode == DeviceMode::UNSCALED && mSource == AINPUT_SOURCE_TOUCHPAD) {
// Populate RELATIVE_X and RELATIVE_Y motion ranges for touchpad capture mode.
@@ -153,46 +153,46 @@
// touchpad in one sample cycle.
const InputDeviceInfo::MotionRange& x = mOrientedRanges.x;
const InputDeviceInfo::MotionRange& y = mOrientedRanges.y;
- info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -x.max, x.max, x.flat, x.fuzz,
- x.resolution);
- info->addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -y.max, y.max, y.flat, y.fuzz,
- y.resolution);
+ info.addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_X, mSource, -x.max, x.max, x.flat, x.fuzz,
+ x.resolution);
+ info.addMotionRange(AMOTION_EVENT_AXIS_RELATIVE_Y, mSource, -y.max, y.max, y.flat, y.fuzz,
+ y.resolution);
}
if (mOrientedRanges.size) {
- info->addMotionRange(*mOrientedRanges.size);
+ info.addMotionRange(*mOrientedRanges.size);
}
if (mOrientedRanges.touchMajor) {
- info->addMotionRange(*mOrientedRanges.touchMajor);
- info->addMotionRange(*mOrientedRanges.touchMinor);
+ info.addMotionRange(*mOrientedRanges.touchMajor);
+ info.addMotionRange(*mOrientedRanges.touchMinor);
}
if (mOrientedRanges.toolMajor) {
- info->addMotionRange(*mOrientedRanges.toolMajor);
- info->addMotionRange(*mOrientedRanges.toolMinor);
+ info.addMotionRange(*mOrientedRanges.toolMajor);
+ info.addMotionRange(*mOrientedRanges.toolMinor);
}
if (mOrientedRanges.orientation) {
- info->addMotionRange(*mOrientedRanges.orientation);
+ info.addMotionRange(*mOrientedRanges.orientation);
}
if (mOrientedRanges.distance) {
- info->addMotionRange(*mOrientedRanges.distance);
+ info.addMotionRange(*mOrientedRanges.distance);
}
if (mOrientedRanges.tilt) {
- info->addMotionRange(*mOrientedRanges.tilt);
+ info.addMotionRange(*mOrientedRanges.tilt);
}
if (mCursorScrollAccumulator.haveRelativeVWheel()) {
- info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
}
if (mCursorScrollAccumulator.haveRelativeHWheel()) {
- info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+ info.addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
}
- info->setButtonUnderPad(mParameters.hasButtonUnderPad);
- info->setUsiVersion(mParameters.usiVersion);
+ info.setButtonUnderPad(mParameters.hasButtonUnderPad);
+ info.setUsiVersion(mParameters.usiVersion);
}
void TouchInputMapper::dump(std::string& dump) {
@@ -229,11 +229,12 @@
dump += StringPrintf(INDENT4 "[%d]: id=%d, x=%d, y=%d, pressure=%d, "
"touchMajor=%d, touchMinor=%d, toolMajor=%d, toolMinor=%d, "
"orientation=%d, tiltX=%d, tiltY=%d, distance=%d, "
- "toolType=%d, isHovering=%s\n",
+ "toolType=%s, isHovering=%s\n",
i, pointer.id, pointer.x, pointer.y, pointer.pressure,
pointer.touchMajor, pointer.touchMinor, pointer.toolMajor,
pointer.toolMinor, pointer.orientation, pointer.tiltX, pointer.tiltY,
- pointer.distance, pointer.toolType, toString(pointer.isHovering));
+ pointer.distance, ftl::enum_string(pointer.toolType).c_str(),
+ toString(pointer.isHovering));
}
dump += StringPrintf(INDENT3 "Last Cooked Button State: 0x%08x\n",
@@ -248,7 +249,7 @@
"pressure=%0.3f, touchMajor=%0.3f, touchMinor=%0.3f, "
"toolMajor=%0.3f, toolMinor=%0.3f, "
"orientation=%0.3f, tilt=%0.3f, distance=%0.3f, "
- "toolType=%d, isHovering=%s\n",
+ "toolType=%s, isHovering=%s\n",
i, pointerProperties.id, pointerCoords.getX(), pointerCoords.getY(),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y),
@@ -260,7 +261,7 @@
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TILT),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_DISTANCE),
- pointerProperties.toolType,
+ ftl::enum_string(pointerProperties.toolType).c_str(),
toString(mLastCookedState.cookedPointerData.isHovering(i)));
}
@@ -1582,10 +1583,10 @@
mCurrentRawState.rawPointerData.pointerForId(id);
if (isStylusToolType(pointer.toolType)) {
mCurrentCookedState.stylusIdBits.markBit(id);
- } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER ||
- pointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+ } else if (pointer.toolType == ToolType::FINGER ||
+ pointer.toolType == ToolType::UNKNOWN) {
mCurrentCookedState.fingerIdBits.markBit(id);
- } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_MOUSE) {
+ } else if (pointer.toolType == ToolType::MOUSE) {
mCurrentCookedState.mouseIdBits.markBit(id);
}
}
@@ -1704,7 +1705,7 @@
PointerCoords& coords = currentPointerData.editPointerCoordsWithId(*mFusedStylusPointerId);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pressure);
- if (mExternalStylusState.toolType != AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+ if (mExternalStylusState.toolType != ToolType::UNKNOWN) {
PointerProperties& properties =
currentPointerData.editPointerPropertiesWithId(*mFusedStylusPointerId);
properties.toolType = mExternalStylusState.toolType;
@@ -2678,7 +2679,7 @@
PointerProperties pointerProperties;
pointerProperties.clear();
pointerProperties.id = 0;
- pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties.toolType = ToolType::FINGER;
PointerCoords pointerCoords;
pointerCoords.clear();
@@ -2887,7 +2888,7 @@
mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ 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);
@@ -2922,8 +2923,7 @@
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id =
mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType =
- AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
mPointerGesture.tapX);
@@ -3010,7 +3010,7 @@
mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ 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);
@@ -3040,9 +3040,10 @@
uint32_t index = mPointerGesture.currentGestureIdToIndex[id];
const PointerProperties& properties = mPointerGesture.currentGestureProperties[index];
const PointerCoords& coords = mPointerGesture.currentGestureCoords[index];
- ALOGD(" currentGesture[%d]: index=%d, toolType=%d, "
+ ALOGD(" currentGesture[%d]: index=%d, toolType=%s, "
"x=%0.3f, y=%0.3f, pressure=%0.3f",
- id, index, properties.toolType, coords.getAxisValue(AMOTION_EVENT_AXIS_X),
+ id, index, ftl::enum_string(properties.toolType).c_str(),
+ coords.getAxisValue(AMOTION_EVENT_AXIS_X),
coords.getAxisValue(AMOTION_EVENT_AXIS_Y),
coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
}
@@ -3051,9 +3052,10 @@
uint32_t index = mPointerGesture.lastGestureIdToIndex[id];
const PointerProperties& properties = mPointerGesture.lastGestureProperties[index];
const PointerCoords& coords = mPointerGesture.lastGestureCoords[index];
- ALOGD(" lastGesture[%d]: index=%d, toolType=%d, "
+ ALOGD(" lastGesture[%d]: index=%d, toolType=%s, "
"x=%0.3f, y=%0.3f, pressure=%0.3f",
- id, index, properties.toolType, coords.getAxisValue(AMOTION_EVENT_AXIS_X),
+ id, index, ftl::enum_string(properties.toolType).c_str(),
+ coords.getAxisValue(AMOTION_EVENT_AXIS_X),
coords.getAxisValue(AMOTION_EVENT_AXIS_Y),
coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
}
@@ -3342,7 +3344,7 @@
mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
mPointerGesture.referenceGestureX);
@@ -3435,7 +3437,7 @@
mPointerGesture.currentGestureProperties[i].clear();
mPointerGesture.currentGestureProperties[i].id = gestureId;
- mPointerGesture.currentGestureProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[i].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[i].clear();
mPointerGesture.currentGestureCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X,
mPointerGesture.referenceGestureX +
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index df66846..bc358b9 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -78,8 +78,8 @@
int32_t distance{};
int32_t tiltX{};
int32_t tiltY{};
- // A fully decoded AMOTION_EVENT_TOOL_TYPE constant.
- int32_t toolType{AMOTION_EVENT_TOOL_TYPE_UNKNOWN};
+ // A fully decoded ToolType constant.
+ ToolType toolType{ToolType::UNKNOWN};
bool isHovering{false};
};
@@ -150,7 +150,7 @@
~TouchInputMapper() override;
uint32_t getSources() const override;
- void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration* config,
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index 3309767..661461b 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -206,6 +206,11 @@
return AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD;
}
+void TouchpadInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
+ InputMapper::populateDeviceInfo(info);
+ mGestureConverter.populateMotionRanges(info);
+}
+
void TouchpadInputMapper::dump(std::string& dump) {
dump += INDENT2 "Touchpad Input Mapper:\n";
dump += INDENT3 "Gesture converter:\n";
@@ -251,8 +256,9 @@
std::list<NotifyArgs> TouchpadInputMapper::reset(nsecs_t when) {
mStateConverter.reset();
- mGestureConverter.reset();
- return InputMapper::reset(when);
+ std::list<NotifyArgs> out = mGestureConverter.reset(when);
+ out += InputMapper::reset(when);
+ return out;
}
std::list<NotifyArgs> TouchpadInputMapper::process(const RawEvent* rawEvent) {
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
index d693bca..fb36d92 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
@@ -41,6 +41,7 @@
~TouchpadInputMapper();
uint32_t getSources() const override;
+ void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
void dump(std::string& dump) override;
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
diff --git a/services/inputflinger/reader/mapper/VibratorInputMapper.cpp b/services/inputflinger/reader/mapper/VibratorInputMapper.cpp
index 7645b12..2c77fc4 100644
--- a/services/inputflinger/reader/mapper/VibratorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/VibratorInputMapper.cpp
@@ -29,10 +29,10 @@
return 0;
}
-void VibratorInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
+void VibratorInputMapper::populateDeviceInfo(InputDeviceInfo& info) {
InputMapper::populateDeviceInfo(info);
- info->setVibrator(true);
+ info.setVibrator(true);
}
std::list<NotifyArgs> VibratorInputMapper::process(const RawEvent* rawEvent) {
diff --git a/services/inputflinger/reader/mapper/VibratorInputMapper.h b/services/inputflinger/reader/mapper/VibratorInputMapper.h
index e98f63a..e665973 100644
--- a/services/inputflinger/reader/mapper/VibratorInputMapper.h
+++ b/services/inputflinger/reader/mapper/VibratorInputMapper.h
@@ -26,7 +26,7 @@
virtual ~VibratorInputMapper();
virtual uint32_t getSources() const override;
- virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo) override;
+ virtual void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
[[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
[[nodiscard]] std::list<NotifyArgs> vibrate(const VibrationSequence& sequence, ssize_t repeat,
diff --git a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp
index f6a42bd..f70be72 100644
--- a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp
+++ b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.cpp
@@ -154,18 +154,18 @@
// --- MultiTouchMotionAccumulator::Slot ---
-int32_t MultiTouchMotionAccumulator::Slot::getToolType() const {
+ToolType MultiTouchMotionAccumulator::Slot::getToolType() const {
if (mHaveAbsMtToolType) {
switch (mAbsMtToolType) {
case MT_TOOL_FINGER:
- return AMOTION_EVENT_TOOL_TYPE_FINGER;
+ return ToolType::FINGER;
case MT_TOOL_PEN:
- return AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ return ToolType::STYLUS;
case MT_TOOL_PALM:
- return AMOTION_EVENT_TOOL_TYPE_PALM;
+ return ToolType::PALM;
}
}
- return AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+ return ToolType::UNKNOWN;
}
} // namespace android
diff --git a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h
index 3c1a2a9..943dde5 100644
--- a/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h
+++ b/services/inputflinger/reader/mapper/accumulator/MultiTouchMotionAccumulator.h
@@ -45,7 +45,7 @@
inline int32_t getTrackingId() const { return mAbsMtTrackingId; }
inline int32_t getPressure() const { return mAbsMtPressure; }
inline int32_t getDistance() const { return mAbsMtDistance; }
- int32_t getToolType() const;
+ ToolType getToolType() const;
private:
friend class MultiTouchMotionAccumulator;
diff --git a/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.cpp b/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.cpp
index 6b84f32..8c4bed3 100644
--- a/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.cpp
+++ b/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.cpp
@@ -141,21 +141,21 @@
return result;
}
-int32_t TouchButtonAccumulator::getToolType() const {
+ToolType TouchButtonAccumulator::getToolType() const {
if (mBtnToolMouse || mBtnToolLens) {
- return AMOTION_EVENT_TOOL_TYPE_MOUSE;
+ return ToolType::MOUSE;
}
if (mBtnToolRubber) {
- return AMOTION_EVENT_TOOL_TYPE_ERASER;
+ return ToolType::ERASER;
}
if (mBtnToolPen || mBtnToolBrush || mBtnToolPencil || mBtnToolAirbrush) {
- return AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ return ToolType::STYLUS;
}
if (mBtnToolFinger || mBtnToolDoubleTap || mBtnToolTripleTap || mBtnToolQuadTap ||
mBtnToolQuintTap) {
- return AMOTION_EVENT_TOOL_TYPE_FINGER;
+ return ToolType::FINGER;
}
- return AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
+ return ToolType::UNKNOWN;
}
bool TouchButtonAccumulator::isToolActive() const {
diff --git a/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h b/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h
index c2aa2ad..c5fd5f5 100644
--- a/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h
+++ b/services/inputflinger/reader/mapper/accumulator/TouchButtonAccumulator.h
@@ -36,7 +36,7 @@
void process(const RawEvent* rawEvent);
uint32_t getButtonState() const;
- int32_t getToolType() const;
+ ToolType getToolType() const;
bool isToolActive() const;
bool isHovering() const;
bool hasStylus() const;
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index bc9f4c0..fd2be5f 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -16,13 +16,14 @@
#include "gestures/GestureConverter.h"
+#include <optional>
#include <sstream>
#include <android-base/stringprintf.h>
-#include <android/input.h>
#include <ftl/enum.h>
#include <linux/input-event-codes.h>
#include <log/log_main.h>
+#include <ui/FloatRect.h>
#include "TouchCursorInputMapperCommon.h"
#include "input/Input.h"
@@ -71,8 +72,54 @@
return out.str();
}
-void GestureConverter::reset() {
- mButtonState = 0;
+std::list<NotifyArgs> GestureConverter::reset(nsecs_t when) {
+ std::list<NotifyArgs> out;
+ switch (mCurrentClassification) {
+ case MotionClassification::TWO_FINGER_SWIPE:
+ out.push_back(endScroll(when, when));
+ break;
+ case MotionClassification::MULTI_FINGER_SWIPE:
+ out += handleMultiFingerSwipeLift(when, when);
+ break;
+ case MotionClassification::PINCH:
+ out += endPinch(when, when);
+ break;
+ case MotionClassification::NONE:
+ // When a button is pressed, the Gestures library always ends the current gesture,
+ // so we don't have to worry about the case where buttons need to be lifted during a
+ // pinch or swipe.
+ if (mButtonState) {
+ out += releaseAllButtons(when, when);
+ }
+ break;
+ default:
+ break;
+ }
+ mCurrentClassification = MotionClassification::NONE;
+ mDownTime = 0;
+ return out;
+}
+
+void GestureConverter::populateMotionRanges(InputDeviceInfo& info) const {
+ info.addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, SOURCE, 0.0f, 1.0f, 0, 0, 0);
+
+ // TODO(b/259547750): set this using the raw axis ranges from the touchpad when pointer capture
+ // is enabled.
+ if (std::optional<FloatRect> rect = mPointerController->getBounds(); rect.has_value()) {
+ info.addMotionRange(AMOTION_EVENT_AXIS_X, SOURCE, rect->left, rect->right, 0, 0, 0);
+ info.addMotionRange(AMOTION_EVENT_AXIS_Y, SOURCE, rect->top, rect->bottom, 0, 0, 0);
+ }
+
+ info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_X_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0);
+ info.addMotionRange(AMOTION_EVENT_AXIS_GESTURE_Y_OFFSET, SOURCE, -1.0f, 1.0f, 0, 0, 0);
+
+ // The other axes that can be reported don't have ranges that are easy to define. RELATIVE_X/Y
+ // and GESTURE_SCROLL_X/Y_DISTANCE are the result of acceleration functions being applied to
+ // finger movements, so their maximum values can't simply be derived from the size of the
+ // touchpad. GESTURE_PINCH_SCALE_FACTOR's maximum value depends on the minimum finger separation
+ // that the pad can report, which cannot be determined from its raw axis information. (Assuming
+ // a minimum finger separation of 1 unit would let us calculate a theoretical maximum, but it
+ // would be orders of magnitude too high, so probably not very useful.)
}
std::list<NotifyArgs> GestureConverter::handleGesture(nsecs_t when, nsecs_t readTime,
@@ -196,6 +243,39 @@
return out;
}
+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);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerDown ? 1.0f : 0.0f);
+ uint32_t newButtonState = mButtonState;
+ for (uint32_t button = AMOTION_EVENT_BUTTON_PRIMARY; button <= AMOTION_EVENT_BUTTON_FORWARD;
+ button <<= 1) {
+ if (mButtonState & button) {
+ newButtonState &= ~button;
+ out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_BUTTON_RELEASE,
+ button, newButtonState, /*pointerCount=*/1,
+ mFingerProps.data(), &coords, xCursorPosition,
+ yCursorPosition));
+ }
+ }
+ if (pointerDown) {
+ coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 0.0f);
+ out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /*actionButton=*/0,
+ newButtonState, /*pointerCount=*/1, mFingerProps.data(),
+ &coords, xCursorPosition, yCursorPosition));
+ }
+ mButtonState = 0;
+ return out;
+}
+
std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readTime,
const Gesture& gesture) {
std::list<NotifyArgs> out;
@@ -241,6 +321,10 @@
return {};
}
+ return endScroll(when, readTime);
+}
+
+NotifyArgs GestureConverter::endScroll(nsecs_t when, nsecs_t readTime) {
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);
@@ -343,8 +427,6 @@
[[nodiscard]] std::list<NotifyArgs> GestureConverter::handlePinch(nsecs_t when, nsecs_t readTime,
const Gesture& gesture) {
- std::list<NotifyArgs> out;
-
const auto [xCursorPosition, yCursorPosition] = mPointerController->getPosition();
// Pinch gesture phases are reported a little differently from others, in that the same details
@@ -368,6 +450,7 @@
mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
mDownTime = when;
+ std::list<NotifyArgs> out;
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/* actionButton= */ 0, mButtonState, /* pointerCount= */ 1,
mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition,
@@ -382,19 +465,7 @@
}
if (gesture.details.pinch.zoom_state == GESTURES_ZOOM_END) {
- 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,
- mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition,
- yCursorPosition));
- out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 1, mFingerProps.data(),
- mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
- mCurrentClassification = MotionClassification::NONE;
- mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 0);
- return out;
+ return endPinch(when, readTime);
}
mPinchFingerSeparation *= gesture.details.pinch.dz;
@@ -406,9 +477,27 @@
mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_X,
xCursorPosition + mPinchFingerSeparation / 2);
mFakeFingerCoords[1].setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition);
- out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0,
- mButtonState, /* pointerCount= */ 2, mFingerProps.data(),
+ return {makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /*actionButton=*/0,
+ mButtonState, /*pointerCount=*/2, mFingerProps.data(),
+ mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)};
+}
+
+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,
+ mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition,
+ yCursorPosition));
+ out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /*actionButton=*/0,
+ mButtonState, /*pointerCount=*/1, mFingerProps.data(),
mFakeFingerCoords.data(), xCursorPosition, yCursorPosition));
+ mCurrentClassification = MotionClassification::NONE;
+ mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_PINCH_SCALE_FACTOR, 0);
return out;
}
@@ -418,10 +507,7 @@
const PointerProperties* pointerProperties,
const PointerCoords* pointerCoords,
float xCursorPosition, float yCursorPosition) {
- // TODO(b/260226362): consider what the appropriate source for these events is.
- const uint32_t source = AINPUT_SOURCE_MOUSE;
-
- return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, source,
+ return NotifyMotionArgs(mReaderContext.getNextId(), when, readTime, mDeviceId, SOURCE,
mPointerController->getDisplayId(), /* policyFlags= */ POLICY_FLAG_WAKE,
action, /* actionButton= */ actionButton, /* flags= */ 0,
mReaderContext.getGlobalMetaState(), buttonState,
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.h b/services/inputflinger/reader/mapper/gestures/GestureConverter.h
index 2ec5841..70e8fb7 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.h
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.h
@@ -21,6 +21,7 @@
#include <memory>
#include <PointerControllerInterface.h>
+#include <android/input.h>
#include <utils/Timers.h>
#include "EventHub.h"
@@ -43,7 +44,9 @@
std::string dump() const;
void setOrientation(ui::Rotation orientation) { mOrientation = orientation; }
- void reset();
+ [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when);
+
+ void populateMotionRanges(InputDeviceInfo& info) const;
[[nodiscard]] std::list<NotifyArgs> handleGesture(nsecs_t when, nsecs_t readTime,
const Gesture& gesture);
@@ -52,15 +55,19 @@
[[nodiscard]] NotifyArgs handleMove(nsecs_t when, nsecs_t readTime, const Gesture& gesture);
[[nodiscard]] std::list<NotifyArgs> handleButtonsChange(nsecs_t when, nsecs_t readTime,
const Gesture& gesture);
+ [[nodiscard]] std::list<NotifyArgs> releaseAllButtons(nsecs_t when, nsecs_t readTime);
[[nodiscard]] std::list<NotifyArgs> handleScroll(nsecs_t when, nsecs_t readTime,
const Gesture& gesture);
[[nodiscard]] NotifyArgs handleFling(nsecs_t when, nsecs_t readTime, const Gesture& gesture);
+ [[nodiscard]] NotifyArgs endScroll(nsecs_t when, nsecs_t readTime);
+
[[nodiscard]] std::list<NotifyArgs> handleMultiFingerSwipe(nsecs_t when, nsecs_t readTime,
uint32_t fingerCount, float dx,
float dy);
[[nodiscard]] std::list<NotifyArgs> handleMultiFingerSwipeLift(nsecs_t when, nsecs_t readTime);
[[nodiscard]] std::list<NotifyArgs> handlePinch(nsecs_t when, nsecs_t readTime,
const Gesture& gesture);
+ [[nodiscard]] std::list<NotifyArgs> endPinch(nsecs_t when, nsecs_t readTime);
NotifyMotionArgs makeMotionArgs(nsecs_t when, nsecs_t readTime, int32_t action,
int32_t actionButton, int32_t buttonState,
@@ -92,12 +99,15 @@
// We never need any PointerProperties other than the finger tool type, so we can just keep a
// const array of them.
const std::array<PointerProperties, MAX_FAKE_FINGERS> mFingerProps = {{
- {.id = 0, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER},
- {.id = 1, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER},
- {.id = 2, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER},
- {.id = 3, .toolType = AMOTION_EVENT_TOOL_TYPE_FINGER},
+ {.id = 0, .toolType = ToolType::FINGER},
+ {.id = 1, .toolType = ToolType::FINGER},
+ {.id = 2, .toolType = ToolType::FINGER},
+ {.id = 3, .toolType = ToolType::FINGER},
}};
std::array<PointerCoords, MAX_FAKE_FINGERS> mFakeFingerCoords = {};
+
+ // TODO(b/260226362): consider what the appropriate source for these events is.
+ static constexpr uint32_t SOURCE = AINPUT_SOURCE_MOUSE;
};
} // namespace android
diff --git a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp
index c091a51..e89262a 100644
--- a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.cpp
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+// clang-format off
+#include "../Macros.h"
+// clang-format on
#include "gestures/HardwareStateConverter.h"
#include <chrono>
@@ -80,14 +83,9 @@
schs.fingers.clear();
for (size_t i = 0; i < mMotionAccumulator.getSlotCount(); i++) {
MultiTouchMotionAccumulator::Slot slot = mMotionAccumulator.getSlot(i);
- if (!slot.isInUse()) {
- continue;
- }
// Some touchpads continue to report contacts even after they've identified them as palms.
- // We want to exclude these contacts from the HardwareStates, but still need to report a
- // tracking ID of -1 if a finger turns into a palm.
- const bool isPalm = slot.getToolType() == AMOTION_EVENT_TOOL_TYPE_PALM;
- if (isPalm && mFingerSlots.find(i) == mFingerSlots.end()) {
+ // We want to exclude these contacts from the HardwareStates.
+ if (!slot.isInUse() || slot.getToolType() == ToolType::PALM) {
continue;
}
@@ -101,12 +99,7 @@
fingerState.orientation = slot.getOrientation();
fingerState.position_x = slot.getX();
fingerState.position_y = slot.getY();
- fingerState.tracking_id = isPalm ? -1 : slot.getTrackingId();
- if (fingerState.tracking_id == -1) {
- mFingerSlots.erase(i);
- } else {
- mFingerSlots.insert(i);
- }
+ fingerState.tracking_id = slot.getTrackingId();
}
schs.state.fingers = schs.fingers.data();
schs.state.finger_cnt = schs.fingers.size();
@@ -117,7 +110,6 @@
void HardwareStateConverter::reset() {
mCursorButtonAccumulator.reset(mDeviceContext);
mTouchButtonAccumulator.reset();
- mFingerSlots.clear();
mMscTimestamp = 0;
}
diff --git a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
index d6787b7..c314b0d 100644
--- a/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
+++ b/services/inputflinger/reader/mapper/gestures/HardwareStateConverter.h
@@ -54,7 +54,6 @@
MultiTouchMotionAccumulator mMotionAccumulator;
TouchButtonAccumulator mTouchButtonAccumulator;
int32_t mMscTimestamp = 0;
- std::set<size_t> mFingerSlots;
};
} // namespace android
diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp
index bbf7e8e..c6d541e 100644
--- a/services/inputflinger/tests/GestureConverter_test.cpp
+++ b/services/inputflinger/tests/GestureConverter_test.cpp
@@ -93,7 +93,7 @@
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
WithCoords(POINTER_X - 5, POINTER_Y + 10), WithRelativeMotion(-5, 10),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithButtonState(0),
+ WithToolType(ToolType::FINGER), WithButtonState(0),
WithPressure(0.0f)));
ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X - 5, POINTER_Y + 10));
@@ -111,7 +111,7 @@
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_MOVE),
WithCoords(POINTER_X + 10, POINTER_Y + 5), WithRelativeMotion(10, 5),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithButtonState(0),
+ WithToolType(ToolType::FINGER), WithButtonState(0),
WithPressure(0.0f)));
ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X + 10, POINTER_Y + 5));
@@ -133,14 +133,14 @@
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY |
AMOTION_EVENT_BUTTON_SECONDARY),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
@@ -148,7 +148,7 @@
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY |
AMOTION_EVENT_BUTTON_SECONDARY),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
// Then release the left button
Gesture leftUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
@@ -162,7 +162,7 @@
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
WithButtonState(AMOTION_EVENT_BUTTON_SECONDARY),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
// Finally release the right button
Gesture rightUpGesture(kGestureButtonsChange, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
@@ -175,12 +175,12 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY), WithButtonState(0),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithButtonState(0),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
}
TEST_F(GestureConverterTest, DragWithButton) {
@@ -198,14 +198,14 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY),
WithCoords(POINTER_X, POINTER_Y),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
// Move
Gesture moveGesture(kGestureMove, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, -5, 10);
@@ -215,7 +215,7 @@
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithCoords(POINTER_X - 5, POINTER_Y + 10), WithRelativeMotion(-5, 10),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER),
+ WithToolType(ToolType::FINGER),
WithButtonState(AMOTION_EVENT_BUTTON_PRIMARY), WithPressure(1.0f)));
ASSERT_NO_FATAL_FAILURE(mFakePointerController->assertPosition(POINTER_X - 5, POINTER_Y + 10));
@@ -231,12 +231,12 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
WithActionButton(AMOTION_EVENT_BUTTON_PRIMARY), WithButtonState(0),
WithCoords(POINTER_X - 5, POINTER_Y + 10),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithButtonState(0),
WithCoords(POINTER_X - 5, POINTER_Y + 10),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
}
TEST_F(GestureConverterTest, Scroll) {
@@ -252,7 +252,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithCoords(POINTER_X, POINTER_Y),
WithGestureScrollDistance(0, 0, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime),
+ WithToolType(ToolType::FINGER), WithDownTime(downTime),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
@@ -260,7 +260,7 @@
WithCoords(POINTER_X, POINTER_Y - 10),
WithGestureScrollDistance(0, 10, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER),
+ WithToolType(ToolType::FINGER),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE)));
Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
@@ -271,7 +271,7 @@
WithCoords(POINTER_X, POINTER_Y - 15),
WithGestureScrollDistance(0, 5, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER),
+ WithToolType(ToolType::FINGER),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE)));
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
@@ -283,7 +283,7 @@
WithCoords(POINTER_X, POINTER_Y - 15),
WithGestureScrollDistance(0, 0, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER),
+ WithToolType(ToolType::FINGER),
WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE)));
}
@@ -301,14 +301,14 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithCoords(POINTER_X, POINTER_Y),
WithGestureScrollDistance(0, 0, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime)));
+ WithToolType(ToolType::FINGER), WithDownTime(downTime)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithCoords(POINTER_X - 10, POINTER_Y),
WithGestureScrollDistance(0, 10, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5);
args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture);
@@ -318,7 +318,7 @@
WithCoords(POINTER_X - 15, POINTER_Y),
WithGestureScrollDistance(0, 5, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1,
GESTURES_FLING_START);
@@ -329,7 +329,7 @@
WithCoords(POINTER_X - 15, POINTER_Y),
WithGestureScrollDistance(0, 0, EPSILON),
WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
}
TEST_F(GestureConverterTest, Scroll_ClearsClassificationAndOffsetsAfterGesture) {
@@ -393,7 +393,7 @@
ASSERT_THAT(arg,
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(1u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(1u), WithToolType(ToolType::FINGER)));
PointerCoords finger0Start = arg.pointerCoords[0];
args.pop_front();
arg = std::get<NotifyMotionArgs>(args.front());
@@ -402,7 +402,7 @@
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(2u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(2u), WithToolType(ToolType::FINGER)));
PointerCoords finger1Start = arg.pointerCoords[1];
args.pop_front();
arg = std::get<NotifyMotionArgs>(args.front());
@@ -411,7 +411,7 @@
2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(3u), WithToolType(ToolType::FINGER)));
PointerCoords finger2Start = arg.pointerCoords[2];
args.pop_front();
@@ -420,7 +420,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithGestureOffset(0, -0.01, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(3u), WithToolType(ToolType::FINGER)));
EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX());
EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX());
EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX());
@@ -437,7 +437,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithGestureOffset(0, -0.005, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(3u), WithToolType(ToolType::FINGER)));
EXPECT_EQ(arg.pointerCoords[0].getX(), finger0Start.getX());
EXPECT_EQ(arg.pointerCoords[1].getX(), finger1Start.getX());
EXPECT_EQ(arg.pointerCoords[2].getX(), finger2Start.getX());
@@ -453,19 +453,19 @@
2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(3u), WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
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), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(2u), WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(1u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(1u), WithToolType(ToolType::FINGER)));
}
TEST_F(GestureConverterTest, ThreeFingerSwipe_Rotated) {
@@ -560,7 +560,7 @@
ASSERT_THAT(arg,
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(1u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(1u), WithToolType(ToolType::FINGER)));
PointerCoords finger0Start = arg.pointerCoords[0];
args.pop_front();
arg = std::get<NotifyMotionArgs>(args.front());
@@ -569,7 +569,7 @@
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(2u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(2u), WithToolType(ToolType::FINGER)));
PointerCoords finger1Start = arg.pointerCoords[1];
args.pop_front();
arg = std::get<NotifyMotionArgs>(args.front());
@@ -578,7 +578,7 @@
2 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(3u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(3u), WithToolType(ToolType::FINGER)));
PointerCoords finger2Start = arg.pointerCoords[2];
args.pop_front();
arg = std::get<NotifyMotionArgs>(args.front());
@@ -587,7 +587,7 @@
3 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(4u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(4u), WithToolType(ToolType::FINGER)));
PointerCoords finger3Start = arg.pointerCoords[3];
args.pop_front();
@@ -596,7 +596,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithGestureOffset(0.01, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(4u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(4u), WithToolType(ToolType::FINGER)));
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);
@@ -615,7 +615,7 @@
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithGestureOffset(0.005, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(4u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(4u), WithToolType(ToolType::FINGER)));
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);
@@ -633,26 +633,26 @@
3 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(4u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(4u), WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
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), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(3u), WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
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), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(2u), WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithGestureOffset(0, 0, EPSILON),
WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
- WithPointerCount(1u), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithPointerCount(1u), WithToolType(ToolType::FINGER)));
}
TEST_F(GestureConverterTest, Pinch_Inwards) {
@@ -668,7 +668,7 @@
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON),
WithCoords(POINTER_X - 100, POINTER_Y), WithPointerCount(1u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
@@ -676,7 +676,7 @@
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON),
WithPointerCoords(1, POINTER_X + 100, POINTER_Y), WithPointerCount(2u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* dz= */ 0.8, GESTURES_ZOOM_UPDATE);
@@ -688,7 +688,7 @@
WithGesturePinchScaleFactor(0.8f, EPSILON),
WithPointerCoords(0, POINTER_X - 80, POINTER_Y),
WithPointerCoords(1, POINTER_X + 80, POINTER_Y), WithPointerCount(2u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
GESTURES_ZOOM_END);
@@ -699,13 +699,13 @@
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON), WithPointerCount(2u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON), WithPointerCount(1u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
}
TEST_F(GestureConverterTest, Pinch_Outwards) {
@@ -721,7 +721,7 @@
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON),
WithCoords(POINTER_X - 100, POINTER_Y), WithPointerCount(1u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_DOWN |
@@ -729,7 +729,7 @@
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON),
WithPointerCoords(1, POINTER_X + 100, POINTER_Y), WithPointerCount(2u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
Gesture updateGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME,
/* dz= */ 1.2, GESTURES_ZOOM_UPDATE);
@@ -741,7 +741,7 @@
WithGesturePinchScaleFactor(1.2f, EPSILON),
WithPointerCoords(0, POINTER_X - 120, POINTER_Y),
WithPointerCoords(1, POINTER_X + 120, POINTER_Y), WithPointerCount(2u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
Gesture endGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /* dz= */ 1,
GESTURES_ZOOM_END);
@@ -752,13 +752,13 @@
1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON), WithPointerCount(2u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
args.pop_front();
ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
WithMotionClassification(MotionClassification::PINCH),
WithGesturePinchScaleFactor(1.0f, EPSILON), WithPointerCount(1u),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER)));
+ WithToolType(ToolType::FINGER)));
}
TEST_F(GestureConverterTest, Pinch_ClearsClassificationAndScaleFactorAfterGesture) {
@@ -785,4 +785,107 @@
WithGesturePinchScaleFactor(0, EPSILON)));
}
+TEST_F(GestureConverterTest, ResetWithButtonPressed) {
+ InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
+ GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
+
+ 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, downGesture);
+
+ std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
+ ASSERT_EQ(3u, args.size());
+
+ EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ 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)));
+ args.pop_front();
+ EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
+ WithActionButton(AMOTION_EVENT_BUTTON_SECONDARY), WithButtonState(0),
+ WithCoords(POINTER_X, POINTER_Y),
+ WithToolType(ToolType::FINGER)));
+ args.pop_front();
+ ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithButtonState(0),
+ WithCoords(POINTER_X, POINTER_Y),
+ WithToolType(ToolType::FINGER)));
+}
+
+TEST_F(GestureConverterTest, ResetDuringScroll) {
+ InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
+ GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
+
+ Gesture startGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -10);
+ (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, startGesture);
+
+ std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
+ ASSERT_EQ(1u, args.size());
+ ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
+ WithCoords(POINTER_X, POINTER_Y - 10),
+ WithGestureScrollDistance(0, 0, EPSILON),
+ WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE),
+ WithToolType(ToolType::FINGER),
+ WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE)));
+}
+
+TEST_F(GestureConverterTest, ResetDuringThreeFingerSwipe) {
+ InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
+ GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
+
+ Gesture startGesture(kGestureSwipe, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dx=*/0,
+ /*dy=*/10);
+ (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, startGesture);
+
+ std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
+ ASSERT_EQ(3u, args.size());
+ EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ 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), WithToolType(ToolType::FINGER)));
+ args.pop_front();
+ EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ 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), WithToolType(ToolType::FINGER)));
+ args.pop_front();
+ EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithGestureOffset(0, 0, EPSILON),
+ WithMotionClassification(MotionClassification::MULTI_FINGER_SWIPE),
+ WithPointerCount(1u), WithToolType(ToolType::FINGER)));
+}
+
+TEST_F(GestureConverterTest, ResetDuringPinch) {
+ InputDeviceContext deviceContext(*mDevice, EVENTHUB_ID);
+ GestureConverter converter(*mReader->getContext(), deviceContext, DEVICE_ID);
+
+ Gesture startGesture(kGesturePinch, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, /*dz=*/1,
+ GESTURES_ZOOM_START);
+ (void)converter.handleGesture(ARBITRARY_TIME, READ_TIME, startGesture);
+
+ std::list<NotifyArgs> args = converter.reset(ARBITRARY_TIME);
+ ASSERT_EQ(2u, args.size());
+ EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_POINTER_UP |
+ 1 << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT),
+ WithMotionClassification(MotionClassification::PINCH),
+ WithGesturePinchScaleFactor(1.0f, EPSILON), WithPointerCount(2u),
+ WithToolType(ToolType::FINGER)));
+ args.pop_front();
+ EXPECT_THAT(std::get<NotifyMotionArgs>(args.front()),
+ AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
+ WithMotionClassification(MotionClassification::PINCH),
+ WithGesturePinchScaleFactor(1.0f, EPSILON), WithPointerCount(1u),
+ WithToolType(ToolType::FINGER)));
+}
+
} // namespace android
diff --git a/services/inputflinger/tests/HardwareStateConverter_test.cpp b/services/inputflinger/tests/HardwareStateConverter_test.cpp
index 36b9bab..3e97241 100644
--- a/services/inputflinger/tests/HardwareStateConverter_test.cpp
+++ b/services/inputflinger/tests/HardwareStateConverter_test.cpp
@@ -231,8 +231,7 @@
schs = processSync(conv, time);
ASSERT_TRUE(schs.has_value());
- ASSERT_EQ(1, schs->state.finger_cnt);
- EXPECT_EQ(-1, schs->state.fingers[0].tracking_id);
+ ASSERT_EQ(0, schs->state.finger_cnt);
processAxis(conv, time, EV_ABS, ABS_MT_POSITION_X, 53);
processAxis(conv, time, EV_ABS, ABS_MT_POSITION_Y, 97);
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index e299643..a58ad84 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -1464,7 +1464,7 @@
class PointerBuilder {
public:
- PointerBuilder(int32_t id, int32_t toolType) {
+ PointerBuilder(int32_t id, ToolType toolType) {
mProperties.clear();
mProperties.id = id;
mProperties.toolType = toolType;
@@ -1722,7 +1722,7 @@
.eventTime(eventTime)
.rawXCursorPosition(cursorPosition.x)
.rawYCursorPosition(cursorPosition.y)
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER)
.x(position.x)
.y(position.y))
.build();
@@ -1767,7 +1767,7 @@
for (size_t i = 0; i < pointerCount; i++) {
pointerProperties[i].clear();
pointerProperties[i].id = i;
- pointerProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties[i].toolType = ToolType::FINGER;
pointerCoords[i].clear();
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, points[i].x);
@@ -1961,21 +1961,21 @@
// First touch pointer down on right window
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
.build()));
// Second touch pointer down
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(110).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(110).y(100))
.build()));
// First touch pointer lifts. The second one remains down
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(110).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(110).y(100))
.build()));
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
@@ -2069,8 +2069,8 @@
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(150))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(150))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -2085,8 +2085,8 @@
MotionEventBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(150))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(150))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerUpEvent, INJECT_EVENT_TIMEOUT,
@@ -2102,7 +2102,7 @@
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
.pointer(PointerBuilder(/* id */ 1,
- AMOTION_EVENT_TOOL_TYPE_FINGER)
+ ToolType::FINGER)
.x(100)
.y(100))
.build(),
@@ -2154,8 +2154,8 @@
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(300).y(100))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -2179,8 +2179,8 @@
const MotionEvent secondFingerMoveEvent =
MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(310).y(110))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(310).y(110))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerMoveEvent, INJECT_EVENT_TIMEOUT,
@@ -2274,15 +2274,15 @@
args = MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
.policyFlags(DEFAULT_POLICY_FLAGS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
.build()));
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
.policyFlags(DEFAULT_POLICY_FLAGS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(120).y(120))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
spyWindow->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
@@ -2294,8 +2294,8 @@
args = MotionArgsBuilder(AMOTION_EVENT_ACTION_CANCEL, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
.policyFlags(0)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(120).y(120))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL));
@@ -2313,7 +2313,7 @@
args = MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
.policyFlags(DEFAULT_POLICY_FLAGS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
@@ -2358,7 +2358,7 @@
.deviceId(mouseDeviceId)
.downTime(baseTime + 10)
.eventTime(baseTime + 20)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(300)
.y(100))
.build()));
@@ -2372,7 +2372,7 @@
.deviceId(mouseDeviceId)
.downTime(baseTime + 10)
.eventTime(baseTime + 30)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(110)
.y(100))
.build()));
@@ -2386,7 +2386,7 @@
.deviceId(touchDeviceId)
.downTime(baseTime + 40)
.eventTime(baseTime + 40)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(100)
.y(100))
.build()));
@@ -2401,7 +2401,7 @@
.deviceId(touchDeviceId)
.downTime(baseTime + 40)
.eventTime(baseTime + 50)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(100)
.y(100))
.build()));
@@ -2415,7 +2415,7 @@
.deviceId(touchDeviceId)
.downTime(baseTime + 60)
.eventTime(baseTime + 60)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(300)
.y(100))
.build()));
@@ -2429,7 +2429,7 @@
.deviceId(touchDeviceId)
.downTime(baseTime + 60)
.eventTime(baseTime + 70)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(300)
.y(100))
.build()));
@@ -2467,7 +2467,7 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
.build()));
leftWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithDeviceId(mouseDeviceId)));
@@ -2477,7 +2477,7 @@
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
.build()));
leftWindow->consumeMotionEvent(
@@ -2490,7 +2490,7 @@
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
.build()));
leftWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
@@ -2498,7 +2498,7 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
.build()));
leftWindow->consumeMotionEvent(WithMotionAction(ACTION_CANCEL));
@@ -2508,8 +2508,8 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(100).y(100))
.build()));
leftWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(touchDeviceId)));
@@ -2547,21 +2547,21 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
.build()));
// Second touch pointer down
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(350).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
.build()));
// First touch pointer lifts. The second one remains down
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(350).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
.build()));
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
@@ -2572,7 +2572,7 @@
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(320).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(320).y(100))
.build()));
window->consumeMotionEvent(AllOf(WithMotionAction(ACTION_CANCEL), WithDeviceId(touchDeviceId),
@@ -2584,7 +2584,7 @@
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(320).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(320).y(100))
.build()));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
@@ -2592,8 +2592,8 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_0_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(350).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
.build()));
// The pointer_down event should be ignored
window->assertNoEvents();
@@ -2619,7 +2619,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.deviceId(ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(50)
.y(50))
.build()));
@@ -2631,7 +2631,7 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(300).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
.build()));
window->consumeMotionEvent(
@@ -2673,7 +2673,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER,
AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(50)
.y(50))
.build()));
@@ -2685,7 +2685,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(100)
.y(100))
.build()));
@@ -2695,7 +2695,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_UP,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(100)
.y(100))
.build()));
@@ -2709,7 +2709,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(300)
.y(100))
.build()));
@@ -2720,10 +2720,10 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(300)
.y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(1, ToolType::FINGER)
.x(100)
.y(100))
.build()));
@@ -2756,7 +2756,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER,
AINPUT_SOURCE_STYLUS)
.deviceId(stylusDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS)
.x(50)
.y(50))
.build()));
@@ -2768,7 +2768,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(100)
.y(100))
.build()));
@@ -2781,7 +2781,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_STYLUS)
.deviceId(stylusDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS)
.x(50)
.y(50))
.build()));
@@ -2794,7 +2794,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_UP,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(100)
.y(100))
.build()));
@@ -2806,7 +2806,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_STYLUS)
.deviceId(stylusDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS)
.x(50)
.y(50))
.build()));
@@ -2839,40 +2839,40 @@
// Start hovering with stylus
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
// Stop hovering
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_HOVER_EXIT, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
// Stylus touches down
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
// Stylus goes up
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_UP));
// Again hover
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
// Stop hovering
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_HOVER_EXIT, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
@@ -2908,7 +2908,7 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
.build()));
spyWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithDeviceId(mouseDeviceId)));
@@ -2919,7 +2919,7 @@
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
window->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
@@ -2929,7 +2929,7 @@
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(55).y(55))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(55).y(55))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
window->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
@@ -2941,7 +2941,7 @@
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(60).y(60))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(60).y(60))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
@@ -2950,7 +2950,7 @@
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
.build()));
spyWindow->consumeMotionEvent(
@@ -2964,7 +2964,7 @@
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
@@ -2974,7 +2974,7 @@
args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(110).y(110))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(110).y(110))
.build()));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
window->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
@@ -2983,7 +2983,7 @@
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(65).y(65))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(65).y(65))
.build()));
// No more events
@@ -3129,9 +3129,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(900)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(900).y(400))
.build()));
windowRight->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER));
@@ -3140,9 +3138,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
windowRight->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT));
windowLeft->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER));
@@ -3152,9 +3148,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
windowLeft->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
windowLeft->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
@@ -3165,9 +3159,7 @@
AINPUT_SOURCE_MOUSE)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
windowLeft->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
@@ -3177,9 +3169,7 @@
AINPUT_SOURCE_MOUSE)
.buttonState(0)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
windowLeft->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE));
@@ -3187,9 +3177,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_MOUSE)
.buttonState(0)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
windowLeft->consumeMotionUp(ADISPLAY_ID_DEFAULT);
@@ -3198,9 +3186,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(900)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(900).y(400))
.build()));
windowRight->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER));
@@ -3230,14 +3216,14 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
.build()));
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(120).y(120))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
.build()));
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
@@ -3247,7 +3233,7 @@
args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(300).y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->consumeMotionEvent(AllOf(WithMotionAction(ACTION_CANCEL), WithDeviceId(touchDeviceId),
WithPointerCount(2u)));
@@ -3258,7 +3244,7 @@
.deviceId(mouseDeviceId)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(300).y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
@@ -3267,8 +3253,8 @@
mDispatcher->notifyMotion(&(
args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(101).y(101))
- .pointer(PointerBuilder(1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(121).y(121))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(101).y(101))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(121).y(121))
.build()));
window->assertNoEvents();
}
@@ -3293,7 +3279,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(100)
.y(100))
.build()));
@@ -3327,7 +3313,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(100)
.y(100))
.build()));
@@ -3337,7 +3323,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(110)
.y(110))
.build()));
@@ -3356,7 +3342,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(SECOND_DEVICE_ID)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(200)
.y(200))
.build()));
@@ -3380,7 +3366,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_UP,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(SECOND_DEVICE_ID)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(200)
.y(200))
.build()));
@@ -3397,7 +3383,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(SECOND_DEVICE_ID)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(250)
.y(250))
.build()));
@@ -3412,7 +3398,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_UP,
AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(SECOND_DEVICE_ID)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(0, ToolType::FINGER)
.x(250)
.y(250))
.build()));
@@ -3441,9 +3427,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER));
// Inject a series of mouse events for a mouse click
@@ -3451,9 +3435,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
@@ -3464,9 +3446,7 @@
AINPUT_SOURCE_MOUSE)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
@@ -3476,9 +3456,7 @@
AINPUT_SOURCE_MOUSE)
.buttonState(0)
.actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE));
@@ -3486,9 +3464,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_MOUSE)
.buttonState(0)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->consumeMotionUp(ADISPLAY_ID_DEFAULT);
@@ -3496,9 +3472,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_EXIT,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
- .x(300)
- .y(400))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
.build()));
window->assertNoEvents();
}
@@ -3521,7 +3495,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER,
AINPUT_SOURCE_MOUSE)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(300)
.y(400))
.build()));
@@ -3551,7 +3525,7 @@
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
.deviceId(mouseDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE).x(10).y(10))
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(10).y(10))
.build()));
window->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithDeviceId(mouseDeviceId)));
@@ -3560,7 +3534,7 @@
mDispatcher->notifyMotion(
&(args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
.build()));
window->consumeMotionEvent(
@@ -3633,7 +3607,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
.displayId(ADISPLAY_ID_DEFAULT)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(300)
.y(600))
.build()));
@@ -3654,7 +3628,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE,
AINPUT_SOURCE_MOUSE)
.displayId(ADISPLAY_ID_DEFAULT)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ .pointer(PointerBuilder(0, ToolType::MOUSE)
.x(400)
.y(700))
.build()));
@@ -3911,8 +3885,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(-30).y(-50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(-30).y(-50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -4033,7 +4007,7 @@
MotionEvent event = MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER)
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER)
.x(untransformedPoint.x)
.y(untransformedPoint.y))
.build();
@@ -6076,7 +6050,7 @@
const MotionEvent event =
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(20).y(20))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(20).y(20))
.addFlag(AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE)
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED, injectMotionEvent(mDispatcher, event))
@@ -7937,7 +7911,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN,
AINPUT_SOURCE_STYLUS)
.buttonState(AMOTION_EVENT_BUTTON_STYLUS_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS)
.x(50)
.y(50))
.build()));
@@ -7949,7 +7923,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.pointer(PointerBuilder(MOUSE_POINTER_ID,
- AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ ToolType::MOUSE)
.x(50)
.y(50))
.build()));
@@ -8038,8 +8012,8 @@
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(60).y(60))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(60).y(60))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -8093,9 +8067,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_STYLUS)
.buttonState(AMOTION_EVENT_BUTTON_STYLUS_PRIMARY)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS)
- .x(50)
- .y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT);
@@ -8107,9 +8079,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_STYLUS)
.buttonState(0)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS)
- .x(150)
- .y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(150).y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
mDragWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT);
@@ -8122,9 +8092,7 @@
injectMotionEvent(mDispatcher,
MotionEventBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_STYLUS)
.buttonState(0)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_STYLUS)
- .x(150)
- .y(50))
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(150).y(50))
.build()))
<< "Inject motion event should return InputEventInjectionResult::SUCCEEDED";
mDragWindow->consumeMotionUp(ADISPLAY_ID_DEFAULT);
@@ -8182,8 +8150,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(75).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(75).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -8209,8 +8177,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -8225,8 +8193,8 @@
const MotionEvent secondFingerMoveEvent =
MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerMoveEvent, INJECT_EVENT_TIMEOUT,
@@ -8239,8 +8207,8 @@
const MotionEvent secondFingerUpEvent =
MotionEventBuilder(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerUpEvent, INJECT_EVENT_TIMEOUT,
@@ -8265,9 +8233,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_DOWN,
AINPUT_SOURCE_TOUCHSCREEN)
.displayId(SECOND_DISPLAY_ID)
- .pointer(PointerBuilder(0, AMOTION_EVENT_TOOL_TYPE_FINGER)
- .x(100)
- .y(100))
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
.build()));
windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, AMOTION_EVENT_ACTION_DOWN,
SECOND_DISPLAY_ID, /*expectedFlag=*/0);
@@ -8311,7 +8277,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_MOUSE)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.pointer(PointerBuilder(MOUSE_POINTER_ID,
- AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ ToolType::MOUSE)
.x(50)
.y(50))
.build()))
@@ -8326,7 +8292,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_MOUSE)
.buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
.pointer(PointerBuilder(MOUSE_POINTER_ID,
- AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ ToolType::MOUSE)
.x(150)
.y(50))
.build()))
@@ -8341,7 +8307,7 @@
MotionEventBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_MOUSE)
.buttonState(0)
.pointer(PointerBuilder(MOUSE_POINTER_ID,
- AMOTION_EVENT_TOOL_TYPE_MOUSE)
+ ToolType::MOUSE)
.x(150)
.y(50))
.build()))
@@ -8813,8 +8779,8 @@
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -8845,8 +8811,8 @@
const MotionEvent secondFingerDownEvent =
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -8884,8 +8850,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(200))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -9007,8 +8973,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(200))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -9022,9 +8988,9 @@
MotionEventBuilder(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(100).y(200))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
- .pointer(PointerBuilder(/*id=*/2, AMOTION_EVENT_TOOL_TYPE_FINGER).x(-5).y(-5))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(100).y(200))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/2, ToolType::FINGER).x(-5).y(-5))
.build();
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(mDispatcher, thirdFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -9058,8 +9024,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(150))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(10).y(10))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(150))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(10).y(10))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -9073,9 +9039,9 @@
MotionEventBuilder(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(150))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(10).y(10))
- .pointer(PointerBuilder(/*id=*/2, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(150).y(150))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(10).y(10))
+ .pointer(PointerBuilder(/*id=*/2, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, thirdFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -9119,8 +9085,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(10).y(10))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(50).y(50))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(10).y(10))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(50).y(50))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -9166,8 +9132,8 @@
MotionEventBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
.displayId(ADISPLAY_ID_DEFAULT)
.eventTime(systemTime(SYSTEM_TIME_MONOTONIC))
- .pointer(PointerBuilder(/*id=*/0, AMOTION_EVENT_TOOL_TYPE_FINGER).x(10).y(10))
- .pointer(PointerBuilder(/*id=*/1, AMOTION_EVENT_TOOL_TYPE_FINGER).x(150).y(150))
+ .pointer(PointerBuilder(/*id=*/0, ToolType::FINGER).x(10).y(10))
+ .pointer(PointerBuilder(/*id=*/1, ToolType::FINGER).x(150).y(150))
.build();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(mDispatcher, secondFingerDownEvent, INJECT_EVENT_TIMEOUT,
@@ -9221,7 +9187,7 @@
NotifyMotionArgs motionArgs =
generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
ADISPLAY_ID_DEFAULT, {PointF{30, 40}});
- motionArgs.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ motionArgs.pointerProperties[0].toolType = ToolType::STYLUS;
mDispatcher->notifyMotion(&motionArgs);
}
};
diff --git a/services/inputflinger/tests/InputProcessorConverter_test.cpp b/services/inputflinger/tests/InputProcessorConverter_test.cpp
index 161a24f..4b42f4b 100644
--- a/services/inputflinger/tests/InputProcessorConverter_test.cpp
+++ b/services/inputflinger/tests/InputProcessorConverter_test.cpp
@@ -30,7 +30,7 @@
// Create a basic motion event for testing
PointerProperties properties;
properties.id = 0;
- properties.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ properties.toolType = ToolType::FINGER;
PointerCoords coords;
coords.clear();
diff --git a/services/inputflinger/tests/InputProcessor_test.cpp b/services/inputflinger/tests/InputProcessor_test.cpp
index b6deed8..0ffdef9 100644
--- a/services/inputflinger/tests/InputProcessor_test.cpp
+++ b/services/inputflinger/tests/InputProcessor_test.cpp
@@ -37,7 +37,7 @@
// Create a basic motion event for testing
PointerProperties properties;
properties.id = 0;
- properties.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ properties.toolType = ToolType::FINGER;
PointerCoords coords;
coords.clear();
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 0de3bfb..92d5357 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -123,7 +123,7 @@
static void assertAxisResolution(MultiTouchInputMapper& mapper, int axis, float resolution) {
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
const InputDeviceInfo::MotionRange* motionRange =
info.getMotionRange(axis, AINPUT_SOURCE_TOUCHSCREEN);
@@ -132,7 +132,7 @@
static void assertAxisNotPresent(MultiTouchInputMapper& mapper, int axis) {
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
const InputDeviceInfo::MotionRange* motionRange =
info.getMotionRange(axis, AINPUT_SOURCE_TOUCHSCREEN);
@@ -255,11 +255,11 @@
private:
uint32_t getSources() const override { return mSources; }
- void populateDeviceInfo(InputDeviceInfo* deviceInfo) override {
+ void populateDeviceInfo(InputDeviceInfo& deviceInfo) override {
InputMapper::populateDeviceInfo(deviceInfo);
if (mKeyboardType != AINPUT_KEYBOARD_TYPE_NONE) {
- deviceInfo->setKeyboardType(mKeyboardType);
+ deviceInfo.setKeyboardType(mKeyboardType);
}
}
@@ -1732,7 +1732,7 @@
mDevice->sendSync();
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertStylusGestureNotified(mDeviceInfo.getId()));
@@ -1751,7 +1751,7 @@
mDevice->sendSync();
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))));
+ WithToolType(ToolType::FINGER))));
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertStylusGestureNotNotified());
@@ -1768,7 +1768,7 @@
mDevice->sendSync();
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertStylusGestureNotified(mDeviceInfo.getId()));
}
@@ -1864,12 +1864,12 @@
TestFixture::mTouchscreen->sendSync();
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithButtonState(AMOTION_EVENT_BUTTON_STYLUS_PRIMARY),
WithDeviceId(touchscreenId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithButtonState(AMOTION_EVENT_BUTTON_STYLUS_PRIMARY),
WithDeviceId(touchscreenId))));
@@ -1877,11 +1877,11 @@
TestFixture::mTouchscreen->sendSync();
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
// Release the stylus button.
@@ -1896,7 +1896,7 @@
const auto touchscreenId = TestFixture::mTouchscreenInfo.getId();
const auto stylusId = TestFixture::mStylusInfo.getId();
auto toolTypeDevice =
- AllOf(WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithDeviceId(touchscreenId));
+ AllOf(WithToolType(ToolType::STYLUS), WithDeviceId(touchscreenId));
// Press the stylus button.
TestFixture::mStylus->pressKey(BTN_STYLUS);
@@ -1980,7 +1980,7 @@
TestFixture::mTouchscreen->sendSync();
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
// Press and release a stylus button. Each change in button state also generates a MOVE event.
@@ -1990,12 +1990,12 @@
WithKeyCode(AKEYCODE_STYLUS_BUTTON_PRIMARY), WithDeviceId(stylusId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithButtonState(AMOTION_EVENT_BUTTON_STYLUS_PRIMARY),
WithDeviceId(touchscreenId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithButtonState(AMOTION_EVENT_BUTTON_STYLUS_PRIMARY),
WithDeviceId(touchscreenId))));
@@ -2005,11 +2005,11 @@
WithKeyCode(AKEYCODE_STYLUS_BUTTON_PRIMARY), WithDeviceId(stylusId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_RELEASE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
// Finish the stylus gesture.
@@ -2017,7 +2017,7 @@
TestFixture::mTouchscreen->sendSync();
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
}
@@ -2039,7 +2039,7 @@
TestFixture::mTouchscreen->sendSync();
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
// Press and release a stylus button. Each change only generates a MOVE motion event.
@@ -2050,7 +2050,7 @@
WithKeyCode(AKEYCODE_STYLUS_BUTTON_PRIMARY), WithDeviceId(stylusId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
TestFixture::mStylus->releaseKey(BTN_STYLUS);
@@ -2059,7 +2059,7 @@
WithKeyCode(AKEYCODE_STYLUS_BUTTON_PRIMARY), WithDeviceId(stylusId))));
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
// Finish the stylus gesture.
@@ -2067,7 +2067,7 @@
TestFixture::mTouchscreen->sendSync();
ASSERT_NO_FATAL_FAILURE(TestFixture::mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId))));
}
@@ -2108,7 +2108,7 @@
mDevice->sendSync();
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId), WithPressure(100.f / RAW_PRESSURE_MAX))));
// Change the pressure on the external stylus, and ensure the touchscreen generates a MOVE
@@ -2116,7 +2116,7 @@
stylus->setPressure(200);
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId), WithPressure(200.f / RAW_PRESSURE_MAX))));
// The external stylus did not generate any events.
@@ -2162,7 +2162,7 @@
// it shows up as a finger pointer.
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDeviceId(touchscreenId),
+ WithToolType(ToolType::FINGER), WithDeviceId(touchscreenId),
WithPressure(1.f))));
// Change the pressure on the external stylus. Since the pressure was not present at the start
@@ -2175,7 +2175,7 @@
mDevice->sendSync();
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))));
+ WithToolType(ToolType::FINGER))));
// Start a new gesture. Since we have a valid pressure value, it shows up as a stylus.
mDevice->sendTrackingId(FIRST_TRACKING_ID);
@@ -2184,7 +2184,7 @@
mDevice->sendSync();
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS), WithButtonState(0),
+ WithToolType(ToolType::STYLUS), WithButtonState(0),
WithDeviceId(touchscreenId), WithPressure(200.f / RAW_PRESSURE_MAX))));
// The external stylus did not generate any events.
@@ -2220,7 +2220,7 @@
mTestListener
->assertNotifyMotionWasCalled(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
WithToolType(
- AMOTION_EVENT_TOOL_TYPE_FINGER),
+ ToolType::FINGER),
WithButtonState(0),
WithDeviceId(touchscreenId),
WithPressure(1.f)),
@@ -3808,7 +3808,7 @@
CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
// Initially there may not be a valid motion range.
ASSERT_EQ(nullptr, info.getMotionRange(AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_MOUSE));
@@ -3820,7 +3820,7 @@
mFakePointerController->setBounds(1, 2, 800 - 1, 480 - 1);
InputDeviceInfo info2;
- mapper.populateDeviceInfo(&info2);
+ mapper.populateDeviceInfo(info2);
ASSERT_NO_FATAL_FAILURE(assertMotionRange(info2,
AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_MOUSE,
@@ -3838,7 +3838,7 @@
CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
ASSERT_NO_FATAL_FAILURE(assertMotionRange(info,
AINPUT_MOTION_RANGE_X, AINPUT_SOURCE_TRACKBALL,
@@ -3875,7 +3875,7 @@
ASSERT_EQ(0, args.edgeFlags);
ASSERT_EQ(uint32_t(1), args.pointerCount);
ASSERT_EQ(0, args.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, args.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, args.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertCursorPointerCoords(args.pointerCoords[0], 0.0f, 0.0f, 1.0f));
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.xPrecision);
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.yPrecision);
@@ -3893,7 +3893,7 @@
ASSERT_EQ(0, args.edgeFlags);
ASSERT_EQ(uint32_t(1), args.pointerCount);
ASSERT_EQ(0, args.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, args.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, args.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertCursorPointerCoords(args.pointerCoords[0], 0.0f, 0.0f, 1.0f));
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.xPrecision);
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.yPrecision);
@@ -3914,7 +3914,7 @@
ASSERT_EQ(0, args.edgeFlags);
ASSERT_EQ(uint32_t(1), args.pointerCount);
ASSERT_EQ(0, args.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, args.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, args.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertCursorPointerCoords(args.pointerCoords[0], 0.0f, 0.0f, 0.0f));
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.xPrecision);
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.yPrecision);
@@ -3932,7 +3932,7 @@
ASSERT_EQ(0, args.edgeFlags);
ASSERT_EQ(uint32_t(1), args.pointerCount);
ASSERT_EQ(0, args.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, args.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, args.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertCursorPointerCoords(args.pointerCoords[0], 0.0f, 0.0f, 0.0f));
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.xPrecision);
ASSERT_EQ(TRACKBALL_MOVEMENT_THRESHOLD, args.yPrecision);
@@ -5195,7 +5195,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -5219,7 +5219,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -5242,7 +5242,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -5292,7 +5292,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -5315,7 +5315,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -5360,7 +5360,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x, VIRTUAL_DISPLAY_WIDTH), toDisplayY(y, VIRTUAL_DISPLAY_HEIGHT),
1, 0, 0, 0, 0, 0, 0, 0));
@@ -5387,7 +5387,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x, VIRTUAL_DISPLAY_WIDTH), toDisplayY(y, VIRTUAL_DISPLAY_HEIGHT),
1, 0, 0, 0, 0, 0, 0, 0));
@@ -5412,7 +5412,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x, VIRTUAL_DISPLAY_WIDTH), toDisplayY(y, VIRTUAL_DISPLAY_HEIGHT),
1, 0, 0, 0, 0, 0, 0, 0));
@@ -5455,7 +5455,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -5480,7 +5480,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -5503,7 +5503,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x), toDisplayY(y), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -6151,14 +6151,14 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// eraser
processKey(mapper, BTN_TOOL_RUBBER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::ERASER, motionArgs.pointerProperties[0].toolType);
// stylus
processKey(mapper, BTN_TOOL_RUBBER, 0);
@@ -6166,7 +6166,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// brush
processKey(mapper, BTN_TOOL_PEN, 0);
@@ -6174,7 +6174,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// pencil
processKey(mapper, BTN_TOOL_BRUSH, 0);
@@ -6182,7 +6182,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// air-brush
processKey(mapper, BTN_TOOL_PENCIL, 0);
@@ -6190,7 +6190,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// mouse
processKey(mapper, BTN_TOOL_AIRBRUSH, 0);
@@ -6198,7 +6198,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, motionArgs.pointerProperties[0].toolType);
// lens
processKey(mapper, BTN_TOOL_MOUSE, 0);
@@ -6206,7 +6206,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, motionArgs.pointerProperties[0].toolType);
// double-tap
processKey(mapper, BTN_TOOL_LENS, 0);
@@ -6214,7 +6214,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// triple-tap
processKey(mapper, BTN_TOOL_DOUBLETAP, 0);
@@ -6222,7 +6222,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// quad-tap
processKey(mapper, BTN_TOOL_TRIPLETAP, 0);
@@ -6230,7 +6230,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// finger
processKey(mapper, BTN_TOOL_QUADTAP, 0);
@@ -6238,28 +6238,28 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// stylus trumps finger
processKey(mapper, BTN_TOOL_PEN, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// eraser trumps stylus
processKey(mapper, BTN_TOOL_RUBBER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::ERASER, motionArgs.pointerProperties[0].toolType);
// mouse trumps eraser
processKey(mapper, BTN_TOOL_MOUSE, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, motionArgs.pointerProperties[0].toolType);
// back to default tool type
processKey(mapper, BTN_TOOL_MOUSE, 0);
@@ -6269,7 +6269,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
}
TEST_F(SingleTouchInputMapperTest, Process_WhenBtnTouchPresent_HoversIfItsValueIsZero) {
@@ -6659,7 +6659,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
ASSERT_TRUE(fakePointerController->isPointerShown());
ASSERT_NO_FATAL_FAILURE(
@@ -6683,7 +6683,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
ASSERT_FALSE(fakePointerController->isPointerShown());
}
@@ -7125,7 +7125,7 @@
mStylusState.when = ARBITRARY_TIME;
mStylusState.pressure = 0.f;
- mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ mStylusState.toolType = ToolType::STYLUS;
mReader->getContext()->setExternalStylusDevices({mExternalStylusDeviceInfo});
configureDevice(InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE);
processExternalStylusState(mapper);
@@ -7149,7 +7149,7 @@
void testStartFusedStylusGesture(SingleTouchInputMapper& mapper) {
auto toolTypeSource =
- AllOf(WithSource(EXPECTED_SOURCE), WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS));
+ AllOf(WithSource(EXPECTED_SOURCE), WithToolType(ToolType::STYLUS));
// The first pointer is withheld.
processDown(mapper, 100, 200);
@@ -7184,7 +7184,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithSource(EXPECTED_SOURCE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
mStylusState.pressure = 0.f;
processExternalStylusState(mapper);
@@ -7194,7 +7194,7 @@
void testUnsuccessfulFusionGesture(SingleTouchInputMapper& mapper) {
auto toolTypeSource =
- AllOf(WithSource(EXPECTED_SOURCE), WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER));
+ AllOf(WithSource(EXPECTED_SOURCE), WithToolType(ToolType::FINGER));
// The first pointer is withheld when an external stylus is connected,
// and a timeout is requested.
@@ -7252,7 +7252,7 @@
TEST_F(ExternalStylusFusionTest, SuccessfulFusion_PressureFirst) {
SingleTouchInputMapper& mapper = initializeInputMapperWithExternalStylus();
auto toolTypeSource =
- AllOf(WithSource(EXPECTED_SOURCE), WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS));
+ AllOf(WithSource(EXPECTED_SOURCE), WithToolType(ToolType::STYLUS));
// The external stylus reports pressure first. It is ignored for now.
mStylusState.pressure = 1.f;
@@ -7295,7 +7295,7 @@
TEST_F(ExternalStylusFusionTest, FusedPointerReportsPressureChanges) {
SingleTouchInputMapper& mapper = initializeInputMapperWithExternalStylus();
auto toolTypeSource =
- AllOf(WithSource(EXPECTED_SOURCE), WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS));
+ AllOf(WithSource(EXPECTED_SOURCE), WithToolType(ToolType::STYLUS));
mStylusState.pressure = 0.8f;
processExternalStylusState(mapper);
@@ -7357,7 +7357,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP), WithSource(EXPECTED_SOURCE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
ASSERT_NO_FATAL_FAILURE(mReader->getContext()->assertTimeoutWasNotRequested());
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
@@ -7368,17 +7368,17 @@
auto source = WithSource(EXPECTED_SOURCE);
mStylusState.pressure = 1.f;
- mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_ERASER;
+ mStylusState.toolType = ToolType::ERASER;
processExternalStylusState(mapper);
processDown(mapper, 100, 200);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(source, WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_ERASER))));
+ WithToolType(ToolType::ERASER))));
ASSERT_NO_FATAL_FAILURE(mReader->getContext()->assertTimeoutWasNotRequested());
// The external stylus reports a tool change. We wait for some time for a touch event.
- mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ mStylusState.toolType = ToolType::STYLUS;
processExternalStylusState(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
ASSERT_NO_FATAL_FAILURE(
@@ -7389,11 +7389,11 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(source, WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
ASSERT_NO_FATAL_FAILURE(mReader->getContext()->assertTimeoutWasNotRequested());
// There is another tool type change.
- mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mStylusState.toolType = ToolType::FINGER;
processExternalStylusState(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
ASSERT_NO_FATAL_FAILURE(
@@ -7404,13 +7404,13 @@
handleTimeout(mapper, ARBITRARY_TIME + TOUCH_DATA_TIMEOUT);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(source, WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))));
+ WithToolType(ToolType::FINGER))));
processUp(mapper);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(source, WithMotionAction(AMOTION_EVENT_ACTION_UP),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))));
+ WithToolType(ToolType::FINGER))));
ASSERT_NO_FATAL_FAILURE(mReader->getContext()->assertTimeoutWasNotRequested());
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
@@ -7419,7 +7419,7 @@
TEST_F(ExternalStylusFusionTest, FusedPointerReportsButtons) {
SingleTouchInputMapper& mapper = initializeInputMapperWithExternalStylus();
auto toolTypeSource =
- AllOf(WithSource(EXPECTED_SOURCE), WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS));
+ AllOf(WithSource(EXPECTED_SOURCE), WithToolType(ToolType::STYLUS));
ASSERT_NO_FATAL_FAILURE(testStartFusedStylusGesture(mapper));
@@ -7636,7 +7636,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -7655,9 +7655,9 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -7686,9 +7686,9 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -7715,9 +7715,9 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -7738,7 +7738,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -7763,7 +7763,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -7790,9 +7790,9 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -7819,9 +7819,9 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -7842,7 +7842,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -7865,7 +7865,7 @@
ASSERT_EQ(0, motionArgs.edgeFlags);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NEAR(X_PRECISION, motionArgs.xPrecision, EPSILON);
@@ -7953,7 +7953,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -7961,9 +7961,9 @@
ASSERT_EQ(ACTION_POINTER_1_DOWN, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -7983,9 +7983,9 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8002,9 +8002,9 @@
ASSERT_EQ(ACTION_POINTER_0_UP, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8014,7 +8014,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8029,7 +8029,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8047,9 +8047,9 @@
ASSERT_EQ(ACTION_POINTER_0_DOWN, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8066,9 +8066,9 @@
ASSERT_EQ(ACTION_POINTER_1_UP, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8078,7 +8078,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8090,7 +8090,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8123,7 +8123,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8131,9 +8131,9 @@
ASSERT_EQ(ACTION_POINTER_1_DOWN, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8151,9 +8151,9 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8171,9 +8171,9 @@
ASSERT_EQ(ACTION_POINTER_0_UP, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x1), toDisplayY(y1), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8183,7 +8183,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8196,7 +8196,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(1, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x2), toDisplayY(y2), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8212,9 +8212,9 @@
ASSERT_EQ(ACTION_POINTER_0_DOWN, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8232,9 +8232,9 @@
ASSERT_EQ(ACTION_POINTER_1_UP, motionArgs.action);
ASSERT_EQ(size_t(2), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1, motionArgs.pointerProperties[1].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[1],
@@ -8244,7 +8244,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8256,7 +8256,7 @@
ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
ASSERT_EQ(size_t(1), motionArgs.pointerCount);
ASSERT_EQ(0, motionArgs.pointerProperties[0].id);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(x3), toDisplayY(y3), 1, 0, 0, 0, 0, 0, 0, 0));
@@ -8444,7 +8444,7 @@
MultiTouchInputMapper& mapper = addMapperAndConfigure<MultiTouchInputMapper>();
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
ASSERT_NO_FATAL_FAILURE(assertMotionRange(info,
AINPUT_MOTION_RANGE_PRESSURE, AINPUT_SOURCE_TOUCHSCREEN,
0.0f, RAW_PRESSURE_MAX * 0.01, 0.0f, 0.0f));
@@ -8783,14 +8783,14 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// eraser
processKey(mapper, BTN_TOOL_RUBBER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::ERASER, motionArgs.pointerProperties[0].toolType);
// stylus
processKey(mapper, BTN_TOOL_RUBBER, 0);
@@ -8798,7 +8798,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// brush
processKey(mapper, BTN_TOOL_PEN, 0);
@@ -8806,7 +8806,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// pencil
processKey(mapper, BTN_TOOL_BRUSH, 0);
@@ -8814,7 +8814,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// air-brush
processKey(mapper, BTN_TOOL_PENCIL, 0);
@@ -8822,7 +8822,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// mouse
processKey(mapper, BTN_TOOL_AIRBRUSH, 0);
@@ -8830,7 +8830,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, motionArgs.pointerProperties[0].toolType);
// lens
processKey(mapper, BTN_TOOL_MOUSE, 0);
@@ -8838,7 +8838,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, motionArgs.pointerProperties[0].toolType);
// double-tap
processKey(mapper, BTN_TOOL_LENS, 0);
@@ -8846,7 +8846,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// triple-tap
processKey(mapper, BTN_TOOL_DOUBLETAP, 0);
@@ -8854,7 +8854,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// quad-tap
processKey(mapper, BTN_TOOL_TRIPLETAP, 0);
@@ -8862,7 +8862,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// finger
processKey(mapper, BTN_TOOL_QUADTAP, 0);
@@ -8870,42 +8870,42 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// stylus trumps finger
processKey(mapper, BTN_TOOL_PEN, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// eraser trumps stylus
processKey(mapper, BTN_TOOL_RUBBER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::ERASER, motionArgs.pointerProperties[0].toolType);
// mouse trumps eraser
processKey(mapper, BTN_TOOL_MOUSE, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::MOUSE, motionArgs.pointerProperties[0].toolType);
// MT tool type trumps BTN tool types: MT_TOOL_FINGER
processToolType(mapper, MT_TOOL_FINGER); // this is the first time we send MT_TOOL_TYPE
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// MT tool type trumps BTN tool types: MT_TOOL_PEN
processToolType(mapper, MT_TOOL_PEN);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::STYLUS, motionArgs.pointerProperties[0].toolType);
// back to default tool type
processToolType(mapper, -1); // use a deliberately undefined tool type, for testing
@@ -8916,7 +8916,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
}
TEST_F(MultiTouchInputMapperTest, Process_WhenBtnTouchPresent_HoversIfItsValueIsZero) {
@@ -9531,7 +9531,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// finger move
processId(mapper, 1);
@@ -9539,14 +9539,14 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// finger up.
processId(mapper, -1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// new finger down
processId(mapper, 1);
@@ -9554,7 +9554,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
}
/**
@@ -9576,7 +9576,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// Tool changed to MT_TOOL_PALM expect sending the cancel event.
processToolType(mapper, MT_TOOL_PALM);
@@ -9602,7 +9602,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
}
/**
@@ -9624,7 +9624,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// Second finger down.
processSlot(mapper, SECOND_SLOT);
@@ -9633,7 +9633,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(ACTION_POINTER_1_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[1].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[1].toolType);
// If the tool type of the first finger changes to MT_TOOL_PALM,
// we expect to receive ACTION_POINTER_UP with cancel flag.
@@ -9699,7 +9699,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// Second finger down.
processSlot(mapper, SECOND_SLOT);
@@ -9708,7 +9708,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(ACTION_POINTER_1_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// If the tool type of the first finger changes to MT_TOOL_PALM,
// we expect to receive ACTION_POINTER_UP with cancel flag.
@@ -9743,7 +9743,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(uint32_t(1), motionArgs.pointerCount);
// third finger move
@@ -9797,7 +9797,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// Second finger down.
processSlot(mapper, SECOND_SLOT);
@@ -9806,7 +9806,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(ACTION_POINTER_1_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
// If the tool type of the second finger changes to MT_TOOL_PALM,
// we expect to receive ACTION_POINTER_UP with cancel flag.
@@ -10003,7 +10003,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
WithSource(AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
// Now that we know the device supports styluses, ensure that the device is re-configured with
// the stylus source.
@@ -10025,7 +10025,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
WithSource(AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
}
TEST_F(MultiTouchInputMapperTest, Process_WhenConfigEnabled_ShouldShowDirectStylusPointer) {
@@ -10048,7 +10048,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
ASSERT_TRUE(fakePointerController->isPointerShown());
ASSERT_NO_FATAL_FAILURE(
@@ -10075,7 +10075,7 @@
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS),
+ WithToolType(ToolType::STYLUS),
WithPointerCoords(0, toDisplayX(100), toDisplayY(200)))));
ASSERT_FALSE(fakePointerController->isPointerShown());
}
@@ -10468,7 +10468,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(1U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::NONE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(
assertPointerCoords(motionArgs.pointerCoords[0], 0, 0, 1, 0, 0, 0, 0, 0, 0, 0));
@@ -10490,7 +10490,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(1U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::TWO_FINGER_SWIPE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0], 0,
movingDistance * mPointerMovementScale, 1, 0, 0, 0,
@@ -10528,7 +10528,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(1U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::NONE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(
assertPointerCoords(motionArgs.pointerCoords[0], 0, 0, 1, 0, 0, 0, 0, 0, 0, 0));
@@ -10550,7 +10550,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(1U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::TWO_FINGER_SWIPE, motionArgs.classification);
// New coordinate is the scaled relative coordinate from the initial coordinate.
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0], 0,
@@ -10584,7 +10584,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(1U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::NONE, motionArgs.classification);
// One pointer for PRESS, and its coordinate is used as the origin for pointer coordinates.
ASSERT_NO_FATAL_FAILURE(
@@ -10610,15 +10610,15 @@
ASSERT_EQ(1U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_CANCEL, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(1U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::NONE, motionArgs.classification);
ASSERT_EQ(2U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_POINTER_DOWN, motionArgs.action & AMOTION_EVENT_ACTION_MASK);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::NONE, motionArgs.classification);
// Two pointers' scaled relative coordinates from their initial centroid.
// Initial y coordinates are 0 as y1 and y2 have the same value.
@@ -10648,7 +10648,7 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(2U, motionArgs.pointerCount);
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
- ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_FINGER, motionArgs.pointerProperties[0].toolType);
+ ASSERT_EQ(ToolType::FINGER, motionArgs.pointerProperties[0].toolType);
ASSERT_EQ(MotionClassification::NONE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0], cookedX1,
movingDistance * 2 * mPointerMovementScale, 1, 0, 0,
@@ -10718,12 +10718,12 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
WithSource(AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_STYLUS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
// TODO(b/257078296): Pointer mode generates extra event.
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE),
WithSource(AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_STYLUS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
// Make the viewport inactive. This will put the device in disabled mode, and the ongoing stylus
@@ -10735,12 +10735,12 @@
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL),
WithSource(AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_STYLUS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
// TODO(b/257078296): Pointer mode generates extra event.
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(
AllOf(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL),
WithSource(AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_STYLUS),
- WithToolType(AMOTION_EVENT_TOOL_TYPE_STYLUS))));
+ WithToolType(ToolType::STYLUS))));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
}
diff --git a/services/inputflinger/tests/NotifyArgs_test.cpp b/services/inputflinger/tests/NotifyArgs_test.cpp
index 6715585..1536756 100644
--- a/services/inputflinger/tests/NotifyArgs_test.cpp
+++ b/services/inputflinger/tests/NotifyArgs_test.cpp
@@ -54,7 +54,7 @@
for (size_t i = 0; i < pointerCount; i++) {
pointerProperties[i].clear();
pointerProperties[i].id = i;
- pointerProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties[i].toolType = ToolType::FINGER;
pointerCoords[i].clear();
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, x++);
diff --git a/services/inputflinger/tests/PreferStylusOverTouch_test.cpp b/services/inputflinger/tests/PreferStylusOverTouch_test.cpp
index 9014dfb..9818176 100644
--- a/services/inputflinger/tests/PreferStylusOverTouch_test.cpp
+++ b/services/inputflinger/tests/PreferStylusOverTouch_test.cpp
@@ -45,8 +45,8 @@
PointerCoords pointerCoords[pointerCount];
const int32_t deviceId = isFromSource(source, TOUCHSCREEN) ? TOUCH_DEVICE_ID : STYLUS_DEVICE_ID;
- const int32_t toolType = isFromSource(source, TOUCHSCREEN) ? AMOTION_EVENT_TOOL_TYPE_FINGER
- : AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ const ToolType toolType =
+ isFromSource(source, TOUCHSCREEN) ? ToolType::FINGER : ToolType::STYLUS;
for (size_t i = 0; i < pointerCount; i++) {
pointerProperties[i].clear();
pointerProperties[i].id = i;
@@ -278,20 +278,20 @@
// Event from a stylus device, but with finger tool type
args = generateMotionArgs(/*downTime=*/1, /*eventTime=*/1, DOWN, {{1, 2}}, STYLUS);
// Keep source stylus, but make the tool type touch
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ args.pointerProperties[0].toolType = ToolType::FINGER;
assertNotBlocked(args);
// Second pointer (stylus pointer) goes down, from the same device
args = generateMotionArgs(/*downTime=*/1, /*eventTime=*/2, POINTER_1_DOWN, {{1, 2}, {10, 20}},
STYLUS);
// Keep source stylus, but make the tool type touch
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[0].toolType = ToolType::STYLUS;
assertNotBlocked(args);
// Second pointer (stylus pointer) goes down, from the same device
args = generateMotionArgs(/*downTime=*/1, /*eventTime=*/3, MOVE, {{2, 3}, {11, 21}}, STYLUS);
// Keep source stylus, but make the tool type touch
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ args.pointerProperties[0].toolType = ToolType::FINGER;
assertNotBlocked(args);
}
@@ -418,14 +418,14 @@
// Introduce a stylus pointer into the device 1 stream. It should be ignored.
args = generateMotionArgs(/*downTime=*/1, /*eventTime=*/3, POINTER_1_DOWN, {{1, 2}, {3, 4}},
TOUCHSCREEN);
- args.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[1].toolType = ToolType::STYLUS;
args.source = STYLUS;
assertDropped(args);
// Lift up touch from the mixed touch/stylus device
args = generateMotionArgs(/*downTime=*/1, /*eventTime=*/4, CANCEL, {{1, 2}, {3, 4}},
TOUCHSCREEN);
- args.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[1].toolType = ToolType::STYLUS;
args.source = STYLUS;
assertDropped(args);
diff --git a/services/inputflinger/tests/TestInputListenerMatchers.h b/services/inputflinger/tests/TestInputListenerMatchers.h
index 09f7ae8..338b747 100644
--- a/services/inputflinger/tests/TestInputListenerMatchers.h
+++ b/services/inputflinger/tests/TestInputListenerMatchers.h
@@ -138,8 +138,8 @@
MATCHER_P(WithToolType, toolType, "InputEvent with specified tool type") {
const auto argToolType = arg.pointerProperties[0].toolType;
- *result_listener << "expected tool type " << motionToolTypeToString(toolType) << ", but got "
- << motionToolTypeToString(argToolType);
+ *result_listener << "expected tool type " << ftl::enum_string(toolType) << ", but got "
+ << ftl::enum_string(argToolType);
return argToolType == toolType;
}
diff --git a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
index 3f749b1..2a9ace0 100644
--- a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
+++ b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
@@ -79,7 +79,7 @@
for (size_t i = 0; i < pointerCount; i++) {
pointerProperties[i].clear();
pointerProperties[i].id = i;
- pointerProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties[i].toolType = ToolType::FINGER;
pointerCoords[i].clear();
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, points[i].x);
@@ -507,7 +507,7 @@
TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenStylusSourceWithFingerToolIsReceived) {
mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
NotifyMotionArgs args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ args.pointerProperties[0].toolType = ToolType::FINGER;
args.source = AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
}
@@ -548,15 +548,15 @@
// Now touch down stylus
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/3, DOWN, {{10, 20, 30}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/4, MOVE, {{40, 50, 60}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/5, UP, {{40, 50, 60}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
}
@@ -617,14 +617,14 @@
info.addSource(AINPUT_SOURCE_STYLUS);
mBlocker->notifyInputDevicesChanged({info});
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
- args1.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args1.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args1);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN));
// Move the stylus, setting large TOUCH_MAJOR/TOUCH_MINOR dimensions
NotifyMotionArgs args2 =
generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}});
- args2.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args2.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args2);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
@@ -632,7 +632,7 @@
// it's a palm.
NotifyMotionArgs args3 =
generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}});
- args3.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args3.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args3);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP));
}
@@ -655,21 +655,21 @@
// Stylus pointer down
NotifyMotionArgs args2 = generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, POINTER_1_DOWN,
{{1, 2, 3}, {10, 20, 30}});
- args2.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args2.pointerProperties[1].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args2);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(POINTER_1_DOWN));
// Large touch oval on the next finger move
NotifyMotionArgs args3 = generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, MOVE,
{{1, 2, 300}, {11, 21, 30}});
- args3.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args3.pointerProperties[1].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args3);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
// Lift up the finger pointer. It should be canceled due to the heuristic filter.
NotifyMotionArgs args4 = generateMotionArgs(/*downTime=*/0, 3 * RESAMPLE_PERIOD, POINTER_0_UP,
{{1, 2, 300}, {11, 21, 30}});
- args4.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args4.pointerProperties[1].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args4);
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithMotionAction(POINTER_0_UP), WithFlags(FLAG_CANCELED)));
@@ -677,7 +677,7 @@
NotifyMotionArgs args5 =
generateMotionArgs(/*downTime=*/0, 4 * RESAMPLE_PERIOD, MOVE, {{12, 22, 30}});
args5.pointerProperties[0].id = args4.pointerProperties[1].id;
- args5.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args5.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args5);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
@@ -685,7 +685,7 @@
NotifyMotionArgs args6 =
generateMotionArgs(/*downTime=*/0, 5 * RESAMPLE_PERIOD, UP, {{4, 5, 200}});
args6.pointerProperties[0].id = args4.pointerProperties[1].id;
- args6.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args6.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args6);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP));
}
diff --git a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
index be85026..9a19b97 100644
--- a/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/CursorInputFuzzer.cpp
@@ -60,7 +60,7 @@
std::list<NotifyArgs> unused =
mapper.configure(fdp->ConsumeIntegral<nsecs_t>(), &policyConfig, 0);
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
},
[&]() -> void {
int32_t type, code;
diff --git a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
index 2909129..6617f65 100644
--- a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
@@ -28,7 +28,7 @@
// Create a basic motion event for testing
PointerProperties properties;
properties.id = 0;
- properties.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ properties.toolType = getFuzzedToolType(fdp);
PointerCoords coords;
coords.clear();
for (int32_t i = 0; i < fdp.ConsumeIntegralInRange<int32_t>(0, MAX_AXES); i++) {
diff --git a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
index 8e2d677..33e7dbf 100644
--- a/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/KeyboardInputFuzzer.cpp
@@ -59,7 +59,7 @@
},
[&]() -> void {
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
},
[&]() -> void { mapper.getSources(); },
[&]() -> void {
diff --git a/services/inputflinger/tests/fuzzers/MapperHelpers.h b/services/inputflinger/tests/fuzzers/MapperHelpers.h
index 2cb5cdf..d9a07b9 100644
--- a/services/inputflinger/tests/fuzzers/MapperHelpers.h
+++ b/services/inputflinger/tests/fuzzers/MapperHelpers.h
@@ -66,6 +66,14 @@
namespace android {
+template<class Fdp>
+ToolType getFuzzedToolType(Fdp& fdp) {
+ const int32_t toolType = fdp.template ConsumeIntegralInRange<int32_t>(
+ static_cast<int32_t>(ToolType::ftl_first),
+ static_cast<int32_t>(ToolType::ftl_last));
+ return static_cast<ToolType>(toolType);
+}
+
class FuzzEventHub : public EventHubInterface {
InputDeviceIdentifier mIdentifier;
std::vector<TouchVideoFrame> mVideoFrames;
diff --git a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
index 011455b..20db39d 100644
--- a/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/MultiTouchInputFuzzer.cpp
@@ -74,7 +74,7 @@
},
[&]() -> void {
InputDeviceInfo info;
- mapper.populateDeviceInfo(&info);
+ mapper.populateDeviceInfo(info);
},
[&]() -> void { mapper.getSources(); },
[&]() -> void {
@@ -128,7 +128,7 @@
StylusState state{fdp->ConsumeIntegral<nsecs_t>(),
fdp->ConsumeFloatingPoint<float>(),
fdp->ConsumeIntegral<uint32_t>(),
- fdp->ConsumeIntegral<int32_t>()};
+ getFuzzedToolType(*fdp)};
std::list<NotifyArgs> unused = mapper.updateExternalStylusState(state);
},
[&]() -> void { mapper.getAssociatedDisplayId(); },
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 0fb3cad..398d602 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -1648,7 +1648,7 @@
int deviceId = c->getDeviceId();
int sensorDeviceId = getDeviceIdFromHandle(sensorHandle);
if (sensorDeviceId != c->getDeviceId()) {
- ALOGE("Cannot configure direct channel created for device %d with a sensor that belongs"
+ ALOGE("Cannot configure direct channel created for device %d with a sensor that belongs "
"to device %d", c->getDeviceId(), sensorDeviceId);
return BAD_VALUE;
}
diff --git a/services/stats/Android.bp b/services/stats/Android.bp
index 7d358e1..6b99627 100644
--- a/services/stats/Android.bp
+++ b/services/stats/Android.bp
@@ -21,6 +21,7 @@
"android.frameworks.stats@1.0",
"android.frameworks.stats-V2-ndk",
"libbinder_ndk",
+ "libexpresslog",
"libhidlbase",
"liblog",
"libstatslog",
diff --git a/services/stats/StatsAidl.cpp b/services/stats/StatsAidl.cpp
index 0f01507..b22f903 100644
--- a/services/stats/StatsAidl.cpp
+++ b/services/stats/StatsAidl.cpp
@@ -22,6 +22,7 @@
#include "StatsAidl.h"
+#include <Counter.h>
#include <log/log.h>
#include <stats_annotations.h>
#include <stats_event.h>
@@ -29,11 +30,18 @@
#include <unordered_map>
+namespace {
+ static const char* g_AtomErrorMetricName =
+ "statsd_errors.value_report_vendor_atom_errors_count";
+}
+
namespace aidl {
namespace android {
namespace frameworks {
namespace stats {
+using ::android::expresslog::Counter;
+
template <typename E>
constexpr typename std::underlying_type<E>::type to_underlying(E e) noexcept {
return static_cast<typename std::underlying_type<E>::type>(e);
@@ -86,12 +94,14 @@
ndk::ScopedAStatus StatsHal::reportVendorAtom(const VendorAtom& vendorAtom) {
if (vendorAtom.atomId < 100000 || vendorAtom.atomId >= 200000) {
ALOGE("Atom ID %ld is not a valid vendor atom ID", (long)vendorAtom.atomId);
+ Counter::logIncrement(g_AtomErrorMetricName);
return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "Not a valid vendor atom ID");
}
if (vendorAtom.reverseDomainName.length() > 50) {
ALOGE("Vendor atom reverse domain name %s is too long.",
vendorAtom.reverseDomainName.c_str());
+ Counter::logIncrement(g_AtomErrorMetricName);
return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "Vendor atom reverse domain name is too long");
}
@@ -100,8 +110,9 @@
if (vendorAtom.atomAnnotations) {
if (!write_atom_annotations(event, *vendorAtom.atomAnnotations)) {
- ALOGE("Atom ID %ld has incompatible atom level annotation", (long)vendorAtom.atomId);
AStatsEvent_release(event);
+ ALOGE("Atom ID %ld has incompatible atom level annotation", (long)vendorAtom.atomId);
+ Counter::logIncrement(g_AtomErrorMetricName);
return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "invalid atom annotation");
}
@@ -222,6 +233,7 @@
default: {
AStatsEvent_release(event);
ALOGE("Atom ID %ld has invalid atomValue.getTag", (long)vendorAtom.atomId);
+ Counter::logIncrement(g_AtomErrorMetricName);
return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "invalid atomValue.getTag");
break;
@@ -235,9 +247,10 @@
VLOG("Atom ID %ld has %ld annotations for field #%ld", (long)vendorAtom.atomId,
(long)fieldAnnotations.size(), (long)atomValueIdx + 2);
if (!write_field_annotations(event, fieldAnnotations)) {
+ AStatsEvent_release(event);
ALOGE("Atom ID %ld has incompatible field level annotation for field #%ld",
(long)vendorAtom.atomId, (long)atomValueIdx + 2);
- AStatsEvent_release(event);
+ Counter::logIncrement(g_AtomErrorMetricName);
return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
-1, "invalid atom field annotation");
}
@@ -249,6 +262,7 @@
AStatsEvent_release(event);
if (ret <= 0) {
ALOGE("Error writing Atom ID %ld. Result: %d", (long)vendorAtom.atomId, ret);
+ Counter::logIncrement(g_AtomErrorMetricName);
}
return ret <= 0 ? ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ret,
"report atom failed")
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
index eae5871..35ca3a5 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFECompositionState.h
@@ -210,8 +210,8 @@
// The dimming flag
bool dimmingEnabled{true};
- float currentSdrHdrRatio = 1.f;
- float desiredSdrHdrRatio = 1.f;
+ float currentHdrSdrRatio = 1.f;
+ float desiredHdrSdrRatio = 1.f;
gui::CachingHint cachingHint = gui::CachingHint::Enabled;
virtual ~LayerFECompositionState();
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
index d5c488e..ce2b96f 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
@@ -247,6 +247,10 @@
ui::Dataspace getDataspace() const { return mOutputDataspace.get(); }
+ float getHdrSdrRatio() const {
+ return getOutputLayer()->getLayerFE().getCompositionState()->currentHdrSdrRatio;
+ };
+
wp<GraphicBuffer> getBuffer() const { return mBuffer.get(); }
bool isProtected() const { return mIsProtected.get(); }
diff --git a/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp b/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp
index 615d04b..426cc57 100644
--- a/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/LayerFECompositionState.cpp
@@ -121,9 +121,9 @@
dumpVal(out, "dataspace", toString(dataspace), dataspace);
dumpVal(out, "hdr metadata types", hdrMetadata.validTypes);
dumpVal(out, "dimming enabled", dimmingEnabled);
- if (currentSdrHdrRatio > 1.01f || desiredSdrHdrRatio > 1.01f) {
- dumpVal(out, "current sdr/hdr ratio", currentSdrHdrRatio);
- dumpVal(out, "desired sdr/hdr ratio", desiredSdrHdrRatio);
+ if (currentHdrSdrRatio > 1.01f || desiredHdrSdrRatio > 1.01f) {
+ dumpVal(out, "current hdr/sdr ratio", currentHdrSdrRatio);
+ dumpVal(out, "desired hdr/sdr ratio", desiredHdrSdrRatio);
}
dumpVal(out, "colorTransform", colorTransform);
dumpVal(out, "caching hint", toString(cachingHint));
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 1b86cd3..0ac0ecb 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -344,8 +344,8 @@
// RANGE_EXTENDED can "self-promote" to HDR, but is still rendered for a particular
// range that we may need to re-adjust to the current display conditions
if ((state.dataspace & HAL_DATASPACE_RANGE_MASK) == HAL_DATASPACE_RANGE_EXTENDED &&
- layerFEState->currentSdrHdrRatio > 1.01f) {
- layerBrightnessNits *= layerFEState->currentSdrHdrRatio;
+ layerFEState->currentHdrSdrRatio > 1.01f) {
+ layerBrightnessNits *= layerFEState->currentHdrSdrRatio;
}
state.dimmingRatio =
std::clamp(layerBrightnessNits / getOutput().getState().displayBrightnessNits, 0.f,
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
index a00ce57..8ced0ac 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp
@@ -378,6 +378,10 @@
// to avoid flickering/color differences.
return true;
}
+ // TODO(b/274804887): temp fix of overdimming issue, skip caching if hsdr/sdr ratio > 1.01f
+ if (layer.getState()->getHdrSdrRatio() > 1.01f) {
+ return true;
+ }
return false;
});
}
diff --git a/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp b/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
index ca5ba69..bd030d0 100644
--- a/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
@@ -662,6 +662,26 @@
EXPECT_FALSE(cachedSet.requiresHolePunch());
}
+TEST_F(CachedSetTest, holePunch_requiresNonHdrWithExtendedBrightness) {
+ const auto dataspace = static_cast<ui::Dataspace>(ui::Dataspace::STANDARD_DCI_P3 |
+ ui::Dataspace::TRANSFER_SRGB |
+ ui::Dataspace::RANGE_EXTENDED);
+ mTestLayers[0]->outputLayerCompositionState.dataspace = dataspace;
+ mTestLayers[0]->layerFECompositionState.currentHdrSdrRatio = 5.f;
+ mTestLayers[0]->layerState->update(&mTestLayers[0]->outputLayer);
+
+ CachedSet::Layer& layer = *mTestLayers[0]->cachedSetLayer.get();
+ auto& layerFECompositionState = mTestLayers[0]->layerFECompositionState;
+ layerFECompositionState.buffer = sp<GraphicBuffer>::make();
+ layerFECompositionState.blendMode = hal::BlendMode::NONE;
+ sp<mock::LayerFE> layerFE = mTestLayers[0]->layerFE;
+
+ CachedSet cachedSet(layer);
+ EXPECT_CALL(*layerFE, hasRoundedCorners()).WillRepeatedly(Return(true));
+
+ EXPECT_FALSE(cachedSet.requiresHolePunch());
+}
+
TEST_F(CachedSetTest, holePunch_requiresNoBlending) {
CachedSet::Layer& layer = *mTestLayers[0]->cachedSetLayer.get();
auto& layerFECompositionState = mTestLayers[0]->layerFECompositionState;
diff --git a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
index f05223c..36f71bb 100644
--- a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
+++ b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
@@ -219,7 +219,7 @@
std::lock_guard lock(mPowerHalMutex);
HalWrapper* const halWrapper = getPowerHal();
if (halWrapper != nullptr) {
- halWrapper->sendActualWorkDuration(*actualDuration + kTargetSafetyMargin,
+ halWrapper->sendActualWorkDuration(*actualDuration + sTargetSafetyMargin,
TimePoint::now());
}
}
@@ -232,12 +232,11 @@
}
const std::optional<Duration> predictedDuration = estimateWorkDuration(true);
-
if (predictedDuration.has_value()) {
std::lock_guard lock(mPowerHalMutex);
HalWrapper* const halWrapper = getPowerHal();
if (halWrapper != nullptr) {
- halWrapper->sendActualWorkDuration(*predictedDuration + kTargetSafetyMargin,
+ halWrapper->sendActualWorkDuration(*predictedDuration + sTargetSafetyMargin,
TimePoint::now());
}
}
@@ -812,6 +811,10 @@
const bool AidlPowerHalWrapper::sTraceHintSessionData =
base::GetBoolProperty(std::string("debug.sf.trace_hint_sessions"), false);
+const Duration PowerAdvisor::sTargetSafetyMargin = std::chrono::microseconds(
+ base::GetIntProperty<int64_t>("debug.sf.hint_margin_us",
+ ticks<std::micro>(PowerAdvisor::kDefaultTargetSafetyMargin)));
+
PowerAdvisor::HalWrapper* PowerAdvisor::getPowerHal() {
if (!mHasHal) {
return nullptr;
diff --git a/services/surfaceflinger/DisplayHardware/PowerAdvisor.h b/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
index d45e7cb..c4cfdc3 100644
--- a/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
+++ b/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
@@ -274,7 +274,8 @@
// An adjustable safety margin which pads the "actual" value sent to PowerHAL,
// encouraging more aggressive boosting to give SurfaceFlinger a larger margin for error
- static constexpr const Duration kTargetSafetyMargin{1ms};
+ static const Duration sTargetSafetyMargin;
+ static constexpr const Duration kDefaultTargetSafetyMargin{1ms};
// How long we expect hwc to run after the present call until it waits for the fence
static constexpr const Duration kFenceWaitStartDelayValidated{150us};
diff --git a/services/surfaceflinger/FrontEnd/LayerHierarchy.h b/services/surfaceflinger/FrontEnd/LayerHierarchy.h
index 3dd89ba..b25b731 100644
--- a/services/surfaceflinger/FrontEnd/LayerHierarchy.h
+++ b/services/surfaceflinger/FrontEnd/LayerHierarchy.h
@@ -104,6 +104,16 @@
static const TraversalPath ROOT;
};
+ struct TraversalPathHash {
+ std::size_t operator()(const LayerHierarchy::TraversalPath& key) const {
+ uint32_t hashCode = key.id * 31;
+ if (key.mirrorRootId != UNASSIGNED_LAYER_ID) {
+ hashCode += key.mirrorRootId * 31;
+ }
+ return std::hash<size_t>{}(hashCode);
+ }
+ };
+
// Helper class to add nodes to an existing traversal id and removes the
// node when it goes out of scope.
class ScopedAddToTraversalPath {
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
index 8a45093..2d6d8ad 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.cpp
@@ -28,9 +28,14 @@
const LayerHierarchy::TraversalPath& path)
: path(path) {
static uint32_t sUniqueSequenceId = 0;
- // Provide a unique id for clones otherwise keeping using the sequence id.
- // The seq id can still be useful for debugging if its available.
- uniqueSequence = (path.isClone()) ? sUniqueSequenceId++ : state.id;
+ // Provide a unique id for all snapshots.
+ // A front end layer can generate multiple snapshots if its mirrored.
+ // Additionally, if the layer is not reachable, we may choose to destroy
+ // and recreate the snapshot in which case the unique sequence id will
+ // change. The consumer shouldn't tie any lifetimes to this unique id but
+ // register a LayerLifecycleManager::ILifecycleListener or get a list of
+ // destroyed layers from LayerLifecycleManager.
+ uniqueSequence = sUniqueSequenceId++;
sequence = static_cast<int32_t>(state.id);
name = state.name;
textureName = state.textureName;
@@ -39,6 +44,8 @@
inputInfo.id = static_cast<int32_t>(uniqueSequence);
inputInfo.ownerUid = static_cast<int32_t>(state.ownerUid);
inputInfo.ownerPid = state.ownerPid;
+ uid = state.ownerUid;
+ pid = state.ownerPid;
changes = RequestedLayerState::Changes::Created;
mirrorRootPath = path.variant == LayerHierarchy::Variant::Mirror
? path
@@ -174,7 +181,12 @@
std::stringstream debug;
debug << "Snapshot{" << path.toString() << name << " isVisible=" << isVisible << " {"
<< getIsVisibleReason() << "} changes=" << changes.string()
- << " layerStack=" << outputFilter.layerStack.id << "}";
+ << " layerStack=" << outputFilter.layerStack.id << " geomLayerBounds={"
+ << geomLayerBounds.left << "," << geomLayerBounds.top << "," << geomLayerBounds.bottom
+ << "," << geomLayerBounds.right << "}"
+ << " geomLayerTransform={tx=" << geomLayerTransform.tx()
+ << ",ty=" << geomLayerTransform.ty() << "}"
+ << "}";
return debug.str();
}
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.h b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
index 6fb2f57..5491d9a 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.h
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
@@ -89,10 +89,13 @@
gui::GameMode gameMode;
scheduler::LayerInfo::FrameRate frameRate;
ui::Transform::RotationFlags fixedTransformHint;
+ std::optional<ui::Transform::RotationFlags> transformHint;
bool handleSkipScreenshotFlag = false;
int32_t frameRateSelectionPriority;
LayerHierarchy::TraversalPath mirrorRootPath;
bool unreachable = true;
+ uid_t uid;
+ pid_t pid;
ChildState childState;
static bool isOpaqueFormat(PixelFormat format);
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index a16de1b..babcbe7 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -21,10 +21,16 @@
#include "LayerSnapshotBuilder.h"
#include <gui/TraceUtils.h>
+#include <ui/FloatRect.h>
+
#include <numeric>
+#include <optional>
+
+#include <gui/TraceUtils.h>
#include "DisplayHardware/HWC2.h"
#include "DisplayHardware/Hal.h"
#include "LayerLog.h"
+#include "LayerSnapshotBuilder.h"
#include "TimeStats/TimeStats.h"
#include "ftl/small_map.h"
@@ -101,43 +107,52 @@
}
/**
+ * Returns the bounds used to fill the input frame and the touchable region.
+ *
* Similar to getInputTransform, we need to update the bounds to include the transform.
* This is because bounds don't include the buffer transform, where the input assumes
* that's already included.
*/
-Rect getInputBounds(const LayerSnapshot& snapshot) {
- if (!snapshot.hasBufferOrSidebandStream()) {
- return snapshot.croppedBufferSize;
+std::pair<FloatRect, bool> getInputBounds(const LayerSnapshot& snapshot, bool fillParentBounds) {
+ FloatRect inputBounds = snapshot.croppedBufferSize.toFloatRect();
+ if (snapshot.hasBufferOrSidebandStream() && snapshot.croppedBufferSize.isValid() &&
+ snapshot.localTransform.getType() != ui::Transform::IDENTITY) {
+ inputBounds = snapshot.localTransform.transform(inputBounds);
}
- if (snapshot.localTransform.getType() == ui::Transform::IDENTITY ||
- !snapshot.croppedBufferSize.isValid()) {
- return snapshot.croppedBufferSize;
+ bool inputBoundsValid = snapshot.croppedBufferSize.isValid();
+ if (!inputBoundsValid) {
+ /**
+ * Input bounds are based on the layer crop or buffer size. But if we are using
+ * the layer bounds as the input bounds (replaceTouchableRegionWithCrop flag) then
+ * we can use the parent bounds as the input bounds if the layer does not have buffer
+ * or a crop. We want to unify this logic but because of compat reasons we cannot always
+ * use the parent bounds. A layer without a buffer can get input. So when a window is
+ * initially added, its touchable region can fill its parent layer bounds and that can
+ * have negative consequences.
+ */
+ inputBounds = fillParentBounds ? snapshot.geomLayerBounds : FloatRect{};
}
- return snapshot.localTransform.transform(snapshot.croppedBufferSize);
+
+ // Clamp surface inset to the input bounds.
+ const float inset = static_cast<float>(snapshot.inputInfo.surfaceInset);
+ const float xSurfaceInset = std::clamp(inset, 0.f, inputBounds.getWidth() / 2.f);
+ const float ySurfaceInset = std::clamp(inset, 0.f, inputBounds.getHeight() / 2.f);
+
+ // Apply the insets to the input bounds.
+ inputBounds.left += xSurfaceInset;
+ inputBounds.top += ySurfaceInset;
+ inputBounds.right -= xSurfaceInset;
+ inputBounds.bottom -= ySurfaceInset;
+ return {inputBounds, inputBoundsValid};
}
-void fillInputFrameInfo(gui::WindowInfo& info, const ui::Transform& screenToDisplay,
- const LayerSnapshot& snapshot) {
- Rect tmpBounds = getInputBounds(snapshot);
- if (!tmpBounds.isValid()) {
- info.touchableRegion.clear();
- // A layer could have invalid input bounds and still expect to receive touch input if it has
- // replaceTouchableRegionWithCrop. For that case, the input transform needs to be calculated
- // correctly to determine the coordinate space for input events. Use an empty rect so that
- // the layer will receive input in its own layer space.
- tmpBounds = Rect::EMPTY_RECT;
- }
-
+Rect getInputBoundsInDisplaySpace(const LayerSnapshot& snapshot, const FloatRect& insetBounds,
+ const ui::Transform& screenToDisplay) {
// InputDispatcher works in the display device's coordinate space. Here, we calculate the
// frame and transform used for the layer, which determines the bounds and the coordinate space
// within which the layer will receive input.
- //
- // The coordinate space within which each of the bounds are specified is explicitly documented
- // in the variable name. For example "inputBoundsInLayer" is specified in layer space. A
- // Transform converts one coordinate space to another, which is apparent in its naming. For
- // example, "layerToDisplay" transforms layer space to display space.
- //
+
// Coordinate space definitions:
// - display: The display device's coordinate space. Correlates to pixels on the display.
// - screen: The post-rotation coordinate space for the display, a.k.a. logical display space.
@@ -145,37 +160,34 @@
// - input: The coordinate space in which this layer will receive input events. This could be
// different than layer space if a surfaceInset is used, which changes the origin
// of the input space.
- const FloatRect inputBoundsInLayer = tmpBounds.toFloatRect();
-
- // Clamp surface inset to the input bounds.
- const auto surfaceInset = static_cast<float>(info.surfaceInset);
- const float xSurfaceInset =
- std::max(0.f, std::min(surfaceInset, inputBoundsInLayer.getWidth() / 2.f));
- const float ySurfaceInset =
- std::max(0.f, std::min(surfaceInset, inputBoundsInLayer.getHeight() / 2.f));
-
- // Apply the insets to the input bounds.
- const FloatRect insetBoundsInLayer(inputBoundsInLayer.left + xSurfaceInset,
- inputBoundsInLayer.top + ySurfaceInset,
- inputBoundsInLayer.right - xSurfaceInset,
- inputBoundsInLayer.bottom - ySurfaceInset);
// Crop the input bounds to ensure it is within the parent's bounds.
- const FloatRect croppedInsetBoundsInLayer =
- snapshot.geomLayerBounds.intersect(insetBoundsInLayer);
+ const FloatRect croppedInsetBoundsInLayer = snapshot.geomLayerBounds.intersect(insetBounds);
const ui::Transform layerToScreen = getInputTransform(snapshot);
const ui::Transform layerToDisplay = screenToDisplay * layerToScreen;
- const Rect roundedFrameInDisplay{layerToDisplay.transform(croppedInsetBoundsInLayer)};
+ return Rect{layerToDisplay.transform(croppedInsetBoundsInLayer)};
+}
+
+void fillInputFrameInfo(gui::WindowInfo& info, const ui::Transform& screenToDisplay,
+ const LayerSnapshot& snapshot) {
+ auto [inputBounds, inputBoundsValid] = getInputBounds(snapshot, /*fillParentBounds=*/false);
+ if (!inputBoundsValid) {
+ info.touchableRegion.clear();
+ }
+
+ const Rect roundedFrameInDisplay =
+ getInputBoundsInDisplaySpace(snapshot, inputBounds, screenToDisplay);
info.frameLeft = roundedFrameInDisplay.left;
info.frameTop = roundedFrameInDisplay.top;
info.frameRight = roundedFrameInDisplay.right;
info.frameBottom = roundedFrameInDisplay.bottom;
ui::Transform inputToLayer;
- inputToLayer.set(insetBoundsInLayer.left, insetBoundsInLayer.top);
- const ui::Transform inputToDisplay = layerToDisplay * inputToLayer;
+ inputToLayer.set(inputBounds.left, inputBounds.top);
+ const ui::Transform layerToScreen = getInputTransform(snapshot);
+ const ui::Transform inputToDisplay = screenToDisplay * layerToScreen * inputToLayer;
// InputDispatcher expects a display-to-input transform.
info.transform = inputToDisplay.inverse();
@@ -642,12 +654,14 @@
snapshot.relativeLayerMetadata.mMap.clear();
}
-uint32_t getDisplayRotationFlags(
- const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displays,
- const ui::LayerStack& layerStack) {
- static frontend::DisplayInfo sDefaultDisplayInfo = {.isPrimary = false};
- auto display = displays.get(layerStack).value_or(sDefaultDisplayInfo).get();
- return display.isPrimary ? display.rotationFlags : 0;
+uint32_t getPrimaryDisplayRotationFlags(
+ const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displays) {
+ for (auto& [_, display] : displays) {
+ if (display.isPrimary) {
+ return display.rotationFlags;
+ }
+ }
+ return 0;
}
void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& args,
@@ -674,8 +688,7 @@
? requested.layerStack
: parentSnapshot.outputFilter.layerStack;
- uint32_t displayRotationFlags =
- getDisplayRotationFlags(args.displays, snapshot.outputFilter.layerStack);
+ uint32_t primaryDisplayRotationFlags = getPrimaryDisplayRotationFlags(args.displays);
const bool forceUpdate = args.forceUpdate == ForceUpdateFlags::ALL ||
snapshot.changes.any(RequestedLayerState::Changes::Visibility |
RequestedLayerState::Changes::Created);
@@ -689,7 +702,7 @@
: Fence::NO_FENCE;
snapshot.buffer =
requested.externalTexture ? requested.externalTexture->getBuffer() : nullptr;
- snapshot.bufferSize = requested.getBufferSize(displayRotationFlags);
+ snapshot.bufferSize = requested.getBufferSize(primaryDisplayRotationFlags);
snapshot.geomBufferSize = snapshot.bufferSize;
snapshot.croppedBufferSize = requested.getCroppedBufferSize(snapshot.bufferSize);
snapshot.dataspace = requested.dataspace;
@@ -707,8 +720,8 @@
snapshot.sidebandStream = requested.sidebandStream;
snapshot.transparentRegionHint = requested.transparentRegion;
snapshot.color.rgb = requested.getColor().rgb;
- snapshot.currentSdrHdrRatio = requested.currentSdrHdrRatio;
- snapshot.desiredSdrHdrRatio = requested.desiredSdrHdrRatio;
+ snapshot.currentHdrSdrRatio = requested.currentHdrSdrRatio;
+ snapshot.desiredHdrSdrRatio = requested.desiredHdrSdrRatio;
}
if (snapshot.isHiddenByPolicyFromParent &&
@@ -744,15 +757,28 @@
snapshot.gameMode = requested.metadata.has(gui::METADATA_GAME_MODE)
? requested.gameMode
: parentSnapshot.gameMode;
- snapshot.fixedTransformHint = requested.fixedTransformHint != ui::Transform::ROT_INVALID
- ? requested.fixedTransformHint
- : parentSnapshot.fixedTransformHint;
// Display mirrors are always placed in a VirtualDisplay so we never want to capture layers
// marked as skip capture
snapshot.handleSkipScreenshotFlag = parentSnapshot.handleSkipScreenshotFlag ||
(requested.layerStackToMirror != ui::INVALID_LAYER_STACK);
}
+ if (forceUpdate || snapshot.changes.any(RequestedLayerState::Changes::AffectsChildren) ||
+ args.displayChanges) {
+ snapshot.fixedTransformHint = requested.fixedTransformHint != ui::Transform::ROT_INVALID
+ ? requested.fixedTransformHint
+ : parentSnapshot.fixedTransformHint;
+
+ if (snapshot.fixedTransformHint != ui::Transform::ROT_INVALID) {
+ snapshot.transformHint = snapshot.fixedTransformHint;
+ } else {
+ const auto display = args.displays.get(snapshot.outputFilter.layerStack);
+ snapshot.transformHint = display.has_value()
+ ? std::make_optional<>(display->get().transformHint)
+ : std::nullopt;
+ }
+ }
+
if (forceUpdate ||
snapshot.changes.any(RequestedLayerState::Changes::FrameRate |
RequestedLayerState::Changes::Hierarchy)) {
@@ -792,7 +818,7 @@
if (forceUpdate ||
snapshot.changes.any(RequestedLayerState::Changes::Hierarchy |
RequestedLayerState::Changes::Geometry)) {
- updateLayerBounds(snapshot, requested, parentSnapshot, displayRotationFlags);
+ updateLayerBounds(snapshot, requested, parentSnapshot, primaryDisplayRotationFlags);
updateRoundedCorner(snapshot, requested, parentSnapshot);
}
@@ -863,10 +889,10 @@
void LayerSnapshotBuilder::updateLayerBounds(LayerSnapshot& snapshot,
const RequestedLayerState& requested,
const LayerSnapshot& parentSnapshot,
- uint32_t displayRotationFlags) {
+ uint32_t primaryDisplayRotationFlags) {
snapshot.croppedBufferSize = requested.getCroppedBufferSize(snapshot.bufferSize);
snapshot.geomCrop = requested.crop;
- snapshot.localTransform = requested.getTransform(displayRotationFlags);
+ snapshot.localTransform = requested.getTransform(primaryDisplayRotationFlags);
snapshot.localTransformInverse = snapshot.localTransform.inverse();
snapshot.geomLayerTransform = parentSnapshot.geomLayerTransform * snapshot.localTransform;
const bool transformWasInvalid = snapshot.invalidTransform;
@@ -880,14 +906,14 @@
requestedT.dsdy(), requestedT.dtdx(), requestedT.dtdy());
std::string bufferDebug;
if (requested.externalTexture) {
- auto unRotBuffer = requested.getUnrotatedBufferSize(displayRotationFlags);
+ auto unRotBuffer = requested.getUnrotatedBufferSize(primaryDisplayRotationFlags);
auto& destFrame = requested.destinationFrame;
bufferDebug = base::StringPrintf(" buffer={%d,%d} displayRot=%d"
" destFrame={%d,%d,%d,%d} unRotBuffer={%d,%d}",
requested.externalTexture->getWidth(),
requested.externalTexture->getHeight(),
- displayRotationFlags, destFrame.left, destFrame.top,
- destFrame.right, destFrame.bottom,
+ primaryDisplayRotationFlags, destFrame.left,
+ destFrame.top, destFrame.right, destFrame.bottom,
unRotBuffer.getHeight(), unRotBuffer.getWidth());
}
ALOGW("Resetting transform for %s because it is invalid.%s%s",
@@ -1008,12 +1034,26 @@
auto cropLayerSnapshot = getSnapshot(requested.touchCropId);
if (snapshot.inputInfo.replaceTouchableRegionWithCrop) {
- const Rect bounds(cropLayerSnapshot ? cropLayerSnapshot->transformedBounds
- : snapshot.transformedBounds);
- snapshot.inputInfo.touchableRegion = Region(displayInfo.transform.transform(bounds));
+ Rect inputBoundsInDisplaySpace;
+ if (!cropLayerSnapshot) {
+ FloatRect inputBounds = getInputBounds(snapshot, /*fillParentBounds=*/true).first;
+ inputBoundsInDisplaySpace =
+ getInputBoundsInDisplaySpace(snapshot, inputBounds, displayInfo.transform);
+ } else {
+ FloatRect inputBounds =
+ getInputBounds(*cropLayerSnapshot, /*fillParentBounds=*/true).first;
+ inputBoundsInDisplaySpace =
+ getInputBoundsInDisplaySpace(*cropLayerSnapshot, inputBounds,
+ displayInfo.transform);
+ }
+ snapshot.inputInfo.touchableRegion = Region(inputBoundsInDisplaySpace);
} else if (cropLayerSnapshot) {
+ FloatRect inputBounds = getInputBounds(*cropLayerSnapshot, /*fillParentBounds=*/true).first;
+ Rect inputBoundsInDisplaySpace =
+ getInputBoundsInDisplaySpace(*cropLayerSnapshot, inputBounds,
+ displayInfo.transform);
snapshot.inputInfo.touchableRegion = snapshot.inputInfo.touchableRegion.intersect(
- displayInfo.transform.transform(Rect{cropLayerSnapshot->transformedBounds}));
+ displayInfo.transform.transform(inputBoundsInDisplaySpace));
}
// Inherit the trusted state from the parent hierarchy, but don't clobber the trusted state
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h
index 3997a0a..7b1ff27 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.h
@@ -68,6 +68,7 @@
void update(const Args&);
std::vector<std::unique_ptr<LayerSnapshot>>& getSnapshots();
LayerSnapshot* getSnapshot(uint32_t layerId) const;
+ LayerSnapshot* getSnapshot(const LayerHierarchy::TraversalPath& id) const;
typedef std::function<void(const LayerSnapshot& snapshot)> ConstVisitor;
@@ -86,7 +87,6 @@
private:
friend class LayerSnapshotTest;
- LayerSnapshot* getSnapshot(const LayerHierarchy::TraversalPath& id) const;
static LayerSnapshot getRootSnapshot();
// return true if we were able to successfully update the snapshots via
@@ -120,16 +120,8 @@
void updateChildState(LayerSnapshot& snapshot, const LayerSnapshot& childSnapshot,
const Args& args);
- struct TraversalPathHash {
- std::size_t operator()(const LayerHierarchy::TraversalPath& key) const {
- uint32_t hashCode = key.id * 31;
- if (key.mirrorRootId != UNASSIGNED_LAYER_ID) {
- hashCode += key.mirrorRootId * 31;
- }
- return std::hash<size_t>{}(hashCode);
- }
- };
- std::unordered_map<LayerHierarchy::TraversalPath, LayerSnapshot*, TraversalPathHash>
+ std::unordered_map<LayerHierarchy::TraversalPath, LayerSnapshot*,
+ LayerHierarchy::TraversalPathHash>
mIdToSnapshot;
std::vector<std::unique_ptr<LayerSnapshot>> mSnapshots;
LayerSnapshot mRootSnapshot;
diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
index a5fdaf4..1f670c8 100644
--- a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
+++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
@@ -100,8 +100,8 @@
layerStack = ui::DEFAULT_LAYER_STACK;
transformToDisplayInverse = false;
dataspace = ui::Dataspace::UNKNOWN;
- desiredSdrHdrRatio = 1.f;
- currentSdrHdrRatio = 1.f;
+ desiredHdrSdrRatio = 1.f;
+ currentHdrSdrRatio = 1.f;
dataspaceRequested = false;
hdrMetadata.validTypes = 0;
surfaceDamageRegion = Region::INVALID_REGION;
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 9521371..755e585 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -52,8 +52,11 @@
#include <system/graphics-base-v1.0.h>
#include <ui/DataspaceUtils.h>
#include <ui/DebugUtils.h>
+#include <ui/FloatRect.h>
#include <ui/GraphicBuffer.h>
#include <ui/PixelFormat.h>
+#include <ui/Rect.h>
+#include <ui/Transform.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/NativeHandle.h>
@@ -335,6 +338,7 @@
return nullptr;
}
mGetHandleCalled = true;
+ mHandleAlive = true;
return sp<LayerHandle>::make(mFlinger, sp<Layer>::fromExisting(this));
}
@@ -639,8 +643,8 @@
snapshot->surfaceDamage = surfaceDamageRegion;
snapshot->hasProtectedContent = isProtected();
snapshot->dimmingEnabled = isDimmingEnabled();
- snapshot->currentSdrHdrRatio = getCurrentSdrHdrRatio();
- snapshot->desiredSdrHdrRatio = getDesiredSdrHdrRatio();
+ snapshot->currentHdrSdrRatio = getCurrentHdrSdrRatio();
+ snapshot->desiredHdrSdrRatio = getDesiredHdrSdrRatio();
snapshot->cachingHint = getCachingHint();
const bool usesRoundedCorners = hasRoundedCorners();
@@ -1501,7 +1505,7 @@
transformHint = ui::Transform::ROT_0;
}
- setTransformHint(transformHint);
+ setTransformHintLegacy(transformHint);
}
// ----------------------------------------------------------------------------
@@ -1649,9 +1653,9 @@
mFlinger->mFrameTracer->onDestroy(layerId);
}
-size_t Layer::getChildrenCount() const {
+size_t Layer::getDescendantCount() const {
size_t count = 0;
- for (const sp<Layer>& child : mCurrentChildren) {
+ for (const sp<Layer>& child : mDrawingChildren) {
count += 1 + child->getChildrenCount();
}
return count;
@@ -1898,6 +1902,12 @@
}
}
+void Layer::traverseChildren(const LayerVector::Visitor& visitor) {
+ for (const sp<Layer>& child : mDrawingChildren) {
+ visitor(child.get());
+ }
+}
+
LayerVector Layer::makeChildrenTraversalList(LayerVector::StateSet stateSet,
const std::vector<Layer*>& layersInTree) {
LOG_ALWAYS_FATAL_IF(stateSet == LayerVector::StateSet::Invalid,
@@ -2297,62 +2307,21 @@
}
void Layer::fillInputFrameInfo(WindowInfo& info, const ui::Transform& screenToDisplay) {
- Rect tmpBounds = getInputBounds();
- if (!tmpBounds.isValid()) {
+ auto [inputBounds, inputBoundsValid] = getInputBounds(/*fillParentBounds=*/false);
+ if (!inputBoundsValid) {
info.touchableRegion.clear();
- // A layer could have invalid input bounds and still expect to receive touch input if it has
- // replaceTouchableRegionWithCrop. For that case, the input transform needs to be calculated
- // correctly to determine the coordinate space for input events. Use an empty rect so that
- // the layer will receive input in its own layer space.
- tmpBounds = Rect::EMPTY_RECT;
}
- // InputDispatcher works in the display device's coordinate space. Here, we calculate the
- // frame and transform used for the layer, which determines the bounds and the coordinate space
- // within which the layer will receive input.
- //
- // The coordinate space within which each of the bounds are specified is explicitly documented
- // in the variable name. For example "inputBoundsInLayer" is specified in layer space. A
- // Transform converts one coordinate space to another, which is apparent in its naming. For
- // example, "layerToDisplay" transforms layer space to display space.
- //
- // Coordinate space definitions:
- // - display: The display device's coordinate space. Correlates to pixels on the display.
- // - screen: The post-rotation coordinate space for the display, a.k.a. logical display space.
- // - layer: The coordinate space of this layer.
- // - input: The coordinate space in which this layer will receive input events. This could be
- // different than layer space if a surfaceInset is used, which changes the origin
- // of the input space.
- const FloatRect inputBoundsInLayer = tmpBounds.toFloatRect();
-
- // Clamp surface inset to the input bounds.
- const auto surfaceInset = static_cast<float>(info.surfaceInset);
- const float xSurfaceInset =
- std::max(0.f, std::min(surfaceInset, inputBoundsInLayer.getWidth() / 2.f));
- const float ySurfaceInset =
- std::max(0.f, std::min(surfaceInset, inputBoundsInLayer.getHeight() / 2.f));
-
- // Apply the insets to the input bounds.
- const FloatRect insetBoundsInLayer(inputBoundsInLayer.left + xSurfaceInset,
- inputBoundsInLayer.top + ySurfaceInset,
- inputBoundsInLayer.right - xSurfaceInset,
- inputBoundsInLayer.bottom - ySurfaceInset);
-
- // Crop the input bounds to ensure it is within the parent's bounds.
- const FloatRect croppedInsetBoundsInLayer = mBounds.intersect(insetBoundsInLayer);
-
- const ui::Transform layerToScreen = getInputTransform();
- const ui::Transform layerToDisplay = screenToDisplay * layerToScreen;
-
- const Rect roundedFrameInDisplay{layerToDisplay.transform(croppedInsetBoundsInLayer)};
+ const Rect roundedFrameInDisplay = getInputBoundsInDisplaySpace(inputBounds, screenToDisplay);
info.frameLeft = roundedFrameInDisplay.left;
info.frameTop = roundedFrameInDisplay.top;
info.frameRight = roundedFrameInDisplay.right;
info.frameBottom = roundedFrameInDisplay.bottom;
ui::Transform inputToLayer;
- inputToLayer.set(insetBoundsInLayer.left, insetBoundsInLayer.top);
- const ui::Transform inputToDisplay = layerToDisplay * inputToLayer;
+ inputToLayer.set(inputBounds.left, inputBounds.top);
+ const ui::Transform layerToScreen = getInputTransform();
+ const ui::Transform inputToDisplay = screenToDisplay * layerToScreen * inputToLayer;
// InputDispatcher expects a display-to-input transform.
info.transform = inputToDisplay.inverse();
@@ -2485,13 +2454,23 @@
info.inputConfig |= WindowInfo::InputConfig::DROP_INPUT;
}
- auto cropLayer = mDrawingState.touchableRegionCrop.promote();
+ sp<Layer> cropLayer = mDrawingState.touchableRegionCrop.promote();
if (info.replaceTouchableRegionWithCrop) {
- const Rect bounds(cropLayer ? cropLayer->mScreenBounds : mScreenBounds);
- info.touchableRegion = Region(displayTransform.transform(bounds));
+ Rect inputBoundsInDisplaySpace;
+ if (!cropLayer) {
+ FloatRect inputBounds = getInputBounds(/*fillParentBounds=*/true).first;
+ inputBoundsInDisplaySpace = getInputBoundsInDisplaySpace(inputBounds, displayTransform);
+ } else {
+ FloatRect inputBounds = cropLayer->getInputBounds(/*fillParentBounds=*/true).first;
+ inputBoundsInDisplaySpace =
+ cropLayer->getInputBoundsInDisplaySpace(inputBounds, displayTransform);
+ }
+ info.touchableRegion = Region(inputBoundsInDisplaySpace);
} else if (cropLayer != nullptr) {
- info.touchableRegion = info.touchableRegion.intersect(
- displayTransform.transform(Rect{cropLayer->mScreenBounds}));
+ FloatRect inputBounds = cropLayer->getInputBounds(/*fillParentBounds=*/true).first;
+ Rect inputBoundsInDisplaySpace =
+ cropLayer->getInputBoundsInDisplaySpace(inputBounds, displayTransform);
+ info.touchableRegion = info.touchableRegion.intersect(inputBoundsInDisplaySpace);
}
// Inherit the trusted state from the parent hierarchy, but don't clobber the trusted state
@@ -2513,6 +2492,27 @@
return info;
}
+Rect Layer::getInputBoundsInDisplaySpace(const FloatRect& inputBounds,
+ const ui::Transform& screenToDisplay) {
+ // InputDispatcher works in the display device's coordinate space. Here, we calculate the
+ // frame and transform used for the layer, which determines the bounds and the coordinate space
+ // within which the layer will receive input.
+
+ // Coordinate space definitions:
+ // - display: The display device's coordinate space. Correlates to pixels on the display.
+ // - screen: The post-rotation coordinate space for the display, a.k.a. logical display space.
+ // - layer: The coordinate space of this layer.
+ // - input: The coordinate space in which this layer will receive input events. This could be
+ // different than layer space if a surfaceInset is used, which changes the origin
+ // of the input space.
+
+ // Crop the input bounds to ensure it is within the parent's bounds.
+ const FloatRect croppedInputBounds = mBounds.intersect(inputBounds);
+ const ui::Transform layerToScreen = getInputTransform();
+ const ui::Transform layerToDisplay = screenToDisplay * layerToScreen;
+ return Rect{layerToDisplay.transform(croppedInputBounds)};
+}
+
sp<Layer> Layer::getClonedRoot() {
if (mClonedChild != nullptr) {
return sp<Layer>::fromExisting(this);
@@ -2865,9 +2865,13 @@
void Layer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
for (const auto& handle : mDrawingState.callbackHandles) {
- handle->transformHint = mSkipReportingTransformHint
- ? std::nullopt
- : std::make_optional<uint32_t>(mTransformHint);
+ if (mFlinger->mLayerLifecycleManagerEnabled) {
+ handle->transformHint = mTransformHint;
+ } else {
+ handle->transformHint = mSkipReportingTransformHint
+ ? std::nullopt
+ : std::make_optional<uint32_t>(mTransformHintLegacy);
+ }
handle->dequeueReadyTime = dequeueReadyTime;
handle->currentMaxAcquiredBufferCount =
mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(mOwnerUid);
@@ -3141,11 +3145,11 @@
}
bool Layer::setExtendedRangeBrightness(float currentBufferRatio, float desiredRatio) {
- if (mDrawingState.currentSdrHdrRatio == currentBufferRatio &&
- mDrawingState.desiredSdrHdrRatio == desiredRatio)
+ if (mDrawingState.currentHdrSdrRatio == currentBufferRatio &&
+ mDrawingState.desiredHdrSdrRatio == desiredRatio)
return false;
- mDrawingState.currentSdrHdrRatio = currentBufferRatio;
- mDrawingState.desiredSdrHdrRatio = desiredRatio;
+ mDrawingState.currentHdrSdrRatio = currentBufferRatio;
+ mDrawingState.desiredHdrSdrRatio = desiredRatio;
mDrawingState.modified = true;
setTransactionFlags(eTransactionNeeded);
return true;
@@ -3400,8 +3404,8 @@
if (lastDataspace != mBufferInfo.mDataspace) {
mFlinger->mHdrLayerInfoChanged = true;
}
- if (mBufferInfo.mDesiredSdrHdrRatio != mDrawingState.desiredSdrHdrRatio) {
- mBufferInfo.mDesiredSdrHdrRatio = mDrawingState.desiredSdrHdrRatio;
+ if (mBufferInfo.mDesiredHdrSdrRatio != mDrawingState.desiredHdrSdrRatio) {
+ mBufferInfo.mDesiredHdrSdrRatio = mDrawingState.desiredHdrSdrRatio;
mFlinger->mHdrLayerInfoChanged = true;
}
mBufferInfo.mCrop = computeBufferCrop(mDrawingState);
@@ -3462,20 +3466,46 @@
}
/**
+ * Returns the bounds used to fill the input frame and the touchable region.
+ *
* Similar to getInputTransform, we need to update the bounds to include the transform.
* This is because bounds don't include the buffer transform, where the input assumes
* that's already included.
*/
-Rect Layer::getInputBounds() const {
- if (!hasBufferOrSidebandStream()) {
- return getCroppedBufferSize(getDrawingState());
+std::pair<FloatRect, bool> Layer::getInputBounds(bool fillParentBounds) const {
+ Rect croppedBufferSize = getCroppedBufferSize(getDrawingState());
+ FloatRect inputBounds = croppedBufferSize.toFloatRect();
+ if (hasBufferOrSidebandStream() && croppedBufferSize.isValid() &&
+ mDrawingState.transform.getType() != ui::Transform::IDENTITY) {
+ inputBounds = mDrawingState.transform.transform(inputBounds);
}
- Rect bufferBounds = getCroppedBufferSize(getDrawingState());
- if (mDrawingState.transform.getType() == ui::Transform::IDENTITY || !bufferBounds.isValid()) {
- return bufferBounds;
+ bool inputBoundsValid = croppedBufferSize.isValid();
+ if (!inputBoundsValid) {
+ /**
+ * Input bounds are based on the layer crop or buffer size. But if we are using
+ * the layer bounds as the input bounds (replaceTouchableRegionWithCrop flag) then
+ * we can use the parent bounds as the input bounds if the layer does not have buffer
+ * or a crop. We want to unify this logic but because of compat reasons we cannot always
+ * use the parent bounds. A layer without a buffer can get input. So when a window is
+ * initially added, its touchable region can fill its parent layer bounds and that can
+ * have negative consequences.
+ */
+ inputBounds = fillParentBounds ? mBounds : FloatRect{};
}
- return mDrawingState.transform.transform(bufferBounds);
+
+ // Clamp surface inset to the input bounds.
+ const float inset = static_cast<float>(mDrawingState.inputInfo.surfaceInset);
+ const float xSurfaceInset = std::clamp(inset, 0.f, inputBounds.getWidth() / 2.f);
+ const float ySurfaceInset = std::clamp(inset, 0.f, inputBounds.getHeight() / 2.f);
+
+ // Apply the insets to the input bounds.
+ inputBounds.left += xSurfaceInset;
+ inputBounds.top += ySurfaceInset;
+ inputBounds.right -= xSurfaceInset;
+ inputBounds.bottom -= ySurfaceInset;
+
+ return {inputBounds, inputBoundsValid};
}
bool Layer::simpleBufferUpdate(const layer_state_t& s) const {
@@ -3661,9 +3691,9 @@
}
if (s.what & layer_state_t::eExtendedRangeBrightnessChanged) {
- if (mDrawingState.currentSdrHdrRatio != s.currentSdrHdrRatio ||
- mDrawingState.desiredSdrHdrRatio != s.desiredSdrHdrRatio) {
- ALOGV("%s: false [eDimmingEnabledChanged changed]", __func__);
+ if (mDrawingState.currentHdrSdrRatio != s.currentHdrSdrRatio ||
+ mDrawingState.desiredHdrSdrRatio != s.desiredHdrSdrRatio) {
+ ALOGV("%s: false [eExtendedRangeBrightnessChanged changed]", __func__);
return false;
}
}
@@ -4001,10 +4031,10 @@
return mBufferInfo.mBuffer ? mBufferInfo.mBuffer->getBuffer() : nullptr;
}
-void Layer::setTransformHint(ui::Transform::RotationFlags displayTransformHint) {
- mTransformHint = getFixedTransformHint();
- if (mTransformHint == ui::Transform::ROT_INVALID) {
- mTransformHint = displayTransformHint;
+void Layer::setTransformHintLegacy(ui::Transform::RotationFlags displayTransformHint) {
+ mTransformHintLegacy = getFixedTransformHint();
+ if (mTransformHintLegacy == ui::Transform::ROT_INVALID) {
+ mTransformHintLegacy = displayTransformHint;
}
mSkipReportingTransformHint = false;
}
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index f7e1969..1af648a 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -225,8 +225,8 @@
gui::DropInputMode dropInputMode;
bool autoRefresh = false;
bool dimmingEnabled = true;
- float currentSdrHdrRatio = 1.f;
- float desiredSdrHdrRatio = 1.f;
+ float currentHdrSdrRatio = 1.f;
+ float desiredHdrSdrRatio = 1.f;
gui::CachingHint cachingHint = gui::CachingHint::Enabled;
int64_t latchedVsyncId = 0;
};
@@ -296,8 +296,8 @@
virtual bool hasColorTransform() const;
virtual bool isColorSpaceAgnostic() const { return mDrawingState.colorSpaceAgnostic; }
virtual bool isDimmingEnabled() const { return getDrawingState().dimmingEnabled; }
- float getDesiredSdrHdrRatio() const { return getDrawingState().desiredSdrHdrRatio; }
- float getCurrentSdrHdrRatio() const { return getDrawingState().currentSdrHdrRatio; }
+ float getDesiredHdrSdrRatio() const { return getDrawingState().desiredHdrSdrRatio; }
+ float getCurrentHdrSdrRatio() const { return getDrawingState().currentHdrSdrRatio; }
gui::CachingHint getCachingHint() const { return getDrawingState().cachingHint; }
bool setTransform(uint32_t /*transform*/);
@@ -455,8 +455,6 @@
sp<GraphicBuffer> getBuffer() const;
const std::shared_ptr<renderengine::ExternalTexture>& getExternalTexture() const;
- ui::Transform::RotationFlags getTransformHint() const { return mTransformHint; }
-
/*
* Returns if a frame is ready
*/
@@ -519,7 +517,7 @@
uint64_t mFrameNumber;
bool mFrameLatencyNeeded{false};
- float mDesiredSdrHdrRatio = 1.f;
+ float mDesiredHdrSdrRatio = 1.f;
};
BufferInfo mBufferInfo;
@@ -570,6 +568,8 @@
FloatRect getBounds(const Region& activeTransparentRegion) const;
FloatRect getBounds() const;
+ Rect getInputBoundsInDisplaySpace(const FloatRect& insetBounds,
+ const ui::Transform& displayTransform);
// Compute bounds for the layer and cache the results.
void computeBounds(FloatRect parentBounds, ui::Transform parentTransform, float shadowRadius);
@@ -700,6 +700,7 @@
void traverse(LayerVector::StateSet, const LayerVector::Visitor&);
void traverseInReverseZOrder(LayerVector::StateSet, const LayerVector::Visitor&);
void traverseInZOrder(LayerVector::StateSet, const LayerVector::Visitor&);
+ void traverseChildren(const LayerVector::Visitor&);
/**
* Traverse only children in z order, ignoring relative layers that are not children of the
@@ -707,7 +708,10 @@
*/
void traverseChildrenInZOrder(LayerVector::StateSet, const LayerVector::Visitor&);
- size_t getChildrenCount() const;
+ size_t getDescendantCount() const;
+ size_t getChildrenCount() const { return mDrawingChildren.size(); }
+ bool isHandleAlive() const { return mHandleAlive; }
+ bool onHandleDestroyed() { return mHandleAlive = false; }
// ONLY CALL THIS FROM THE LAYER DTOR!
// See b/141111965. We need to add current children to offscreen layers in
@@ -872,6 +876,9 @@
};
};
bool hasBuffer() const { return mBufferInfo.mBuffer != nullptr; }
+ void setTransformHint(std::optional<ui::Transform::RotationFlags> transformHint) {
+ mTransformHint = transformHint;
+ }
protected:
// For unit tests
@@ -932,7 +939,7 @@
* "replaceTouchableRegionWithCrop" is specified. In this case, the layer will receive input
* in this layer's space, regardless of the specified crop layer.
*/
- Rect getInputBounds() const;
+ std::pair<FloatRect, bool> getInputBounds(bool fillParentBounds) const;
// constant
sp<SurfaceFlinger> mFlinger;
@@ -1148,14 +1155,15 @@
float mBorderWidth;
half4 mBorderColor;
- void setTransformHint(ui::Transform::RotationFlags);
+ void setTransformHintLegacy(ui::Transform::RotationFlags);
const uint32_t mTextureName;
// Transform hint provided to the producer. This must be accessed holding
// the mStateLock.
- ui::Transform::RotationFlags mTransformHint = ui::Transform::ROT_0;
+ ui::Transform::RotationFlags mTransformHintLegacy = ui::Transform::ROT_0;
bool mSkipReportingTransformHint = true;
+ std::optional<ui::Transform::RotationFlags> mTransformHint = std::nullopt;
ReleaseCallbackId mPreviousReleaseCallbackId = ReleaseCallbackId::INVALID_ID;
uint64_t mPreviousReleasedFrameNumber = 0;
@@ -1192,6 +1200,7 @@
std::vector<std::pair<frontend::LayerHierarchy::TraversalPath, sp<LayerFE>>> mLayerFEs;
std::unique_ptr<frontend::LayerSnapshot> mSnapshot =
std::make_unique<frontend::LayerSnapshot>();
+ bool mHandleAlive = false;
};
std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate);
diff --git a/services/surfaceflinger/LayerProtoHelper.cpp b/services/surfaceflinger/LayerProtoHelper.cpp
index 5c91b91..b5ae1a7 100644
--- a/services/surfaceflinger/LayerProtoHelper.cpp
+++ b/services/surfaceflinger/LayerProtoHelper.cpp
@@ -15,6 +15,8 @@
*/
// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#include "FrontEnd/LayerCreationArgs.h"
+#include "FrontEnd/LayerSnapshot.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wextra"
@@ -248,47 +250,88 @@
outRegion.bottom = proto.bottom();
}
-void LayerProtoHelper::writeHierarchyToProto(
- LayersProto& outLayersProto, const frontend::LayerHierarchy& root,
- const frontend::LayerSnapshotBuilder& snapshotBuilder,
- const std::unordered_map<uint32_t, sp<Layer>>& legacyLayers, uint32_t traceFlags) {
- using Variant = frontend::LayerHierarchy::Variant;
- frontend::LayerSnapshot defaultSnapshot;
-
- LayerProto* layerProto = outLayersProto.add_layers();
- const frontend::RequestedLayerState& layer = *root.getLayer();
- frontend::LayerSnapshot* snapshot = snapshotBuilder.getSnapshot(layer.id);
-
- if (!snapshot) {
- defaultSnapshot.uniqueSequence = layer.id;
- snapshot = &defaultSnapshot;
- }
- writeSnapshotToProto(layerProto, layer, *snapshot, traceFlags);
- for (const auto& [child, variant] : root.mChildren) {
- if (variant == Variant::Attached || variant == Variant::Detached) {
- layerProto->add_children(child->getLayer()->id);
- } else if (variant == Variant::Relative) {
- layerProto->add_relatives(child->getLayer()->id);
+LayersProto LayerProtoFromSnapshotGenerator::generate(const frontend::LayerHierarchy& root) {
+ mLayersProto.clear_layers();
+ std::unordered_set<uint64_t> stackIdsToSkip;
+ if ((mTraceFlags & LayerTracing::TRACE_VIRTUAL_DISPLAYS) == 0) {
+ for (const auto& [layerStack, displayInfo] : mDisplayInfos) {
+ if (displayInfo.isVirtual) {
+ stackIdsToSkip.insert(layerStack.id);
+ }
}
}
- auto parent = root.getParent();
- if (parent && parent->getLayer()) {
- layerProto->set_parent(parent->getLayer()->id);
- } else {
- layerProto->set_parent(-1);
+ frontend::LayerHierarchy::TraversalPath path = frontend::LayerHierarchy::TraversalPath::ROOT;
+ for (auto& [child, variant] : root.mChildren) {
+ if (variant != frontend::LayerHierarchy::Variant::Attached ||
+ stackIdsToSkip.find(child->getLayer()->layerStack.id) != stackIdsToSkip.end()) {
+ continue;
+ }
+ frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path,
+ child->getLayer()->id,
+ variant);
+ LayerProtoFromSnapshotGenerator::writeHierarchyToProto(*child, path);
}
- auto relativeParent = root.getRelativeParent();
- if (relativeParent && relativeParent->getLayer()) {
- layerProto->set_z_order_relative_of(relativeParent->getLayer()->id);
- } else {
- layerProto->set_z_order_relative_of(-1);
+ // fill in relative and parent info
+ for (int i = 0; i < mLayersProto.layers_size(); i++) {
+ auto layerProto = mLayersProto.mutable_layers()->Mutable(i);
+ auto it = mChildToRelativeParent.find(layerProto->id());
+ if (it == mChildToRelativeParent.end()) {
+ layerProto->set_z_order_relative_of(-1);
+ } else {
+ layerProto->set_z_order_relative_of(it->second);
+ }
+ it = mChildToParent.find(layerProto->id());
+ if (it == mChildToParent.end()) {
+ layerProto->set_parent(-1);
+ } else {
+ layerProto->set_parent(it->second);
+ }
}
- if (traceFlags & LayerTracing::TRACE_COMPOSITION) {
- auto it = legacyLayers.find(layer.id);
- if (it != legacyLayers.end()) {
+ mDefaultSnapshots.clear();
+ mChildToRelativeParent.clear();
+ return std::move(mLayersProto);
+}
+
+frontend::LayerSnapshot* LayerProtoFromSnapshotGenerator::getSnapshot(
+ frontend::LayerHierarchy::TraversalPath& path, const frontend::RequestedLayerState& layer) {
+ frontend::LayerSnapshot* snapshot = mSnapshotBuilder.getSnapshot(path);
+ if (snapshot) {
+ return snapshot;
+ } else {
+ mDefaultSnapshots[path] = frontend::LayerSnapshot(layer, path);
+ return &mDefaultSnapshots[path];
+ }
+}
+
+void LayerProtoFromSnapshotGenerator::writeHierarchyToProto(
+ const frontend::LayerHierarchy& root, frontend::LayerHierarchy::TraversalPath& path) {
+ using Variant = frontend::LayerHierarchy::Variant;
+ LayerProto* layerProto = mLayersProto.add_layers();
+ const frontend::RequestedLayerState& layer = *root.getLayer();
+ frontend::LayerSnapshot* snapshot = getSnapshot(path, layer);
+ LayerProtoHelper::writeSnapshotToProto(layerProto, layer, *snapshot, mTraceFlags);
+
+ for (const auto& [child, variant] : root.mChildren) {
+ frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path,
+ child->getLayer()->id,
+ variant);
+ frontend::LayerSnapshot* childSnapshot = getSnapshot(path, layer);
+ if (variant == Variant::Attached || variant == Variant::Detached ||
+ variant == Variant::Mirror) {
+ mChildToParent[childSnapshot->uniqueSequence] = snapshot->uniqueSequence;
+ layerProto->add_children(childSnapshot->uniqueSequence);
+ } else if (variant == Variant::Relative) {
+ mChildToRelativeParent[childSnapshot->uniqueSequence] = snapshot->uniqueSequence;
+ layerProto->add_relatives(childSnapshot->uniqueSequence);
+ }
+ }
+
+ if (mTraceFlags & LayerTracing::TRACE_COMPOSITION) {
+ auto it = mLegacyLayers.find(layer.id);
+ if (it != mLegacyLayers.end()) {
it->second->writeCompositionStateToProto(layerProto);
}
}
@@ -298,7 +341,10 @@
if (variant == Variant::Detached) {
continue;
}
- writeHierarchyToProto(outLayersProto, *child, snapshotBuilder, legacyLayers, traceFlags);
+ frontend::LayerHierarchy::ScopedAddToTraversalPath addChildToPath(path,
+ child->getLayer()->id,
+ variant);
+ writeHierarchyToProto(*child, path);
}
}
@@ -345,6 +391,7 @@
layerInfo->set_shadow_radius(snapshot.shadowRadius);
layerInfo->set_id(snapshot.uniqueSequence);
+ layerInfo->set_original_id(snapshot.sequence);
layerInfo->set_name(requestedState.name);
layerInfo->set_type("Layer");
diff --git a/services/surfaceflinger/LayerProtoHelper.h b/services/surfaceflinger/LayerProtoHelper.h
index 38d73f6..b84a49b 100644
--- a/services/surfaceflinger/LayerProtoHelper.h
+++ b/services/surfaceflinger/LayerProtoHelper.h
@@ -25,6 +25,9 @@
#include <ui/Rect.h>
#include <ui/Region.h>
#include <ui/Transform.h>
+#include <cstdint>
+#include "FrontEnd/LayerHierarchy.h"
+#include "FrontEnd/LayerSnapshot.h"
namespace android {
namespace surfaceflinger {
@@ -58,11 +61,6 @@
static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix);
static void writeToProto(const android::BlurRegion region, BlurRegion*);
static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion);
- static void writeHierarchyToProto(LayersProto& layersProto,
- const frontend::LayerHierarchy& root,
- const frontend::LayerSnapshotBuilder& snapshotBuilder,
- const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers,
- uint32_t traceFlags);
static void writeSnapshotToProto(LayerProto* outProto,
const frontend::RequestedLayerState& requestedState,
const frontend::LayerSnapshot& snapshot, uint32_t traceFlags);
@@ -70,5 +68,38 @@
const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos);
};
+class LayerProtoFromSnapshotGenerator {
+public:
+ LayerProtoFromSnapshotGenerator(
+ const frontend::LayerSnapshotBuilder& snapshotBuilder,
+ const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displayInfos,
+ const std::unordered_map<uint32_t, sp<Layer>>& legacyLayers, uint32_t traceFlags)
+ : mSnapshotBuilder(snapshotBuilder),
+ mLegacyLayers(legacyLayers),
+ mDisplayInfos(displayInfos),
+ mTraceFlags(traceFlags) {}
+ LayersProto generate(const frontend::LayerHierarchy& root);
+
+private:
+ void writeHierarchyToProto(const frontend::LayerHierarchy& root,
+ frontend::LayerHierarchy::TraversalPath& path);
+ frontend::LayerSnapshot* getSnapshot(frontend::LayerHierarchy::TraversalPath& path,
+ const frontend::RequestedLayerState& layer);
+
+ const frontend::LayerSnapshotBuilder& mSnapshotBuilder;
+ const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers;
+ const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& mDisplayInfos;
+ uint32_t mTraceFlags;
+ LayersProto mLayersProto;
+ // winscope expects all the layers, so provide a snapshot even if it not currently drawing
+ std::unordered_map<frontend::LayerHierarchy::TraversalPath, frontend::LayerSnapshot,
+ frontend::LayerHierarchy::TraversalPathHash>
+ mDefaultSnapshots;
+ std::unordered_map<uint32_t /* child unique seq*/, uint32_t /* relative parent unique seq*/>
+ mChildToRelativeParent;
+ std::unordered_map<uint32_t /* child unique seq*/, uint32_t /* parent unique seq*/>
+ mChildToParent;
+};
+
} // namespace surfaceflinger
} // namespace android
diff --git a/services/surfaceflinger/LayerRenderArea.cpp b/services/surfaceflinger/LayerRenderArea.cpp
index 03a7f22..1b8ff28 100644
--- a/services/surfaceflinger/LayerRenderArea.cpp
+++ b/services/surfaceflinger/LayerRenderArea.cpp
@@ -39,9 +39,12 @@
LayerRenderArea::LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop,
ui::Size reqSize, ui::Dataspace reqDataSpace, bool childrenOnly,
- bool allowSecureLayers)
+ bool allowSecureLayers, const ui::Transform& layerTransform,
+ const Rect& layerBufferSize)
: RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, allowSecureLayers),
mLayer(std::move(layer)),
+ mLayerTransform(layerTransform),
+ mLayerBufferSize(layerBufferSize),
mCrop(crop),
mFlinger(flinger),
mChildrenOnly(childrenOnly) {}
@@ -60,7 +63,8 @@
Rect LayerRenderArea::getSourceCrop() const {
if (mCrop.isEmpty()) {
- return mLayer->getBufferSize(mLayer->getDrawingState());
+ // TODO this should probably be mBounds instead of just buffer bounds
+ return mLayerBufferSize;
} else {
return mCrop;
}
@@ -70,7 +74,7 @@
using namespace std::string_literals;
if (!mChildrenOnly) {
- mTransform = mLayer->getTransform().inverse();
+ mTransform = mLayerTransform.inverse();
}
if (mFlinger.mLayerLifecycleManagerEnabled) {
diff --git a/services/surfaceflinger/LayerRenderArea.h b/services/surfaceflinger/LayerRenderArea.h
index 322dbd1..9bb13b3 100644
--- a/services/surfaceflinger/LayerRenderArea.h
+++ b/services/surfaceflinger/LayerRenderArea.h
@@ -33,7 +33,8 @@
class LayerRenderArea : public RenderArea {
public:
LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop, ui::Size reqSize,
- ui::Dataspace reqDataSpace, bool childrenOnly, bool allowSecureLayers);
+ ui::Dataspace reqDataSpace, bool childrenOnly, bool allowSecureLayers,
+ const ui::Transform& layerTransform, const Rect& layerBufferSize);
const ui::Transform& getTransform() const override;
bool isSecure() const override;
@@ -45,6 +46,8 @@
private:
const sp<Layer> mLayer;
+ const ui::Transform mLayerTransform;
+ const Rect mLayerBufferSize;
const Rect mCrop;
ui::Transform mTransform;
diff --git a/services/surfaceflinger/OWNERS b/services/surfaceflinger/OWNERS
index 6011d0d..4e7da82 100644
--- a/services/surfaceflinger/OWNERS
+++ b/services/surfaceflinger/OWNERS
@@ -4,5 +4,7 @@
lpy@google.com
pdwilliams@google.com
racarr@google.com
+ramindani@google.com
+rnlee@google.com
scroggo@google.com
vishnun@google.com
diff --git a/services/surfaceflinger/Scheduler/Android.bp b/services/surfaceflinger/Scheduler/Android.bp
index 5bd8a99..d5d8688 100644
--- a/services/surfaceflinger/Scheduler/Android.bp
+++ b/services/surfaceflinger/Scheduler/Android.bp
@@ -60,7 +60,4 @@
"libgtest",
"libscheduler",
],
- sanitize: {
- address: true,
- },
}
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index f18dfdc..7f8d394 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -109,7 +109,6 @@
void Scheduler::setPacesetterDisplay(std::optional<PhysicalDisplayId> pacesetterIdOpt) {
demotePacesetterDisplay();
- std::scoped_lock lock(mDisplayLock);
promotePacesetterDisplay(pacesetterIdOpt);
}
@@ -123,26 +122,34 @@
std::shared_ptr<VsyncSchedule> vsyncSchedule) {
demotePacesetterDisplay();
- std::scoped_lock lock(mDisplayLock);
- mRefreshRateSelectors.emplace_or_replace(displayId, std::move(selectorPtr));
- mVsyncSchedules.emplace_or_replace(displayId, std::move(vsyncSchedule));
+ std::shared_ptr<VsyncSchedule> pacesetterVsyncSchedule;
+ {
+ std::scoped_lock lock(mDisplayLock);
+ mRefreshRateSelectors.emplace_or_replace(displayId, std::move(selectorPtr));
+ mVsyncSchedules.emplace_or_replace(displayId, std::move(vsyncSchedule));
- promotePacesetterDisplay();
+ pacesetterVsyncSchedule = promotePacesetterDisplayLocked();
+ }
+ applyNewVsyncSchedule(std::move(pacesetterVsyncSchedule));
}
void Scheduler::unregisterDisplay(PhysicalDisplayId displayId) {
demotePacesetterDisplay();
- std::scoped_lock lock(mDisplayLock);
- mRefreshRateSelectors.erase(displayId);
- mVsyncSchedules.erase(displayId);
+ std::shared_ptr<VsyncSchedule> pacesetterVsyncSchedule;
+ {
+ std::scoped_lock lock(mDisplayLock);
+ mRefreshRateSelectors.erase(displayId);
+ mVsyncSchedules.erase(displayId);
- // Do not allow removing the final display. Code in the scheduler expects
- // there to be at least one display. (This may be relaxed in the future with
- // headless virtual display.)
- LOG_ALWAYS_FATAL_IF(mRefreshRateSelectors.empty(), "Cannot unregister all displays!");
+ // Do not allow removing the final display. Code in the scheduler expects
+ // there to be at least one display. (This may be relaxed in the future with
+ // headless virtual display.)
+ LOG_ALWAYS_FATAL_IF(mRefreshRateSelectors.empty(), "Cannot unregister all displays!");
- promotePacesetterDisplay();
+ pacesetterVsyncSchedule = promotePacesetterDisplayLocked();
+ }
+ applyNewVsyncSchedule(std::move(pacesetterVsyncSchedule));
}
void Scheduler::run() {
@@ -678,6 +685,18 @@
}
void Scheduler::promotePacesetterDisplay(std::optional<PhysicalDisplayId> pacesetterIdOpt) {
+ std::shared_ptr<VsyncSchedule> pacesetterVsyncSchedule;
+
+ {
+ std::scoped_lock lock(mDisplayLock);
+ pacesetterVsyncSchedule = promotePacesetterDisplayLocked(pacesetterIdOpt);
+ }
+
+ applyNewVsyncSchedule(std::move(pacesetterVsyncSchedule));
+}
+
+std::shared_ptr<VsyncSchedule> Scheduler::promotePacesetterDisplayLocked(
+ std::optional<PhysicalDisplayId> pacesetterIdOpt) {
// TODO(b/241286431): Choose the pacesetter display.
mPacesetterDisplayId = pacesetterIdOpt.value_or(mRefreshRateSelectors.begin()->first);
ALOGI("Display %s is the pacesetter", to_string(*mPacesetterDisplayId).c_str());
@@ -697,14 +716,22 @@
vsyncSchedule->startPeriodTransition(mSchedulerCallback, refreshRate.getPeriod(),
true /* force */);
}
+ return vsyncSchedule;
+}
+void Scheduler::applyNewVsyncSchedule(std::shared_ptr<VsyncSchedule> vsyncSchedule) {
onNewVsyncSchedule(vsyncSchedule->getDispatch());
+ std::vector<android::EventThread*> threads;
{
std::lock_guard<std::mutex> lock(mConnectionsLock);
+ threads.reserve(mConnections.size());
for (auto& [_, connection] : mConnections) {
- connection.thread->onNewVsyncSchedule(vsyncSchedule);
+ threads.push_back(connection.thread.get());
}
}
+ for (auto* thread : threads) {
+ thread->onNewVsyncSchedule(vsyncSchedule);
+ }
}
void Scheduler::demotePacesetterDisplay() {
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 74547d5..3423652 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -321,7 +321,18 @@
// Chooses a pacesetter among the registered displays, unless `pacesetterIdOpt` is specified.
// The new `mPacesetterDisplayId` is never `std::nullopt`.
void promotePacesetterDisplay(std::optional<PhysicalDisplayId> pacesetterIdOpt = std::nullopt)
+ REQUIRES(kMainThreadContext) EXCLUDES(mDisplayLock);
+
+ // Changes to the displays (e.g. registering and unregistering) must be made
+ // while mDisplayLock is locked, and the new pacesetter then must be promoted while
+ // mDisplayLock is still locked. However, a new pacesetter means that
+ // MessageQueue and EventThread need to use the new pacesetter's
+ // VsyncSchedule, and this must happen while mDisplayLock is *not* locked,
+ // or else we may deadlock with EventThread.
+ std::shared_ptr<VsyncSchedule> promotePacesetterDisplayLocked(
+ std::optional<PhysicalDisplayId> pacesetterIdOpt = std::nullopt)
REQUIRES(kMainThreadContext, mDisplayLock);
+ void applyNewVsyncSchedule(std::shared_ptr<VsyncSchedule>) EXCLUDES(mDisplayLock);
// Blocks until the pacesetter's idle timer thread exits. `mDisplayLock` must not be locked by
// the caller on the main thread to avoid deadlock, since the timer thread locks it before exit.
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 639ea27..a31f681 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2532,8 +2532,6 @@
}
updateCursorAsync();
- updateInputFlinger();
-
if (mLayerTracingEnabled && !mLayerTracing.flagIsSet(LayerTracing::TRACE_COMPOSITION)) {
// This will block and tracing should only be enabled for debugging.
addToLayerTracing(mVisibleRegionsDirty, frameTime.ns(), vsyncId.value);
@@ -2763,7 +2761,7 @@
// RANGE_EXTENDED layers may identify themselves as being "HDR" via a desired sdr/hdr ratio
if ((snapshot.dataspace & (int32_t)Dataspace::RANGE_MASK) ==
(int32_t)Dataspace::RANGE_EXTENDED &&
- snapshot.desiredSdrHdrRatio > 1.01f) {
+ snapshot.desiredHdrSdrRatio > 1.01f) {
return true;
}
return false;
@@ -2863,6 +2861,11 @@
layer->releasePendingBuffer(presentTime.ns());
}
+ mTransactionCallbackInvoker.addPresentFence(std::move(presentFence));
+ mTransactionCallbackInvoker.sendCallbacks(false /* onCommitOnly */);
+ mTransactionCallbackInvoker.clearCompletedTransactions();
+ updateInputFlinger();
+
std::vector<std::pair<std::shared_ptr<compositionengine::Display>, sp<HdrLayerInfoReporter>>>
hdrInfoListeners;
bool haveNewListeners = false;
@@ -2900,11 +2903,9 @@
const auto* outputLayer =
compositionDisplay->getOutputLayerForLayer(layerFe);
if (outputLayer) {
- // TODO(b/267350616): Rename SdrHdrRatio -> HdrSdrRatio
- // everywhere
- const float desiredHdrSdrRatio = snapshot.desiredSdrHdrRatio <= 1.f
+ const float desiredHdrSdrRatio = snapshot.desiredHdrSdrRatio <= 1.f
? std::numeric_limits<float>::infinity()
- : snapshot.desiredSdrHdrRatio;
+ : snapshot.desiredHdrSdrRatio;
info.mergeDesiredRatio(desiredHdrSdrRatio);
info.numberOfHdrLayers++;
const auto displayFrame = outputLayer->getState().displayFrame;
@@ -2924,10 +2925,6 @@
mHdrLayerInfoChanged = false;
- mTransactionCallbackInvoker.addPresentFence(std::move(presentFence));
- mTransactionCallbackInvoker.sendCallbacks(false /* onCommitOnly */);
- mTransactionCallbackInvoker.clearCompletedTransactions();
-
mTimeStats->incrementTotalFrames();
mTimeStats->setPresentFenceGlobal(presentFenceTime);
@@ -4093,8 +4090,34 @@
ALOGE("AddClientLayer failed, mNumLayers (%zu) >= MAX_LAYERS (%zu)", mNumLayers.load(),
MAX_LAYERS);
static_cast<void>(mScheduler->schedule([=] {
+ ALOGE("Dumping layer keeping > 20 children alive:");
+ bool leakingParentLayerFound = false;
+ mDrawingState.traverse([&](Layer* layer) {
+ if (leakingParentLayerFound) {
+ return;
+ }
+ if (layer->getChildrenCount() > 20) {
+ leakingParentLayerFound = true;
+ sp<Layer> parent = sp<Layer>::fromExisting(layer);
+ while (parent) {
+ ALOGE("Parent Layer: %s handleIsAlive: %s", parent->getName().c_str(),
+ std::to_string(parent->isHandleAlive()).c_str());
+ parent = parent->getParent();
+ }
+ // Sample up to 100 layers
+ ALOGE("Dumping random sampling of child layers total(%zu): ",
+ layer->getChildrenCount());
+ int sampleSize = (layer->getChildrenCount() / 100) + 1;
+ layer->traverseChildren([&](Layer* layer) {
+ if (rand() % sampleSize == 0) {
+ ALOGE("Child Layer: %s", layer->getName().c_str());
+ }
+ });
+ }
+ });
+
ALOGE("Dumping random sampling of on-screen layers: ");
- mDrawingState.traverse([&](Layer *layer) {
+ mDrawingState.traverse([&](Layer* layer) {
// Aim to dump about 200 layers to avoid totally trashing
// logcat. On the other hand, if there really are 4096 layers
// something has gone totally wrong its probably the most
@@ -4103,6 +4126,8 @@
ALOGE("Layer: %s", layer->getName().c_str());
}
});
+ ALOGE("Dumping random sampling of off-screen layers total(%zu): ",
+ mOffscreenLayers.size());
for (Layer* offscreenLayer : mOffscreenLayers) {
if (rand() % 20 == 13) {
ALOGE("Offscreen-layer: %s", offscreenLayer->getName().c_str());
@@ -4931,7 +4956,7 @@
if (layer->setDimmingEnabled(s.dimmingEnabled)) flags |= eTraversalNeeded;
}
if (what & layer_state_t::eExtendedRangeBrightnessChanged) {
- if (layer->setExtendedRangeBrightness(s.currentSdrHdrRatio, s.desiredSdrHdrRatio)) {
+ if (layer->setExtendedRangeBrightness(s.currentHdrSdrRatio, s.desiredHdrSdrRatio)) {
flags |= eTraversalNeeded;
}
}
@@ -5106,6 +5131,12 @@
if (layer->setSidebandStream(s.sidebandStream)) flags |= eTraversalNeeded;
}
if (what & layer_state_t::eBufferChanged) {
+ std::optional<ui::Transform::RotationFlags> transformHint = std::nullopt;
+ frontend::LayerSnapshot* snapshot = mLayerSnapshotBuilder.getSnapshot(layer->sequence);
+ if (snapshot) {
+ transformHint = snapshot->transformHint;
+ }
+ layer->setTransformHint(transformHint);
if (layer->setBuffer(composerState.externalTexture, *s.bufferData, postTime,
desiredPresentTime, isAutoTimestamp, dequeueBufferTimestamp,
frameTimelineInfo)) {
@@ -5299,6 +5330,7 @@
Mutex::Autolock lock(mStateLock);
markLayerPendingRemovalLocked(layer);
+ layer->onHandleDestroyed();
mBufferCountTracker.remove(handle);
layer.clear();
@@ -5791,17 +5823,9 @@
return layersProto;
}
- const frontend::LayerHierarchy& root = mLayerHierarchyBuilder.getHierarchy();
- LayersProto layersProto;
- for (auto& [child, variant] : root.mChildren) {
- if (variant != frontend::LayerHierarchy::Variant::Attached ||
- stackIdsToSkip.find(child->getLayer()->layerStack.id) != stackIdsToSkip.end()) {
- continue;
- }
- LayerProtoHelper::writeHierarchyToProto(layersProto, *child, mLayerSnapshotBuilder,
- mLegacyLayers, traceFlags);
- }
- return layersProto;
+ return LayerProtoFromSnapshotGenerator(mLayerSnapshotBuilder, mFrontEndDisplayInfos, {},
+ traceFlags)
+ .generate(mLayerHierarchyBuilder.getHierarchy());
}
google::protobuf::RepeatedPtrField<DisplayProto> SurfaceFlinger::dumpDisplayProto() const {
@@ -7027,13 +7051,34 @@
bool childrenOnly = args.childrenOnly;
RenderAreaFuture renderAreaFuture = ftl::defer([=]() -> std::unique_ptr<RenderArea> {
+ ui::Transform layerTransform;
+ Rect layerBufferSize;
+ if (mLayerLifecycleManagerEnabled) {
+ frontend::LayerSnapshot* snapshot =
+ mLayerSnapshotBuilder.getSnapshot(parent->getSequence());
+ if (!snapshot) {
+ ALOGW("Couldn't find layer snapshot for %d", parent->getSequence());
+ } else {
+ layerTransform = snapshot->localTransform;
+ layerBufferSize = snapshot->bufferSize;
+ }
+ } else {
+ layerTransform = parent->getTransform();
+ layerBufferSize = parent->getBufferSize(parent->getDrawingState());
+ }
+
return std::make_unique<LayerRenderArea>(*this, parent, crop, reqSize, dataspace,
- childrenOnly, args.captureSecureLayers);
+ childrenOnly, args.captureSecureLayers,
+ layerTransform, layerBufferSize);
});
GetLayerSnapshotsFunction getLayerSnapshots;
if (mLayerLifecycleManagerEnabled) {
- FloatRect parentCrop = crop.isEmpty() ? FloatRect(0, 0, reqSize.width, reqSize.height)
- : crop.toFloatRect();
+ std::optional<FloatRect> parentCrop = std::nullopt;
+ if (args.childrenOnly) {
+ parentCrop = crop.isEmpty() ? FloatRect(0, 0, reqSize.width, reqSize.height)
+ : crop.toFloatRect();
+ }
+
getLayerSnapshots = getLayerSnapshotsForScreenshots(parent->sequence, args.uid,
std::move(excludeLayerIds),
args.childrenOnly, parentCrop);
@@ -7983,7 +8028,7 @@
if (layerStack && snapshot->outputFilter.layerStack != *layerStack) {
return;
}
- if (uid != CaptureArgs::UNSET_UID && snapshot->inputInfo.ownerUid != uid) {
+ if (uid != CaptureArgs::UNSET_UID && snapshot->uid != uid) {
return;
}
if (!snapshot->hasSomethingToDraw()) {
@@ -8010,7 +8055,8 @@
std::function<std::vector<std::pair<Layer*, sp<LayerFE>>>()>
SurfaceFlinger::getLayerSnapshotsForScreenshots(uint32_t rootLayerId, uint32_t uid,
std::unordered_set<uint32_t> excludeLayerIds,
- bool childrenOnly, const FloatRect& parentCrop) {
+ bool childrenOnly,
+ const std::optional<FloatRect>& parentCrop) {
return [&, rootLayerId, uid, excludeLayerIds = std::move(excludeLayerIds), childrenOnly,
parentCrop]() {
auto root = mLayerHierarchyBuilder.getPartialHierarchy(rootLayerId, childrenOnly);
@@ -8023,7 +8069,7 @@
.globalShadowSettings = mDrawingState.globalShadowSettings,
.supportsBlur = mSupportsBlur,
.forceFullDamage = mForceFullDamage,
- .parentCrop = {parentCrop},
+ .parentCrop = parentCrop,
.excludeLayerIds = std::move(excludeLayerIds),
.supportedLayerGenericMetadata =
getHwComposer().getSupportedLayerGenericMetadata(),
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 42d5db7..74d00dd 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1382,7 +1382,7 @@
snapshotFilterFn);
std::function<std::vector<std::pair<Layer*, sp<LayerFE>>>()> getLayerSnapshotsForScreenshots(
uint32_t rootLayerId, uint32_t uid, std::unordered_set<uint32_t> excludeLayerIds,
- bool childrenOnly, const FloatRect& parentCrop);
+ bool childrenOnly, const std::optional<FloatRect>& optionalParentCrop);
const sp<WindowInfosListenerInvoker> mWindowInfosListenerInvoker;
diff --git a/services/surfaceflinger/TEST_MAPPING b/services/surfaceflinger/TEST_MAPPING
index cab33ae..57752b7 100644
--- a/services/surfaceflinger/TEST_MAPPING
+++ b/services/surfaceflinger/TEST_MAPPING
@@ -5,6 +5,14 @@
},
{
"name": "libcompositionengine_test"
+ },
+ {
+ "name": "libscheduler_test"
+ }
+ ],
+ "hwasan-presubmit": [
+ {
+ "name": "libscheduler_test"
}
]
}
diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
index 8fd6538..593c4ff 100644
--- a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
+++ b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
@@ -27,9 +27,7 @@
namespace android::surfaceflinger {
class FakeExternalTexture : public renderengine::ExternalTexture {
- const sp<GraphicBuffer> mEmptyBuffer =
- sp<GraphicBuffer>::make(1u, 1u, PIXEL_FORMAT_RGBA_8888,
- GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN);
+ const sp<GraphicBuffer> mEmptyBuffer = nullptr;
uint32_t mWidth;
uint32_t mHeight;
uint64_t mId;
@@ -587,7 +585,7 @@
displayInfo.receivesInput = proto.receives_input();
displayInfo.isSecure = proto.is_secure();
displayInfo.isPrimary = proto.is_primary();
- displayInfo.isPrimary = proto.is_virtual();
+ displayInfo.isVirtual = proto.is_virtual();
displayInfo.rotationFlags = (ui::Transform::RotationFlags)proto.rotation_flags();
displayInfo.transformHint = (ui::Transform::RotationFlags)proto.transform_hint();
return displayInfo;
@@ -595,7 +593,7 @@
void TransactionProtoParser::fromProto(
const google::protobuf::RepeatedPtrField<proto::DisplayInfo>& proto,
- display::DisplayMap<ui::LayerStack, frontend::DisplayInfo> outDisplayInfos) {
+ display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& outDisplayInfos) {
outDisplayInfos.clear();
for (const proto::DisplayInfo& displayInfo : proto) {
outDisplayInfos.emplace_or_replace(ui::LayerStack::fromValue(displayInfo.layer_stack()),
diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.h b/services/surfaceflinger/Tracing/TransactionProtoParser.h
index 50944fc..d6c98e1 100644
--- a/services/surfaceflinger/Tracing/TransactionProtoParser.h
+++ b/services/surfaceflinger/Tracing/TransactionProtoParser.h
@@ -49,15 +49,16 @@
proto::TransactionState toProto(const std::map<uint32_t /* layerId */, TracingLayerState>&);
proto::LayerCreationArgs toProto(const LayerCreationArgs& args);
proto::LayerState toProto(const ResolvedComposerState&);
- proto::DisplayInfo toProto(const frontend::DisplayInfo&, uint32_t layerStack);
+ static proto::DisplayInfo toProto(const frontend::DisplayInfo&, uint32_t layerStack);
TransactionState fromProto(const proto::TransactionState&);
void mergeFromProto(const proto::LayerState&, TracingLayerState& outState);
void fromProto(const proto::LayerCreationArgs&, LayerCreationArgs& outArgs);
std::unique_ptr<FlingerDataMapper> mMapper;
- frontend::DisplayInfo fromProto(const proto::DisplayInfo&);
- void fromProto(const google::protobuf::RepeatedPtrField<proto::DisplayInfo>&,
- display::DisplayMap<ui::LayerStack, frontend::DisplayInfo> outDisplayInfos);
+ static frontend::DisplayInfo fromProto(const proto::DisplayInfo&);
+ static void fromProto(
+ const google::protobuf::RepeatedPtrField<proto::DisplayInfo>&,
+ display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& outDisplayInfos);
private:
proto::DisplayState toProto(const DisplayState&);
diff --git a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp
index 68a6cfc..4b4ce18 100644
--- a/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp
+++ b/services/surfaceflinger/Tracing/tools/LayerTraceGenerator.cpp
@@ -92,6 +92,16 @@
for (int j = 0; j < entry.transactions_size(); j++) {
// apply transactions
TransactionState transaction = parser.fromProto(entry.transactions(j));
+ for (auto& resolvedComposerState : transaction.states) {
+ if (resolvedComposerState.state.what & layer_state_t::eInputInfoChanged) {
+ if (!resolvedComposerState.state.windowInfoHandle->getInfo()->inputConfig.test(
+ gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL)) {
+ // create a fake token since the FE expects a valid token
+ resolvedComposerState.state.windowInfoHandle->editInfo()->token =
+ sp<BBinder>::make();
+ }
+ }
+ }
transactions.emplace_back(std::move(transaction));
}
@@ -138,29 +148,10 @@
lifecycleManager.getGlobalChanges().string().c_str());
lifecycleManager.commitChanges();
- // write layers trace
- auto tracingFlags = LayerTracing::TRACE_INPUT | LayerTracing::TRACE_BUFFERS;
- std::unordered_set<uint64_t> stackIdsToSkip;
- if ((tracingFlags & LayerTracing::TRACE_VIRTUAL_DISPLAYS) == 0) {
- for (const auto& displayInfo : displayInfos) {
- if (displayInfo.second.isVirtual) {
- stackIdsToSkip.insert(displayInfo.first.id);
- }
- }
- }
- const frontend::LayerHierarchy& root = hierarchyBuilder.getHierarchy();
-
- LayersProto layersProto;
- for (auto& [child, variant] : root.mChildren) {
- if (variant != frontend::LayerHierarchy::Variant::Attached ||
- stackIdsToSkip.find(child->getLayer()->layerStack.id) != stackIdsToSkip.end()) {
- continue;
- }
- LayerProtoHelper::writeHierarchyToProto(layersProto, *child, snapshotBuilder, {},
- tracingFlags);
- }
-
+ LayersProto layersProto = LayerProtoFromSnapshotGenerator(snapshotBuilder, displayInfos, {},
+ layerTracing.getFlags())
+ .generate(hierarchyBuilder.getHierarchy());
auto displayProtos = LayerProtoHelper::writeDisplayInfoToProto(displayInfos);
layerTracing.notify(visibleRegionsDirty, entry.elapsed_realtime_nanos(), entry.vsync_id(),
&layersProto, {}, &displayProtos);
diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp b/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
index c088e7b..4304259 100644
--- a/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
+++ b/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
@@ -25,6 +25,7 @@
#include <gui/WindowInfo.h>
#include <renderengine/mock/FakeExternalTexture.h>
#include <ui/DisplayStatInfo.h>
+#include <ui/Transform.h>
#include <FuzzableDataspaces.h>
#include <surfaceflinger_fuzzers_utils.h>
@@ -42,6 +43,7 @@
void invokeEffectLayer();
LayerCreationArgs createLayerCreationArgs(TestableSurfaceFlinger* flinger, sp<Client> client);
Rect getFuzzedRect();
+ ui::Transform getFuzzedTransform();
FrameTimelineInfo getFuzzedFrameTimelineInfo();
private:
@@ -54,6 +56,12 @@
mFdp.ConsumeIntegral<int32_t>() /*bottom*/);
}
+ui::Transform LayerFuzzer::getFuzzedTransform() {
+ return ui::Transform(mFdp.ConsumeIntegral<int32_t>() /*orientation*/,
+ mFdp.ConsumeIntegral<int32_t>() /*width*/,
+ mFdp.ConsumeIntegral<int32_t>() /*height*/);
+}
+
FrameTimelineInfo LayerFuzzer::getFuzzedFrameTimelineInfo() {
FrameTimelineInfo ftInfo;
ftInfo.vsyncId = mFdp.ConsumeIntegral<int64_t>();
@@ -166,7 +174,7 @@
{mFdp.ConsumeIntegral<int32_t>(),
mFdp.ConsumeIntegral<int32_t>()} /*reqSize*/,
mFdp.PickValueInArray(kDataspaces), mFdp.ConsumeBool(),
- mFdp.ConsumeBool());
+ mFdp.ConsumeBool(), getFuzzedTransform(), getFuzzedRect());
layerArea.render([]() {} /*drawLayers*/);
if (!ownsHandle) {
diff --git a/services/surfaceflinger/layerproto/layers.proto b/services/surfaceflinger/layerproto/layers.proto
index 3598308..e9add2e 100644
--- a/services/surfaceflinger/layerproto/layers.proto
+++ b/services/surfaceflinger/layerproto/layers.proto
@@ -138,6 +138,8 @@
float requested_corner_radius = 56;
RectProto destination_frame = 57;
+
+ uint32 original_id = 58;
}
message PositionProto {
diff --git a/services/surfaceflinger/tests/WindowInfosListener_test.cpp b/services/surfaceflinger/tests/WindowInfosListener_test.cpp
index 042d37b..f4a8f03 100644
--- a/services/surfaceflinger/tests/WindowInfosListener_test.cpp
+++ b/services/surfaceflinger/tests/WindowInfosListener_test.cpp
@@ -25,8 +25,7 @@
using gui::DisplayInfo;
using gui::WindowInfo;
-using WindowInfosPredicate =
- std::function<bool(const std::vector<WindowInfo>&, const std::vector<DisplayInfo>&)>;
+using WindowInfosPredicate = std::function<bool(const std::vector<WindowInfo>&)>;
class WindowInfosListenerTest : public ::testing::Test {
protected:
@@ -43,8 +42,8 @@
: mPredicate(std::move(predicate)), mPromise(promise) {}
void onWindowInfosChanged(const std::vector<WindowInfo>& windowInfos,
- const std::vector<DisplayInfo>& displayInfos) override {
- if (mPredicate(windowInfos, displayInfos)) {
+ const std::vector<DisplayInfo>&) override {
+ if (mPredicate(windowInfos)) {
mPromise.set_value();
}
}
@@ -77,16 +76,6 @@
return nullptr;
}
-const DisplayInfo* findMatchingDisplayInfo(int32_t displayId,
- const std::vector<DisplayInfo>& displayInfos) {
- for (const DisplayInfo& displayInfo : displayInfos) {
- if (displayInfo.displayId == displayId) {
- return &displayInfo;
- }
- }
- return nullptr;
-}
-
TEST_F(WindowInfosListenerTest, WindowInfoAddedAndRemoved) {
std::string name = "Test Layer";
sp<IBinder> token = sp<BBinder>::make();
@@ -104,16 +93,14 @@
.setInputWindowInfo(surfaceControl, windowInfo)
.apply();
- auto windowPresent = [&](const std::vector<WindowInfo>& windowInfos,
- const std::vector<DisplayInfo>&) {
+ auto windowPresent = [&](const std::vector<WindowInfo>& windowInfos) {
return findMatchingWindowInfo(windowInfo, windowInfos);
};
ASSERT_TRUE(waitForWindowInfosPredicate(windowPresent));
Transaction().reparent(surfaceControl, nullptr).apply();
- auto windowNotPresent = [&](const std::vector<WindowInfo>& windowInfos,
- const std::vector<DisplayInfo>&) {
+ auto windowNotPresent = [&](const std::vector<WindowInfo>& windowInfos) {
return !findMatchingWindowInfo(windowInfo, windowInfos);
};
ASSERT_TRUE(waitForWindowInfosPredicate(windowNotPresent));
@@ -137,8 +124,7 @@
.setInputWindowInfo(surfaceControl, windowInfo)
.apply();
- auto windowIsPresentAndTouchableRegionEmpty = [&](const std::vector<WindowInfo>& windowInfos,
- const std::vector<DisplayInfo>&) {
+ auto windowIsPresentAndTouchableRegionEmpty = [&](const std::vector<WindowInfo>& windowInfos) {
auto foundWindowInfo = findMatchingWindowInfo(windowInfo, windowInfos);
if (!foundWindowInfo) {
return false;
@@ -151,21 +137,14 @@
Transaction().setInputWindowInfo(surfaceControl, windowInfo).apply();
auto windowIsPresentAndTouchableRegionMatches =
- [&](const std::vector<WindowInfo>& windowInfos,
- const std::vector<DisplayInfo>& displayInfos) {
+ [&](const std::vector<WindowInfo>& windowInfos) {
auto foundWindowInfo = findMatchingWindowInfo(windowInfo, windowInfos);
if (!foundWindowInfo) {
return false;
}
- auto displayInfo =
- findMatchingDisplayInfo(foundWindowInfo->displayId, displayInfos);
- if (!displayInfo) {
- return false;
- }
-
auto touchableRegion =
- displayInfo->transform.transform(foundWindowInfo->touchableRegion);
+ foundWindowInfo->transform.transform(foundWindowInfo->touchableRegion);
return touchableRegion.hasSameRects(windowInfo.touchableRegion);
};
ASSERT_TRUE(waitForWindowInfosPredicate(windowIsPresentAndTouchableRegionMatches));
diff --git a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
index 5f9214c..3e3d8f0 100644
--- a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
+++ b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
@@ -20,7 +20,9 @@
#include <fstream>
#include <iostream>
#include <string>
+#include <unordered_map>
+#include <LayerProtoHelper.h>
#include <LayerTraceGenerator.h>
#include <Tracing/TransactionProtoParser.h>
#include <layerproto/LayerProtoHeader.h>
@@ -84,20 +86,23 @@
std::vector<std::filesystem::path> TransactionTraceTestSuite::sTransactionTraces{};
struct LayerInfo {
- int id;
+ int32_t id;
std::string name;
- int parent;
+ int32_t parent;
int z;
uint64_t curr_frame;
float x;
float y;
uint32_t bufferWidth;
uint32_t bufferHeight;
+ Rect touchableRegionBounds;
};
bool operator==(const LayerInfo& lh, const LayerInfo& rh) {
- return std::make_tuple(lh.id, lh.name, lh.parent, lh.z, lh.curr_frame) ==
- std::make_tuple(rh.id, rh.name, rh.parent, rh.z, rh.curr_frame);
+ return std::make_tuple(lh.id, lh.name, lh.parent, lh.z, lh.curr_frame, lh.bufferWidth,
+ lh.bufferHeight, lh.touchableRegionBounds) ==
+ std::make_tuple(rh.id, rh.name, rh.parent, rh.z, rh.curr_frame, rh.bufferWidth,
+ rh.bufferHeight, rh.touchableRegionBounds);
}
bool compareById(const LayerInfo& a, const LayerInfo& b) {
@@ -108,7 +113,9 @@
*os << "Layer [" << info.id << "] name=" << info.name << " parent=" << info.parent
<< " z=" << info.z << " curr_frame=" << info.curr_frame << " x=" << info.x
<< " y=" << info.y << " bufferWidth=" << info.bufferWidth
- << " bufferHeight=" << info.bufferHeight;
+ << " bufferHeight=" << info.bufferHeight << "touchableRegionBounds={"
+ << info.touchableRegionBounds.left << "," << info.touchableRegionBounds.top << ","
+ << info.touchableRegionBounds.right << "," << info.touchableRegionBounds.bottom << "}";
}
struct find_id : std::unary_function<LayerInfo, bool> {
@@ -118,6 +125,17 @@
};
static LayerInfo getLayerInfoFromProto(::android::surfaceflinger::LayerProto& proto) {
+ Rect touchableRegionBounds = Rect::INVALID_RECT;
+ // ignore touchable region for layers without buffers, the new fe aggressively avoids
+ // calculating state for layers that are not visible which could lead to mismatches
+ if (proto.has_input_window_info() && proto.input_window_info().has_touchable_region() &&
+ proto.has_active_buffer()) {
+ Region touchableRegion;
+ LayerProtoHelper::readFromProto(proto.input_window_info().touchable_region(),
+ touchableRegion);
+ touchableRegionBounds = touchableRegion.bounds();
+ }
+
return {proto.id(),
proto.name(),
proto.parent(),
@@ -126,7 +144,8 @@
proto.has_position() ? proto.position().x() : -1,
proto.has_position() ? proto.position().y() : -1,
proto.has_active_buffer() ? proto.active_buffer().width() : 0,
- proto.has_active_buffer() ? proto.active_buffer().height() : 0};
+ proto.has_active_buffer() ? proto.active_buffer().height() : 0,
+ touchableRegionBounds};
}
TEST_P(TransactionTraceTestSuite, validateEndState) {
@@ -143,16 +162,27 @@
expectedLayers.reserve(static_cast<size_t>(expectedLastEntry.layers().layers_size()));
for (int i = 0; i < expectedLastEntry.layers().layers_size(); i++) {
auto layer = expectedLastEntry.layers().layers(i);
- expectedLayers.push_back(getLayerInfoFromProto(layer));
+ LayerInfo layerInfo = getLayerInfoFromProto(layer);
+ expectedLayers.push_back(layerInfo);
}
std::sort(expectedLayers.begin(), expectedLayers.end(), compareById);
+ std::unordered_map<int32_t /* snapshotId*/, int32_t /*layerId*/> snapshotIdToLayerId;
std::vector<LayerInfo> actualLayers;
actualLayers.reserve(static_cast<size_t>(actualLastEntry.layers().layers_size()));
for (int i = 0; i < actualLastEntry.layers().layers_size(); i++) {
auto layer = actualLastEntry.layers().layers(i);
- actualLayers.push_back(getLayerInfoFromProto(layer));
+ LayerInfo layerInfo = getLayerInfoFromProto(layer);
+ snapshotIdToLayerId[layerInfo.id] = static_cast<int32_t>(layer.original_id());
+ actualLayers.push_back(layerInfo);
}
+
+ for (auto& layer : actualLayers) {
+ layer.id = snapshotIdToLayerId[layer.id];
+ auto it = snapshotIdToLayerId.find(layer.parent);
+ layer.parent = it == snapshotIdToLayerId.end() ? -1 : it->second;
+ }
+
std::sort(actualLayers.begin(), actualLayers.end(), compareById);
size_t i = 0;
diff --git a/services/surfaceflinger/tests/unittests/PowerAdvisorTest.cpp b/services/surfaceflinger/tests/unittests/PowerAdvisorTest.cpp
index 2d66d3c..d22ce17 100644
--- a/services/surfaceflinger/tests/unittests/PowerAdvisorTest.cpp
+++ b/services/surfaceflinger/tests/unittests/PowerAdvisorTest.cpp
@@ -42,12 +42,12 @@
void fakeBasicFrameTiming(TimePoint startTime, Duration vsyncPeriod);
void setExpectedTiming(Duration totalFrameTargetDuration, TimePoint expectedPresentTime);
Duration getFenceWaitDelayDuration(bool skipValidate);
+ Duration getErrorMargin();
protected:
TestableSurfaceFlinger mFlinger;
std::unique_ptr<PowerAdvisor> mPowerAdvisor;
NiceMock<MockAidlPowerHalWrapper>* mMockAidlWrapper;
- Duration kErrorMargin = 1ms;
};
void PowerAdvisorTest::SetUp() FTL_FAKE_GUARD(mPowerAdvisor->mPowerHalMutex) {
@@ -77,6 +77,8 @@
mPowerAdvisor->setCommitStart(startTime);
mPowerAdvisor->setFrameDelay(0ns);
mPowerAdvisor->setTargetWorkDuration(vsyncPeriod);
+ ON_CALL(*mMockAidlWrapper, getTargetWorkDuration())
+ .WillByDefault(Return(std::make_optional(vsyncPeriod)));
}
Duration PowerAdvisorTest::getFenceWaitDelayDuration(bool skipValidate) {
@@ -84,6 +86,10 @@
: PowerAdvisor::kFenceWaitStartDelayValidated);
}
+Duration PowerAdvisorTest::getErrorMargin() {
+ return mPowerAdvisor->sTargetSafetyMargin;
+}
+
namespace {
TEST_F(PowerAdvisorTest, hintSessionUseHwcDisplay) {
@@ -109,7 +115,7 @@
// increment the frame
startTime += vsyncPeriod;
- const Duration expectedDuration = kErrorMargin + presentDuration + postCompDuration;
+ const Duration expectedDuration = getErrorMargin() + presentDuration + postCompDuration;
EXPECT_CALL(*mMockAidlWrapper, sendActualWorkDuration(Eq(expectedDuration), _)).Times(1);
fakeBasicFrameTiming(startTime, vsyncPeriod);
@@ -145,7 +151,7 @@
// increment the frame
startTime += vsyncPeriod;
- const Duration expectedDuration = kErrorMargin + presentDuration +
+ const Duration expectedDuration = getErrorMargin() + presentDuration +
getFenceWaitDelayDuration(false) - hwcBlockedDuration + postCompDuration;
EXPECT_CALL(*mMockAidlWrapper, sendActualWorkDuration(Eq(expectedDuration), _)).Times(1);
@@ -185,7 +191,7 @@
// increment the frame
startTime += vsyncPeriod;
- const Duration expectedDuration = kErrorMargin + presentDuration + postCompDuration;
+ const Duration expectedDuration = getErrorMargin() + presentDuration + postCompDuration;
EXPECT_CALL(*mMockAidlWrapper, sendActualWorkDuration(Eq(expectedDuration), _)).Times(1);
fakeBasicFrameTiming(startTime, vsyncPeriod);
diff --git a/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp b/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp
index 3dea189..dd72174 100644
--- a/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp
+++ b/services/surfaceflinger/tests/unittests/TransactionProtoParserTest.cpp
@@ -19,6 +19,7 @@
#include <limits> // std::numeric_limits
#include <gui/SurfaceComposerClient.h>
+#include <ui/Rotation.h>
#include "LayerProtoHelper.h"
#include "Tracing/TransactionProtoParser.h"
@@ -103,4 +104,48 @@
ASSERT_EQ(t1.displays[0].token, t2.displays[0].token);
}
+TEST(TransactionProtoParserTest, parseDisplayInfo) {
+ frontend::DisplayInfo d1;
+ d1.info.displayId = 42;
+ d1.info.logicalWidth = 43;
+ d1.info.logicalHeight = 44;
+ d1.info.transform.set(1, 2, 3, 4);
+ d1.transform = d1.info.transform.inverse();
+ d1.receivesInput = true;
+ d1.isSecure = false;
+ d1.isPrimary = true;
+ d1.isVirtual = false;
+ d1.rotationFlags = ui::Transform::ROT_180;
+ d1.transformHint = ui::Transform::ROT_90;
+
+ const uint32_t layerStack = 2;
+ google::protobuf::RepeatedPtrField<proto::DisplayInfo> displayProtos;
+ auto displayInfoProto = displayProtos.Add();
+ *displayInfoProto = TransactionProtoParser::toProto(d1, layerStack);
+ display::DisplayMap<ui::LayerStack, frontend::DisplayInfo> displayInfos;
+ TransactionProtoParser::fromProto(displayProtos, displayInfos);
+
+ ASSERT_TRUE(displayInfos.contains(ui::LayerStack::fromValue(layerStack)));
+ frontend::DisplayInfo d2 = displayInfos.get(ui::LayerStack::fromValue(layerStack))->get();
+ EXPECT_EQ(d1.info.displayId, d2.info.displayId);
+ EXPECT_EQ(d1.info.logicalWidth, d2.info.logicalWidth);
+ EXPECT_EQ(d1.info.logicalHeight, d2.info.logicalHeight);
+
+ EXPECT_EQ(d1.info.transform.dsdx(), d2.info.transform.dsdx());
+ EXPECT_EQ(d1.info.transform.dsdy(), d2.info.transform.dsdy());
+ EXPECT_EQ(d1.info.transform.dtdx(), d2.info.transform.dtdx());
+ EXPECT_EQ(d1.info.transform.dtdy(), d2.info.transform.dtdy());
+
+ EXPECT_EQ(d1.transform.dsdx(), d2.transform.dsdx());
+ EXPECT_EQ(d1.transform.dsdy(), d2.transform.dsdy());
+ EXPECT_EQ(d1.transform.dtdx(), d2.transform.dtdx());
+ EXPECT_EQ(d1.transform.dtdy(), d2.transform.dtdy());
+
+ EXPECT_EQ(d1.receivesInput, d2.receivesInput);
+ EXPECT_EQ(d1.isSecure, d2.isSecure);
+ EXPECT_EQ(d1.isVirtual, d2.isVirtual);
+ EXPECT_EQ(d1.rotationFlags, d2.rotationFlags);
+ EXPECT_EQ(d1.transformHint, d2.transformHint);
+}
+
} // namespace android
diff --git a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockAidlPowerHalWrapper.h b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockAidlPowerHalWrapper.h
index 5654691..3ed85e0 100644
--- a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockAidlPowerHalWrapper.h
+++ b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockAidlPowerHalWrapper.h
@@ -47,6 +47,8 @@
MOCK_METHOD(void, sendActualWorkDuration, (Duration actualDuration, TimePoint timestamp),
(override));
MOCK_METHOD(bool, shouldReconnectHAL, (), (override));
+ MOCK_METHOD(std::vector<int32_t>, getPowerHintSessionThreadIds, (), (override));
+ MOCK_METHOD(std::optional<Duration>, getTargetWorkDuration, (), (override));
};
} // namespace android::Hwc2::mock
\ No newline at end of file
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 1bff50d..dec3b20 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -514,7 +514,6 @@
case VK_FORMAT_R8_UNORM:
native_format = android::PIXEL_FORMAT_R_8;
break;
- // TODO: Do we need to query for VK_EXT_rgba10x6_formats here?
case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16:
native_format = android::PIXEL_FORMAT_RGBA_10101010;
break;
@@ -805,9 +804,23 @@
}
}
- // TODO query VK_EXT_rgba10x6_formats support
+ bool rgba10x6_formats_ext = false;
+ uint32_t exts_count;
+ const auto& driver = GetData(pdev).driver;
+ driver.EnumerateDeviceExtensionProperties(pdev, nullptr, &exts_count,
+ nullptr);
+ std::vector<VkExtensionProperties> props(exts_count);
+ driver.EnumerateDeviceExtensionProperties(pdev, nullptr, &exts_count,
+ props.data());
+ for (uint32_t i = 0; i < exts_count; i++) {
+ VkExtensionProperties prop = props[i];
+ if (strcmp(prop.extensionName,
+ VK_EXT_RGBA10X6_FORMATS_EXTENSION_NAME) == 0) {
+ rgba10x6_formats_ext = true;
+ }
+ }
desc.format = AHARDWAREBUFFER_FORMAT_R10G10B10A10_UNORM;
- if (AHardwareBuffer_isSupported(&desc)) {
+ if (AHardwareBuffer_isSupported(&desc) && rgba10x6_formats_ext) {
all_formats.emplace_back(
VkSurfaceFormatKHR{VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16,
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR});