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

Commit 0dc092cc authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Clean some unnecessary abstraction of ATMI about keyguard

Since ATMS and WM were put in the same package with the same lock,
the abstraction is no longer needed and can be called directly.
Move notifyKeyguardFlagsChanged to DisplayContent because most of
the operations are associated to the display.

This contains one logic change is that if isKeyguardLocked() is false,
then skip notifyKeyguardFlagsChanged() because visibility won't change.

That reduces unnecessary invocation of root.ensureActivitiesVisible
such as an activity uses FLAG_SHOW_WHEN_LOCKED while device is unlocked.

Bug: 163976519
Test: CtsActivityManagerDeviceTestCases

Change-Id: I13e7d965df62c44eb07e9db7c7ac33ab990212bd
parent f774fb2f
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -4121,8 +4121,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final boolean containsShowWhenLocked = containsShowWhenLockedWindow();
        final boolean containsShowWhenLocked = containsShowWhenLockedWindow();
        if (containsDismissKeyguard != mLastContainsDismissKeyguardWindow
        if (containsDismissKeyguard != mLastContainsDismissKeyguardWindow
                || containsShowWhenLocked != mLastContainsShowWhenLockedWindow) {
                || containsShowWhenLocked != mLastContainsShowWhenLockedWindow) {
            mWmService.notifyKeyguardFlagsChanged(null /* callback */,
            mDisplayContent.notifyKeyguardFlagsChanged();
                    getDisplayContent().getDisplayId());
        }
        }
        mLastContainsDismissKeyguardWindow = containsDismissKeyguard;
        mLastContainsDismissKeyguardWindow = containsDismissKeyguard;
        mLastContainsShowWhenLockedWindow = containsShowWhenLocked;
        mLastContainsShowWhenLockedWindow = containsShowWhenLocked;
+0 −15
Original line number Original line Diff line number Diff line
@@ -242,21 +242,6 @@ public abstract class ActivityTaskManagerInternal {
            @Nullable String callingFeatureId, Intent intent, @Nullable IBinder resultTo,
            @Nullable String callingFeatureId, Intent intent, @Nullable IBinder resultTo,
            int startFlags, @Nullable Bundle options, int userId);
            int startFlags, @Nullable Bundle options, int userId);


    /**
     * Called when Keyguard flags might have changed.
     *
     * @param callback Callback to run after activity visibilities have been reevaluated. This can
     *                 be used from window manager so that when the callback is called, it's
     *                 guaranteed that all apps have their visibility updated accordingly.
     * @param displayId The id of the display where the keyguard flags changed.
     */
    public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId);

    /**
     * Called when the trusted state of Keyguard has changed.
     */
    public abstract void notifyKeyguardTrustedChanged();

    /**
    /**
     * Called after virtual display Id is updated by
     * Called after virtual display Id is updated by
     * {@link com.android.server.vr.Vr2dDisplay} with a specific
     * {@link com.android.server.vr.Vr2dDisplay} with a specific
+0 −37
Original line number Original line Diff line number Diff line
@@ -63,7 +63,6 @@ import static android.provider.Settings.System.FONT_SCALE;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_WAKE;
import static android.view.WindowManager.TRANSIT_WAKE;


import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
@@ -5415,42 +5414,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    false /*validateIncomingUser*/);
                    false /*validateIncomingUser*/);
        }
        }


        @Override
        public void notifyKeyguardFlagsChanged(@Nullable Runnable callback, int displayId) {
            synchronized (mGlobalLock) {

                // We might change the visibilities here, so prepare an empty app transition which
                // might be overridden later if we actually change visibilities.
                final DisplayContent dc = mRootWindowContainer.getDisplayContent(displayId);
                if (dc == null) {
                    return;
                }
                final boolean wasTransitionSet = dc.mAppTransition.isTransitionSet();
                if (!wasTransitionSet) {
                    dc.prepareAppTransition(TRANSIT_NONE);
                }
                mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);

                // If there was a transition set already we don't want to interfere with it as we
                // might be starting it too early.
                if (!wasTransitionSet) {
                    dc.executeAppTransition();
                }
            }
            if (callback != null) {
                callback.run();
            }
        }

        @Override
        public void notifyKeyguardTrustedChanged() {
            synchronized (mGlobalLock) {
                if (mKeyguardController.isKeyguardShowing(DEFAULT_DISPLAY)) {
                    mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
                }
            }
        }

        /**
        /**
         * Called after virtual display Id is updated by
         * Called after virtual display Id is updated by
         * {@link com.android.server.vr.Vr2dDisplay} with a specific
         * {@link com.android.server.vr.Vr2dDisplay} with a specific
+25 −0
Original line number Original line Diff line number Diff line
@@ -80,6 +80,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.DisplayAreaOrganizer.FEATURE_IME;
import static android.window.DisplayAreaOrganizer.FEATURE_IME;
@@ -5913,6 +5914,30 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        mSleeping = asleep;
        mSleeping = asleep;
    }
    }


    /**
     * Notifies that some Keyguard flags have changed and the visibilities of the activities may
     * need to be reevaluated.
     */
    void notifyKeyguardFlagsChanged() {
        if (!isKeyguardLocked()) {
            // If keyguard is not locked, the change of flags won't affect activity visibility.
            return;
        }
        // We might change the visibilities here, so prepare an empty app transition which might be
        // overridden later if we actually change visibilities.
        final boolean wasTransitionSet = mAppTransition.isTransitionSet();
        if (!wasTransitionSet) {
            prepareAppTransition(TRANSIT_NONE);
        }
        mRootWindowContainer.ensureActivitiesVisible(null, 0, false /* preserveWindows */);

        // If there was a transition set already we don't want to interfere with it as we might be
        // starting it too early.
        if (!wasTransitionSet) {
            executeAppTransition();
        }
    }

    /**
    /**
     * Check if the display has {@link Display#FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD} applied.
     * Check if the display has {@link Display#FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD} applied.
     */
     */
+2 −1
Original line number Original line Diff line number Diff line
@@ -1710,7 +1710,8 @@ public class DisplayPolicy {


        if (mShowingDream != mLastShowingDream) {
        if (mShowingDream != mLastShowingDream) {
            mLastShowingDream = mShowingDream;
            mLastShowingDream = mShowingDream;
            mService.notifyShowingDreamChanged();
            // Notify that isShowingDreamLw (which is checked in KeyguardController) has changed.
            mDisplayContent.notifyKeyguardFlagsChanged();
        }
        }


        mService.mPolicy.setAllowLockscreenWhenOn(getDisplayId(), mAllowLockscreenWhenOn);
        mService.mPolicy.setAllowLockscreenWhenOn(getDisplayId(), mAllowLockscreenWhenOn);
Loading