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
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index ba29bc8..e51bece 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -2875,11 +2875,8 @@
         @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 @@
             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 @@
             }
             // 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;