Merge "Add support for detecting Keyboard backlight using sysfs node"
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index 6fb9a4d..5cd2dea 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -193,8 +193,9 @@
{ OPT, "events/ext4/ext4_da_write_end/enable" },
{ OPT, "events/ext4/ext4_sync_file_enter/enable" },
{ OPT, "events/ext4/ext4_sync_file_exit/enable" },
- { REQ, "events/block/block_rq_issue/enable" },
- { REQ, "events/block/block_rq_complete/enable" },
+ { REQ, "events/block/block_bio_queue/enable" },
+ { REQ, "events/block/block_bio_complete/enable" },
+ { REQ, "events/ufs/ufshcd_command/enable" },
} },
{ "mmc", "eMMC commands", 0, {
{ REQ, "events/mmc/enable" },
diff --git a/data/etc/android.software.credentials.xml b/data/etc/android.software.credentials.xml
new file mode 100644
index 0000000..234d144
--- /dev/null
+++ b/data/etc/android.software.credentials.xml
@@ -0,0 +1,19 @@
+<?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.
+-->
+
+<permissions>
+ <feature name="android.software.credentials" />
+</permissions>
diff --git a/data/etc/handheld_core_hardware.xml b/data/etc/handheld_core_hardware.xml
index 8fdd8d0..0833012 100644
--- a/data/etc/handheld_core_hardware.xml
+++ b/data/etc/handheld_core_hardware.xml
@@ -52,6 +52,7 @@
<feature name="android.software.print" />
<feature name="android.software.companion_device_setup" />
<feature name="android.software.autofill" />
+ <feature name="android.software.credentials" />
<feature name="android.software.cant_save_state" />
<feature name="android.software.secure_lock_screen" />
<feature name="android.software.window_magnification" />
diff --git a/data/etc/tablet_core_hardware.xml b/data/etc/tablet_core_hardware.xml
index 59d5b10..6af4d91 100644
--- a/data/etc/tablet_core_hardware.xml
+++ b/data/etc/tablet_core_hardware.xml
@@ -52,6 +52,7 @@
<feature name="android.software.print" />
<feature name="android.software.companion_device_setup" />
<feature name="android.software.autofill" />
+ <feature name="android.software.credentials" />
<feature name="android.software.cant_save_state" />
<feature name="android.software.secure_lock_screen" />
<feature name="android.software.window_magnification" />
diff --git a/include/android/input.h b/include/android/input.h
index 8cd9e95..7080386 100644
--- a/include/android/input.h
+++ b/include/android/input.h
@@ -840,6 +840,12 @@
* This classification type should be used to accelerate the long press behaviour.
*/
AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS = 2,
+ /**
+ * Classification constant: touchpad two-finger swipe.
+ *
+ * The current event stream represents the user swiping with two fingers on a touchpad.
+ */
+ AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE = 3,
};
/**
diff --git a/include/input/Input.h b/include/input/Input.h
index 2dd651e..172e5b4 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -289,6 +289,10 @@
* The current gesture likely represents a user intentionally exerting force on the touchscreen.
*/
DEEP_PRESS = AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS,
+ /**
+ * The current gesture represents the user swiping with two fingers on a touchpad.
+ */
+ TWO_FINGER_SWIPE = AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE,
};
/**
diff --git a/include/input/VelocityTracker.h b/include/input/VelocityTracker.h
index f6556d6..294879e 100644
--- a/include/input/VelocityTracker.h
+++ b/include/input/VelocityTracker.h
@@ -160,8 +160,12 @@
void configureStrategy(int32_t axis);
+ // Generates a VelocityTrackerStrategy instance for the given Strategy type.
+ // The `deltaValues` parameter indicates whether or not the created strategy should treat motion
+ // values as deltas (and not as absolute values). This the parameter is applicable only for
+ // strategies that support differential axes.
static std::unique_ptr<VelocityTrackerStrategy> createStrategy(const Strategy strategy,
- bool isCumulative);
+ bool deltaValues);
};
diff --git a/libs/binder/RpcTrusty.cpp b/libs/binder/RpcTrusty.cpp
index ea49eef..3b53b05 100644
--- a/libs/binder/RpcTrusty.cpp
+++ b/libs/binder/RpcTrusty.cpp
@@ -26,8 +26,12 @@
using android::base::unique_fd;
-sp<IBinder> RpcTrustyConnect(const char* device, const char* port) {
+sp<RpcSession> RpcTrustyConnectWithSessionInitializer(
+ const char* device, const char* port,
+ std::function<void(sp<RpcSession>&)> sessionInitializer) {
auto session = RpcSession::make(RpcTransportCtxFactoryTipcAndroid::make());
+ // using the callback to initialize the session
+ sessionInitializer(session);
auto request = [=] {
int tipcFd = tipc_connect(device, port);
if (tipcFd < 0) {
@@ -40,6 +44,11 @@
LOG(ERROR) << "Failed to set up Trusty client. Error: " << statusToString(status).c_str();
return nullptr;
}
+ return session;
+}
+
+sp<IBinder> RpcTrustyConnect(const char* device, const char* port) {
+ auto session = RpcTrustyConnectWithSessionInitializer(device, port, [](auto) {});
return session->getRootObject();
}
diff --git a/libs/binder/include_trusty/binder/RpcTrusty.h b/libs/binder/include_trusty/binder/RpcTrusty.h
index f124e0c..b034b9b 100644
--- a/libs/binder/include_trusty/binder/RpcTrusty.h
+++ b/libs/binder/include_trusty/binder/RpcTrusty.h
@@ -22,4 +22,8 @@
sp<IBinder> RpcTrustyConnect(const char* device, const char* port);
+sp<RpcSession> RpcTrustyConnectWithSessionInitializer(
+ const char* device, const char* port,
+ std::function<void(sp<RpcSession>&)> sessionInitializer);
+
} // namespace android
diff --git a/libs/binder/ndk/Android.bp b/libs/binder/ndk/Android.bp
index 33d28e6..8ae7537 100644
--- a/libs/binder/ndk/Android.bp
+++ b/libs/binder/ndk/Android.bp
@@ -182,4 +182,8 @@
name: "libbinder_ndk",
symbol_file: "libbinder_ndk.map.txt",
first_version: "29",
+ export_header_libs: [
+ "libbinder_ndk_headers",
+ "libbinder_ndk_helper_headers",
+ ],
}
diff --git a/libs/binder/rust/Android.bp b/libs/binder/rust/Android.bp
index 0ec6183..a135796 100644
--- a/libs/binder/rust/Android.bp
+++ b/libs/binder/rust/Android.bp
@@ -30,6 +30,7 @@
apex_available: [
"//apex_available:platform",
"com.android.compos",
+ "com.android.rkpd",
"com.android.uwb",
"com.android.virt",
],
@@ -80,6 +81,7 @@
apex_available: [
"//apex_available:platform",
"com.android.compos",
+ "com.android.rkpd",
"com.android.uwb",
"com.android.virt",
],
@@ -138,6 +140,7 @@
apex_available: [
"//apex_available:platform",
"com.android.compos",
+ "com.android.rkpd",
"com.android.uwb",
"com.android.virt",
],
diff --git a/libs/binder/rust/rpcbinder/Android.bp b/libs/binder/rust/rpcbinder/Android.bp
index f169390..5ebc27f 100644
--- a/libs/binder/rust/rpcbinder/Android.bp
+++ b/libs/binder/rust/rpcbinder/Android.bp
@@ -16,7 +16,7 @@
],
rustlibs: [
"libbinder_ndk_sys",
- "libbinder_rpc_unstable_bindgen",
+ "libbinder_rpc_unstable_bindgen_sys",
"libbinder_rs",
"libdowncast_rs",
"liblibc",
@@ -29,6 +29,35 @@
min_sdk_version: "Tiramisu",
}
+// Build a separate rust_library rather than depending directly on libbinder_rpc_unstable_bindgen,
+// to work around the fact that rust_bindgen targets only produce rlibs and not dylibs, which would
+// result in duplicate conflicting versions of libbinder_ndk_sys. This will hopefully be fixed in
+// the build system, at which point we can delete this target and go back to using
+// libbinder_rpc_unstable_bindgen directly.
+rust_library {
+ name: "libbinder_rpc_unstable_bindgen_sys",
+ crate_name: "binder_rpc_unstable_bindgen",
+ srcs: [
+ ":libbinder_rpc_unstable_bindgen",
+ ],
+ visibility: [":__subpackages__"],
+ rustlibs: [
+ "libbinder_ndk_sys",
+ ],
+ shared_libs: [
+ "libbinder_rpc_unstable",
+ "libutils",
+ ],
+ apex_available: [
+ "com.android.compos",
+ "com.android.uwb",
+ "com.android.virt",
+ ],
+ min_sdk_version: "Tiramisu",
+ lints: "none",
+ clippy_lints: "none",
+}
+
// TODO(b/184872979): remove once the RPC Binder API is stabilised.
rust_bindgen {
name: "libbinder_rpc_unstable_bindgen",
@@ -36,6 +65,15 @@
crate_name: "binder_rpc_unstable_bindgen",
visibility: [":__subpackages__"],
source_stem: "bindings",
+ bindgen_flags: [
+ "--blocklist-type",
+ "AIBinder",
+ "--raw-line",
+ "use binder_ndk_sys::AIBinder;",
+ ],
+ rustlibs: [
+ "libbinder_ndk_sys",
+ ],
shared_libs: [
"libbinder_rpc_unstable",
"libutils",
@@ -52,6 +90,9 @@
name: "libbinder_rpc_unstable_bindgen_test",
srcs: [":libbinder_rpc_unstable_bindgen"],
crate_name: "binder_rpc_unstable_bindgen",
+ rustlibs: [
+ "libbinder_ndk_sys",
+ ],
test_suites: ["general-tests"],
auto_gen_config: true,
clippy_lints: "none",
diff --git a/libs/binder/rust/rpcbinder/src/client.rs b/libs/binder/rust/rpcbinder/src/client.rs
index dfc6f06..743800b 100644
--- a/libs/binder/rust/rpcbinder/src/client.rs
+++ b/libs/binder/rust/rpcbinder/src/client.rs
@@ -14,10 +14,7 @@
* limitations under the License.
*/
-use binder::{
- unstable_api::{new_spibinder, AIBinder},
- FromIBinder, SpIBinder, StatusCode, Strong,
-};
+use binder::{unstable_api::new_spibinder, FromIBinder, SpIBinder, StatusCode, Strong};
use std::os::{
raw::{c_int, c_void},
unix::io::RawFd,
@@ -27,7 +24,7 @@
pub fn get_vsock_rpc_service(cid: u32, port: u32) -> Option<SpIBinder> {
// SAFETY: AIBinder returned by RpcClient has correct reference count, and the ownership can
// safely be taken by new_spibinder.
- unsafe { new_spibinder(binder_rpc_unstable_bindgen::RpcClient(cid, port) as *mut AIBinder) }
+ unsafe { new_spibinder(binder_rpc_unstable_bindgen::RpcClient(cid, port)) }
}
/// Connects to an RPC Binder server for a particular interface over vsock.
@@ -54,7 +51,7 @@
new_spibinder(binder_rpc_unstable_bindgen::RpcPreconnectedClient(
Some(request_fd_wrapper),
param,
- ) as *mut AIBinder)
+ ))
}
}
diff --git a/libs/binder/rust/rpcbinder/src/server.rs b/libs/binder/rust/rpcbinder/src/server.rs
index d98a439..aeb23c6 100644
--- a/libs/binder/rust/rpcbinder/src/server.rs
+++ b/libs/binder/rust/rpcbinder/src/server.rs
@@ -14,7 +14,10 @@
* limitations under the License.
*/
-use binder::{unstable_api::AsNative, SpIBinder};
+use binder::{
+ unstable_api::{AIBinder, AsNative},
+ SpIBinder,
+};
use std::{os::raw, ptr::null_mut};
/// Runs a binder RPC server, serving the supplied binder service implementation on the given vsock
@@ -44,7 +47,7 @@
F: FnOnce(),
{
fn run_server(&mut self, mut service: SpIBinder, port: u32) -> bool {
- let service = service.as_native_mut() as *mut binder_rpc_unstable_bindgen::AIBinder;
+ let service = service.as_native_mut();
let param = self.as_void_ptr();
// SAFETY: Service ownership is transferring to the server and won't be valid afterward.
@@ -106,10 +109,7 @@
}
}
-unsafe extern "C" fn factory_wrapper(
- cid: u32,
- context: *mut raw::c_void,
-) -> *mut binder_rpc_unstable_bindgen::AIBinder {
+unsafe extern "C" fn factory_wrapper(cid: u32, context: *mut raw::c_void) -> *mut AIBinder {
// SAFETY: `context` was created from an `&mut RpcServerFactoryRef` by
// `run_rpc_server_with_factory`, and we are still within the lifetime of the value it is
// pointing to.
@@ -117,7 +117,7 @@
let factory = factory_ptr.as_mut().unwrap();
if let Some(mut service) = factory(cid) {
- service.as_native_mut() as *mut binder_rpc_unstable_bindgen::AIBinder
+ service.as_native_mut()
} else {
null_mut()
}
diff --git a/libs/binderthreadstate/test.cpp b/libs/binderthreadstate/test.cpp
index 2f73137..df1f35d 100644
--- a/libs/binderthreadstate/test.cpp
+++ b/libs/binderthreadstate/test.cpp
@@ -73,6 +73,15 @@
CHECK(ret.isOk()) << ret;
}
+static std::string getStackPointerDebugInfo() {
+ const void* hwbinderSp = android::hardware::IPCThreadState::self()->getServingStackPointer();
+ const void* binderSp = android::IPCThreadState::self()->getServingStackPointer();
+
+ std::stringstream ss;
+ ss << "(hwbinder sp: " << hwbinderSp << " binder sp: " << binderSp << ")";
+ return ss.str();
+}
+
static inline std::ostream& operator<<(std::ostream& o, const BinderCallType& s) {
return o << static_cast<std::underlying_type_t<BinderCallType>>(s);
}
@@ -88,17 +97,21 @@
return android::hardware::Status::ok();
}
Return<void> call(int32_t idx) {
+ bool doCallHidl = thisId == kP1Id && idx % 4 < 2;
+
LOG(INFO) << "HidlServer CALL " << thisId << " to " << otherId << " at idx: " << idx
- << " with tid: " << gettid();
- CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall());
+ << " with tid: " << gettid() << " calling " << (doCallHidl ? "HIDL" : "AIDL");
+ CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall())
+ << " before call " << getStackPointerDebugInfo();
if (idx > 0) {
- if (thisId == kP1Id && idx % 4 < 2) {
+ if (doCallHidl) {
callHidl(otherId, idx - 1);
} else {
callAidl(otherId, idx - 1);
}
}
- CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall());
+ CHECK_EQ(BinderCallType::HWBINDER, getCurrentServingCall())
+ << " after call " << getStackPointerDebugInfo();
return android::hardware::Status::ok();
}
};
@@ -113,17 +126,20 @@
return Status::ok();
}
Status call(int32_t idx) {
+ bool doCallHidl = thisId == kP2Id && idx % 4 < 2;
LOG(INFO) << "AidlServer CALL " << thisId << " to " << otherId << " at idx: " << idx
- << " with tid: " << gettid();
- CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall());
+ << " with tid: " << gettid() << " calling " << (doCallHidl ? "HIDL" : "AIDL");
+ CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall())
+ << " before call " << getStackPointerDebugInfo();
if (idx > 0) {
- if (thisId == kP2Id && idx % 4 < 2) {
+ if (doCallHidl) {
callHidl(otherId, idx - 1);
} else {
callAidl(otherId, idx - 1);
}
}
- CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall());
+ CHECK_EQ(BinderCallType::BINDER, getCurrentServingCall())
+ << " after call " << getStackPointerDebugInfo();
return Status::ok();
}
};
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index a9d6b0e..fc0b1ee 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -912,8 +912,9 @@
uncacheBuffer.token = BufferCache::getInstance().getToken();
uncacheBuffer.id = cacheId;
- sf->setTransactionState(FrameTimelineInfo{}, {}, {}, 0, Transaction::getDefaultApplyToken(), {},
- systemTime(), true, uncacheBuffer, false, {}, generateId());
+ sf->setTransactionState(FrameTimelineInfo{}, {}, {}, ISurfaceComposer::eOneWay,
+ Transaction::getDefaultApplyToken(), {}, systemTime(), true,
+ uncacheBuffer, false, {}, generateId());
}
void SurfaceComposerClient::Transaction::cacheBuffers() {
diff --git a/libs/input/Input.cpp b/libs/input/Input.cpp
index 2b7483d..579b28e 100644
--- a/libs/input/Input.cpp
+++ b/libs/input/Input.cpp
@@ -87,6 +87,8 @@
return "AMBIGUOUS_GESTURE";
case MotionClassification::DEEP_PRESS:
return "DEEP_PRESS";
+ case MotionClassification::TWO_FINGER_SWIPE:
+ return "TWO_FINGER_SWIPE";
}
}
diff --git a/libs/nativewindow/Android.bp b/libs/nativewindow/Android.bp
index fbfecf6..3503a9e 100644
--- a/libs/nativewindow/Android.bp
+++ b/libs/nativewindow/Android.bp
@@ -61,6 +61,9 @@
// Android O
first_version: "26",
+ export_header_libs: [
+ "libnativewindow_ndk_headers",
+ ],
}
cc_library {
diff --git a/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp b/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp
index 6f10a67..6a61d36 100644
--- a/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp
+++ b/libs/sensor/fuzz/bittube_fuzzer/bittube_fuzzer.cpp
@@ -24,14 +24,14 @@
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
FuzzedDataProvider fdp(data, size);
- BitTube bittube(size);
+ sp<BitTube> bittube(new BitTube(size));
Parcel parcel[5];
- bittube.writeToParcel(parcel);
+ bittube->writeToParcel(parcel);
sp<BitTube> tube(new BitTube(size));
- bittube.sendObjects<uint8_t>(tube, data, size);
+ bittube->sendObjects<uint8_t>(tube, data, size);
uint8_t recvData[size];
for (int i = 0; i < size; i++) recvData[i] = fdp.ConsumeIntegral<uint8_t>();
- bittube.recvObjects<uint8_t>(tube, recvData, size);
+ bittube->recvObjects<uint8_t>(tube, recvData, size);
return 0;
}
diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp
index c1e935a..62cf255 100644
--- a/opengl/libs/Android.bp
+++ b/opengl/libs/Android.bp
@@ -12,7 +12,10 @@
name: "libETC1",
srcs: ["ETC1/etc1.cpp"],
host_supported: true,
- cflags: ["-Wall", "-Werror"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
target: {
android: {
@@ -37,6 +40,9 @@
symbol_file: "libEGL.map.txt",
first_version: "9",
unversioned_until: "current",
+ export_header_libs: [
+ "libEGL_headers",
+ ],
}
ndk_library {
@@ -44,6 +50,9 @@
symbol_file: "libGLESv1_CM.map.txt",
first_version: "9",
unversioned_until: "current",
+ export_header_libs: [
+ "libGLESv1_CM_headers",
+ ],
}
ndk_library {
@@ -51,6 +60,9 @@
symbol_file: "libGLESv2.map.txt",
first_version: "9",
unversioned_until: "current",
+ export_header_libs: [
+ "libGLESv2_headers",
+ ],
}
ndk_library {
@@ -58,6 +70,9 @@
symbol_file: "libGLESv3.map.txt",
first_version: "18",
unversioned_until: "current",
+ export_header_libs: [
+ "libGLESv3_headers",
+ ],
}
cc_defaults {
@@ -170,7 +185,11 @@
"libEGL_getProcAddress",
"libEGL_blobCache",
],
- ldflags: ["-Wl,--exclude-libs=ALL,--Bsymbolic-functions"],
+ ldflags: [
+ "-Wl,--exclude-libs=libEGL_getProcAddress.a",
+ "-Wl,--exclude-libs=libEGL_blobCache.a",
+ "-Wl,--Bsymbolic-functions",
+ ],
export_include_dirs: ["EGL/include"],
stubs: {
symbol_file: "libEGL.map.txt",
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index efa67db..8348d6c 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -28,7 +28,7 @@
// Cache size limits.
static const size_t maxKeySize = 12 * 1024;
static const size_t maxValueSize = 64 * 1024;
-static const size_t maxTotalSize = 2 * 1024 * 1024;
+static const size_t maxTotalSize = 32 * 1024 * 1024;
// The time in seconds to wait before saving newly inserted cache entries.
static const unsigned int deferredSaveDelay = 4;
diff --git a/services/inputflinger/Android.bp b/services/inputflinger/Android.bp
index 5b286dc..88a9acb 100644
--- a/services/inputflinger/Android.bp
+++ b/services/inputflinger/Android.bp
@@ -191,7 +191,16 @@
"libinputservice_test",
"Bug-115739809",
"StructLayout_test",
+
+ // native fuzzers
"inputflinger_latencytracker_fuzzer",
+ "inputflinger_cursor_input_fuzzer",
+ "inputflinger_keyboard_input_fuzzer",
+ "inputflinger_multitouch_input_fuzzer",
+ "inputflinger_switch_input_fuzzer",
+ "inputflinger_input_reader_fuzzer",
+ "inputflinger_blocking_queue_fuzzer",
+ "inputflinger_input_classifier_fuzzer",
// Java/Kotlin targets
"CtsWindowManagerDeviceTestCases",
diff --git a/services/inputflinger/InputListener.cpp b/services/inputflinger/InputListener.cpp
index dce327e..54d0e02 100644
--- a/services/inputflinger/InputListener.cpp
+++ b/services/inputflinger/InputListener.cpp
@@ -34,19 +34,7 @@
// --- NotifyConfigurationChangedArgs ---
NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(int32_t id, nsecs_t eventTime)
- : NotifyArgs(id, eventTime) {}
-
-NotifyConfigurationChangedArgs::NotifyConfigurationChangedArgs(
- const NotifyConfigurationChangedArgs& other)
- : NotifyArgs(other.id, other.eventTime) {}
-
-bool NotifyConfigurationChangedArgs::operator==(const NotifyConfigurationChangedArgs& rhs) const {
- return id == rhs.id && eventTime == rhs.eventTime;
-}
-
-void NotifyConfigurationChangedArgs::notify(InputListenerInterface& listener) const {
- listener.notifyConfigurationChanged(this);
-}
+ : id(id), eventTime(eventTime) {}
// --- NotifyKeyArgs ---
@@ -54,7 +42,8 @@
uint32_t source, int32_t displayId, uint32_t policyFlags,
int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
int32_t metaState, nsecs_t downTime)
- : NotifyArgs(id, eventTime),
+ : id(id),
+ eventTime(eventTime),
deviceId(deviceId),
source(source),
displayId(displayId),
@@ -67,32 +56,6 @@
downTime(downTime),
readTime(readTime) {}
-NotifyKeyArgs::NotifyKeyArgs(const NotifyKeyArgs& other)
- : NotifyArgs(other.id, other.eventTime),
- deviceId(other.deviceId),
- source(other.source),
- displayId(other.displayId),
- policyFlags(other.policyFlags),
- action(other.action),
- flags(other.flags),
- keyCode(other.keyCode),
- scanCode(other.scanCode),
- metaState(other.metaState),
- downTime(other.downTime),
- readTime(other.readTime) {}
-
-bool NotifyKeyArgs::operator==(const NotifyKeyArgs& rhs) const {
- return id == rhs.id && eventTime == rhs.eventTime && readTime == rhs.readTime &&
- deviceId == rhs.deviceId && source == rhs.source && displayId == rhs.displayId &&
- policyFlags == rhs.policyFlags && action == rhs.action && flags == rhs.flags &&
- keyCode == rhs.keyCode && scanCode == rhs.scanCode && metaState == rhs.metaState &&
- downTime == rhs.downTime;
-}
-
-void NotifyKeyArgs::notify(InputListenerInterface& listener) const {
- listener.notifyKey(this);
-}
-
// --- NotifyMotionArgs ---
NotifyMotionArgs::NotifyMotionArgs(
@@ -103,7 +66,8 @@
const PointerCoords* pointerCoords, float xPrecision, float yPrecision,
float xCursorPosition, float yCursorPosition, nsecs_t downTime,
const std::vector<TouchVideoFrame>& videoFrames)
- : NotifyArgs(id, eventTime),
+ : id(id),
+ eventTime(eventTime),
deviceId(deviceId),
source(source),
displayId(displayId),
@@ -130,7 +94,8 @@
}
NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other)
- : NotifyArgs(other.id, other.eventTime),
+ : id(other.id),
+ eventTime(other.eventTime),
deviceId(other.deviceId),
source(other.source),
displayId(other.displayId),
@@ -220,41 +185,24 @@
flags);
}
-void NotifyMotionArgs::notify(InputListenerInterface& listener) const {
- listener.notifyMotion(this);
-}
-
// --- NotifySwitchArgs ---
NotifySwitchArgs::NotifySwitchArgs(int32_t id, nsecs_t eventTime, uint32_t policyFlags,
uint32_t switchValues, uint32_t switchMask)
- : NotifyArgs(id, eventTime),
+ : id(id),
+ eventTime(eventTime),
policyFlags(policyFlags),
switchValues(switchValues),
switchMask(switchMask) {}
-NotifySwitchArgs::NotifySwitchArgs(const NotifySwitchArgs& other)
- : NotifyArgs(other.id, other.eventTime),
- policyFlags(other.policyFlags),
- switchValues(other.switchValues),
- switchMask(other.switchMask) {}
-
-bool NotifySwitchArgs::operator==(const NotifySwitchArgs rhs) const {
- return id == rhs.id && eventTime == rhs.eventTime && policyFlags == rhs.policyFlags &&
- switchValues == rhs.switchValues && switchMask == rhs.switchMask;
-}
-
-void NotifySwitchArgs::notify(InputListenerInterface& listener) const {
- listener.notifySwitch(this);
-}
-
// --- NotifySensorArgs ---
NotifySensorArgs::NotifySensorArgs(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
InputDeviceSensorType sensorType,
InputDeviceSensorAccuracy accuracy, bool accuracyChanged,
nsecs_t hwTimestamp, std::vector<float> values)
- : NotifyArgs(id, eventTime),
+ : id(id),
+ eventTime(eventTime),
deviceId(deviceId),
source(source),
sensorType(sensorType),
@@ -263,76 +211,49 @@
hwTimestamp(hwTimestamp),
values(std::move(values)) {}
-NotifySensorArgs::NotifySensorArgs(const NotifySensorArgs& other)
- : NotifyArgs(other.id, other.eventTime),
- deviceId(other.deviceId),
- source(other.source),
- sensorType(other.sensorType),
- accuracy(other.accuracy),
- accuracyChanged(other.accuracyChanged),
- hwTimestamp(other.hwTimestamp),
- values(other.values) {}
-
-bool NotifySensorArgs::operator==(const NotifySensorArgs rhs) const {
- return id == rhs.id && eventTime == rhs.eventTime && sensorType == rhs.sensorType &&
- accuracy == rhs.accuracy && accuracyChanged == rhs.accuracyChanged &&
- hwTimestamp == rhs.hwTimestamp && values == rhs.values;
-}
-
-void NotifySensorArgs::notify(InputListenerInterface& listener) const {
- listener.notifySensor(this);
-}
-
// --- NotifyVibratorStateArgs ---
NotifyVibratorStateArgs::NotifyVibratorStateArgs(int32_t id, nsecs_t eventTime, int32_t deviceId,
bool isOn)
- : NotifyArgs(id, eventTime), deviceId(deviceId), isOn(isOn) {}
+ : id(id), eventTime(eventTime), deviceId(deviceId), isOn(isOn) {}
NotifyVibratorStateArgs::NotifyVibratorStateArgs(const NotifyVibratorStateArgs& other)
- : NotifyArgs(other.id, other.eventTime), deviceId(other.deviceId), isOn(other.isOn) {}
-
-bool NotifyVibratorStateArgs::operator==(const NotifyVibratorStateArgs rhs) const {
- return id == rhs.id && eventTime == rhs.eventTime && deviceId == rhs.deviceId &&
- isOn == rhs.isOn;
-}
-
-void NotifyVibratorStateArgs::notify(InputListenerInterface& listener) const {
- listener.notifyVibratorState(this);
-}
+ : id(other.id), eventTime(other.eventTime), deviceId(other.deviceId), isOn(other.isOn) {}
// --- NotifyDeviceResetArgs ---
NotifyDeviceResetArgs::NotifyDeviceResetArgs(int32_t id, nsecs_t eventTime, int32_t deviceId)
- : NotifyArgs(id, eventTime), deviceId(deviceId) {}
-
-NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other)
- : NotifyArgs(other.id, other.eventTime), deviceId(other.deviceId) {}
-
-bool NotifyDeviceResetArgs::operator==(const NotifyDeviceResetArgs& rhs) const {
- return id == rhs.id && eventTime == rhs.eventTime && deviceId == rhs.deviceId;
-}
-
-void NotifyDeviceResetArgs::notify(InputListenerInterface& listener) const {
- listener.notifyDeviceReset(this);
-}
+ : id(id), eventTime(eventTime), deviceId(deviceId) {}
// --- NotifyPointerCaptureChangedArgs ---
NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(
int32_t id, nsecs_t eventTime, const PointerCaptureRequest& request)
- : NotifyArgs(id, eventTime), request(request) {}
+ : id(id), eventTime(eventTime), request(request) {}
-NotifyPointerCaptureChangedArgs::NotifyPointerCaptureChangedArgs(
- const NotifyPointerCaptureChangedArgs& other)
- : NotifyArgs(other.id, other.eventTime), request(other.request) {}
+// --- InputListenerInterface ---
-bool NotifyPointerCaptureChangedArgs::operator==(const NotifyPointerCaptureChangedArgs& rhs) const {
- return id == rhs.id && eventTime == rhs.eventTime && request == rhs.request;
-}
+// Helper to std::visit with lambdas.
+template <typename... V>
+struct Visitor : V... {};
+// explicit deduction guide (not needed as of C++20)
+template <typename... V>
+Visitor(V...) -> Visitor<V...>;
-void NotifyPointerCaptureChangedArgs::notify(InputListenerInterface& listener) const {
- listener.notifyPointerCaptureChanged(this);
+void InputListenerInterface::notify(const NotifyArgs& generalArgs) {
+ Visitor v{
+ [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(&args); },
+ [&](const NotifyKeyArgs& args) { notifyKey(&args); },
+ [&](const NotifyMotionArgs& args) { notifyMotion(&args); },
+ [&](const NotifySwitchArgs& args) { notifySwitch(&args); },
+ [&](const NotifySensorArgs& args) { notifySensor(&args); },
+ [&](const NotifyVibratorStateArgs& args) { notifyVibratorState(&args); },
+ [&](const NotifyDeviceResetArgs& args) { notifyDeviceReset(&args); },
+ [&](const NotifyPointerCaptureChangedArgs& args) {
+ notifyPointerCaptureChanged(&args);
+ },
+ };
+ std::visit(v, generalArgs);
}
// --- QueuedInputListener ---
@@ -350,47 +271,47 @@
void QueuedInputListener::notifyConfigurationChanged(
const NotifyConfigurationChangedArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifyConfigurationChangedArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::notifyKey(const NotifyKeyArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifyKeyArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::notifyMotion(const NotifyMotionArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifyMotionArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifySwitchArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::notifySensor(const NotifySensorArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifySensorArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifyVibratorStateArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifyDeviceResetArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(std::make_unique<NotifyPointerCaptureChangedArgs>(*args));
+ mArgsQueue.emplace_back(*args);
}
void QueuedInputListener::flush() {
- for (const std::unique_ptr<NotifyArgs>& args : mArgsQueue) {
- args->notify(mInnerListener);
+ for (const NotifyArgs& args : mArgsQueue) {
+ mInnerListener.notify(args);
}
mArgsQueue.clear();
}
diff --git a/services/inputflinger/InputProcessor.cpp b/services/inputflinger/InputProcessor.cpp
index 0749441..02d62bf 100644
--- a/services/inputflinger/InputProcessor.cpp
+++ b/services/inputflinger/InputProcessor.cpp
@@ -22,6 +22,7 @@
#include <android-base/stringprintf.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
+#include <input/Input.h>
#include <inttypes.h>
#include <log/log.h>
#include <algorithm>
@@ -123,40 +124,38 @@
// --- ClassifierEvent ---
-ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyMotionArgs> args)
- : type(ClassifierEventType::MOTION), args(std::move(args)){};
-ClassifierEvent::ClassifierEvent(std::unique_ptr<NotifyDeviceResetArgs> args)
- : type(ClassifierEventType::DEVICE_RESET), args(std::move(args)){};
-ClassifierEvent::ClassifierEvent(ClassifierEventType type, std::unique_ptr<NotifyArgs> args)
- : type(type), args(std::move(args)){};
+ClassifierEvent::ClassifierEvent(const NotifyMotionArgs& args)
+ : type(ClassifierEventType::MOTION), args(args){};
-ClassifierEvent::ClassifierEvent(ClassifierEvent&& other)
- : type(other.type), args(std::move(other.args)){};
+ClassifierEvent::ClassifierEvent(const NotifyDeviceResetArgs& args)
+ : type(ClassifierEventType::DEVICE_RESET), args(args){};
+
+ClassifierEvent::ClassifierEvent(ClassifierEventType type, std::optional<NotifyArgs> args)
+ : type(type), args(args){};
ClassifierEvent& ClassifierEvent::operator=(ClassifierEvent&& other) {
type = other.type;
- args = std::move(other.args);
+ args = other.args;
return *this;
}
ClassifierEvent ClassifierEvent::createHalResetEvent() {
- return ClassifierEvent(ClassifierEventType::HAL_RESET, nullptr);
+ return ClassifierEvent(ClassifierEventType::HAL_RESET, std::nullopt);
}
ClassifierEvent ClassifierEvent::createExitEvent() {
- return ClassifierEvent(ClassifierEventType::EXIT, nullptr);
+ return ClassifierEvent(ClassifierEventType::EXIT, std::nullopt);
}
std::optional<int32_t> ClassifierEvent::getDeviceId() const {
switch (type) {
case ClassifierEventType::MOTION: {
- NotifyMotionArgs* motionArgs = static_cast<NotifyMotionArgs*>(args.get());
- return motionArgs->deviceId;
+ const NotifyMotionArgs& motionArgs = std::get<NotifyMotionArgs>(*args);
+ return motionArgs.deviceId;
}
case ClassifierEventType::DEVICE_RESET: {
- NotifyDeviceResetArgs* deviceResetArgs =
- static_cast<NotifyDeviceResetArgs*>(args.get());
- return deviceResetArgs->deviceId;
+ const NotifyDeviceResetArgs& deviceResetArgs = std::get<NotifyDeviceResetArgs>(*args);
+ return deviceResetArgs.deviceId;
}
case ClassifierEventType::HAL_RESET: {
return std::nullopt;
@@ -212,12 +211,12 @@
bool halResponseOk = true;
switch (event.type) {
case ClassifierEventType::MOTION: {
- NotifyMotionArgs* motionArgs = static_cast<NotifyMotionArgs*>(event.args.get());
- common::MotionEvent motionEvent = notifyMotionArgsToHalMotionEvent(*motionArgs);
+ NotifyMotionArgs& motionArgs = std::get<NotifyMotionArgs>(*event.args);
+ common::MotionEvent motionEvent = notifyMotionArgsToHalMotionEvent(motionArgs);
common::Classification classification;
ndk::ScopedAStatus response = mService->classify(motionEvent, &classification);
if (response.isOk()) {
- updateClassification(motionArgs->deviceId, motionArgs->eventTime,
+ updateClassification(motionArgs.deviceId, motionArgs.eventTime,
getMotionClassification(classification));
}
break;
@@ -307,8 +306,7 @@
updateLastDownTime(args.deviceId, args.downTime);
}
- ClassifierEvent event(std::make_unique<NotifyMotionArgs>(args));
- enqueueEvent(std::move(event));
+ enqueueEvent(args);
return getClassification(args.deviceId);
}
@@ -328,7 +326,7 @@
std::optional<int32_t> eventDeviceId = event.getDeviceId();
return eventDeviceId && (*eventDeviceId == deviceId);
});
- enqueueEvent(std::make_unique<NotifyDeviceResetArgs>(args));
+ enqueueEvent(args);
}
void MotionClassifier::dump(std::string& dump) {
@@ -436,7 +434,13 @@
mQueuedListener.notifyMotion(args);
} else {
NotifyMotionArgs newArgs(*args);
- newArgs.classification = mMotionClassifier->classify(newArgs);
+ const MotionClassification newClassification = mMotionClassifier->classify(newArgs);
+ LOG_ALWAYS_FATAL_IF(args->classification != MotionClassification::NONE &&
+ newClassification != MotionClassification::NONE,
+ "Conflicting classifications %s (new) and %s (old)!",
+ motionClassificationToString(newClassification),
+ motionClassificationToString(args->classification));
+ newArgs.classification = newClassification;
mQueuedListener.notifyMotion(&newArgs);
}
} // release lock
diff --git a/services/inputflinger/InputProcessor.h b/services/inputflinger/InputProcessor.h
index bbf391e..f4d02b6 100644
--- a/services/inputflinger/InputProcessor.h
+++ b/services/inputflinger/InputProcessor.h
@@ -35,12 +35,12 @@
struct ClassifierEvent {
ClassifierEventType type;
- std::unique_ptr<NotifyArgs> args;
+ std::optional<NotifyArgs> args;
- ClassifierEvent(ClassifierEventType type, std::unique_ptr<NotifyArgs> args);
- ClassifierEvent(std::unique_ptr<NotifyMotionArgs> args);
- ClassifierEvent(std::unique_ptr<NotifyDeviceResetArgs> args);
- ClassifierEvent(ClassifierEvent&& other);
+ ClassifierEvent(ClassifierEventType type, std::optional<NotifyArgs> args);
+ ClassifierEvent(const NotifyMotionArgs& args);
+ ClassifierEvent(const NotifyDeviceResetArgs& args);
+ ClassifierEvent(ClassifierEvent&& other) = default;
ClassifierEvent& operator=(ClassifierEvent&& other);
// Convenience function to create a HAL_RESET event
diff --git a/services/inputflinger/include/InputListener.h b/services/inputflinger/include/InputListener.h
index c8ab6c5..036d57e 100644
--- a/services/inputflinger/include/InputListener.h
+++ b/services/inputflinger/include/InputListener.h
@@ -26,41 +26,25 @@
class InputListenerInterface;
-
-/* Superclass of all input event argument objects */
-struct NotifyArgs {
+/* Describes a configuration change event. */
+struct NotifyConfigurationChangedArgs {
int32_t id;
nsecs_t eventTime;
- inline NotifyArgs() : id(0), eventTime(0) {}
-
- inline explicit NotifyArgs(int32_t id, nsecs_t eventTime) : id(id), eventTime(eventTime) {}
-
- virtual ~NotifyArgs() { }
-
- virtual void notify(InputListenerInterface& listener) const = 0;
-};
-
-
-/* Describes a configuration change event. */
-struct NotifyConfigurationChangedArgs : public NotifyArgs {
-
inline NotifyConfigurationChangedArgs() { }
- bool operator==(const NotifyConfigurationChangedArgs& rhs) const;
-
NotifyConfigurationChangedArgs(int32_t id, nsecs_t eventTime);
- NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other);
+ bool operator==(const NotifyConfigurationChangedArgs& rhs) const = default;
- virtual ~NotifyConfigurationChangedArgs() { }
-
- void notify(InputListenerInterface& listener) const override;
+ NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other) = default;
};
-
/* Describes a key event. */
-struct NotifyKeyArgs : public NotifyArgs {
+struct NotifyKeyArgs {
+ int32_t id;
+ nsecs_t eventTime;
+
int32_t deviceId;
uint32_t source;
int32_t displayId;
@@ -80,18 +64,16 @@
int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
nsecs_t downTime);
- bool operator==(const NotifyKeyArgs& rhs) const;
+ bool operator==(const NotifyKeyArgs& rhs) const = default;
- NotifyKeyArgs(const NotifyKeyArgs& other);
-
- virtual ~NotifyKeyArgs() { }
-
- void notify(InputListenerInterface& listener) const override;
+ NotifyKeyArgs(const NotifyKeyArgs& other) = default;
};
-
/* Describes a motion event. */
-struct NotifyMotionArgs : public NotifyArgs {
+struct NotifyMotionArgs {
+ int32_t id;
+ nsecs_t eventTime;
+
int32_t deviceId;
uint32_t source;
int32_t displayId;
@@ -136,17 +118,16 @@
NotifyMotionArgs(const NotifyMotionArgs& other);
- virtual ~NotifyMotionArgs() { }
-
bool operator==(const NotifyMotionArgs& rhs) const;
- void notify(InputListenerInterface& listener) const override;
-
std::string dump() const;
};
/* Describes a sensor event. */
-struct NotifySensorArgs : public NotifyArgs {
+struct NotifySensorArgs {
+ int32_t id;
+ nsecs_t eventTime;
+
int32_t deviceId;
uint32_t source;
InputDeviceSensorType sensorType;
@@ -161,17 +142,14 @@
InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy,
bool accuracyChanged, nsecs_t hwTimestamp, std::vector<float> values);
- NotifySensorArgs(const NotifySensorArgs& other);
-
- bool operator==(const NotifySensorArgs rhs) const;
-
- ~NotifySensorArgs() override {}
-
- void notify(InputListenerInterface& listener) const override;
+ NotifySensorArgs(const NotifySensorArgs& other) = default;
};
/* Describes a switch event. */
-struct NotifySwitchArgs : public NotifyArgs {
+struct NotifySwitchArgs {
+ int32_t id;
+ nsecs_t eventTime;
+
uint32_t policyFlags;
uint32_t switchValues;
uint32_t switchMask;
@@ -181,54 +159,48 @@
NotifySwitchArgs(int32_t id, nsecs_t eventTime, uint32_t policyFlags, uint32_t switchValues,
uint32_t switchMask);
- NotifySwitchArgs(const NotifySwitchArgs& other);
+ NotifySwitchArgs(const NotifySwitchArgs& other) = default;
- bool operator==(const NotifySwitchArgs rhs) const;
-
- virtual ~NotifySwitchArgs() { }
-
- void notify(InputListenerInterface& listener) const override;
+ bool operator==(const NotifySwitchArgs& rhs) const = default;
};
-
/* Describes a device reset event, such as when a device is added,
* reconfigured, or removed. */
-struct NotifyDeviceResetArgs : public NotifyArgs {
+struct NotifyDeviceResetArgs {
+ int32_t id;
+ nsecs_t eventTime;
+
int32_t deviceId;
inline NotifyDeviceResetArgs() { }
NotifyDeviceResetArgs(int32_t id, nsecs_t eventTime, int32_t deviceId);
- NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other);
+ NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) = default;
- bool operator==(const NotifyDeviceResetArgs& rhs) const;
-
- virtual ~NotifyDeviceResetArgs() { }
-
- void notify(InputListenerInterface& listener) const override;
+ bool operator==(const NotifyDeviceResetArgs& rhs) const = default;
};
/* Describes a change in the state of Pointer Capture. */
-struct NotifyPointerCaptureChangedArgs : public NotifyArgs {
+struct NotifyPointerCaptureChangedArgs {
// The sequence number of the Pointer Capture request, if enabled.
+ int32_t id;
+ nsecs_t eventTime;
+
PointerCaptureRequest request;
inline NotifyPointerCaptureChangedArgs() {}
NotifyPointerCaptureChangedArgs(int32_t id, nsecs_t eventTime, const PointerCaptureRequest&);
- NotifyPointerCaptureChangedArgs(const NotifyPointerCaptureChangedArgs& other);
-
- bool operator==(const NotifyPointerCaptureChangedArgs& rhs) const;
-
- virtual ~NotifyPointerCaptureChangedArgs() {}
-
- void notify(InputListenerInterface& listener) const override;
+ NotifyPointerCaptureChangedArgs(const NotifyPointerCaptureChangedArgs& other) = default;
};
/* Describes a vibrator state event. */
-struct NotifyVibratorStateArgs : public NotifyArgs {
+struct NotifyVibratorStateArgs {
+ int32_t id;
+ nsecs_t eventTime;
+
int32_t deviceId;
bool isOn;
@@ -237,14 +209,12 @@
NotifyVibratorStateArgs(int32_t id, nsecs_t eventTIme, int32_t deviceId, bool isOn);
NotifyVibratorStateArgs(const NotifyVibratorStateArgs& other);
-
- bool operator==(const NotifyVibratorStateArgs rhs) const;
-
- virtual ~NotifyVibratorStateArgs() {}
-
- void notify(InputListenerInterface& listener) const override;
};
+using NotifyArgs = std::variant<NotifyConfigurationChangedArgs, NotifyKeyArgs, NotifyMotionArgs,
+ NotifySensorArgs, NotifySwitchArgs, NotifyDeviceResetArgs,
+ NotifyPointerCaptureChangedArgs, NotifyVibratorStateArgs>;
+
/*
* The interface used by the InputReader to notify the InputListener about input events.
*/
@@ -263,6 +233,8 @@
virtual void notifyVibratorState(const NotifyVibratorStateArgs* args) = 0;
virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) = 0;
virtual void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) = 0;
+
+ void notify(const NotifyArgs& args);
};
/*
@@ -287,7 +259,7 @@
private:
InputListenerInterface& mInnerListener;
- std::vector<std::unique_ptr<NotifyArgs>> mArgsQueue;
+ std::vector<NotifyArgs> mArgsQueue;
};
} // namespace android
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 8c241f2..4cd2cce 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -1950,7 +1950,8 @@
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, currentIdBits, -1,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
mCurrentMotionAborted = true;
}
}
@@ -1970,7 +1971,8 @@
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, currentIdBits, -1,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
}
} else {
// There may be pointers going up and pointers going down and pointers moving
@@ -2005,7 +2007,8 @@
mLastCookedState.cookedPointerData.pointerProperties,
mLastCookedState.cookedPointerData.pointerCoords,
mLastCookedState.cookedPointerData.idToIndex, dispatchedIdBits, upId,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
dispatchedIdBits.clearBit(upId);
mCurrentCookedState.cookedPointerData.canceledIdBits.clearBit(upId);
}
@@ -2020,7 +2023,8 @@
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, dispatchedIdBits, -1,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
}
// Dispatch pointer down events using the new pointer locations.
@@ -2038,7 +2042,8 @@
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, dispatchedIdBits,
- downId, mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ downId, mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
}
}
}
@@ -2054,7 +2059,7 @@
mLastCookedState.cookedPointerData.pointerCoords,
mLastCookedState.cookedPointerData.idToIndex,
mLastCookedState.cookedPointerData.hoveringIdBits, -1, mOrientedXPrecision,
- mOrientedYPrecision, mDownTime);
+ mOrientedYPrecision, mDownTime, MotionClassification::NONE);
mSentHoverEnter = false;
}
}
@@ -2071,7 +2076,8 @@
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex,
mCurrentCookedState.cookedPointerData.hoveringIdBits, -1,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
mSentHoverEnter = true;
}
@@ -2081,7 +2087,8 @@
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex,
mCurrentCookedState.cookedPointerData.hoveringIdBits, -1,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
}
}
@@ -2098,7 +2105,8 @@
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
}
}
@@ -2115,7 +2123,8 @@
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ mOrientedXPrecision, mOrientedYPrecision, mDownTime,
+ MotionClassification::NONE);
}
}
@@ -2502,6 +2511,10 @@
// Send events!
int32_t metaState = getContext()->getGlobalMetaState();
int32_t buttonState = mCurrentCookedState.buttonState;
+ const MotionClassification classification =
+ mPointerGesture.currentGestureMode == PointerGesture::Mode::SWIPE
+ ? MotionClassification::TWO_FINGER_SWIPE
+ : MotionClassification::NONE;
uint32_t flags = 0;
@@ -2542,7 +2555,7 @@
flags, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.lastGestureProperties, mPointerGesture.lastGestureCoords,
mPointerGesture.lastGestureIdToIndex, dispatchedGestureIdBits, -1, 0, 0,
- mPointerGesture.downTime);
+ mPointerGesture.downTime, classification);
dispatchedGestureIdBits.clear();
} else {
@@ -2561,7 +2574,7 @@
AMOTION_EVENT_EDGE_FLAG_NONE, mPointerGesture.lastGestureProperties,
mPointerGesture.lastGestureCoords,
mPointerGesture.lastGestureIdToIndex, dispatchedGestureIdBits, id, 0,
- 0, mPointerGesture.downTime);
+ 0, mPointerGesture.downTime, classification);
dispatchedGestureIdBits.clearBit(id);
}
@@ -2575,7 +2588,7 @@
mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords,
mPointerGesture.currentGestureIdToIndex, dispatchedGestureIdBits, -1, 0, 0,
- mPointerGesture.downTime);
+ mPointerGesture.downTime, classification);
}
// Send motion events for all pointers that went down.
@@ -2595,7 +2608,7 @@
mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords,
mPointerGesture.currentGestureIdToIndex, dispatchedGestureIdBits, id, 0,
- 0, mPointerGesture.downTime);
+ 0, mPointerGesture.downTime, classification);
}
}
@@ -2606,7 +2619,8 @@
mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords,
mPointerGesture.currentGestureIdToIndex,
- mPointerGesture.currentGestureIdBits, -1, 0, 0, mPointerGesture.downTime);
+ mPointerGesture.currentGestureIdBits, -1, 0, 0, mPointerGesture.downTime,
+ MotionClassification::NONE);
} else if (dispatchedGestureIdBits.isEmpty() && !mPointerGesture.lastGestureIdBits.isEmpty()) {
// Synthesize a hover move event after all pointers go up to indicate that
// the pointer is hovering again even if the user is not currently touching
@@ -2653,6 +2667,10 @@
}
void TouchInputMapper::abortPointerGestures(nsecs_t when, nsecs_t readTime, uint32_t policyFlags) {
+ const MotionClassification classification =
+ mPointerGesture.lastGestureMode == PointerGesture::Mode::SWIPE
+ ? MotionClassification::TWO_FINGER_SWIPE
+ : MotionClassification::NONE;
// Cancel previously dispatches pointers.
if (!mPointerGesture.lastGestureIdBits.isEmpty()) {
int32_t metaState = getContext()->getGlobalMetaState();
@@ -2661,7 +2679,7 @@
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.lastGestureProperties, mPointerGesture.lastGestureCoords,
mPointerGesture.lastGestureIdToIndex, mPointerGesture.lastGestureIdBits, -1,
- 0, 0, mPointerGesture.downTime);
+ 0, 0, mPointerGesture.downTime, classification);
}
// Reset the current pointer gesture.
@@ -3611,7 +3629,8 @@
int32_t edgeFlags, const PointerProperties* properties,
const PointerCoords* coords, const uint32_t* idToIndex,
BitSet32 idBits, int32_t changedId, float xPrecision,
- float yPrecision, nsecs_t downTime) {
+ float yPrecision, nsecs_t downTime,
+ MotionClassification classification) {
PointerCoords pointerCoords[MAX_POINTERS];
PointerProperties pointerProperties[MAX_POINTERS];
uint32_t pointerCount = 0;
@@ -3659,9 +3678,9 @@
[this](TouchVideoFrame& frame) { frame.rotate(this->mInputDeviceOrientation); });
NotifyMotionArgs args(getContext()->getNextId(), when, readTime, deviceId, source, displayId,
policyFlags, action, actionButton, flags, metaState, buttonState,
- MotionClassification::NONE, edgeFlags, pointerCount, pointerProperties,
- pointerCoords, xPrecision, yPrecision, xCursorPosition, yCursorPosition,
- downTime, std::move(frames));
+ classification, edgeFlags, pointerCount, pointerProperties, pointerCoords,
+ xPrecision, yPrecision, xCursorPosition, yCursorPosition, downTime,
+ std::move(frames));
getListener().notifyMotion(&args);
}
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index bd4cff6..31806e1 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -779,7 +779,8 @@
int32_t action, int32_t actionButton, int32_t flags, int32_t metaState,
int32_t buttonState, int32_t edgeFlags, const PointerProperties* properties,
const PointerCoords* coords, const uint32_t* idToIndex, BitSet32 idBits,
- int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime);
+ int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime,
+ MotionClassification classification);
// Updates pointer coords and properties for pointers with specified ids that have moved.
// Returns true if any of them changed.
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 5577bd4..f1f1abd 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -9751,6 +9751,7 @@
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(MotionClassification::NONE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(
assertPointerCoords(motionArgs.pointerCoords[0], 0, 0, 1, 0, 0, 0, 0, 0, 0, 0));
@@ -9772,6 +9773,7 @@
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(MotionClassification::TWO_FINGER_SWIPE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0], 0,
movingDistance * mPointerMovementScale, 1, 0, 0, 0,
0, 0, 0, 0));
@@ -9809,6 +9811,7 @@
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(MotionClassification::NONE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(
assertPointerCoords(motionArgs.pointerCoords[0], 0, 0, 1, 0, 0, 0, 0, 0, 0, 0));
@@ -9830,6 +9833,7 @@
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(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,
movingDistance * mPointerMovementScale, 1, 0, 0, 0,
@@ -9863,6 +9867,7 @@
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(MotionClassification::NONE, motionArgs.classification);
// One pointer for PRESS, and its coordinate is used as the origin for pointer coordinates.
ASSERT_NO_FATAL_FAILURE(
assertPointerCoords(motionArgs.pointerCoords[0], 0, 0, 1, 0, 0, 0, 0, 0, 0, 0));
@@ -9892,9 +9897,11 @@
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(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(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.
float cookedX1 = (x1 - x2) / 2 * mPointerXZoomScale;
@@ -9924,6 +9931,7 @@
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(MotionClassification::NONE, motionArgs.classification);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0], cookedX1,
movingDistance * 2 * mPointerMovementScale, 1, 0, 0,
0, 0, 0, 0, 0));
diff --git a/services/stats/StatsAidl.cpp b/services/stats/StatsAidl.cpp
index 8d6a9bd..3de51a4 100644
--- a/services/stats/StatsAidl.cpp
+++ b/services/stats/StatsAidl.cpp
@@ -66,6 +66,61 @@
AStatsEvent_writeBool(event,
atomValue.get<VendorAtomValue::boolValue>());
break;
+ case VendorAtomValue::repeatedIntValue: {
+ const std::optional<std::vector<int>>& repeatedIntValue =
+ atomValue.get<VendorAtomValue::repeatedIntValue>();
+ AStatsEvent_writeInt32Array(event, repeatedIntValue->data(),
+ repeatedIntValue->size());
+ break;
+ }
+ case VendorAtomValue::repeatedLongValue: {
+ const std::optional<std::vector<int64_t>>& repeatedLongValue =
+ atomValue.get<VendorAtomValue::repeatedLongValue>();
+ AStatsEvent_writeInt64Array(event, repeatedLongValue->data(),
+ repeatedLongValue->size());
+ break;
+ }
+ case VendorAtomValue::repeatedFloatValue: {
+ const std::optional<std::vector<float>>& repeatedFloatValue =
+ atomValue.get<VendorAtomValue::repeatedFloatValue>();
+ AStatsEvent_writeFloatArray(event, repeatedFloatValue->data(),
+ repeatedFloatValue->size());
+ break;
+ }
+ case VendorAtomValue::repeatedStringValue: {
+ const std::optional<std::vector<std::optional<std::string>>>& repeatedStringValue =
+ atomValue.get<VendorAtomValue::repeatedStringValue>();
+ const std::vector<std::optional<std::string>>& repeatedStringVector =
+ *repeatedStringValue;
+ const char* cStringArray[repeatedStringVector.size()];
+
+ for (int i = 0; i < repeatedStringVector.size(); ++i) {
+ cStringArray[i] = repeatedStringVector[i]->c_str();
+ }
+
+ AStatsEvent_writeStringArray(event, cStringArray, repeatedStringVector.size());
+ break;
+ }
+ case VendorAtomValue::repeatedBoolValue: {
+ const std::optional<std::vector<bool>>& repeatedBoolValue =
+ atomValue.get<VendorAtomValue::repeatedBoolValue>();
+ const std::vector<bool>& repeatedBoolVector = *repeatedBoolValue;
+ bool boolArray[repeatedBoolValue->size()];
+
+ for (int i = 0; i < repeatedBoolVector.size(); ++i) {
+ boolArray[i] = repeatedBoolVector[i];
+ }
+
+ AStatsEvent_writeBoolArray(event, boolArray, repeatedBoolVector.size());
+ break;
+ }
+ case VendorAtomValue::byteArrayValue: {
+ const std::optional<std::vector<uint8_t>>& byteArrayValue =
+ atomValue.get<VendorAtomValue::byteArrayValue>();
+
+ AStatsEvent_writeByteArray(event, byteArrayValue->data(), byteArrayValue->size());
+ break;
+ }
}
}
AStatsEvent_build(event);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f3551ae..e27c713 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4935,6 +4935,25 @@
const auto flag = args.empty() ? ""s : std::string(String8(args[0]));
+ // Traversal of drawing state must happen on the main thread.
+ // Otherwise, SortedVector may have shared ownership during concurrent
+ // traversals, which can result in use-after-frees.
+ std::string compositionLayers;
+ mScheduler
+ ->schedule([&] {
+ StringAppendF(&compositionLayers, "Composition layers\n");
+ mDrawingState.traverseInZOrder([&](Layer* layer) {
+ auto* compositionState = layer->getCompositionState();
+ if (!compositionState || !compositionState->isVisible) return;
+
+ android::base::StringAppendF(&compositionLayers, "* Layer %p (%s)\n", layer,
+ layer->getDebugName() ? layer->getDebugName()
+ : "<unknown>");
+ compositionState->dump(compositionLayers);
+ });
+ })
+ .get();
+
bool dumpLayers = true;
{
TimedLock lock(mStateLock, s2ns(1), __func__);
@@ -4947,7 +4966,7 @@
(it->second)(args, asProto, result);
dumpLayers = false;
} else if (!asProto) {
- dumpAllLocked(args, result);
+ dumpAllLocked(args, compositionLayers, result);
}
}
@@ -5254,7 +5273,8 @@
}
}
-void SurfaceFlinger::dumpAllLocked(const DumpArgs& args, std::string& result) const {
+void SurfaceFlinger::dumpAllLocked(const DumpArgs& args, const std::string& compositionLayers,
+ std::string& result) const {
const bool colorize = !args.empty() && args[0] == String16("--color");
Colorizer colorizer(colorize);
@@ -5302,18 +5322,7 @@
StringAppendF(&result, "Visible layers (count = %zu)\n", mNumLayers.load());
colorizer.reset(result);
- {
- StringAppendF(&result, "Composition layers\n");
- mDrawingState.traverseInZOrder([&](Layer* layer) {
- auto* compositionState = layer->getCompositionState();
- if (!compositionState || !compositionState->isVisible) return;
-
- android::base::StringAppendF(&result, "* Layer %p (%s)\n", layer,
- layer->getDebugName() ? layer->getDebugName()
- : "<unknown>");
- compositionState->dump(result);
- });
- }
+ result.append(compositionLayers);
colorizer.bold(result);
StringAppendF(&result, "Displays (%zu entries)\n", mDisplays.size());
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index fdaacf0..3c92d56 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -1044,7 +1044,8 @@
/*
* Debugging & dumpsys
*/
- void dumpAllLocked(const DumpArgs& args, std::string& result) const REQUIRES(mStateLock);
+ void dumpAllLocked(const DumpArgs& args, const std::string& compositionLayers,
+ std::string& result) const REQUIRES(mStateLock);
void dumpHwcLayersMinidumpLocked(std::string& result) const REQUIRES(mStateLock);
void appendSfConfigString(std::string& result) const;
diff --git a/services/surfaceflinger/layerproto/Android.bp b/services/surfaceflinger/layerproto/Android.bp
index 973a439..7287dd0 100644
--- a/services/surfaceflinger/layerproto/Android.bp
+++ b/services/surfaceflinger/layerproto/Android.bp
@@ -44,10 +44,11 @@
}
java_library_static {
- name: "layersprotosnano",
+ name: "layersprotoslite",
host_supported: true,
proto: {
- type: "nano",
+ type: "lite",
+ include_dirs: ["external/protobuf/src"],
},
srcs: ["*.proto"],
sdk_version: "core_platform",
@@ -56,7 +57,7 @@
jarjar_rules: "jarjar-rules.txt",
},
host: {
- static_libs: ["libprotobuf-java-nano"],
+ static_libs: ["libprotobuf-java-lite"],
},
},
}