Loading core/java/android/view/SurfaceControl.java +6 −0 Original line number Diff line number Diff line Loading @@ -441,6 +441,12 @@ public final class SurfaceControl implements Parcelable { */ public static final int METADATA_TASK_ID = 3; /** * Accessibility ID to allow association between surfaces and accessibility tree. * @hide */ public static final int METADATA_ACCESSIBILITY_ID = 4; /** * A wrapper around GraphicBuffer that contains extra information about how to * interpret the screenshot GraphicBuffer. Loading services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java +16 −4 Original line number Diff line number Diff line Loading @@ -972,6 +972,9 @@ public class AccessibilityWindowManager { if (shouldComputeWindows) { mWindowManagerInternal.computeWindowsForAccessibility(displayId); } mWindowManagerInternal.setAccessibilityIdToSurfaceMetadata( windowToken.asBinder(), windowId); return windowId; } Loading @@ -991,7 +994,7 @@ public class AccessibilityWindowManager { final int removedWindowId = removeAccessibilityInteractionConnectionInternalLocked( token, mGlobalWindowTokens, mGlobalInteractionConnections); if (removedWindowId >= 0) { onAccessibilityInteractionConnectionRemovedLocked(removedWindowId); onAccessibilityInteractionConnectionRemovedLocked(removedWindowId, token); if (DEBUG) { Slog.i(LOG_TAG, "Removed global connection for pid:" + Binder.getCallingPid() + " with windowId: " + removedWindowId + " and token: " Loading @@ -1007,7 +1010,8 @@ public class AccessibilityWindowManager { getWindowTokensForUserLocked(userId), getInteractionConnectionsForUserLocked(userId)); if (removedWindowIdForUser >= 0) { onAccessibilityInteractionConnectionRemovedLocked(removedWindowIdForUser); onAccessibilityInteractionConnectionRemovedLocked( removedWindowIdForUser, token); if (DEBUG) { Slog.i(LOG_TAG, "Removed user connection for pid:" + Binder.getCallingPid() + " with windowId: " + removedWindowIdForUser + " and userId:" Loading Loading @@ -1069,18 +1073,21 @@ public class AccessibilityWindowManager { * @param userId The userId to remove */ private void removeAccessibilityInteractionConnectionLocked(int windowId, int userId) { IBinder window = null; if (userId == UserHandle.USER_ALL) { window = mGlobalWindowTokens.get(windowId); mGlobalWindowTokens.remove(windowId); mGlobalInteractionConnections.remove(windowId); } else { if (isValidUserForWindowTokensLocked(userId)) { window = getWindowTokensForUserLocked(userId).get(windowId); getWindowTokensForUserLocked(userId).remove(windowId); } if (isValidUserForInteractionConnectionsLocked(userId)) { getInteractionConnectionsForUserLocked(userId).remove(windowId); } } onAccessibilityInteractionConnectionRemovedLocked(windowId); onAccessibilityInteractionConnectionRemovedLocked(windowId, window); if (DEBUG) { Slog.i(LOG_TAG, "Removing interaction connection to windowId: " + windowId); } Loading @@ -1091,12 +1098,17 @@ public class AccessibilityWindowManager { * * @param windowId Removed windowId */ private void onAccessibilityInteractionConnectionRemovedLocked(int windowId) { private void onAccessibilityInteractionConnectionRemovedLocked( int windowId, @Nullable IBinder binder) { // Active window will not update, if windows callback is unregistered. // Update active window to invalid, when its a11y interaction connection is removed. if (!isTrackingWindowsLocked() && windowId >= 0 && mActiveWindowId == windowId) { mActiveWindowId = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID; } if (binder != null) { mWindowManagerInternal.setAccessibilityIdToSurfaceMetadata( binder, AccessibilityWindowInfo.UNDEFINED_WINDOW_ID); } } /** Loading services/core/java/com/android/server/wm/WindowManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -550,4 +550,10 @@ public abstract class WindowManagerInternal { * the next time the activities are opened. */ public abstract void clearSnapshotCache(); /** * Assigns accessibility ID a window surface as a layer metadata. */ public abstract void setAccessibilityIdToSurfaceMetadata( IBinder windowToken, int accessibilityWindowId); } services/core/java/com/android/server/wm/WindowManagerService.java +21 −0 Original line number Diff line number Diff line Loading @@ -7398,6 +7398,27 @@ public class WindowManagerService extends IWindowManager.Stub public @Nullable KeyInterceptionInfo getKeyInterceptionInfoFromToken(IBinder inputToken) { return mKeyInterceptionInfoForToken.get(inputToken); } @Override public void setAccessibilityIdToSurfaceMetadata( IBinder windowToken, int accessibilityWindowId) { synchronized (mGlobalLock) { final WindowState state = mWindowMap.get(windowToken); if (state == null) { Slog.w(TAG, "Cannot find window which accessibility connection is added to"); return; } try (SurfaceControl.Transaction t = new SurfaceControl.Transaction()) { t.setMetadata( state.mSurfaceControl, SurfaceControl.METADATA_ACCESSIBILITY_ID, accessibilityWindowId); t.apply(); } finally { SurfaceControl.closeTransaction(); } } } } void registerAppFreezeListener(AppFreezeListener listener) { Loading Loading
core/java/android/view/SurfaceControl.java +6 −0 Original line number Diff line number Diff line Loading @@ -441,6 +441,12 @@ public final class SurfaceControl implements Parcelable { */ public static final int METADATA_TASK_ID = 3; /** * Accessibility ID to allow association between surfaces and accessibility tree. * @hide */ public static final int METADATA_ACCESSIBILITY_ID = 4; /** * A wrapper around GraphicBuffer that contains extra information about how to * interpret the screenshot GraphicBuffer. Loading
services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java +16 −4 Original line number Diff line number Diff line Loading @@ -972,6 +972,9 @@ public class AccessibilityWindowManager { if (shouldComputeWindows) { mWindowManagerInternal.computeWindowsForAccessibility(displayId); } mWindowManagerInternal.setAccessibilityIdToSurfaceMetadata( windowToken.asBinder(), windowId); return windowId; } Loading @@ -991,7 +994,7 @@ public class AccessibilityWindowManager { final int removedWindowId = removeAccessibilityInteractionConnectionInternalLocked( token, mGlobalWindowTokens, mGlobalInteractionConnections); if (removedWindowId >= 0) { onAccessibilityInteractionConnectionRemovedLocked(removedWindowId); onAccessibilityInteractionConnectionRemovedLocked(removedWindowId, token); if (DEBUG) { Slog.i(LOG_TAG, "Removed global connection for pid:" + Binder.getCallingPid() + " with windowId: " + removedWindowId + " and token: " Loading @@ -1007,7 +1010,8 @@ public class AccessibilityWindowManager { getWindowTokensForUserLocked(userId), getInteractionConnectionsForUserLocked(userId)); if (removedWindowIdForUser >= 0) { onAccessibilityInteractionConnectionRemovedLocked(removedWindowIdForUser); onAccessibilityInteractionConnectionRemovedLocked( removedWindowIdForUser, token); if (DEBUG) { Slog.i(LOG_TAG, "Removed user connection for pid:" + Binder.getCallingPid() + " with windowId: " + removedWindowIdForUser + " and userId:" Loading Loading @@ -1069,18 +1073,21 @@ public class AccessibilityWindowManager { * @param userId The userId to remove */ private void removeAccessibilityInteractionConnectionLocked(int windowId, int userId) { IBinder window = null; if (userId == UserHandle.USER_ALL) { window = mGlobalWindowTokens.get(windowId); mGlobalWindowTokens.remove(windowId); mGlobalInteractionConnections.remove(windowId); } else { if (isValidUserForWindowTokensLocked(userId)) { window = getWindowTokensForUserLocked(userId).get(windowId); getWindowTokensForUserLocked(userId).remove(windowId); } if (isValidUserForInteractionConnectionsLocked(userId)) { getInteractionConnectionsForUserLocked(userId).remove(windowId); } } onAccessibilityInteractionConnectionRemovedLocked(windowId); onAccessibilityInteractionConnectionRemovedLocked(windowId, window); if (DEBUG) { Slog.i(LOG_TAG, "Removing interaction connection to windowId: " + windowId); } Loading @@ -1091,12 +1098,17 @@ public class AccessibilityWindowManager { * * @param windowId Removed windowId */ private void onAccessibilityInteractionConnectionRemovedLocked(int windowId) { private void onAccessibilityInteractionConnectionRemovedLocked( int windowId, @Nullable IBinder binder) { // Active window will not update, if windows callback is unregistered. // Update active window to invalid, when its a11y interaction connection is removed. if (!isTrackingWindowsLocked() && windowId >= 0 && mActiveWindowId == windowId) { mActiveWindowId = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID; } if (binder != null) { mWindowManagerInternal.setAccessibilityIdToSurfaceMetadata( binder, AccessibilityWindowInfo.UNDEFINED_WINDOW_ID); } } /** Loading
services/core/java/com/android/server/wm/WindowManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -550,4 +550,10 @@ public abstract class WindowManagerInternal { * the next time the activities are opened. */ public abstract void clearSnapshotCache(); /** * Assigns accessibility ID a window surface as a layer metadata. */ public abstract void setAccessibilityIdToSurfaceMetadata( IBinder windowToken, int accessibilityWindowId); }
services/core/java/com/android/server/wm/WindowManagerService.java +21 −0 Original line number Diff line number Diff line Loading @@ -7398,6 +7398,27 @@ public class WindowManagerService extends IWindowManager.Stub public @Nullable KeyInterceptionInfo getKeyInterceptionInfoFromToken(IBinder inputToken) { return mKeyInterceptionInfoForToken.get(inputToken); } @Override public void setAccessibilityIdToSurfaceMetadata( IBinder windowToken, int accessibilityWindowId) { synchronized (mGlobalLock) { final WindowState state = mWindowMap.get(windowToken); if (state == null) { Slog.w(TAG, "Cannot find window which accessibility connection is added to"); return; } try (SurfaceControl.Transaction t = new SurfaceControl.Transaction()) { t.setMetadata( state.mSurfaceControl, SurfaceControl.METADATA_ACCESSIBILITY_ID, accessibilityWindowId); t.apply(); } finally { SurfaceControl.closeTransaction(); } } } } void registerAppFreezeListener(AppFreezeListener listener) { Loading