Skip to content

Commit eeec678

Browse files
Arpit SinghAndroid (Google) Code Review
authored andcommitted
Revert "[11/n Dispatcher refactor] Move isTouchTrusted to WindowInfo"
Revert submission 31063667 Reason for revert: b/389024840 Reverted changes: /q/submissionid:31063667 Change-Id: I6e49f735d54317d86e309c31d1694c9ee75dc553
1 parent 60448cf commit eeec678

2 files changed

Lines changed: 15 additions & 19 deletions

File tree

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ InputDispatcher::InputDispatcher(InputDispatcherPolicyInterface& policy,
954954
mDispatchEnabled(false),
955955
mDispatchFrozen(false),
956956
mInputFilterEnabled(false),
957+
mMaximumObscuringOpacityForTouch(1.0f),
957958
mFocusedDisplayId(ui::LogicalDisplayId::DEFAULT),
958959
mWindowTokenWithPointerCapture(nullptr),
959960
mAwaitedApplicationDisplayId(ui::LogicalDisplayId::INVALID),
@@ -3163,8 +3164,8 @@ InputDispatcher::DispatcherWindowInfo::computeTouchOcclusionInfo(
31633164
return info;
31643165
}
31653166

3166-
bool InputDispatcher::DispatcherWindowInfo::isTouchTrusted(
3167-
const TouchOcclusionInfo& occlusionInfo) const {
3167+
bool InputDispatcher::isTouchTrustedLocked(
3168+
const DispatcherWindowInfo::TouchOcclusionInfo& occlusionInfo) const {
31683169
if (occlusionInfo.hasBlockingOcclusion) {
31693170
ALOGW("Untrusted touch due to occlusion by %s/%s", occlusionInfo.obscuringPackage.c_str(),
31703171
occlusionInfo.obscuringUid.toString().c_str());
@@ -5270,9 +5271,8 @@ std::string InputDispatcher::DispatcherWindowInfo::dumpDisplayAndWindowInfo() co
52705271
return dump;
52715272
}
52725273

5273-
bool InputDispatcher::canWindowReceiveMotionLocked(
5274-
const sp<android::gui::WindowInfoHandle>& window,
5275-
const android::inputdispatcher::MotionEntry& motionEntry) const {
5274+
bool InputDispatcher::canWindowReceiveMotionLocked(const sp<WindowInfoHandle>& window,
5275+
const MotionEntry& motionEntry) const {
52765276
const WindowInfo& info = *window->getInfo();
52775277

52785278
// Skip spy window targets that are not valid for targeted injection.
@@ -5307,7 +5307,7 @@ bool InputDispatcher::canWindowReceiveMotionLocked(
53075307
const auto [x, y] = resolveTouchedPosition(motionEntry);
53085308
DispatcherWindowInfo::TouchOcclusionInfo occlusionInfo =
53095309
mWindowInfos.computeTouchOcclusionInfo(window, x, y);
5310-
if (!mWindowInfos.isTouchTrusted(occlusionInfo)) {
5310+
if (!isTouchTrustedLocked(occlusionInfo)) {
53115311
if (DEBUG_TOUCH_OCCLUSION) {
53125312
ALOGD("Stack of obscuring windows during untrusted touch (%.1f, %.1f):", x, y);
53135313
for (const auto& log : occlusionInfo.debugInfo) {
@@ -5751,8 +5751,13 @@ bool InputDispatcher::recentWindowsAreOwnedByLocked(gui::Pid pid, gui::Uid uid)
57515751
}
57525752

57535753
void InputDispatcher::setMaximumObscuringOpacityForTouch(float opacity) {
5754+
if (opacity < 0 || opacity > 1) {
5755+
LOG_ALWAYS_FATAL("Maximum obscuring opacity for touch should be >= 0 and <= 1");
5756+
return;
5757+
}
5758+
57545759
std::scoped_lock lock(mLock);
5755-
mWindowInfos.setMaximumObscuringOpacityForTouch(opacity);
5760+
mMaximumObscuringOpacityForTouch = opacity;
57565761
}
57575762

57585763
std::tuple<const TouchState*, const TouchedWindow*, ui::LogicalDisplayId>
@@ -7357,11 +7362,4 @@ std::string InputDispatcher::ConnectionManager::dump(nsecs_t currentTime) const
73577362
return dump;
73587363
}
73597364

7360-
void InputDispatcher::DispatcherWindowInfo::setMaximumObscuringOpacityForTouch(float opacity) {
7361-
if (opacity < 0 || opacity > 1) {
7362-
LOG_ALWAYS_FATAL("Maximum obscuring opacity for touch should be >= 0 and <= 1");
7363-
}
7364-
mMaximumObscuringOpacityForTouch = opacity;
7365-
}
7366-
73677365
} // namespace android::inputdispatcher

services/inputflinger/dispatcher/InputDispatcher.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,6 @@ class InputDispatcher : public android::InputDispatcherInterface {
290290

291291
void removeDisplay(ui::LogicalDisplayId displayId);
292292

293-
void setMaximumObscuringOpacityForTouch(float opacity);
294-
295293
// Get a reference to window handles by display, return an empty vector if not found.
296294
const std::vector<sp<android::gui::WindowInfoHandle>>& getWindowHandlesForDisplay(
297295
ui::LogicalDisplayId displayId) const;
@@ -336,8 +334,6 @@ class InputDispatcher : public android::InputDispatcherInterface {
336334
sp<android::gui::WindowInfoHandle> findWallpaperWindowBelow(
337335
const sp<android::gui::WindowInfoHandle>& windowHandle) const;
338336

339-
bool isTouchTrusted(const TouchOcclusionInfo& occlusionInfo) const;
340-
341337
std::string dumpDisplayAndWindowInfo() const;
342338

343339
private:
@@ -346,7 +342,6 @@ class InputDispatcher : public android::InputDispatcherInterface {
346342
mWindowHandlesByDisplay;
347343
std::unordered_map<ui::LogicalDisplayId /*displayId*/, android::gui::DisplayInfo>
348344
mDisplayInfos;
349-
float mMaximumObscuringOpacityForTouch{1.0f};
350345
};
351346

352347
DispatcherWindowInfo mWindowInfos GUARDED_BY(mLock);
@@ -448,6 +443,7 @@ class InputDispatcher : public android::InputDispatcherInterface {
448443
bool mDispatchEnabled GUARDED_BY(mLock);
449444
bool mDispatchFrozen GUARDED_BY(mLock);
450445
bool mInputFilterEnabled GUARDED_BY(mLock);
446+
float mMaximumObscuringOpacityForTouch GUARDED_BY(mLock);
451447

452448
// This map is not really needed, but it helps a lot with debugging (dumpsys input).
453449
// In the java layer, touch mode states are spread across multiple DisplayContent objects,
@@ -650,6 +646,8 @@ class InputDispatcher : public android::InputDispatcherInterface {
650646
void addDragEventLocked(const MotionEntry& entry) REQUIRES(mLock);
651647
void finishDragAndDrop(ui::LogicalDisplayId displayId, float x, float y) REQUIRES(mLock);
652648

649+
bool isTouchTrustedLocked(const DispatcherWindowInfo::TouchOcclusionInfo& occlusionInfo) const
650+
REQUIRES(mLock);
653651
std::string getApplicationWindowLabel(const InputApplicationHandle* applicationHandle,
654652
const sp<android::gui::WindowInfoHandle>& windowHandle);
655653

0 commit comments

Comments
 (0)