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

Commit 08f6bc03 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Don't use WMS.mWindowMap to synchronize WM critical section (36/n)"

parents 6d9ce04b db485dec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ java_genrule {
    srcs: [":services.core.unboosted"],
    tools: ["lockedregioncodeinjection"],
    cmd: "$(location lockedregioncodeinjection) " +
        "  --targets \"Lcom/android/server/am/ActivityManagerService;,Lcom/android/server/wm/WindowHashMap;\" " +
        "  --targets \"Lcom/android/server/am/ActivityManagerService;,Lcom/android/server/wm/WindowManagerGlobalLock;\" " +
        "  --pre \"com/android/server/am/ActivityManagerService.boostPriorityForLockedSection,com/android/server/wm/WindowManagerService.boostPriorityForLockedSection\" " +
        "  --post \"com/android/server/am/ActivityManagerService.resetPriorityAfterLockedSection,com/android/server/wm/WindowManagerService.resetPriorityAfterLockedSection\" " +
        "  -o $(out) " +
+8 −8
Original line number Diff line number Diff line
@@ -735,7 +735,7 @@ final class AccessibilityController {
                }

                public void setShown(boolean shown, boolean animate) {
                    synchronized (mService.mWindowMap) {
                    synchronized (mService.mGlobalLock) {
                        if (mShown == shown) {
                            return;
                        }
@@ -750,13 +750,13 @@ final class AccessibilityController {
                @SuppressWarnings("unused")
                // Called reflectively from an animator.
                public int getAlpha() {
                    synchronized (mService.mWindowMap) {
                    synchronized (mService.mGlobalLock) {
                        return mAlpha;
                    }
                }

                public void setAlpha(int alpha) {
                    synchronized (mService.mWindowMap) {
                    synchronized (mService.mGlobalLock) {
                        if (mAlpha == alpha) {
                            return;
                        }
@@ -769,7 +769,7 @@ final class AccessibilityController {
                }

                public void setBounds(Region bounds) {
                    synchronized (mService.mWindowMap) {
                    synchronized (mService.mGlobalLock) {
                        if (mBounds.equals(bounds)) {
                            return;
                        }
@@ -782,7 +782,7 @@ final class AccessibilityController {
                }

                public void updateSize() {
                    synchronized (mService.mWindowMap) {
                    synchronized (mService.mGlobalLock) {
                        mWindowManager.getDefaultDisplay().getRealSize(mTempPoint);
                        mSurfaceControl.setSize(mTempPoint.x, mTempPoint.y);
                        invalidate(mDirtyRect);
@@ -801,7 +801,7 @@ final class AccessibilityController {

                /** NOTE: This has to be called within a surface transaction. */
                public void drawIfNeeded() {
                    synchronized (mService.mWindowMap) {
                    synchronized (mService.mGlobalLock) {
                        if (!mInvalidated) {
                            return;
                        }
@@ -948,7 +948,7 @@ final class AccessibilityController {
                    } break;

                    case MESSAGE_SHOW_MAGNIFIED_REGION_BOUNDS_IF_NEEDED : {
                        synchronized (mService.mWindowMap) {
                        synchronized (mService.mGlobalLock) {
                            if (mMagnifedViewport.isMagnifyingLocked()
                                    || isForceShowingMagnifiableBoundsLocked()) {
                                mMagnifedViewport.setMagnifiedRegionBorderShownLocked(true, true);
@@ -1039,7 +1039,7 @@ final class AccessibilityController {
            boolean windowsChanged = false;
            List<WindowInfo> windows = new ArrayList<WindowInfo>();

            synchronized (mService.mWindowMap) {
            synchronized (mService.mGlobalLock) {
                // Do not send the windows if there is no current focus as
                // the window manager is still looking for where to put it.
                // We will do the work when we get a focus change callback.
+2 −2
Original line number Diff line number Diff line
@@ -1924,7 +1924,7 @@ public class AppTransition implements Dump {
                } catch (RemoteException e) {
                    Slog.w(TAG, "Failed to fetch app transition specs: " + e);
                }
                synchronized (mService.mWindowMap) {
                synchronized (mService.mGlobalLock) {
                    mNextAppTransitionAnimationsSpecsPending = false;
                    overridePendingAppTransitionMultiThumb(specs,
                            mNextAppTransitionFutureCallback, null /* finishedCallback */,
@@ -2220,7 +2220,7 @@ public class AppTransition implements Dump {
    }

    private void handleAppTransitionTimeout() {
        synchronized (mService.mWindowMap) {
        synchronized (mService.mGlobalLock) {
            final DisplayContent dc = mDisplayContent;
            if (dc == null) {
                return;
+22 −22
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ public class AppWindowContainerController
            final StartingData startingData;
            final AppWindowToken container;

            synchronized (mWindowMap) {
            synchronized (mGlobalLock) {
                if (mContainer == null) {
                    if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "mContainer was null while trying to"
                            + " add starting window");
@@ -169,7 +169,7 @@ public class AppWindowContainerController
            }
            if (surface != null) {
                boolean abort = false;
                synchronized (mWindowMap) {
                synchronized (mGlobalLock) {
                    // If the window was successfully added, then
                    // we need to remove it.
                    if (container.removed || container.startingData == null) {
@@ -219,7 +219,7 @@ public class AppWindowContainerController
        super(listener, service);
        mHandler = new H(service.mH.getLooper());
        mToken = token;
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            AppWindowToken atoken = mRoot.getAppWindowToken(mToken.asBinder());
            if (atoken != null) {
                // TODO: Should this throw an exception instead?
@@ -256,7 +256,7 @@ public class AppWindowContainerController
    }

    public void removeContainer(int displayId) {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            final DisplayContent dc = mRoot.getDisplayContent(displayId);
            if (dc == null) {
                Slog.w(TAG_WM, "removeAppToken: Attempted to remove binder token: "
@@ -274,7 +274,7 @@ public class AppWindowContainerController
    }

    public void reparent(TaskWindowContainerController taskController, int position) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (DEBUG_ADD_REMOVE) Slog.i(TAG_WM, "reparent: moving app token=" + mToken
                    + " to task=" + taskController + " at " + position);
            if (mContainer == null) {
@@ -294,7 +294,7 @@ public class AppWindowContainerController

    public Configuration setOrientation(int requestedOrientation, int displayId,
            Configuration displayConfig, boolean freezeScreenIfNeeded) {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM,
                        "Attempted to set orientation of non-existing app token: " + mToken);
@@ -310,7 +310,7 @@ public class AppWindowContainerController
    }

    public int getOrientation() {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                return SCREEN_ORIENTATION_UNSPECIFIED;
            }
@@ -320,7 +320,7 @@ public class AppWindowContainerController
    }

    public void setDisablePreviewScreenshots(boolean disable) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM, "Attempted to set disable screenshots of non-existing app"
                        + " token: " + mToken);
@@ -331,7 +331,7 @@ public class AppWindowContainerController
    }

    public void setVisibility(boolean visible, boolean deferHidingClient) {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM, "Attempted to set visibility of non-existing app token: "
                        + mToken);
@@ -449,7 +449,7 @@ public class AppWindowContainerController
     * of Keyguard flags it's going to set on its windows.
     */
    public void notifyUnknownVisibilityLaunched() {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer != null) {
                mContainer.getDisplayContent().mUnknownAppVisibilityController.notifyLaunched(
                        mContainer);
@@ -461,7 +461,7 @@ public class AppWindowContainerController
            CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags,
            IBinder transferFrom, boolean newTask, boolean taskSwitch, boolean processRunning,
            boolean allowTaskSnapshot, boolean activityCreated, boolean fromRecents) {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "setAppStartingWindow: token=" + mToken
                    + " pkg=" + pkg + " transferFrom=" + transferFrom + " newTask=" + newTask
                    + " taskSwitch=" + taskSwitch + " processRunning=" + processRunning
@@ -611,7 +611,7 @@ public class AppWindowContainerController
    }

    public void removeStartingWindow() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer.startingWindow == null) {
                if (mContainer.startingData != null) {
                    // Starting window has not been added yet, but it is scheduled to be added.
@@ -664,7 +664,7 @@ public class AppWindowContainerController
    }

    public void pauseKeyDispatching() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer != null) {
                mContainer.getDisplayContent().getInputMonitor().pauseDispatchingLw(mContainer);
            }
@@ -672,7 +672,7 @@ public class AppWindowContainerController
    }

    public void resumeKeyDispatching() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer != null) {
                mContainer.getDisplayContent().getInputMonitor().resumeDispatchingLw(mContainer);
            }
@@ -680,7 +680,7 @@ public class AppWindowContainerController
    }

    public void notifyAppResumed(boolean wasStopped) {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM, "Attempted to notify resumed of non-existing app token: " + mToken);
                return;
@@ -690,7 +690,7 @@ public class AppWindowContainerController
    }

    public void notifyAppStopping() {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM, "Attempted to notify stopping on non-existing app token: "
                        + mToken);
@@ -701,7 +701,7 @@ public class AppWindowContainerController
    }

    public void notifyAppStopped() {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM, "Attempted to notify stopped of non-existing app token: "
                        + mToken);
@@ -712,7 +712,7 @@ public class AppWindowContainerController
    }

    public void startFreezingScreen(int configChanges) {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM,
                        "Attempted to freeze screen with non-existing app token: " + mContainer);
@@ -729,7 +729,7 @@ public class AppWindowContainerController
    }

    public void stopFreezingScreen(boolean force) {
        synchronized(mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                return;
            }
@@ -740,7 +740,7 @@ public class AppWindowContainerController
    }

    public void registerRemoteAnimations(RemoteAnimationDefinition definition) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                Slog.w(TAG_WM, "Attempted to register remote animations with non-existing app"
                        + " token: " + mToken);
@@ -775,7 +775,7 @@ public class AppWindowContainerController
     * Apply override app transition base on options & animation type.
     */
    public void applyOptionsLocked(ActivityOptions pendingOptions, Intent intent) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            final int animationType = pendingOptions.getAnimationType();
            final DisplayContent displayContent = mContainer.getDisplayContent();
            switch (animationType) {
@@ -875,7 +875,7 @@ public class AppWindowContainerController
     * signal on the WM side.
     */
    public void setWillCloseOrEnterPip(boolean willCloseOrEnterPip) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                return;
            }
+18 −18
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public class DisplayWindowController
        super(listener, WindowManagerService.getInstance());
        mDisplayId = display.getDisplayId();

        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            final long callingIdentity = Binder.clearCallingIdentity();
            try {
                mRoot.createDisplayContent(display, this /* controller */);
@@ -75,7 +75,7 @@ public class DisplayWindowController

    @Override
    public void removeContainer() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if(mContainer == null) {
                if (DEBUG_DISPLAY) Slog.i(TAG_WM, "removeDisplay: could not find displayId="
                        + mDisplayId);
@@ -102,7 +102,7 @@ public class DisplayWindowController
     * {@link android.hardware.display.DisplayManager.DisplayListener#onDisplayChanged(int)}.
     */
    public void onDisplayChanged() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                if (DEBUG_DISPLAY) Slog.i(TAG_WM, "onDisplayChanged: could not find display="
                        + mDisplayId);
@@ -118,7 +118,7 @@ public class DisplayWindowController
     */
    public void positionChildAt(StackWindowController child, int position,
            boolean includingParents) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (DEBUG_STACK) Slog.i(TAG_WM, "positionTaskStackAt: positioning stack=" + child
                    + " at " + position);
            if (mContainer == null) {
@@ -140,7 +140,7 @@ public class DisplayWindowController
     * attempt to update the IME target before all information about the Windows have been updated.
     */
    public void deferUpdateImeTarget() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            final DisplayContent dc = mRoot.getDisplayContent(mDisplayId);
            if (dc != null) {
                dc.deferUpdateImeTarget();
@@ -152,7 +152,7 @@ public class DisplayWindowController
     * Resumes updating the IME target after deferring. See {@link #deferUpdateImeTarget()}
     */
    public void continueUpdateImeTarget() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            final DisplayContent dc = mRoot.getDisplayContent(mDisplayId);
            if (dc != null) {
                dc.continueUpdateImeTarget();
@@ -167,7 +167,7 @@ public class DisplayWindowController
     * @param moveFocusNow Specifies if we should update the focused window immediately.
     */
    public void setFocusedApp(IBinder token, boolean moveFocusNow) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            if (mContainer == null) {
                if (DEBUG_FOCUS_LIGHT) Slog.i(TAG_WM, "setFocusedApp: could not find displayId="
                        + mDisplayId);
@@ -213,21 +213,21 @@ public class DisplayWindowController
    public void prepareAppTransition(@WindowManager.TransitionType int transit,
            boolean alwaysKeepCurrent, @WindowManager.TransitionFlags int flags,
            boolean forceOverride) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId).prepareAppTransition(transit, alwaysKeepCurrent,
                    flags, forceOverride);
        }
    }

    public void executeAppTransition() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId).executeAppTransition();
        }
    }

    public void overridePendingAppTransition(String packageName,
            int enterAnim, int exitAnim, IRemoteCallback startedCallback) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId).mAppTransition.overridePendingAppTransition(
                    packageName, enterAnim, exitAnim, startedCallback);
        }
@@ -235,7 +235,7 @@ public class DisplayWindowController

    public void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
            int startHeight) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId).mAppTransition.overridePendingAppTransitionScaleUp(
                    startX, startY, startWidth, startHeight);
        }
@@ -243,7 +243,7 @@ public class DisplayWindowController

    public void overridePendingAppTransitionClipReveal(int startX, int startY,
            int startWidth, int startHeight) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId)
                    .mAppTransition.overridePendingAppTransitionClipReveal(startX, startY,
                    startWidth, startHeight);
@@ -252,7 +252,7 @@ public class DisplayWindowController

    public void overridePendingAppTransitionThumb(GraphicBuffer srcThumb, int startX,
            int startY, IRemoteCallback startedCallback, boolean scaleUp) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId)
                    .mAppTransition.overridePendingAppTransitionThumb(srcThumb, startX, startY,
                    startedCallback, scaleUp);
@@ -262,7 +262,7 @@ public class DisplayWindowController
    public void overridePendingAppTransitionAspectScaledThumb(GraphicBuffer srcThumb, int startX,
            int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback,
            boolean scaleUp) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId)
                    .mAppTransition.overridePendingAppTransitionAspectScaledThumb(srcThumb, startX,
                    startY, targetWidth, targetHeight, startedCallback, scaleUp);
@@ -272,7 +272,7 @@ public class DisplayWindowController
    public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs,
            IRemoteCallback onAnimationStartedCallback, IRemoteCallback onAnimationFinishedCallback,
            boolean scaleUp) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId)
                    .mAppTransition.overridePendingAppTransitionMultiThumb(specs,
                    onAnimationStartedCallback, onAnimationFinishedCallback, scaleUp);
@@ -280,14 +280,14 @@ public class DisplayWindowController
    }

    public void overridePendingAppTransitionStartCrossProfileApps() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId)
                    .mAppTransition.overridePendingAppTransitionStartCrossProfileApps();
        }
    }

    public void overridePendingAppTransitionInPlace(String packageName, int anim) {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            mRoot.getDisplayContent(mDisplayId)
                    .mAppTransition.overrideInPlaceAppTransition(packageName, anim);
        }
@@ -299,7 +299,7 @@ public class DisplayWindowController
     * @return The pending app transition of the display.
     */
    public @TransitionType int getPendingAppTransition() {
        synchronized (mWindowMap) {
        synchronized (mGlobalLock) {
            return mRoot.getDisplayContent(mDisplayId).mAppTransition.getAppTransition();
        }
    }
Loading