summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jacky Kao <jackykao@google.com> 2022-03-02 14:39:26 +0800
committer Jacky Kao <jackykao@google.com> 2022-03-03 11:56:18 +0800
commitce4c02258b75bcfd7c4581373da3407c30f54f9e (patch)
tree0b5b4365640e64e5213483914dcc2e3ac1e1bcde
parent081a7c61e6b277efc65f292488618650ac86394c (diff)
Fixs the ANR issue
When doing the drag and drop an app from the Taskbar, the dragState will hold the wm global lock to sync the input state through the surface flinger which callbacks the windows through the onWindowInfoChanged. If we also hold the same lock in the onWindowInfoChanged, then the ANR will happen. To fix this ANR issue, we need to post a message and then handle the windowInfo data. Bug: 221497060 Test: a11y CTS & unit tests Change-Id: Ib655546f5810e357fa45419ece32e9e742b6506c
-rw-r--r--services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java b/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java
index 43317adca04a..f9689a8a2bca 100644
--- a/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java
+++ b/services/core/java/com/android/server/wm/AccessibilityWindowsPopulator.java
@@ -145,6 +145,11 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener {
@Override
public void onWindowInfosChanged(InputWindowHandle[] windowHandles,
DisplayInfo[] displayInfos) {
+ mHandler.post(() -> onWindowInfosChangedInternal(windowHandles, displayInfos));
+ }
+
+ private void onWindowInfosChangedInternal(InputWindowHandle[] windowHandles,
+ DisplayInfo[] displayInfos) {
final List<InputWindowHandle> tempVisibleWindows = new ArrayList<>();
for (InputWindowHandle window : windowHandles) {
@@ -167,13 +172,14 @@ public final class AccessibilityWindowsPopulator extends WindowInfosListener {
mDisplayInfos.put(displayInfo.mDisplayId, displayInfo);
}
- if (!mHandler.hasMessages(
- MyHandler.MESSAGE_NOTIFY_WINDOWS_CHANGED_BY_TIMEOUT)) {
- mHandler.sendEmptyMessageDelayed(
- MyHandler.MESSAGE_NOTIFY_WINDOWS_CHANGED_BY_TIMEOUT,
- WINDOWS_CHANGED_NOTIFICATION_MAX_DURATION_TIMES_MS);
+ if (mWindowsNotificationEnabled) {
+ if (!mHandler.hasMessages(MyHandler.MESSAGE_NOTIFY_WINDOWS_CHANGED_BY_TIMEOUT)) {
+ mHandler.sendEmptyMessageDelayed(
+ MyHandler.MESSAGE_NOTIFY_WINDOWS_CHANGED_BY_TIMEOUT,
+ WINDOWS_CHANGED_NOTIFICATION_MAX_DURATION_TIMES_MS);
+ }
+ populateVisibleWindowHandlesAndNotifyWindowsChangeIfNeeded();
}
- populateVisibleWindowHandlesAndNotifyWindowsChangeIfNeeded();
}
}