Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66bf088c authored by Riley Jones's avatar Riley Jones Committed by Android (Google) Code Review
Browse files

Merge "Unlocking getDisplayByUserIdAndWindowId" into main

parents ddedb160 642e621f
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -611,12 +611,12 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
        if (svcConnTracingEnabled()) {
        if (svcConnTracingEnabled()) {
            logTraceSvcConn("getWindow", "windowId=" + windowId);
            logTraceSvcConn("getWindow", "windowId=" + windowId);
        }
        }
        synchronized (mLock) {
        int displayId = Display.INVALID_DISPLAY;
        int displayId = Display.INVALID_DISPLAY;
        if (windowId != AccessibilityWindowInfo.UNDEFINED_WINDOW_ID) {
        if (windowId != AccessibilityWindowInfo.UNDEFINED_WINDOW_ID) {
                displayId = mA11yWindowManager.getDisplayIdByUserIdAndWindowIdLocked(
            displayId = mA11yWindowManager.getDisplayIdByUserIdAndWindowId(
                    mSystemSupport.getCurrentUserIdLocked(), windowId);
                    mSystemSupport.getCurrentUserIdLocked(), windowId);
        }
        }
        synchronized (mLock) {
            ensureWindowsAvailableTimedLocked(displayId);
            ensureWindowsAvailableTimedLocked(displayId);


            if (!hasRightsToCurrentUserLocked()) {
            if (!hasRightsToCurrentUserLocked()) {
+7 −8
Original line number Original line Diff line number Diff line
@@ -1261,15 +1261,14 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            // the computation for performance reasons.
            // the computation for performance reasons.
            boolean shouldComputeWindows = false;
            boolean shouldComputeWindows = false;
            int displayId = event.getDisplayId();
            int displayId = event.getDisplayId();
            synchronized (mLock) {
            final int windowId = event.getWindowId();
            final int windowId = event.getWindowId();
            if (windowId != AccessibilityWindowInfo.UNDEFINED_WINDOW_ID
            if (windowId != AccessibilityWindowInfo.UNDEFINED_WINDOW_ID
                    && displayId == Display.INVALID_DISPLAY) {
                    && displayId == Display.INVALID_DISPLAY) {
                    displayId = mA11yWindowManager.getDisplayIdByUserIdAndWindowIdLocked(
                displayId = mA11yWindowManager.getDisplayIdByUserIdAndWindowId(
                        resolvedUserId, windowId);
                        resolvedUserId, windowId);
                event.setDisplayId(displayId);
                event.setDisplayId(displayId);
            }
            }

            synchronized (mLock) {
                if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
                if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
                        && displayId != Display.INVALID_DISPLAY
                        && displayId != Display.INVALID_DISPLAY
                        && mA11yWindowManager.isTrackingWindowsLocked(displayId)) {
                        && mA11yWindowManager.isTrackingWindowsLocked(displayId)) {
+5 −2
Original line number Original line Diff line number Diff line
@@ -2038,8 +2038,11 @@ public class AccessibilityWindowManager {
     * @param windowId The windowId
     * @param windowId The windowId
     * @return The display ID
     * @return The display ID
     */
     */
    public int getDisplayIdByUserIdAndWindowIdLocked(int userId, int windowId) {
    public int getDisplayIdByUserIdAndWindowId(int userId, int windowId) {
        final IBinder windowToken = getWindowTokenForUserAndWindowIdLocked(userId, windowId);
        final IBinder windowToken;
        synchronized (mLock) {
            windowToken = getWindowTokenForUserAndWindowIdLocked(userId, windowId);
        }
        if (traceWMEnabled()) {
        if (traceWMEnabled()) {
            logTraceWM("getDisplayIdForWindow", "token=" + windowToken);
            logTraceWM("getDisplayIdForWindow", "token=" + windowToken);
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -214,7 +214,7 @@ public class AbstractAccessibilityServiceConnectionTest {
                .thenReturn(mA11yWindowInfos.get(0));
                .thenReturn(mA11yWindowInfos.get(0));
        when(mMockA11yWindowManager.findA11yWindowInfoByIdLocked(PIP_WINDOWID))
        when(mMockA11yWindowManager.findA11yWindowInfoByIdLocked(PIP_WINDOWID))
                .thenReturn(mA11yWindowInfos.get(1));
                .thenReturn(mA11yWindowInfos.get(1));
        when(mMockA11yWindowManager.getDisplayIdByUserIdAndWindowIdLocked(USER_ID,
        when(mMockA11yWindowManager.getDisplayIdByUserIdAndWindowId(USER_ID,
            WINDOWID_ONSECONDDISPLAY)).thenReturn(SECONDARY_DISPLAY_ID);
            WINDOWID_ONSECONDDISPLAY)).thenReturn(SECONDARY_DISPLAY_ID);
        when(mMockA11yWindowManager.getWindowListLocked(SECONDARY_DISPLAY_ID))
        when(mMockA11yWindowManager.getWindowListLocked(SECONDARY_DISPLAY_ID))
            .thenReturn(mA11yWindowInfosOnSecondDisplay);
            .thenReturn(mA11yWindowInfosOnSecondDisplay);