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

Commit 385935d0 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Gerrit Code Review
Browse files

Merge "setTurnScreenOn can only used as wakeup"

parents 0849b350 5ffa690f
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -77,7 +77,6 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Looper;
import android.os.Parcelable;
import android.os.Parcelable;
import android.os.PersistableBundle;
import android.os.PersistableBundle;
import android.os.PowerManager;
import android.os.Process;
import android.os.Process;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.ServiceManager.ServiceNotFoundException;
@@ -8788,9 +8787,7 @@ public class Activity extends ContextThemeWrapper
     * the activity is visible after the screen is turned on when the lockscreen is up. In addition,
     * the activity is visible after the screen is turned on when the lockscreen is up. In addition,
     * if this flag is set and the activity calls {@link
     * if this flag is set and the activity calls {@link
     * KeyguardManager#requestDismissKeyguard(Activity, KeyguardManager.KeyguardDismissCallback)}
     * KeyguardManager#requestDismissKeyguard(Activity, KeyguardManager.KeyguardDismissCallback)}
     * the screen will turn on. If the screen is off and device is not secured, this flag can turn
     * the screen will turn on.
     * screen on and dismiss keyguard to make this activity visible and resume, which can be used to
     * replace {@link PowerManager#ACQUIRE_CAUSES_WAKEUP}
     *
     *
     * @param turnScreenOn {@code true} to turn on the screen; {@code false} otherwise.
     * @param turnScreenOn {@code true} to turn on the screen; {@code false} otherwise.
     *
     *
+7 −32
Original line number Original line Diff line number Diff line
@@ -190,8 +190,7 @@ class KeyguardController {


        if (keyguardChanged) {
        if (keyguardChanged) {
            // Irrelevant to AOD.
            // Irrelevant to AOD.
            dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */,
            dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */);
                    false /* turningScreenOn */);
            mKeyguardGoingAway = false;
            mKeyguardGoingAway = false;
            if (keyguardShowing) {
            if (keyguardShowing) {
                mDismissalRequested = false;
                mDismissalRequested = false;
@@ -385,6 +384,8 @@ class KeyguardController {
                mService.continueWindowLayout();
                mService.continueWindowLayout();
            }
            }
        }
        }
        dismissMultiWindowModeForTaskIfNeeded(topActivity != null
                ? topActivity.getRootTask() : null);
    }
    }


    /**
    /**
@@ -410,21 +411,6 @@ class KeyguardController {
        }
        }
    }
    }


    /**
     * Called when somebody wants to turn screen on.
     */
    private void handleTurnScreenOn(int displayId) {
        if (displayId != DEFAULT_DISPLAY) {
            return;
        }

        mTaskSupervisor.wakeUp("handleTurnScreenOn");
        if (mKeyguardShowing && canDismissKeyguard()) {
            mWindowManager.dismissKeyguard(null /* callback */, null /* message */);
            mDismissalRequested = true;
        }
    }

    boolean isDisplayOccluded(int displayId) {
    boolean isDisplayOccluded(int displayId) {
        return getDisplayState(displayId).mOccluded;
        return getDisplayState(displayId).mOccluded;
    }
    }
@@ -438,11 +424,9 @@ class KeyguardController {
    }
    }


    private void dismissMultiWindowModeForTaskIfNeeded(
    private void dismissMultiWindowModeForTaskIfNeeded(
            @Nullable Task currentTaskControllingOcclusion, boolean turningScreenOn) {
            @Nullable Task currentTaskControllingOcclusion) {
        // If turningScreenOn is true, it means that the visibility state has changed from
        // currentTaskControllingOcclusion and we should update windowing mode.
        // TODO(b/113840485): Handle docked stack for individual display.
        // TODO(b/113840485): Handle docked stack for individual display.
        if (!turningScreenOn && (!mKeyguardShowing || !isDisplayOccluded(DEFAULT_DISPLAY))) {
        if (!mKeyguardShowing || !isDisplayOccluded(DEFAULT_DISPLAY)) {
            return;
            return;
        }
        }


@@ -581,26 +565,17 @@ class KeyguardController {
                    && controller.mWindowManager.isKeyguardSecure(
                    && controller.mWindowManager.isKeyguardSecure(
                    controller.mService.getCurrentUserId());
                    controller.mService.getCurrentUserId());


            boolean occludingChange = false;
            boolean turningScreenOn = false;
            if (mTopTurnScreenOnActivity != lastTurnScreenOnActivity
            if (mTopTurnScreenOnActivity != lastTurnScreenOnActivity
                    && mTopTurnScreenOnActivity != null
                    && mTopTurnScreenOnActivity != null
                    && !mService.mWindowManager.mPowerManager.isInteractive()
                    && !mService.mWindowManager.mPowerManager.isInteractive()
                    && (mRequestDismissKeyguard || occludedByActivity
                    && (mRequestDismissKeyguard || occludedByActivity)) {
                        || controller.canDismissKeyguard())) {
                controller.mTaskSupervisor.wakeUp("handleTurnScreenOn");
                turningScreenOn = true;
                controller.handleTurnScreenOn(mDisplayId);
                mTopTurnScreenOnActivity.setCurrentLaunchCanTurnScreenOn(false);
                mTopTurnScreenOnActivity.setCurrentLaunchCanTurnScreenOn(false);
            }
            }


            if (lastOccluded != mOccluded) {
            if (lastOccluded != mOccluded) {
                occludingChange = true;
                controller.handleOccludedChanged(mDisplayId, mTopOccludesActivity);
                controller.handleOccludedChanged(mDisplayId, mTopOccludesActivity);
            }
            }

            if (occludingChange || turningScreenOn) {
                controller.dismissMultiWindowModeForTaskIfNeeded(task, turningScreenOn);
            }
        }
        }


        /**
        /**