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

Commit d6cdd94e authored by wilsonshih's avatar wilsonshih Committed by Mohammed Althaf T
Browse files

RESTRICT AUTOMERGE Defer remove splash screen while device is locked

...and activity does not request showWhenLocked.
The splash screen won't contains secure information, so it's safe to
declared as showWhenLocked. But before remove starting window, if the
activity does not request showWhenLocked and device is locked, try to
trigger unoccluding animation, and keep app window hide until transition
animation finish.

Bug: 378088391
Bug: 383131643
Test: run simulate app repeatly, verify the app content won't be visible
during transition animation.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:995631079f89ff54315f847e0d174bcf1a510c90)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:691c9a4eb87f2b10ce472bc1e42c9502786b0ab4)
Merged-In: Ia2ddece125521eefb15d67e22ea863dfae6af112
Change-Id: Ia2ddece125521eefb15d67e22ea863dfae6af112
parent aa74be99
Loading
Loading
Loading
Loading
+29 −3
Original line number Diff line number Diff line
@@ -2761,6 +2761,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        attachStartingSurfaceToAssociatedTask();
    }

    /**
     * If the device is locked and the app does not request showWhenLocked,
     * defer removing the starting window until the transition is complete.
     * This prevents briefly appearing the app context and causing secure concern.
     */
    void deferStartingWindowRemovalForKeyguardUnoccluding() {
        if (mStartingData != null && !mStartingData.mRemoveAfterTransition
                && isKeyguardLocked() && !canShowWhenLockedInner(this) && !isVisibleRequested()
                && isAnimating(PARENTS | CHILDREN, ANIMATION_TYPE_APP_TRANSITION)) {
            mStartingData.mRemoveAfterTransition = true;
        }
    }

    void removeStartingWindow() {
        boolean prevEligibleForLetterboxEducation = isEligibleForLetterboxEducation();

@@ -2799,6 +2812,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final StartingData startingData = mStartingData;
        final WindowState startingWindow = mStartingWindow;
        if (mStartingData != null) {
            if (mStartingData.mRemoveAfterTransition) {
                return;
            }
            surface = mStartingSurface;
            mStartingData = null;
            mStartingSurface = null;
@@ -4431,6 +4447,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                tStartingWindow.mToken = this;
                tStartingWindow.mActivityRecord = this;

                mStartingData.mRemoveAfterTransition = false;
                ProtoLog.v(WM_DEBUG_ADD_REMOVE,
                        "Removing starting %s from %s", tStartingWindow, fromActivity);
                mTransitionController.collect(tStartingWindow);
@@ -4585,17 +4602,22 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (r == null || r.getTaskFragment() == null) {
            return false;
        }
        if (!r.inPinnedWindowingMode() && (r.mShowWhenLocked || r.containsShowWhenLockedWindow())) {
        if (canShowWhenLockedInner(r)) {
            return true;
        } else if (r.mInheritShownWhenLocked) {
            final ActivityRecord activity = r.getTaskFragment().getActivityBelow(r);
            return activity != null && !activity.inPinnedWindowingMode()
                    && (activity.mShowWhenLocked || activity.containsShowWhenLockedWindow());
            return activity != null && canShowWhenLockedInner(activity);
        } else {
            return false;
        }
    }

    /** @see #canShowWhenLocked(ActivityRecord) */
    private static boolean canShowWhenLockedInner(@NonNull ActivityRecord r) {
        return !r.inPinnedWindowingMode() &&
                (r.mShowWhenLocked || r.containsShowWhenLockedWindow());
    }

    /**
     *  Determines if the activity can show while lock-screen is displayed. System displays
     *  activities while lock-screen is displayed only if all activities
@@ -7674,6 +7696,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            mThumbnail = null;
        }

        if (mStartingData != null && mStartingData.mRemoveAfterTransition) {
            mStartingData.mRemoveAfterTransition = false;
            removeStartingWindowAnimation(false /* prepareAnimation */);
        }
        // WindowState.onExitAnimationDone might modify the children list, so make a copy and then
        // traverse the copy.
        final ArrayList<WindowState> children = new ArrayList<>(mChildren);
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public abstract class StartingData {
     * when the parent activity of starting window may be put in a partial area of the task.
     */
    Task mAssociatedTask;
    boolean mRemoveAfterTransition;

    /** Whether the starting window is drawn. */
    boolean mIsDisplayed;
+13 −0
Original line number Diff line number Diff line
@@ -2004,6 +2004,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
        final ActivityRecord atoken = mActivityRecord;
        if (atoken != null) {
            if (atoken.mStartingData != null && mAttrs.type != TYPE_APPLICATION_STARTING
                    && atoken.mStartingData.mRemoveAfterTransition) {
                // Preventing app window from visible during un-occluding animation playing due to
                // alpha blending.
                return false;
            }
            return ((!isParentWindowHidden() && atoken.isVisible())
                    || isAnimating(TRANSITION | PARENTS));
        }
@@ -3090,7 +3096,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            final int mask = FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD
                    | FLAG_ALLOW_LOCK_WHILE_SCREEN_ON;
            WindowManager.LayoutParams sa = mActivityRecord.mStartingWindow.mAttrs;
            final boolean wasShowWhenLocked = (sa.flags & FLAG_SHOW_WHEN_LOCKED) != 0;
            final boolean removeShowWhenLocked = (mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) == 0;
            sa.flags = (sa.flags & ~mask) | (mAttrs.flags & mask);
            if (wasShowWhenLocked && removeShowWhenLocked) {
                // Trigger unoccluding animation if needed.
                mActivityRecord.checkKeyguardFlagsChanged();
                mActivityRecord.deferStartingWindowRemovalForKeyguardUnoccluding();
            }
        }
    }