Cleanup: Block untrusted touches in InputDispatcher
This change removes the BlockUntrustedTouchesMode enum, and related
code, as block_untrusted_touches is now always enforced
Fix: 169067926
Test: atest WindowUntrustedTouchTest
Change-Id: Ie039fb06c2ee7e03d726545190e4e75f58978066
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 1cc4589..4f6c696 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -57,7 +57,6 @@
using android::gui::TouchOcclusionMode;
using android::gui::WindowInfo;
using android::gui::WindowInfoHandle;
-using android::os::BlockUntrustedTouchesMode;
using android::os::IInputConstants;
using android::os::InputEventInjectionResult;
using android::os::InputEventInjectionSync;
@@ -2198,23 +2197,17 @@
}
// Drop events that can't be trusted due to occlusion
- if (mBlockUntrustedTouchesMode != BlockUntrustedTouchesMode::DISABLED) {
- TouchOcclusionInfo occlusionInfo =
- computeTouchOcclusionInfoLocked(windowHandle, x, y);
- if (!isTouchTrustedLocked(occlusionInfo)) {
- if (DEBUG_TOUCH_OCCLUSION) {
- ALOGD("Stack of obscuring windows during untrusted touch (%d, %d):", x, y);
- for (const auto& log : occlusionInfo.debugInfo) {
- ALOGD("%s", log.c_str());
- }
- }
- sendUntrustedTouchCommandLocked(occlusionInfo.obscuringPackage);
- if (mBlockUntrustedTouchesMode == BlockUntrustedTouchesMode::BLOCK) {
- ALOGW("Dropping untrusted touch event due to %s/%d",
- occlusionInfo.obscuringPackage.c_str(), occlusionInfo.obscuringUid);
- continue;
+ TouchOcclusionInfo occlusionInfo = computeTouchOcclusionInfoLocked(windowHandle, x, y);
+ if (!isTouchTrustedLocked(occlusionInfo)) {
+ if (DEBUG_TOUCH_OCCLUSION) {
+ ALOGD("Stack of obscuring windows during untrusted touch (%d, %d):", x, y);
+ for (const auto& log : occlusionInfo.debugInfo) {
+ ALOGD("%s", log.c_str());
}
}
+ ALOGW("Dropping untrusted touch event due to %s/%d",
+ occlusionInfo.obscuringPackage.c_str(), occlusionInfo.obscuringUid);
+ continue;
}
// Drop touch events if requested by input feature
@@ -5051,11 +5044,6 @@
mMaximumObscuringOpacityForTouch = opacity;
}
-void InputDispatcher::setBlockUntrustedTouchesMode(BlockUntrustedTouchesMode mode) {
- std::scoped_lock lock(mLock);
- mBlockUntrustedTouchesMode = mode;
-}
-
std::pair<TouchState*, TouchedWindow*> InputDispatcher::findTouchStateAndWindowLocked(
const sp<IBinder>& token) {
for (auto& [displayId, state] : mTouchStatesByDisplay) {
@@ -5815,14 +5803,6 @@
postCommandLocked(std::move(command));
}
-void InputDispatcher::sendUntrustedTouchCommandLocked(const std::string& obscuringPackage) {
- auto command = [this, obscuringPackage]() REQUIRES(mLock) {
- scoped_unlock unlock(mLock);
- mPolicy->notifyUntrustedTouch(obscuringPackage);
- };
- postCommandLocked(std::move(command));
-}
-
void InputDispatcher::onAnrLocked(const sp<Connection>& connection) {
if (connection == nullptr) {
LOG_ALWAYS_FATAL("Caller must check for nullness");
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index f3dac19..68b8411 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -121,7 +121,6 @@
void setInputFilterEnabled(bool enabled) override;
bool setInTouchMode(bool inTouchMode, int32_t pid, int32_t uid, bool hasPermission) override;
void setMaximumObscuringOpacityForTouch(float opacity) override;
- void setBlockUntrustedTouchesMode(android::os::BlockUntrustedTouchesMode mode) override;
bool transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken,
bool isDragDrop = false) override;
@@ -344,7 +343,6 @@
bool mInputFilterEnabled GUARDED_BY(mLock);
bool mInTouchMode GUARDED_BY(mLock);
float mMaximumObscuringOpacityForTouch GUARDED_BY(mLock);
- android::os::BlockUntrustedTouchesMode mBlockUntrustedTouchesMode GUARDED_BY(mLock);
class DispatcherWindowListener : public gui::WindowInfosListener {
public:
@@ -654,7 +652,6 @@
void sendFocusChangedCommandLocked(const sp<IBinder>& oldToken, const sp<IBinder>& newToken)
REQUIRES(mLock);
void sendDropWindowCommandLocked(const sp<IBinder>& token, float x, float y) REQUIRES(mLock);
- void sendUntrustedTouchCommandLocked(const std::string& obscuringPackage) REQUIRES(mLock);
void onAnrLocked(const sp<Connection>& connection) REQUIRES(mLock);
void onAnrLocked(std::shared_ptr<InputApplicationHandle> application) REQUIRES(mLock);
void updateLastAnrStateLocked(const sp<android::gui::WindowInfoHandle>& window,
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
index d7bc5fb..c7723d0 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
@@ -20,7 +20,7 @@
#include <InputListener.h>
#include <android-base/result.h>
#include <android/gui/FocusRequest.h>
-#include <android/os/BlockUntrustedTouchesMode.h>
+
#include <android/os/InputEventInjectionResult.h>
#include <android/os/InputEventInjectionSync.h>
#include <gui/InputApplication.h>
@@ -136,13 +136,6 @@
*/
virtual void setMaximumObscuringOpacityForTouch(float opacity) = 0;
- /**
- * Sets the mode of the block untrusted touches feature.
- *
- * TODO(b/169067926): Clean-up feature modes.
- */
- virtual void setBlockUntrustedTouchesMode(android::os::BlockUntrustedTouchesMode mode) = 0;
-
/* Transfers touch focus from one window to another window.
*
* Returns true on success. False if the window did not actually have touch focus.
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
index de0b6da..13ed34c 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
@@ -75,9 +75,6 @@
InputDeviceSensorAccuracy accuracy) = 0;
virtual void notifyVibratorState(int32_t deviceId, bool isOn) = 0;
- /* Notifies the system that an untrusted touch occurred. */
- virtual void notifyUntrustedTouch(const std::string& obscuringPackage) = 0;
-
/* Gets the input dispatcher configuration. */
virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) = 0;