Loading services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java +4 −29 Original line number Diff line number Diff line Loading @@ -143,12 +143,8 @@ public class AccessibilityWindowManager { /** * Starts tracking windows changes from window manager by registering callback. * * @return true if callback registers successful. */ boolean startTrackingWindowsLocked() { boolean result = true; void startTrackingWindowsLocked() { if (!mTrackingWindows) { // Turns on the flag before setup the callback. // In some cases, onWindowsForAccessibilityChanged will be called immediately in Loading @@ -158,16 +154,10 @@ public class AccessibilityWindowManager { logTraceWM("setWindowsForAccessibilityCallback", "displayId=" + mDisplayId + ";callback=" + this); } result = mWindowManagerInternal.setWindowsForAccessibilityCallback( mWindowManagerInternal.setWindowsForAccessibilityCallback( mDisplayId, this); if (!result) { mTrackingWindows = false; Slog.w(LOG_TAG, "set windowsObserver callbacks fail, displayId:" + mDisplayId); } } return result; } /** * Stops tracking windows changes from window manager, and clear all windows info. Loading Loading @@ -384,20 +374,6 @@ public class AccessibilityWindowManager { } } /** * Called when the display is reparented and becomes an embedded * display. * * @param embeddedDisplayId The embedded display Id. */ @Override public void onDisplayReparented(int embeddedDisplayId) { // Removes the un-used window observer for the embedded display. synchronized (mLock) { mDisplayWindowsObservers.remove(embeddedDisplayId); } } private boolean shouldUpdateWindowsLocked(boolean forceSend, @NonNull List<WindowInfo> windows) { if (forceSend) { Loading Loading @@ -904,11 +880,10 @@ public class AccessibilityWindowManager { if (observer.isTrackingWindowsLocked()) { return; } if (observer.startTrackingWindowsLocked()) { observer.startTrackingWindowsLocked(); mDisplayWindowsObservers.put(displayId, observer); } } } /** * Stops tracking windows changes from window manager, and clear all windows info for specified Loading services/core/java/com/android/server/wm/AccessibilityController.java +4 −124 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ import android.os.Message; import android.os.Process; import android.os.SystemClock; import android.util.ArraySet; import android.util.IntArray; import android.util.Slog; import android.util.SparseArray; import android.util.TypedValue; Loading @@ -94,7 +93,6 @@ import android.view.animation.Interpolator; import com.android.internal.R; import com.android.internal.os.SomeArgs; import com.android.internal.util.TraceBuffer; import com.android.internal.util.function.pooled.PooledLambda; import com.android.server.LocalServices; import com.android.server.policy.WindowManagerPolicy; import com.android.server.wm.WindowManagerInternal.AccessibilityControllerInternal; Loading Loading @@ -177,17 +175,12 @@ final class AccessibilityController { /** * Sets a callback for observing which windows are touchable for the purposes * of accessibility on specified display. When a display is reparented and becomes * an embedded one, the {@link WindowsForAccessibilityCallback#onDisplayReparented(int)} * will notify the accessibility framework to remove the un-used window observer of * this embedded display. * of accessibility on specified display. * * @param displayId The logical display id. * @param callback The callback. * @return {@code false} if display id is not valid or an embedded display when the callback * isn't null. */ boolean setWindowsForAccessibilityCallback(int displayId, void setWindowsForAccessibilityCallback(int displayId, WindowsForAccessibilityCallback callback) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK)) { mAccessibilityTracing.logTrace( Loading @@ -197,30 +190,15 @@ final class AccessibilityController { } if (callback != null) { final DisplayContent dc = mService.mRoot.getDisplayContentOrCreate(displayId); if (dc == null) { return false; } WindowsForAccessibilityObserver observer = mWindowsForAccessibilityObserver.get(displayId); if (isEmbeddedDisplay(dc)) { // If this display is an embedded one, its window observer should have been set from // window manager after setting its parent window. But if its window observer is // empty, that means this mapping didn't be set, and needs to do this again. // This happened when accessibility window observer is disabled and enabled again. if (observer == null) { handleWindowObserverOfEmbeddedDisplay(displayId, dc.getParentWindow()); } return false; } else if (observer != null) { if (observer != null) { final String errorMessage = "Windows for accessibility callback of display " + displayId + " already set!"; Slog.e(TAG, errorMessage); if (Build.IS_DEBUGGABLE) { throw new IllegalStateException(errorMessage); } removeObserversForEmbeddedChildDisplays(observer); mWindowsForAccessibilityObserver.remove(displayId); } observer = new WindowsForAccessibilityObserver(mService, displayId, callback); Loading @@ -237,10 +215,8 @@ final class AccessibilityController { throw new IllegalStateException(errorMessage); } } removeObserversForEmbeddedChildDisplays(windowsForA11yObserver); mWindowsForAccessibilityObserver.remove(displayId); } return true; } void performComputeChangedWindowsNot(int displayId, boolean forceSend) { Loading Loading @@ -507,54 +483,6 @@ final class AccessibilityController { } } void handleWindowObserverOfEmbeddedDisplay(int embeddedDisplayId, WindowState parentWindow) { handleWindowObserverOfEmbeddedDisplay( embeddedDisplayId, parentWindow, Binder.getCallingUid()); } void handleWindowObserverOfEmbeddedDisplay( int embeddedDisplayId, WindowState parentWindow, int callingUid) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK)) { mAccessibilityTracing.logTrace(TAG + ".handleWindowObserverOfEmbeddedDisplay", FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK, "embeddedDisplayId=" + embeddedDisplayId + "; parentWindowState={" + parentWindow + "}", "".getBytes(), callingUid); } if (embeddedDisplayId == Display.DEFAULT_DISPLAY || parentWindow == null) { return; } mService.mH.sendMessage(PooledLambda.obtainMessage( AccessibilityController::updateWindowObserverOfEmbeddedDisplay, this, embeddedDisplayId, parentWindow)); } private void updateWindowObserverOfEmbeddedDisplay(int embeddedDisplayId, WindowState parentWindow) { final WindowsForAccessibilityObserver windowsForA11yObserver; synchronized (mService.mGlobalLock) { // Finds the parent display of this embedded display WindowState candidate = parentWindow; while (candidate != null) { parentWindow = candidate; candidate = parentWindow.getDisplayContent().getParentWindow(); } final int parentDisplayId = parentWindow.getDisplayId(); // Uses the observer of parent display windowsForA11yObserver = mWindowsForAccessibilityObserver.get(parentDisplayId); } if (windowsForA11yObserver != null) { windowsForA11yObserver.notifyDisplayReparented(embeddedDisplayId); windowsForA11yObserver.addEmbeddedDisplay(embeddedDisplayId); synchronized (mService.mGlobalLock) { // Replaces the observer of embedded display to the one of parent display mWindowsForAccessibilityObserver.put(embeddedDisplayId, windowsForA11yObserver); } } } void onImeSurfaceShownChanged(WindowState windowState, boolean shown) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) { mAccessibilityTracing.logTrace(TAG + ".onImeSurfaceShownChanged", Loading Loading @@ -584,23 +512,6 @@ final class AccessibilityController { + "mWindowsForAccessibilityObserver=" + mWindowsForAccessibilityObserver); } private void removeObserversForEmbeddedChildDisplays(WindowsForAccessibilityObserver observerOfParentDisplay) { final IntArray embeddedDisplayIdList = observerOfParentDisplay.getAndClearEmbeddedDisplayIdList(); for (int index = 0; index < embeddedDisplayIdList.size(); index++) { final int embeddedDisplayId = embeddedDisplayIdList.get(index); mWindowsForAccessibilityObserver.remove(embeddedDisplayId); } } private static boolean isEmbeddedDisplay(DisplayContent dc) { final Display display = dc.getDisplay(); return display.getType() == Display.TYPE_VIRTUAL && dc.getParentWindow() != null; } /** * This class encapsulates the functionality related to display magnification. */ Loading Loading @@ -1534,8 +1445,6 @@ final class AccessibilityController { private final long mRecurringAccessibilityEventsIntervalMillis; private final IntArray mEmbeddedDisplayIdList = new IntArray(0); // Set to true if initializing window population complete. private boolean mInitialized; Loading Loading @@ -1573,28 +1482,6 @@ final class AccessibilityController { } } IntArray getAndClearEmbeddedDisplayIdList() { final IntArray returnedArray = new IntArray(mEmbeddedDisplayIdList.size()); returnedArray.addAll(mEmbeddedDisplayIdList); mEmbeddedDisplayIdList.clear(); return returnedArray; } void addEmbeddedDisplay(int displayId) { if (displayId == mDisplayId) { return; } mEmbeddedDisplayIdList.add(displayId); } void notifyDisplayReparented(int embeddedDisplayId) { // Notifies the A11y framework the display is reparented and // becomes an embedded display for removing the un-used // displayWindowObserver of this embedded one. mCallback.onDisplayReparented(embeddedDisplayId); } boolean shellRootIsAbove(WindowState windowState, ShellRoot shellRoot) { int wsLayer = mService.mPolicy.getWindowLayerLw(windowState); int shellLayer = mService.mPolicy.getWindowLayerFromTypeLw(shellRoot.getWindowType(), Loading Loading @@ -1761,12 +1648,7 @@ final class AccessibilityController { addedWindows.clear(); // Gets the top focused display Id and window token for supporting multi-display. // If this top focused display is an embedded one, using its parent display as the // top focused display. final DisplayContent topFocusedDisplayContent = mService.mRoot.getTopFocusedDisplayContent(); topFocusedDisplayId = isEmbeddedDisplay(topFocusedDisplayContent) ? mDisplayId : topFocusedDisplayContent.getDisplayId(); topFocusedDisplayId = mService.mRoot.getTopFocusedDisplayContent().getDisplayId(); topFocusedWindowToken = topFocusedWindowState.mClient.asBinder(); } mCallback.onWindowsForAccessibilityChanged(forceSend, topFocusedDisplayId, Loading Loading @@ -1970,8 +1852,6 @@ final class AccessibilityController { public String toString() { return "WindowsForAccessibilityObserver{" + "mDisplayId=" + mDisplayId + ", mEmbeddedDisplayIdList=" + Arrays.toString(mEmbeddedDisplayIdList.toArray()) + ", mInitialized=" + mInitialized + '}'; } Loading services/core/java/com/android/server/wm/WindowManagerInternal.java +1 −12 Original line number Diff line number Diff line Loading @@ -122,16 +122,6 @@ public abstract class WindowManagerInternal { */ void onWindowsForAccessibilityChanged(boolean forceSend, int topFocusedDisplayId, IBinder topFocusedWindowToken, @NonNull List<WindowInfo> windows); /** * Called when the display is reparented and becomes an embedded * display. The {@link WindowsForAccessibilityCallback} with the given embedded * display will be replaced by the {@link WindowsForAccessibilityCallback} * associated with its parent display at the same time. * * @param embeddedDisplayId The embedded display Id. */ void onDisplayReparented(int embeddedDisplayId); } /** Loading Loading @@ -375,9 +365,8 @@ public abstract class WindowManagerInternal { * * @param displayId The logical display id. * @param callback The callback. * @return {@code false} if display id is not valid. */ public abstract boolean setWindowsForAccessibilityCallback(int displayId, public abstract void setWindowsForAccessibilityCallback(int displayId, WindowsForAccessibilityCallback callback); /** Loading services/core/java/com/android/server/wm/WindowManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -7455,20 +7455,18 @@ public class WindowManagerService extends IWindowManager.Stub } @Override public boolean setWindowsForAccessibilityCallback(int displayId, public void setWindowsForAccessibilityCallback(int displayId, WindowsForAccessibilityCallback callback) { synchronized (mGlobalLock) { if (mAccessibilityController == null) { mAccessibilityController = new AccessibilityController( WindowManagerService.this); } final boolean result = mAccessibilityController.setWindowsForAccessibilityCallback( displayId, callback); if (!mAccessibilityController.hasCallbacks()) { mAccessibilityController = null; } return result; } } Loading services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java +0 −16 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -836,19 +835,6 @@ public class AccessibilityWindowManagerTest { assertNull(token); } @Test public void onDisplayReparented_shouldRemoveObserver() throws RemoteException { // Starts tracking window of second display. startTrackingPerDisplay(SECONDARY_DISPLAY_ID); assertTrue(mA11yWindowManager.isTrackingWindowsLocked(SECONDARY_DISPLAY_ID)); // Notifies the second display is an embedded one of the default display. final WindowsForAccessibilityCallback callbacks = mCallbackOfWindows.get(Display.DEFAULT_DISPLAY); callbacks.onDisplayReparented(SECONDARY_DISPLAY_ID); // Makes sure the observer of the second display is removed. assertFalse(mA11yWindowManager.isTrackingWindowsLocked(SECONDARY_DISPLAY_ID)); } private void registerLeashedTokenAndWindowId() { mA11yWindowManager.registerIdLocked(mMockHostToken, HOST_WINDOW_ID); mA11yWindowManager.registerIdLocked(mMockEmbeddedToken, EMBEDDED_WINDOW_ID); Loading Loading @@ -878,8 +864,6 @@ public class AccessibilityWindowManagerTest { windowInfosForDisplay.get(DEFAULT_FOCUSED_INDEX).focused = true; } // Turns on windows tracking, and update window info. when(mMockWindowManagerInternal.setWindowsForAccessibilityCallback(eq(displayId), any())) .thenReturn(true); mA11yWindowManager.startTrackingWindows(displayId); // Puts window lists into array. mWindowInfos.put(displayId, windowInfosForDisplay); Loading Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java +4 −29 Original line number Diff line number Diff line Loading @@ -143,12 +143,8 @@ public class AccessibilityWindowManager { /** * Starts tracking windows changes from window manager by registering callback. * * @return true if callback registers successful. */ boolean startTrackingWindowsLocked() { boolean result = true; void startTrackingWindowsLocked() { if (!mTrackingWindows) { // Turns on the flag before setup the callback. // In some cases, onWindowsForAccessibilityChanged will be called immediately in Loading @@ -158,16 +154,10 @@ public class AccessibilityWindowManager { logTraceWM("setWindowsForAccessibilityCallback", "displayId=" + mDisplayId + ";callback=" + this); } result = mWindowManagerInternal.setWindowsForAccessibilityCallback( mWindowManagerInternal.setWindowsForAccessibilityCallback( mDisplayId, this); if (!result) { mTrackingWindows = false; Slog.w(LOG_TAG, "set windowsObserver callbacks fail, displayId:" + mDisplayId); } } return result; } /** * Stops tracking windows changes from window manager, and clear all windows info. Loading Loading @@ -384,20 +374,6 @@ public class AccessibilityWindowManager { } } /** * Called when the display is reparented and becomes an embedded * display. * * @param embeddedDisplayId The embedded display Id. */ @Override public void onDisplayReparented(int embeddedDisplayId) { // Removes the un-used window observer for the embedded display. synchronized (mLock) { mDisplayWindowsObservers.remove(embeddedDisplayId); } } private boolean shouldUpdateWindowsLocked(boolean forceSend, @NonNull List<WindowInfo> windows) { if (forceSend) { Loading Loading @@ -904,11 +880,10 @@ public class AccessibilityWindowManager { if (observer.isTrackingWindowsLocked()) { return; } if (observer.startTrackingWindowsLocked()) { observer.startTrackingWindowsLocked(); mDisplayWindowsObservers.put(displayId, observer); } } } /** * Stops tracking windows changes from window manager, and clear all windows info for specified Loading
services/core/java/com/android/server/wm/AccessibilityController.java +4 −124 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ import android.os.Message; import android.os.Process; import android.os.SystemClock; import android.util.ArraySet; import android.util.IntArray; import android.util.Slog; import android.util.SparseArray; import android.util.TypedValue; Loading @@ -94,7 +93,6 @@ import android.view.animation.Interpolator; import com.android.internal.R; import com.android.internal.os.SomeArgs; import com.android.internal.util.TraceBuffer; import com.android.internal.util.function.pooled.PooledLambda; import com.android.server.LocalServices; import com.android.server.policy.WindowManagerPolicy; import com.android.server.wm.WindowManagerInternal.AccessibilityControllerInternal; Loading Loading @@ -177,17 +175,12 @@ final class AccessibilityController { /** * Sets a callback for observing which windows are touchable for the purposes * of accessibility on specified display. When a display is reparented and becomes * an embedded one, the {@link WindowsForAccessibilityCallback#onDisplayReparented(int)} * will notify the accessibility framework to remove the un-used window observer of * this embedded display. * of accessibility on specified display. * * @param displayId The logical display id. * @param callback The callback. * @return {@code false} if display id is not valid or an embedded display when the callback * isn't null. */ boolean setWindowsForAccessibilityCallback(int displayId, void setWindowsForAccessibilityCallback(int displayId, WindowsForAccessibilityCallback callback) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK)) { mAccessibilityTracing.logTrace( Loading @@ -197,30 +190,15 @@ final class AccessibilityController { } if (callback != null) { final DisplayContent dc = mService.mRoot.getDisplayContentOrCreate(displayId); if (dc == null) { return false; } WindowsForAccessibilityObserver observer = mWindowsForAccessibilityObserver.get(displayId); if (isEmbeddedDisplay(dc)) { // If this display is an embedded one, its window observer should have been set from // window manager after setting its parent window. But if its window observer is // empty, that means this mapping didn't be set, and needs to do this again. // This happened when accessibility window observer is disabled and enabled again. if (observer == null) { handleWindowObserverOfEmbeddedDisplay(displayId, dc.getParentWindow()); } return false; } else if (observer != null) { if (observer != null) { final String errorMessage = "Windows for accessibility callback of display " + displayId + " already set!"; Slog.e(TAG, errorMessage); if (Build.IS_DEBUGGABLE) { throw new IllegalStateException(errorMessage); } removeObserversForEmbeddedChildDisplays(observer); mWindowsForAccessibilityObserver.remove(displayId); } observer = new WindowsForAccessibilityObserver(mService, displayId, callback); Loading @@ -237,10 +215,8 @@ final class AccessibilityController { throw new IllegalStateException(errorMessage); } } removeObserversForEmbeddedChildDisplays(windowsForA11yObserver); mWindowsForAccessibilityObserver.remove(displayId); } return true; } void performComputeChangedWindowsNot(int displayId, boolean forceSend) { Loading Loading @@ -507,54 +483,6 @@ final class AccessibilityController { } } void handleWindowObserverOfEmbeddedDisplay(int embeddedDisplayId, WindowState parentWindow) { handleWindowObserverOfEmbeddedDisplay( embeddedDisplayId, parentWindow, Binder.getCallingUid()); } void handleWindowObserverOfEmbeddedDisplay( int embeddedDisplayId, WindowState parentWindow, int callingUid) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK)) { mAccessibilityTracing.logTrace(TAG + ".handleWindowObserverOfEmbeddedDisplay", FLAGS_WINDOWS_FOR_ACCESSIBILITY_CALLBACK, "embeddedDisplayId=" + embeddedDisplayId + "; parentWindowState={" + parentWindow + "}", "".getBytes(), callingUid); } if (embeddedDisplayId == Display.DEFAULT_DISPLAY || parentWindow == null) { return; } mService.mH.sendMessage(PooledLambda.obtainMessage( AccessibilityController::updateWindowObserverOfEmbeddedDisplay, this, embeddedDisplayId, parentWindow)); } private void updateWindowObserverOfEmbeddedDisplay(int embeddedDisplayId, WindowState parentWindow) { final WindowsForAccessibilityObserver windowsForA11yObserver; synchronized (mService.mGlobalLock) { // Finds the parent display of this embedded display WindowState candidate = parentWindow; while (candidate != null) { parentWindow = candidate; candidate = parentWindow.getDisplayContent().getParentWindow(); } final int parentDisplayId = parentWindow.getDisplayId(); // Uses the observer of parent display windowsForA11yObserver = mWindowsForAccessibilityObserver.get(parentDisplayId); } if (windowsForA11yObserver != null) { windowsForA11yObserver.notifyDisplayReparented(embeddedDisplayId); windowsForA11yObserver.addEmbeddedDisplay(embeddedDisplayId); synchronized (mService.mGlobalLock) { // Replaces the observer of embedded display to the one of parent display mWindowsForAccessibilityObserver.put(embeddedDisplayId, windowsForA11yObserver); } } } void onImeSurfaceShownChanged(WindowState windowState, boolean shown) { if (mAccessibilityTracing.isTracingEnabled(FLAGS_MAGNIFICATION_CALLBACK)) { mAccessibilityTracing.logTrace(TAG + ".onImeSurfaceShownChanged", Loading Loading @@ -584,23 +512,6 @@ final class AccessibilityController { + "mWindowsForAccessibilityObserver=" + mWindowsForAccessibilityObserver); } private void removeObserversForEmbeddedChildDisplays(WindowsForAccessibilityObserver observerOfParentDisplay) { final IntArray embeddedDisplayIdList = observerOfParentDisplay.getAndClearEmbeddedDisplayIdList(); for (int index = 0; index < embeddedDisplayIdList.size(); index++) { final int embeddedDisplayId = embeddedDisplayIdList.get(index); mWindowsForAccessibilityObserver.remove(embeddedDisplayId); } } private static boolean isEmbeddedDisplay(DisplayContent dc) { final Display display = dc.getDisplay(); return display.getType() == Display.TYPE_VIRTUAL && dc.getParentWindow() != null; } /** * This class encapsulates the functionality related to display magnification. */ Loading Loading @@ -1534,8 +1445,6 @@ final class AccessibilityController { private final long mRecurringAccessibilityEventsIntervalMillis; private final IntArray mEmbeddedDisplayIdList = new IntArray(0); // Set to true if initializing window population complete. private boolean mInitialized; Loading Loading @@ -1573,28 +1482,6 @@ final class AccessibilityController { } } IntArray getAndClearEmbeddedDisplayIdList() { final IntArray returnedArray = new IntArray(mEmbeddedDisplayIdList.size()); returnedArray.addAll(mEmbeddedDisplayIdList); mEmbeddedDisplayIdList.clear(); return returnedArray; } void addEmbeddedDisplay(int displayId) { if (displayId == mDisplayId) { return; } mEmbeddedDisplayIdList.add(displayId); } void notifyDisplayReparented(int embeddedDisplayId) { // Notifies the A11y framework the display is reparented and // becomes an embedded display for removing the un-used // displayWindowObserver of this embedded one. mCallback.onDisplayReparented(embeddedDisplayId); } boolean shellRootIsAbove(WindowState windowState, ShellRoot shellRoot) { int wsLayer = mService.mPolicy.getWindowLayerLw(windowState); int shellLayer = mService.mPolicy.getWindowLayerFromTypeLw(shellRoot.getWindowType(), Loading Loading @@ -1761,12 +1648,7 @@ final class AccessibilityController { addedWindows.clear(); // Gets the top focused display Id and window token for supporting multi-display. // If this top focused display is an embedded one, using its parent display as the // top focused display. final DisplayContent topFocusedDisplayContent = mService.mRoot.getTopFocusedDisplayContent(); topFocusedDisplayId = isEmbeddedDisplay(topFocusedDisplayContent) ? mDisplayId : topFocusedDisplayContent.getDisplayId(); topFocusedDisplayId = mService.mRoot.getTopFocusedDisplayContent().getDisplayId(); topFocusedWindowToken = topFocusedWindowState.mClient.asBinder(); } mCallback.onWindowsForAccessibilityChanged(forceSend, topFocusedDisplayId, Loading Loading @@ -1970,8 +1852,6 @@ final class AccessibilityController { public String toString() { return "WindowsForAccessibilityObserver{" + "mDisplayId=" + mDisplayId + ", mEmbeddedDisplayIdList=" + Arrays.toString(mEmbeddedDisplayIdList.toArray()) + ", mInitialized=" + mInitialized + '}'; } Loading
services/core/java/com/android/server/wm/WindowManagerInternal.java +1 −12 Original line number Diff line number Diff line Loading @@ -122,16 +122,6 @@ public abstract class WindowManagerInternal { */ void onWindowsForAccessibilityChanged(boolean forceSend, int topFocusedDisplayId, IBinder topFocusedWindowToken, @NonNull List<WindowInfo> windows); /** * Called when the display is reparented and becomes an embedded * display. The {@link WindowsForAccessibilityCallback} with the given embedded * display will be replaced by the {@link WindowsForAccessibilityCallback} * associated with its parent display at the same time. * * @param embeddedDisplayId The embedded display Id. */ void onDisplayReparented(int embeddedDisplayId); } /** Loading Loading @@ -375,9 +365,8 @@ public abstract class WindowManagerInternal { * * @param displayId The logical display id. * @param callback The callback. * @return {@code false} if display id is not valid. */ public abstract boolean setWindowsForAccessibilityCallback(int displayId, public abstract void setWindowsForAccessibilityCallback(int displayId, WindowsForAccessibilityCallback callback); /** Loading
services/core/java/com/android/server/wm/WindowManagerService.java +2 −4 Original line number Diff line number Diff line Loading @@ -7455,20 +7455,18 @@ public class WindowManagerService extends IWindowManager.Stub } @Override public boolean setWindowsForAccessibilityCallback(int displayId, public void setWindowsForAccessibilityCallback(int displayId, WindowsForAccessibilityCallback callback) { synchronized (mGlobalLock) { if (mAccessibilityController == null) { mAccessibilityController = new AccessibilityController( WindowManagerService.this); } final boolean result = mAccessibilityController.setWindowsForAccessibilityCallback( displayId, callback); if (!mAccessibilityController.hasCallbacks()) { mAccessibilityController = null; } return result; } } Loading
services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java +0 −16 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -836,19 +835,6 @@ public class AccessibilityWindowManagerTest { assertNull(token); } @Test public void onDisplayReparented_shouldRemoveObserver() throws RemoteException { // Starts tracking window of second display. startTrackingPerDisplay(SECONDARY_DISPLAY_ID); assertTrue(mA11yWindowManager.isTrackingWindowsLocked(SECONDARY_DISPLAY_ID)); // Notifies the second display is an embedded one of the default display. final WindowsForAccessibilityCallback callbacks = mCallbackOfWindows.get(Display.DEFAULT_DISPLAY); callbacks.onDisplayReparented(SECONDARY_DISPLAY_ID); // Makes sure the observer of the second display is removed. assertFalse(mA11yWindowManager.isTrackingWindowsLocked(SECONDARY_DISPLAY_ID)); } private void registerLeashedTokenAndWindowId() { mA11yWindowManager.registerIdLocked(mMockHostToken, HOST_WINDOW_ID); mA11yWindowManager.registerIdLocked(mMockEmbeddedToken, EMBEDDED_WINDOW_ID); Loading Loading @@ -878,8 +864,6 @@ public class AccessibilityWindowManagerTest { windowInfosForDisplay.get(DEFAULT_FOCUSED_INDEX).focused = true; } // Turns on windows tracking, and update window info. when(mMockWindowManagerInternal.setWindowsForAccessibilityCallback(eq(displayId), any())) .thenReturn(true); mA11yWindowManager.startTrackingWindows(displayId); // Puts window lists into array. mWindowInfos.put(displayId, windowInfosForDisplay); Loading