@@ -224,120 +224,6 @@ class InputDispatcher : public android::InputDispatcherInterface {
224224 /* * Stores the latest user-activity poke event times per user activity types. */
225225 std::array<nsecs_t , USER_ACTIVITY_EVENT_LAST + 1 > mLastUserActivityTimes GUARDED_BY (mLock );
226226
227- template <typename T>
228- struct StrongPointerHash {
229- std::size_t operator ()(const sp<T>& b) const { return std::hash<T*>{}(b.get ()); }
230- };
231-
232- class ConnectionManager {
233- public:
234- ConnectionManager (sp<Looper> lopper);
235- ~ConnectionManager ();
236-
237- std::shared_ptr<Connection> getConnection (const sp<IBinder>& inputConnectionToken) const ;
238- std::string getConnectionName (const sp<IBinder>& connectionToken) const ;
239-
240- // Find a monitor pid by the provided token.
241- std::optional<gui::Pid> findMonitorPidByToken (const sp<IBinder>& token) const ;
242- void forEachGlobalMonitorConnection (
243- std::function<void (const std::shared_ptr<Connection>&)> f) const ;
244- void forEachGlobalMonitorConnection (
245- ui::LogicalDisplayId displayId,
246- std::function<void (const std::shared_ptr<Connection>&)> f) const ;
247-
248- void createGlobalInputMonitor (ui::LogicalDisplayId displayId,
249- std::unique_ptr<InputChannel>&& inputChannel,
250- const IdGenerator& idGenerator, gui::Pid pid);
251-
252- status_t removeInputChannel (const std::shared_ptr<Connection>& connection);
253- void removeConnection (const std::shared_ptr<Connection>& connection);
254-
255- void createConnection (std::unique_ptr<InputChannel>&& inputChannel,
256- const IdGenerator& idGenerator);
257-
258- std::string dump (nsecs_t currentTime) const ;
259-
260- private:
261- sp<Looper> mLooper ;
262-
263- // All registered connections mapped by input channel token.
264- std::unordered_map<sp<IBinder>, std::shared_ptr<Connection>, StrongPointerHash<IBinder>>
265- mConnectionsByToken ;
266-
267- // Input channels that will receive a copy of all input events sent to the provided display.
268- std::unordered_map<ui::LogicalDisplayId, std::vector<Monitor>> mGlobalMonitorsByDisplay ;
269-
270- void removeMonitorChannel (const sp<IBinder>& connectionToken);
271- };
272-
273- ConnectionManager mConnectionManager GUARDED_BY (mLock );
274-
275- class DispatcherWindowInfo {
276- public:
277- struct TouchOcclusionInfo {
278- bool hasBlockingOcclusion;
279- float obscuringOpacity;
280- std::string obscuringPackage;
281- gui::Uid obscuringUid = gui::Uid::INVALID;
282- std::vector<std::string> debugInfo;
283- };
284-
285- void setWindowHandlesForDisplay (
286- ui::LogicalDisplayId displayId,
287- std::vector<sp<android::gui::WindowInfoHandle>>&& windowHandles);
288-
289- void setDisplayInfos (const std::vector<android::gui::DisplayInfo>& displayInfos);
290-
291- void removeDisplay (ui::LogicalDisplayId displayId);
292-
293- // Get a reference to window handles by display, return an empty vector if not found.
294- const std::vector<sp<android::gui::WindowInfoHandle>>& getWindowHandlesForDisplay (
295- ui::LogicalDisplayId displayId) const ;
296-
297- void forEachWindowHandle (
298- std::function<void (const sp<android::gui::WindowInfoHandle>&)> f) const ;
299-
300- void forEachDisplayId (std::function<void (ui::LogicalDisplayId)> f) const ;
301-
302- // Get the transform for display, returns Identity-transform if display is missing.
303- ui::Transform getDisplayTransform (ui::LogicalDisplayId displayId) const ;
304-
305- // Get the raw transform to use for motion events going to the given window.
306- ui::Transform getRawTransform (const android::gui::WindowInfo&) const ;
307-
308- // Lookup for WindowInfoHandle from token and optionally a display-id. In cases where
309- // display-id is not provided lookup is done for all displays.
310- sp<android::gui::WindowInfoHandle> findWindowHandle (
311- const sp<IBinder>& windowHandleToken,
312- std::optional<ui::LogicalDisplayId> displayId = {}) const ;
313-
314- bool isWindowPresent (const sp<android::gui::WindowInfoHandle>& windowHandle) const ;
315-
316- // Returns the touched window at the given location, excluding the ignoreWindow if provided.
317- sp<android::gui::WindowInfoHandle> findTouchedWindowAt (
318- ui::LogicalDisplayId displayId, float x, float y, bool isStylus = false ,
319- const sp<android::gui::WindowInfoHandle> ignoreWindow = nullptr ) const ;
320-
321- std::vector<sp<android::gui::WindowInfoHandle>> findTouchedSpyWindowsAt (
322- ui::LogicalDisplayId displayId, float x, float y, bool isStylus, DeviceId deviceId,
323- const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay)
324- const ;
325-
326- TouchOcclusionInfo computeTouchOcclusionInfo (
327- const sp<android::gui::WindowInfoHandle>& windowHandle, float x, float y) const ;
328-
329- std::string dumpDisplayAndWindowInfo () const ;
330-
331- private:
332- std::unordered_map<ui::LogicalDisplayId /* displayId*/ ,
333- std::vector<sp<android::gui::WindowInfoHandle>>>
334- mWindowHandlesByDisplay ;
335- std::unordered_map<ui::LogicalDisplayId /* displayId*/ , android::gui::DisplayInfo>
336- mDisplayInfos ;
337- };
338-
339- DispatcherWindowInfo mWindowInfos GUARDED_BY (mLock );
340-
341227 // With each iteration, InputDispatcher nominally processes one queued event,
342228 // a timeout, or a response from an input consumer.
343229 // This method should only be called on the input dispatcher's own thread.
@@ -376,6 +262,11 @@ class InputDispatcher : public android::InputDispatcherInterface {
376262
377263 status_t pilferPointersLocked (const sp<IBinder>& token) REQUIRES(mLock );
378264
265+ template <typename T>
266+ struct StrongPointerHash {
267+ std::size_t operator ()(const sp<T>& b) const { return std::hash<T*>{}(b.get ()); }
268+ };
269+
379270 const HmacKeyManager mHmacKeyManager ;
380271 const std::array<uint8_t , 32 > getSignature (const MotionEntry& motionEntry,
381272 const DispatchEntry& dispatchEntry) const ;
@@ -453,6 +344,103 @@ class InputDispatcher : public android::InputDispatcherInterface {
453344 };
454345 sp<gui::WindowInfosListener> mWindowInfoListener ;
455346
347+ class DispatcherWindowInfo {
348+ public:
349+ void setWindowHandlesForDisplay (
350+ ui::LogicalDisplayId displayId,
351+ std::vector<sp<android::gui::WindowInfoHandle>>&& windowHandles);
352+
353+ void setDisplayInfos (const std::vector<android::gui::DisplayInfo>& displayInfos);
354+
355+ void removeDisplay (ui::LogicalDisplayId displayId);
356+
357+ // Get a reference to window handles by display, return an empty vector if not found.
358+ const std::vector<sp<android::gui::WindowInfoHandle>>& getWindowHandlesForDisplay (
359+ ui::LogicalDisplayId displayId) const ;
360+
361+ void forEachWindowHandle (
362+ std::function<void (const sp<android::gui::WindowInfoHandle>&)> f) const ;
363+
364+ void forEachDisplayId (std::function<void (ui::LogicalDisplayId)> f) const ;
365+
366+ // Get the transform for display, returns Identity-transform if display is missing.
367+ ui::Transform getDisplayTransform (ui::LogicalDisplayId displayId) const ;
368+
369+ // Get the raw transform to use for motion events going to the given window.
370+ ui::Transform getRawTransform (const android::gui::WindowInfo&) const ;
371+
372+ // Lookup for WindowInfoHandle from token and optionally a display-id. In cases where
373+ // display-id is not provided lookup is done for all displays.
374+ sp<android::gui::WindowInfoHandle> findWindowHandle (
375+ const sp<IBinder>& windowHandleToken,
376+ std::optional<ui::LogicalDisplayId> displayId = {}) const ;
377+
378+ bool isWindowPresent (const sp<android::gui::WindowInfoHandle>& windowHandle) const ;
379+
380+ // Returns the touched window at the given location, excluding the ignoreWindow if provided.
381+ sp<android::gui::WindowInfoHandle> findTouchedWindowAt (
382+ ui::LogicalDisplayId displayId, float x, float y, bool isStylus = false ,
383+ const sp<android::gui::WindowInfoHandle> ignoreWindow = nullptr ) const ;
384+
385+ std::vector<sp<android::gui::WindowInfoHandle>> findTouchedSpyWindowsAt (
386+ ui::LogicalDisplayId displayId, float x, float y, bool isStylus, DeviceId deviceId,
387+ const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay)
388+ const ;
389+
390+ std::string dumpDisplayAndWindowInfo () const ;
391+
392+ private:
393+ std::unordered_map<ui::LogicalDisplayId /* displayId*/ ,
394+ std::vector<sp<android::gui::WindowInfoHandle>>>
395+ mWindowHandlesByDisplay ;
396+ std::unordered_map<ui::LogicalDisplayId /* displayId*/ , android::gui::DisplayInfo>
397+ mDisplayInfos ;
398+ };
399+
400+ DispatcherWindowInfo mWindowInfos GUARDED_BY (mLock );
401+
402+ class ConnectionManager {
403+ public:
404+ ConnectionManager (sp<Looper> lopper);
405+ ~ConnectionManager ();
406+
407+ std::shared_ptr<Connection> getConnection (const sp<IBinder>& inputConnectionToken) const ;
408+
409+ // Find a monitor pid by the provided token.
410+ std::optional<gui::Pid> findMonitorPidByToken (const sp<IBinder>& token) const ;
411+ void forEachGlobalMonitorConnection (
412+ std::function<void (const std::shared_ptr<Connection>&)> f) const ;
413+ void forEachGlobalMonitorConnection (
414+ ui::LogicalDisplayId displayId,
415+ std::function<void (const std::shared_ptr<Connection>&)> f) const ;
416+
417+ void createGlobalInputMonitor (ui::LogicalDisplayId displayId,
418+ std::unique_ptr<InputChannel>&& inputChannel,
419+ const IdGenerator& idGenerator, gui::Pid pid);
420+
421+ status_t removeInputChannel (const std::shared_ptr<Connection>& connection);
422+ void removeConnection (const std::shared_ptr<Connection>& connection);
423+
424+ void createConnection (std::unique_ptr<InputChannel>&& inputChannel,
425+ const IdGenerator& idGenerator);
426+
427+ std::string dump (nsecs_t currentTime) const ;
428+
429+ private:
430+ sp<Looper> mLooper ;
431+
432+ // All registered connections mapped by input channel token.
433+ std::unordered_map<sp<IBinder>, std::shared_ptr<Connection>, StrongPointerHash<IBinder>>
434+ mConnectionsByToken ;
435+
436+ // Input channels that will receive a copy of all input events sent to the provided display.
437+ std::unordered_map<ui::LogicalDisplayId, std::vector<Monitor>> mGlobalMonitorsByDisplay ;
438+
439+ void removeMonitorChannel (const sp<IBinder>& connectionToken);
440+ };
441+
442+ ConnectionManager mConnectionManager GUARDED_BY (mLock );
443+
456444 void setInputWindowsLocked (
457445 const std::vector<sp<android::gui::WindowInfoHandle>>& inputWindowHandles,
458446 ui::LogicalDisplayId displayId) REQUIRES(mLock );
@@ -638,12 +626,24 @@ class InputDispatcher : public android::InputDispatcherInterface {
638626 void addDragEventLocked (const MotionEntry& entry) REQUIRES(mLock );
639627 void finishDragAndDrop (ui::LogicalDisplayId displayId, float x, float y) REQUIRES(mLock );
640628
641- bool isTouchTrustedLocked (const DispatcherWindowInfo::TouchOcclusionInfo& occlusionInfo) const
629+ struct TouchOcclusionInfo {
630+ bool hasBlockingOcclusion;
631+ float obscuringOpacity;
632+ std::string obscuringPackage;
633+ gui::Uid obscuringUid = gui::Uid::INVALID;
634+ std::vector<std::string> debugInfo;
635+ };
636+
637+ TouchOcclusionInfo computeTouchOcclusionInfoLocked (
638+ const sp<android::gui::WindowInfoHandle>& windowHandle, float x, float y) const
642639 REQUIRES(mLock );
640+ bool isTouchTrustedLocked (const TouchOcclusionInfo& occlusionInfo) const REQUIRES(mLock );
643641 bool isWindowObscuredAtPointLocked (const sp<android::gui::WindowInfoHandle>& windowHandle,
644642 float x, float y) const REQUIRES(mLock );
645643 bool isWindowObscuredLocked (const sp<android::gui::WindowInfoHandle>& windowHandle) const
646644 REQUIRES(mLock );
645+ std::string dumpWindowForTouchOcclusion (const android::gui::WindowInfo* info,
646+ bool isTouchWindow) const ;
647647 std::string getApplicationWindowLabel (const InputApplicationHandle* applicationHandle,
648648 const sp<android::gui::WindowInfoHandle>& windowHandle);
649649
0 commit comments