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

Commit e5e3d053 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove parameter throwOnError of windowForClientLocked" into main

parents b9bbc264 36099044
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -189,8 +189,8 @@ class DragDropController {
                        return null;
                    }

                    final WindowState callingWin = mService.windowForClientLocked(
                            null, window, false);
                    final WindowState callingWin = mService.windowForClient(
                            null /* session */, window);
                    if (callingWin == null || !callingWin.canReceiveTouchInput()) {
                        Slog.w(TAG_WM, "Bad requesting window " + window);
                        return null;  // !!! TODO: throw here?
@@ -343,7 +343,8 @@ class DragDropController {
                // lookup fails.
                mHandler.removeMessages(MSG_DRAG_END_TIMEOUT, window.asBinder());

                WindowState callingWin = mService.windowForClientLocked(null, window, false);
                final WindowState callingWin = mService.windowForClient(
                        null /* session */, window);
                if (callingWin == null) {
                    Slog.w(TAG_WM, "Bad result-reporting window " + window);
                    return;  // !!! TODO: throw here?
@@ -584,8 +585,8 @@ class DragDropController {
                return false;
            }
            if (mDragState.isAccessibilityDragDrop() && isA11yEnabled) {
                final WindowState winState = mService.windowForClientLocked(
                        null, window, false);
                final WindowState winState = mService.windowForClient(
                        null /* session */, window);
                if (!mDragState.isWindowNotified(winState)) {
                    return false;
                }
+11 −12
Original line number Diff line number Diff line
@@ -573,8 +573,10 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {

    private void actionOnWallpaper(IBinder window,
            BiConsumer<WallpaperController, WindowState> action) {
        final WindowState windowState = mService.windowForClientLocked(this, window, true);
        action.accept(windowState.getDisplayContent().mWallpaperController, windowState);
        final WindowState windowState = mService.windowForClient(this, window);
        if (windowState != null) {
            action.accept(windowState.mDisplayContent.mWallpaperController, windowState);
        }
    }

    @Override
@@ -642,7 +644,8 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
        synchronized (mService.mGlobalLock) {
            final long ident = Binder.clearCallingIdentity();
            try {
                final WindowState windowState = mService.windowForClientLocked(this, window, true);
                final WindowState windowState = mService.windowForClient(this, window);
                if (windowState == null) return;
                WallpaperController wallpaperController =
                        windowState.getDisplayContent().mWallpaperController;
                if (mCanAlwaysUpdateWallpaper
@@ -707,8 +710,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
    public void updateRequestedVisibleTypes(IWindow window, @InsetsType int requestedVisibleTypes,
            @Nullable ImeTracker.Token imeStatsToken) {
        synchronized (mService.mGlobalLock) {
            final WindowState win = mService.windowForClientLocked(this, window,
                    false /* throwOnError */);
            final WindowState win = mService.windowForClient(this, window);
            if (win != null) {
                ImeTracker.forLogging().onProgress(imeStatsToken,
                        ImeTracker.PHASE_WM_UPDATE_REQUESTED_VISIBLE_TYPES);
@@ -746,8 +748,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
    public void updateAnimatingTypes(IWindow window, @InsetsType int animatingTypes,
            @Nullable ImeTracker.Token statsToken) {
        synchronized (mService.mGlobalLock) {
            final WindowState win = mService.windowForClientLocked(this, window,
                    false /* throwOnError */);
            final WindowState win = mService.windowForClient(this, window);
            if (win != null) {
                ImeTracker.forLogging().onProgress(statsToken,
                        ImeTracker.PHASE_WM_UPDATE_ANIMATING_TYPES);
@@ -982,8 +983,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
        final long identity = Binder.clearCallingIdentity();
        try {
            synchronized (mService.mGlobalLock) {
                final WindowState win =
                        mService.windowForClientLocked(this, fromWindow, false /* throwOnError */);
                final WindowState win = mService.windowForClient(this, fromWindow);
                if (win == null) {
                    return false;
                }
@@ -1010,7 +1010,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
            IWindow window,
            OnBackInvokedCallbackInfo callbackInfo) {
        synchronized (mService.mGlobalLock) {
            WindowState windowState = mService.windowForClientLocked(this, window, false);
            final WindowState windowState = mService.windowForClient(this, window);
            if (windowState == null) {
                Slog.i(TAG_WM,
                        "setOnBackInvokedCallback(): No window state for package:" + mPackageName);
@@ -1026,8 +1026,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
        synchronized (mService.mGlobalLock) {
            // TODO(b/353463205) check if we can use mService.getDefaultDisplayContentLocked()
            //  instead of window
            final WindowState win = mService.windowForClientLocked(this, window,
                    false /* throwOnError */);
            final WindowState win = mService.windowForClient(this, window);
            if (win != null) {
                final InsetsStateController insetsStateController =
                        win.getDisplayContent().getInsetsStateController();
+26 −32
Original line number Diff line number Diff line
@@ -1663,7 +1663,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }

            if (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) {
                parentWindow = windowForClientLocked(null, attrs.token, false);
                parentWindow = windowForClient(null /* session */, attrs.token);
                if (parentWindow == null) {
                    ProtoLog.w(WM_ERROR, "Attempted to add window with token that is not a window: "
                            + "%s.  Aborting.", attrs.token);
@@ -2222,7 +2222,7 @@ public class WindowManagerService extends IWindowManager.Stub

    void removeClientToken(Session session, IBinder client) {
        synchronized (mGlobalLock) {
            WindowState win = windowForClientLocked(session, client, false);
            final WindowState win = windowForClient(session, client);
            if (win != null) {
                win.removeIfPossible();
                return;
@@ -2328,9 +2328,11 @@ public class WindowManagerService extends IWindowManager.Stub
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                WindowState w = windowForClientLocked(session, client, false);
                final WindowState w = windowForClient(session, client);
                if (w != null) {
                    w.clearClientTouchableRegion();
                }
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
@@ -2342,7 +2344,7 @@ public class WindowManagerService extends IWindowManager.Stub
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                WindowState w = windowForClientLocked(session, client, false);
                final WindowState w = windowForClient(session, client);
                if (DEBUG_LAYOUT) Slog.d(TAG, "setInsetsWindow " + w
                        + ", contentInsets=" + w.mGivenContentInsets + " -> " + contentInsets
                        + ", visibleInsets=" + w.mGivenVisibleInsets + " -> " + visibleInsets
@@ -2411,7 +2413,7 @@ public class WindowManagerService extends IWindowManager.Stub

    public void pokeDrawLock(Session session, IBinder token) {
        synchronized (mGlobalLock) {
            WindowState window = windowForClientLocked(session, token, false);
            final WindowState window = windowForClient(session, token);
            if (window != null) {
                window.pokeDrawLockLw(mDrawLockTimeoutMillis);
            }
@@ -2428,7 +2430,7 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    public boolean cancelDraw(Session session, IWindow client, int seqId) {
        synchronized (mGlobalLock) {
            final WindowState win = windowForClientLocked(session, client, false);
            final WindowState win = windowForClient(session, client);
            if (win == null) {
                return false;
            }
@@ -2467,7 +2469,7 @@ public class WindowManagerService extends IWindowManager.Stub
        final int uid = Binder.getCallingUid();
        final long origId = Binder.clearCallingIdentity();
        synchronized (mGlobalLock) {
            final WindowState win = windowForClientLocked(session, client, false);
            final WindowState win = windowForClient(session, client);
            if (win == null) {
                return 0;
            }
@@ -2960,7 +2962,7 @@ public class WindowManagerService extends IWindowManager.Stub

        try {
            synchronized (mGlobalLock) {
                WindowState win = windowForClientLocked(session, client, false);
                final WindowState win = windowForClient(session, client);
                if (win == null) {
                    return false;
                }
@@ -2980,7 +2982,7 @@ public class WindowManagerService extends IWindowManager.Stub
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                WindowState win = windowForClientLocked(session, client, false);
                final WindowState win = windowForClient(session, client);
                ProtoLog.d(WM_DEBUG_ADD_REMOVE, "finishDrawingWindow: %s mDrawState=%s",
                        win, (win != null ? win.mWinAnimator.drawStateToString() : "null"));
                if (win != null && win.finishDrawing(postDrawTransaction, seqId)) {
@@ -5149,8 +5151,7 @@ public class WindowManagerService extends IWindowManager.Stub

    void reportDecorViewGestureChanged(Session session, IWindow window, boolean intercepted) {
        synchronized (mGlobalLock) {
            final WindowState win =
                    windowForClientLocked(session, window, false /* throwOnError */);
            final WindowState win = windowForClient(session, window);
            if (win == null) {
                return;
            }
@@ -5162,8 +5163,7 @@ public class WindowManagerService extends IWindowManager.Stub
    void reportSystemGestureExclusionChanged(Session session, IWindow window,
            List<Rect> exclusionRects) {
        synchronized (mGlobalLock) {
            final WindowState win = windowForClientLocked(session, window,
                    false /* throwOnError */);
            final WindowState win = windowForClient(session, window);
            if (win == null) {
                Slog.i(TAG_WM,
                        "reportSystemGestureExclusionChanged(): No window state for package:"
@@ -5179,8 +5179,7 @@ public class WindowManagerService extends IWindowManager.Stub
    void reportKeepClearAreasChanged(Session session, IWindow window,
            List<Rect> restricted, List<Rect> unrestricted) {
        synchronized (mGlobalLock) {
            final WindowState win = windowForClientLocked(session, window,
                    false /* throwOnError */);
            final WindowState win = windowForClient(session, window);
            if (win == null) {
                Slog.i(TAG_WM,
                        "reportKeepClearAreasChanged(): No window state for package:"
@@ -6608,27 +6607,23 @@ public class WindowManagerService extends IWindowManager.Stub
    // Internals
    // -------------------------------------------------------------

    final WindowState windowForClientLocked(Session session, IWindow client, boolean throwOnError) {
        return windowForClientLocked(session, client.asBinder(), throwOnError);
    @Nullable
    @GuardedBy("mGlobalLock")
    final WindowState windowForClient(@Nullable Session session, @NonNull IWindow client) {
        return windowForClient(session, client.asBinder());
    }

    final WindowState windowForClientLocked(Session session, IBinder client, boolean throwOnError) {
    @Nullable
    @GuardedBy("mGlobalLock")
    final WindowState windowForClient(@Nullable Session session, @NonNull IBinder client) {
        WindowState win = mWindowMap.get(client);
        if (DEBUG) Slog.v(TAG_WM, "Looking up client " + client + ": " + win);
        if (win == null) {
            if (throwOnError) {
                throw new IllegalArgumentException(
                        "Requested window " + client + " does not exist");
            }
            ProtoLog.w(WM_ERROR, "Failed looking up window session=%s callers=%s", session,
                    Debug.getCallers(3));
            return null;
        }
        if (session != null && win.mSession != session) {
            if (throwOnError) {
                throw new IllegalArgumentException("Requested window " + client + " is in session "
                        + win.mSession + ", not " + session);
            }
            ProtoLog.w(WM_ERROR, "Failed looking up window session=%s callers=%s", session,
                    Debug.getCallers(3));
            return null;
@@ -7644,7 +7639,7 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    void updateTapExcludeRegion(IWindow client, Region region) {
        synchronized (mGlobalLock) {
            final WindowState callingWin = windowForClientLocked(null, client, false);
            final WindowState callingWin = windowForClient(null /* session */, client);
            if (callingWin == null) {
                ProtoLog.w(WM_ERROR, "Bad requesting window %s", client);
                return;
@@ -7680,7 +7675,7 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                WindowState topWindow = null;
                if (behindClient != null) {
                    topWindow = windowForClientLocked(null, behindClient, /* throwOnError*/ false);
                    topWindow = windowForClient(null /* session */, behindClient);
                }
                WindowState targetWindow = dc.findScrollCaptureTargetWindow(topWindow, taskId);
                if (targetWindow == null) {
@@ -10008,8 +10003,7 @@ public class WindowManagerService extends IWindowManager.Stub
    void grantEmbeddedWindowFocus(Session session, IWindow callingWindow,
            InputTransferToken inputTransferToken, boolean grantFocus) {
        synchronized (mGlobalLock) {
            final WindowState hostWindow =
                    windowForClientLocked(session, callingWindow, false /* throwOnError*/);
            final WindowState hostWindow = windowForClient(session, callingWindow);
            if (hostWindow == null) {
                Slog.e(TAG, "Host window not found");
                return;
@@ -10089,7 +10083,7 @@ public class WindowManagerService extends IWindowManager.Stub
        final SurfaceControl displaySurfaceControl;
        final Rect boundsInDisplay = new Rect(boundsInWindow);
        synchronized (mGlobalLock) {
            final WindowState win = windowForClientLocked(session, window, false);
            final WindowState win = windowForClient(session, window);
            if (win == null) {
                Slog.w(TAG, "Failed to generate DisplayHash. Invalid window");
                mDisplayHashController.sendDisplayHashError(callback,
+1 −1
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public class PresentationControllerTests extends WindowTestsBase {
        final int res = mWm.addWindow(session, clientWindow, params, View.VISIBLE, displayId,
                userId, WindowInsets.Type.defaultVisible(), null, new WindowRelayoutResult());
        assertTrue(res >= WindowManagerGlobal.ADD_OKAY);
        final WindowState window = mWm.windowForClientLocked(session, clientWindow, false);
        final WindowState window = mWm.windowForClient(session, clientWindow);
        window.mHasSurface = true;
        return window;
    }