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

Commit d6eb5a29 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Fix a bug that an activity occluding the keygaurd keeps running behind AOD.

Test: test android.server.am.KeyguardTests
Bug: 123150006
Bug: 122263738
Bug: 124428337
Change-Id: If364e03083e3aea43fbe1bd88cd8089d925b5e98
parent b610eccf
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -132,6 +132,7 @@ message KeyguardControllerProto {


    optional bool keyguard_showing = 1;
    optional bool keyguard_showing = 1;
    repeated KeyguardOccludedProto keyguard_occluded_states= 2;
    repeated KeyguardOccludedProto keyguard_occluded_states= 2;
    optional bool aod_showing = 3;
}
}


message KeyguardOccludedProto {
message KeyguardOccludedProto {
+17 −4
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER;


import static com.android.server.am.KeyguardControllerProto.AOD_SHOWING;
import static com.android.server.am.KeyguardControllerProto.KEYGUARD_OCCLUDED_STATES;
import static com.android.server.am.KeyguardControllerProto.KEYGUARD_OCCLUDED_STATES;
import static com.android.server.am.KeyguardControllerProto.KEYGUARD_SHOWING;
import static com.android.server.am.KeyguardControllerProto.KEYGUARD_SHOWING;
import static com.android.server.am.KeyguardOccludedProto.DISPLAY_ID;
import static com.android.server.am.KeyguardOccludedProto.DISPLAY_ID;
@@ -86,13 +87,23 @@ class KeyguardController {


    /**
    /**
     * @return true if either Keyguard or AOD are showing, not going away, and not being occluded
     * @return true if either Keyguard or AOD are showing, not going away, and not being occluded
     *         on the given display, false otherwise
     *         on the given display, false otherwise.
     */
     */
    boolean isKeyguardOrAodShowing(int displayId) {
    boolean isKeyguardOrAodShowing(int displayId) {
        return (mKeyguardShowing || mAodShowing) && !mKeyguardGoingAway
        return (mKeyguardShowing || mAodShowing) && !mKeyguardGoingAway
                && !isDisplayOccluded(displayId);
                && !isDisplayOccluded(displayId);
    }
    }


    /**
     * @return {@code true} if 1) Keyguard is showing, not going away, and not being occluded on the
     *         given display, or 2) AOD is showing, {@code false} otherwise.
     * TODO(b/125198167): Replace isKeyguardOrAodShowing() by this logic.
     */
    boolean isKeyguardUnoccludedOrAodShowing(int displayId) {
        return (mKeyguardShowing && !mKeyguardGoingAway && !isDisplayOccluded(displayId))
                || mAodShowing;
    }

    /**
    /**
     * @return true if Keyguard is showing, not going away, and not being occluded on the given
     * @return true if Keyguard is showing, not going away, and not being occluded on the given
     *         display, false otherwise
     *         display, false otherwise
@@ -380,10 +391,11 @@ class KeyguardController {
        for (int displayNdx = mRootActivityContainer.getChildCount() - 1;
        for (int displayNdx = mRootActivityContainer.getChildCount() - 1;
             displayNdx >= 0; displayNdx--) {
             displayNdx >= 0; displayNdx--) {
            final ActivityDisplay display = mRootActivityContainer.getChildAt(displayNdx);
            final ActivityDisplay display = mRootActivityContainer.getChildAt(displayNdx);
            final KeyguardDisplayState state = getDisplay(display.mDisplayId);
            final int displayId = display.mDisplayId;
            if (isKeyguardOrAodShowing(display.mDisplayId) && state.mSleepToken == null) {
            final KeyguardDisplayState state = getDisplay(displayId);
            if (isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken == null) {
                state.acquiredSleepToken();
                state.acquiredSleepToken();
            } else if (!isKeyguardOrAodShowing(display.mDisplayId) && state.mSleepToken != null) {
            } else if (!isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken != null) {
                state.releaseSleepToken();
                state.releaseSleepToken();
            }
            }
        }
        }
@@ -528,6 +540,7 @@ class KeyguardController {


    void writeToProto(ProtoOutputStream proto, long fieldId) {
    void writeToProto(ProtoOutputStream proto, long fieldId) {
        final long token = proto.start(fieldId);
        final long token = proto.start(fieldId);
        proto.write(AOD_SHOWING, mAodShowing);
        proto.write(KEYGUARD_SHOWING, mKeyguardShowing);
        proto.write(KEYGUARD_SHOWING, mKeyguardShowing);
        writeDisplayStatesToProto(proto, KEYGUARD_OCCLUDED_STATES);
        writeDisplayStatesToProto(proto, KEYGUARD_OCCLUDED_STATES);
        proto.end(token);
        proto.end(token);