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

Commit 54db1f1a authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Discard invisible pending draw activity if transition starts" into sc-dev am: 42a28cc9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14823312

Change-Id: I792ab0f5158ddb1e309371cbf09758398360f89d
parents 91661120 42a28cc9
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ import com.android.server.apphibernation.AppHibernationManagerInternal;
import com.android.server.apphibernation.AppHibernationService;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.concurrent.TimeUnit;

/**
@@ -216,7 +215,7 @@ class ActivityMetricsLogger {
        /** whether the process of the launching activity didn't have any active activity. */
        final boolean mProcessSwitch;
        /** The activities that should be drawn. */
        final LinkedList<ActivityRecord> mPendingDrawActivities = new LinkedList<>();
        final ArrayList<ActivityRecord> mPendingDrawActivities = new ArrayList<>(2);
        /** The latest activity to have been launched. */
        @NonNull ActivityRecord mLastLaunchedActivity;

@@ -328,6 +327,17 @@ class ActivityMetricsLogger {
            return mPendingDrawActivities.isEmpty();
        }

        /** Only keep the records which can be drawn. */
        void updatePendingDraw() {
            for (int i = mPendingDrawActivities.size() - 1; i >= 0; i--) {
                final ActivityRecord r = mPendingDrawActivities.get(i);
                if (!r.mVisibleRequested) {
                    if (DEBUG_METRICS) Slog.i(TAG, "Discard pending draw " + r);
                    mPendingDrawActivities.remove(i);
                }
            }
        }

        /**
         * @return {@code true} if the transition info should be sent to MetricsLogger, StatsLog, or
         *         LaunchObserver.
@@ -701,6 +711,7 @@ class ActivityMetricsLogger {
            info.mCurrentTransitionDelayMs = info.calculateDelay(timestampNs);
            info.mReason = activityToReason.valueAt(index);
            info.mLoggedTransitionStarting = true;
            info.updatePendingDraw();
            if (info.allDrawn()) {
                done(false /* abort */, info, "notifyTransitionStarting - all windows drawn",
                        timestampNs);
+15 −1
Original line number Diff line number Diff line
@@ -353,8 +353,22 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
        mTrampolineActivity.setVisibility(false);
        notifyWindowsDrawn(mTopActivity);

        assertWithMessage("Trampoline activity is invisble so there should be no undrawn windows")
        assertWithMessage("Trampoline activity is invisible so there should be no undrawn windows")
                .that(mLaunchingState.allDrawn()).isTrue();

        // Since the activity is drawn, the launch event should be reported.
        notifyTransitionStarting(mTopActivity);
        verifyOnActivityLaunchFinished(mTopActivity);
        mLaunchTopByTrampoline = false;
        clearInvocations(mLaunchObserver);

        // Another round without setting visibility of the trampoline activity.
        onActivityLaunchedTrampoline();
        notifyWindowsDrawn(mTopActivity);
        // If the transition can start, the invisible activities should be discarded and the launch
        // event be reported successfully.
        notifyTransitionStarting(mTopActivity);
        verifyOnActivityLaunchFinished(mTopActivity);
    }

    @Test