From 8d66013c673bb8e3e8876907f0ad80c91580a443 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Thu, 11 Jan 2024 16:48:44 -0800 Subject: Use aidl-defined InputChannel for parceling Currently, InputChannel is a manually-written parcelable. In this CL, we introduce an aidl-defined InputChannel, which eventually could also be used in Java as well. Now, whenever an InputChannel needs to be written to parcel, we first create the new android.os.InputChannel and then write that object to parcel. Eventually, we can convert the Java side of InputChannel to use this mechanism, as well. Bug: 161009324 Test: adb shell monkey 1000 Test: atest libgui_test Change-Id: Ib44c5ff02b3c77e0425b59a76195ed100e187317 --- services/inputflinger/InputManager.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'services/inputflinger/InputManager.cpp') diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp index 4863513eb5..823df67d16 100644 --- a/services/inputflinger/InputManager.cpp +++ b/services/inputflinger/InputManager.cpp @@ -260,13 +260,16 @@ void InputManager::dump(std::string& dump) { } // Used by tests only. -binder::Status InputManager::createInputChannel(const std::string& name, InputChannel* outChannel) { +binder::Status InputManager::createInputChannel(const std::string& name, + android::os::InputChannelCore* outChannel) { IPCThreadState* ipc = IPCThreadState::self(); - const int uid = ipc->getCallingUid(); + const uid_t uid = ipc->getCallingUid(); if (uid != AID_SHELL && uid != AID_ROOT) { - ALOGE("Invalid attempt to register input channel over IPC" - "from non shell/root entity (PID: %d)", ipc->getCallingPid()); - return binder::Status::ok(); + LOG(ERROR) << __func__ << " can only be called by SHELL or ROOT users, " + << "but was called from UID " << uid; + return binder::Status:: + fromExceptionCode(EX_SECURITY, + "This uid is not allowed to call createInputChannel"); } base::Result> channel = mDispatcher->createInputChannel(name); -- cgit v1.2.3-59-g8ed1b