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

Commit ed14802c authored by Issei Suzuki's avatar Issei Suzuki Committed by Android (Google) Code Review
Browse files

Merge "Revised logic to sync keyguard occlude status." into sc-v2-dev

parents 2328dee0 311c25b0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ public class KeyguardService extends Service {
                if (transit == TRANSIT_OLD_KEYGUARD_OCCLUDE) {
                    mBinder.setOccluded(true /* isOccluded */, true /* animate */);
                } else if (transit == TRANSIT_OLD_KEYGUARD_UNOCCLUDE) {
                    mBinder.setOccluded(false /* isOccluded */, true /* animate */);
                    mBinder.setOccluded(false /* isOccluded */, false /* animate */);
                }
                // TODO(bc-unlock): Implement (un)occlude animation.
                finishedCallback.onAnimationFinished();
+28 −14
Original line number Diff line number Diff line
@@ -1814,18 +1814,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        mWindowManagerInternal.registerAppTransitionListener(new AppTransitionListener() {
            @Override
            public int onAppTransitionStartingLocked(boolean keyguardGoingAway, long duration,
                    long statusBarAnimationStartTime, long statusBarAnimationDuration) {
            public int onAppTransitionStartingLocked(boolean keyguardGoingAway,
                    boolean keyguardOccluding, long duration, long statusBarAnimationStartTime,
                    long statusBarAnimationDuration) {
                // When remote animation is enabled for KEYGUARD_GOING_AWAY transition, SysUI
                // receives IRemoteAnimationRunner#onAnimationStart to start animation, so we don't
                // need to call IKeyguardService#keyguardGoingAway here.
                return handleStartTransitionForKeyguardLw(keyguardGoingAway
                        && !WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation, duration);
                        && !WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation,
                        keyguardOccluding, duration);
            }

            @Override
            public void onAppTransitionCancelledLocked(boolean keyguardGoingAway) {
                handleStartTransitionForKeyguardLw(keyguardGoingAway, 0 /* duration */);
                handleStartTransitionForKeyguardLw(
                        keyguardGoingAway, false /* keyguardOccludingStarted */,
                        0 /* duration */);
            }
        });

@@ -3048,26 +3052,29 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mPendingKeyguardOccluded = occluded;
            mKeyguardOccludedChanged = true;
        } else {
            setKeyguardOccludedLw(occluded, false /* force */);
            setKeyguardOccludedLw(occluded, false /* force */,
                    false /* transitionStarted */);
        }
    }

    @Override
    public int applyKeyguardOcclusionChange() {
    public int applyKeyguardOcclusionChange(boolean transitionStarted) {
        if (mKeyguardOccludedChanged) {
            if (DEBUG_KEYGUARD) Slog.d(TAG, "transition/occluded changed occluded="
                    + mPendingKeyguardOccluded);
            mKeyguardOccludedChanged = false;
            if (setKeyguardOccludedLw(mPendingKeyguardOccluded, false /* force */)) {
            if (setKeyguardOccludedLw(mPendingKeyguardOccluded, false /* force */,
                    transitionStarted)) {
                return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_WALLPAPER;
            }
        }
        return 0;
    }

    private int handleStartTransitionForKeyguardLw(boolean keyguardGoingAway, long duration) {
        final int res = applyKeyguardOcclusionChange();
        if (res != 0) return res;
    private int handleStartTransitionForKeyguardLw(boolean keyguardGoingAway,
            boolean keyguardOccluding, long duration) {
        final int redoLayout = applyKeyguardOcclusionChange(keyguardOccluding);
        if (redoLayout != 0) return redoLayout;
        if (keyguardGoingAway) {
            if (DEBUG_KEYGUARD) Slog.d(TAG, "Starting keyguard exit animation");
            startKeyguardExitAnimation(SystemClock.uptimeMillis(), duration);
@@ -3269,7 +3276,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    @Override
    public void setKeyguardCandidateLw(WindowState win) {
        mKeyguardCandidate = win;
        setKeyguardOccludedLw(isKeyguardOccluded(), true /* force */);
        setKeyguardOccludedLw(isKeyguardOccluded(), true /* force */,
                false /* keyguardOccludingStarted */);
    }

    /**
@@ -3278,9 +3286,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     * @param isOccluded Whether the Keyguard is occluded by another window.
     * @param force notify the occluded status to KeyguardService and update flags even though
     *             occlude status doesn't change.
     * @param transitionStarted {@code true} if keyguard (un)occluded transition started.
     * @return Whether the flags have changed and we have to redo the layout.
     */
    private boolean setKeyguardOccludedLw(boolean isOccluded, boolean force) {
    private boolean setKeyguardOccludedLw(boolean isOccluded, boolean force,
            boolean transitionStarted) {
        if (DEBUG_KEYGUARD) Slog.d(TAG, "setKeyguardOccluded occluded=" + isOccluded);
        if (isKeyguardOccluded() == isOccluded && !force) {
            return false;
@@ -3288,8 +3298,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        final boolean showing = mKeyguardDelegate.isShowing();
        final boolean animate = showing && !isOccluded;
        mKeyguardDelegate.setOccluded(isOccluded, animate);

        // When remote animation is enabled for keyguard (un)occlude transition, KeyguardService
        // uses remote animation start as a signal to update its occlusion status ,so we don't need
        // to notify here.
        final boolean notify = !WindowManagerService.sEnableRemoteKeyguardOccludeAnimation
                || !transitionStarted;
        mKeyguardDelegate.setOccluded(isOccluded, animate, notify);
        if (!showing) {
            return false;
        }
+5 −2
Original line number Diff line number Diff line
@@ -173,8 +173,11 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     */
    void onKeyguardOccludedChangedLw(boolean occluded);

    /** Applies a keyguard occlusion change if one happened. */
    int applyKeyguardOcclusionChange();
    /**
     * Applies a keyguard occlusion change if one happened.
     * @param transitionStarted Whether keyguard (un)occlude transition is starting or not.
     */
    int applyKeyguardOcclusionChange(boolean transitionStarted);

    /**
     * Interface to the Window Manager state associated with a particular
+2 −8
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import com.android.internal.policy.IKeyguardExitCallback;
import com.android.internal.policy.IKeyguardService;
import com.android.server.UiThread;
import com.android.server.policy.WindowManagerPolicy.OnKeyguardExitResult;
import com.android.server.wm.WindowManagerService;

import java.io.PrintWriter;

@@ -259,13 +258,8 @@ public class KeyguardServiceDelegate {
        }
    }

    /**
     * @deprecated Notify occlude status change via remote animation.
     */
    @Deprecated
    public void setOccluded(boolean isOccluded, boolean animate) {
        if (!WindowManagerService.sEnableRemoteKeyguardOccludeAnimation
                && mKeyguardService != null) {
    public void setOccluded(boolean isOccluded, boolean animate, boolean notify) {
        if (mKeyguardService != null && notify) {
            if (DEBUG) Log.v(TAG, "setOccluded(" + isOccluded + ") animate=" + animate);
            mKeyguardService.setOccluded(isOccluded, animate);
        }
+6 −3
Original line number Diff line number Diff line
@@ -443,6 +443,7 @@ public class AppTransition implements Dump {

        int redoLayout = notifyAppTransitionStartingLocked(
                AppTransition.isKeyguardGoingAwayTransitOld(transit),
                AppTransition.isKeyguardOccludeTransitOld(transit),
                topOpeningAnim != null ? topOpeningAnim.getDurationHint() : 0,
                topOpeningAnim != null
                        ? topOpeningAnim.getStatusBarTransitionsStartTime()
@@ -557,12 +558,14 @@ public class AppTransition implements Dump {
        }
    }

    private int notifyAppTransitionStartingLocked(boolean keyguardGoingAway, long duration,
            long statusBarAnimationStartTime, long statusBarAnimationDuration) {
    private int notifyAppTransitionStartingLocked(boolean keyguardGoingAway,
            boolean keyguardOcclude, long duration, long statusBarAnimationStartTime,
            long statusBarAnimationDuration) {
        int redoLayout = 0;
        for (int i = 0; i < mListeners.size(); i++) {
            redoLayout |= mListeners.get(i).onAppTransitionStartingLocked(keyguardGoingAway,
                    duration, statusBarAnimationStartTime, statusBarAnimationDuration);
                    keyguardOcclude, duration, statusBarAnimationStartTime,
                    statusBarAnimationDuration);
        }
        return redoLayout;
    }
Loading