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

Commit dea4bd98 authored by Chong Zhang's avatar Chong Zhang
Browse files

Fix black frame when unlocking device via clicking on notification

- Make sure to tell the app to start drawing if it has been stopped, app
  could be stopped in visible state.

- When activity is started with NEW_TASK + CLEAR_TASK flags, skip
  resuming of the soon-to-be-removed activity, and run enter animation
  directly on the new activity. Resuming the old activity causes delay,
  and we also run extra enter-exit transition in short succession which
  cause glitches.

bug: 27391256
Change-Id: I390ef9fc9855d70a4a9642c06c87cbe548b8b466
parent 65d15d03
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2182,10 +2182,11 @@ final class ActivityStack {

        ActivityStack lastStack = mStackSupervisor.getLastStack();
        if (next.app != null && next.app.thread != null) {
            if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resume running: " + next);
            if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resume running: " + next
                    + " stopped=" + next.stopped + " visible=" + next.visible);

            // This activity is now becoming visible.
            if (!next.visible) {
            if (!next.visible || next.stopped) {
                mWindowManager.setAppVisibility(next.appToken, true);
            }

+23 −11
Original line number Diff line number Diff line
@@ -1327,20 +1327,32 @@ class ActivityStarter {
                    intentActivity.setTaskToAffiliateWith(mSourceRecord.task);
                }
                mMovedHome = true;
                final ActivityStack launchStack =
                        getLaunchStack(mStartActivity, mLaunchFlags, mStartActivity.task,
                                mOptions, true);

                // If the launch flags carry both NEW_TASK and CLEAR_TASK, the task's activities
                // will be cleared soon by ActivityStarter in setTaskFromIntentActivity().
                // So no point resuming any of the activities here, it just wastes one extra
                // resuming, plus enter AND exit transitions.
                // Here we only want to bring the target stack forward. Transition will be applied
                // to the new activity that's started after the old ones are gone.
                final boolean willClearTask =
                        (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))
                            == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
                if (!willClearTask) {
                    final ActivityStack launchStack = getLaunchStack(
                            mStartActivity, mLaunchFlags, mStartActivity.task, mOptions, true);
                    if (launchStack == null || launchStack == mTargetStack) {
                        // We only want to move to the front, if we aren't going to launch on a
                        // different stack. If we launch on a different stack, we will put the
                        // task on top there.
                    mTargetStack.moveTaskToFrontLocked(intentActivity.task, mNoAnimation,
                            mOptions, mStartActivity.appTimeTracker, "bringingFoundTaskToFront");
                        mTargetStack.moveTaskToFrontLocked(
                                intentActivity.task, mNoAnimation, mOptions,
                                mStartActivity.appTimeTracker, "bringingFoundTaskToFront");
                        mMovedToFront = true;
                    }
                updateTaskReturnToType(intentActivity.task, mLaunchFlags, focusStack);
                    mOptions = null;
                }
                updateTaskReturnToType(intentActivity.task, mLaunchFlags, focusStack);
            }
        }
        if (!mMovedToFront && mDoResume) {
            if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Bring to front target: " + mTargetStack
+6 −7
Original line number Diff line number Diff line
@@ -4254,16 +4254,12 @@ public class WindowManagerService extends IWindowManager.Stub
                wtoken.appDied = false;
                wtoken.removeAllWindows();
            } else if (visible) {
                if (DEBUG_ADD_REMOVE) Slog.v(
                        TAG_WM, "No longer Stopped: " + wtoken);
                wtoken.mAppStopped = false;
                mOpeningApps.add(wtoken);
                wtoken.startingMoved = false;

                // If the token is currently hidden (should be the
                // common case), then we need to set up to wait for
                // its windows to be ready.
                if (wtoken.hidden) {
                // If the token is currently hidden (should be the common case), or has been
                // stopped, then we need to set up to wait for its windows to be ready.
                if (wtoken.hidden || wtoken.mAppStopped) {
                    wtoken.allDrawn = false;
                    wtoken.deferClearAllDrawn = false;
                    wtoken.waitingToShow = true;
@@ -4279,6 +4275,9 @@ public class WindowManagerService extends IWindowManager.Stub
                        wtoken.sendAppVisibilityToClients();
                    }
                }
                if (DEBUG_ADD_REMOVE) Slog.v(
                        TAG_WM, "No longer Stopped: " + wtoken);
                wtoken.mAppStopped = false;
            }

            // If we are preparing an app transition, then delay changing