Don't notify display removed if it's a private virtual display

Some operation will be done When displays are removed/Added,
but virtual private display should be excluded.

Bug: 148760652
Test: manual test:1.Enable the magnification from a11y setting
2. Enable the select to speak and read text on images
3.Tap the a11y shortcut to select to speak the content
4. check if the content is selected correctly.
Change-Id: I8e0fbc4da7cbb6b9c5bf5366115b3863be5243bb
This commit is contained in:
ryanlwlin
2020-02-18 19:52:49 +08:00
parent c4d21d434e
commit 6a34da5a64

View File

@@ -2875,11 +2875,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
@Override
public void onDisplayRemoved(int displayId) {
synchronized (mLock) {
for (int i = 0; i < mDisplaysList.size(); i++) {
if (mDisplaysList.get(i).getDisplayId() == displayId) {
mDisplaysList.remove(i);
break;
}
if (!removeDisplayFromList(displayId)) {
return;
}
if (mInputFilter != null) {
mInputFilter.onDisplayChanged();
@@ -2899,6 +2896,17 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
mA11yWindowManager.stopTrackingWindows(displayId);
}
@GuardedBy("mLock")
private boolean removeDisplayFromList(int displayId) {
for (int i = 0; i < mDisplaysList.size(); i++) {
if (mDisplaysList.get(i).getDisplayId() == displayId) {
mDisplaysList.remove(i);
return true;
}
}
return false;
}
@Override
public void onDisplayChanged(int displayId) {
/* do nothing */
@@ -2910,8 +2918,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
}
// Private virtual displays are created by the ap and is not allowed to access by other
// aps. We assume we could ignore them.
if ((display.getType() == Display.TYPE_VIRTUAL
&& (display.getFlags() & Display.FLAG_PRIVATE) != 0)) {
if (display.getType() == Display.TYPE_VIRTUAL
&& (display.getFlags() & Display.FLAG_PRIVATE) != 0) {
return false;
}
return true;