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

Commit 26e46b53 authored by Ben Lin's avatar Ben Lin
Browse files

Calculate Occulusion base on TDA status.

We currently have a single Flag that globally sets the entire keyguard
state as occluded vs not occluded. On top of this, we can pass TDA
status and base on whether it's moving to the front or to the back, we
can figure out occlusion on a per-display level.

Bug: 364930619
Test: atest android.server.wm.keyguard.KeyguardTests
Flag: EXEMPT refactor

Change-Id: Ie943e7ef6fc0648f38b0883e66eb9c0f6825d0f8
parent 4a3ff7a9
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -169,8 +169,11 @@ public final class TransitionInfo implements Parcelable {
    /** This change represents its start configuration for the duration of the animation. */
    public static final int FLAG_CONFIG_AT_END = 1 << 22;

    /** This change represents one of a Task Display Area. */
    public static final int FLAG_IS_TASK_DISPLAY_AREA = 1 << 23;

    /** The first unused bit. This can be used by remotes to attach custom flags to this change. */
    public static final int FLAG_FIRST_CUSTOM = 1 << 23;
    public static final int FLAG_FIRST_CUSTOM = 1 << 24;

    /** The change belongs to a window that won't contain activities. */
    public static final int FLAGS_IS_NON_APP_WINDOW =
@@ -205,6 +208,7 @@ public final class TransitionInfo implements Parcelable {
            FLAG_MOVED_TO_TOP,
            FLAG_SYNC,
            FLAG_CONFIG_AT_END,
            FLAG_IS_TASK_DISPLAY_AREA,
            FLAG_FIRST_CUSTOM
    }, flag = true)
    public @interface ChangeFlags {}
@@ -553,6 +557,9 @@ public final class TransitionInfo implements Parcelable {
        if ((flags & FLAG_MOVED_TO_TOP) != 0) {
            sb.append(sb.length() == 0 ? "" : "|").append("MOVE_TO_TOP");
        }
        if ((flags & FLAG_IS_TASK_DISPLAY_AREA) != 0) {
            sb.append(sb.length() == 0 ? "" : "|").append("FLAG_IS_TASK_DISPLAY_AREA");
        }
        return sb.toString();
    }

+24 −3
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_APPEARING;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_OCCLUDING;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_UNOCCLUDING;
import static android.view.WindowManager.TRANSIT_SLEEP;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
@@ -194,7 +193,7 @@ public class KeyguardTransitionHandler

        // Occlude/unocclude animations are only played if the keyguard is locked.
        if ((info.getFlags() & TRANSIT_FLAG_KEYGUARD_LOCKED) != 0) {
            if ((info.getFlags() & TRANSIT_FLAG_KEYGUARD_OCCLUDING) != 0) {
            if (isKeyguardOccluding(info)) {
                if (hasOpeningDream(info)) {
                    return startAnimation(mOccludeByDreamTransition, "occlude-by-dream",
                            transition, info, startTransaction, finishTransaction, finishCallback);
@@ -202,7 +201,7 @@ public class KeyguardTransitionHandler
                    return startAnimation(mOccludeTransition, "occlude",
                            transition, info, startTransaction, finishTransaction, finishCallback);
                }
            } else if ((info.getFlags() & TRANSIT_FLAG_KEYGUARD_UNOCCLUDING) != 0) {
            } else if (isKeyguardUnoccluding(info)) {
                return startAnimation(mUnoccludeTransition, "unocclude",
                        transition, info, startTransaction, finishTransaction, finishCallback);
            }
@@ -325,6 +324,28 @@ public class KeyguardTransitionHandler
        return false;
    }

    private static boolean isKeyguardOccluding(@NonNull TransitionInfo info) {
        for (int i = 0; i < info.getChanges().size(); i++) {
            TransitionInfo.Change change = info.getChanges().get(i);
            if (change.hasFlags(TransitionInfo.FLAG_IS_TASK_DISPLAY_AREA)
                    && change.getMode() == TRANSIT_TO_FRONT) {
                return true;
            }
        }
        return false;
    }

    private static boolean isKeyguardUnoccluding(@NonNull TransitionInfo info) {
        for (int i = 0; i < info.getChanges().size(); i++) {
            TransitionInfo.Change change = info.getChanges().get(i);
            if (change.hasFlags(TransitionInfo.FLAG_IS_TASK_DISPLAY_AREA)
                    && change.getMode() == TRANSIT_TO_BACK) {
                return true;
            }
        }
        return false;
    }

    private void finishAnimationImmediately(IBinder transition, StartedTransition playing) {
        final IBinder fakeTransition = new Binder();
        final TransitionInfo fakeInfo = new TransitionInfo(TRANSIT_SLEEP, 0x0);
+4 −0
Original line number Diff line number Diff line
@@ -3559,6 +3559,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
            if (wc.mWmService.mAtmService.mBackNavigationController.isMonitorTransitionTarget(wc)) {
                flags |= TransitionInfo.FLAG_BACK_GESTURE_ANIMATED;
            }
            final TaskDisplayArea tda = wc.asTaskDisplayArea();
            if (tda != null) {
                flags |= TransitionInfo.FLAG_IS_TASK_DISPLAY_AREA;
            }
            final Task task = wc.asTask();
            if (task != null) {
                final ActivityRecord topActivity = task.getTopNonFinishingActivity();