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

Commit 7fc0216e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add sync-group timeout for transition" into sc-v2-dev

parents 6f1aaa7e 2179ef05
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3643,6 +3643,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        if (mPendingRelaunchCount > 0) {
            mPendingRelaunchCount--;
            if (mPendingRelaunchCount == 0 && !isClientVisible()) {
                // Don't count if the client won't report drawn.
                mRelaunchStartTime = 0;
            }
        } else {
            // Update keyguard flags upon finishing relaunch.
            checkKeyguardFlagsChanged();
+31 −0
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@ import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_SYNC_ENGINE;

import android.annotation.NonNull;
import android.util.ArraySet;
import android.util.Slog;
import android.util.SparseArray;
import android.view.SurfaceControl;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;

/**
@@ -65,6 +67,7 @@ class BLASTSyncEngine {
    class SyncGroup {
        final int mSyncId;
        final TransactionReadyListener mListener;
        final Runnable mOnTimeout;
        boolean mReady = false;
        final ArraySet<WindowContainer> mRootMembers = new ArraySet<>();
        private SurfaceControl.Transaction mOrphanTransaction = null;
@@ -72,6 +75,12 @@ class BLASTSyncEngine {
        private SyncGroup(TransactionReadyListener listener, int id) {
            mSyncId = id;
            mListener = listener;
            mOnTimeout = () -> {
                Slog.w(TAG, "Sync group " + mSyncId + " timeout");
                synchronized (mWm.mGlobalLock) {
                    onTimeout();
                }
            };
        }

        /**
@@ -114,6 +123,7 @@ class BLASTSyncEngine {
            }
            mListener.onTransactionReady(mSyncId, merged);
            mActiveSyncs.remove(mSyncId);
            mWm.mH.removeCallbacks(mOnTimeout);
        }

        private void setReady(boolean ready) {
@@ -136,6 +146,17 @@ class BLASTSyncEngine {
        void onCancelSync(WindowContainer wc) {
            mRootMembers.remove(wc);
        }

        private void onTimeout() {
            if (!mActiveSyncs.contains(mSyncId)) return;
            for (int i = mRootMembers.size() - 1; i >= 0; --i) {
                final WindowContainer<?> wc = mRootMembers.valueAt(i);
                if (!wc.isSyncFinished()) {
                    Slog.i(TAG, "Unfinished container: " + wc);
                }
            }
            finishNow();
        }
    }

    private final WindowManagerService mWm;
@@ -147,13 +168,23 @@ class BLASTSyncEngine {
    }

    int startSyncSet(TransactionReadyListener listener) {
        return startSyncSet(listener, WindowState.BLAST_TIMEOUT_DURATION);
    }

    int startSyncSet(TransactionReadyListener listener, long timeoutMs) {
        final int id = mNextSyncId++;
        final SyncGroup s = new SyncGroup(listener, id);
        mActiveSyncs.put(id, s);
        ProtoLog.v(WM_DEBUG_SYNC_ENGINE, "SyncGroup %d: Started for listener: %s", id, listener);
        scheduleTimeout(s, timeoutMs);
        return id;
    }

    @VisibleForTesting
    void scheduleTimeout(SyncGroup s, long timeoutMs) {
        mWm.mH.postDelayed(s.mOnTimeout, timeoutMs);
    }

    void addToSyncSet(int id, WindowContainer wc) {
        mActiveSyncs.get(id).addToSync(wc);
    }
+3 −1
Original line number Diff line number Diff line
@@ -3449,7 +3449,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    @Override
    public String toString() {
        return "Display " + mDisplayId + " info=" + mDisplayInfo + " rootTasks=" + mChildren;
        return "Display{#" + mDisplayId + " state=" + Display.stateToString(mDisplayInfo.state)
                + " size=" + mDisplayInfo.logicalWidth + "x" + mDisplayInfo.logicalHeight
                + " " + Surface.rotationToString(mDisplayInfo.rotation) + "}";
    }

    String getName() {
+2 −2
Original line number Diff line number Diff line
@@ -165,13 +165,13 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
    private boolean mNavBarAttachedToApp = false;
    private int mRecentsDisplayId = INVALID_DISPLAY;

    Transition(@TransitionType int type, @TransitionFlags int flags,
    Transition(@TransitionType int type, @TransitionFlags int flags, long timeoutMs,
            TransitionController controller, BLASTSyncEngine syncEngine) {
        mType = type;
        mFlags = flags;
        mController = controller;
        mSyncEngine = syncEngine;
        mSyncId = mSyncEngine.startSyncSet(this);
        mSyncId = mSyncEngine.startSyncSet(this, timeoutMs);
    }

    void addFlag(int flag) {
+10 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.wm;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
@@ -55,6 +56,11 @@ import java.util.function.LongConsumer;
class TransitionController {
    private static final String TAG = "TransitionController";

    /** The same as legacy APP_TRANSITION_TIMEOUT_MS. */
    private static final int DEFAULT_TIMEOUT_MS = 5000;
    /** Less duration for CHANGE type because it does not involve app startup. */
    private static final int CHANGE_TIMEOUT_MS = 2000;

    // State constants to line-up with legacy app-transition proto expectations.
    private static final int LEGACY_STATE_IDLE = 0;
    private static final int LEGACY_STATE_READY = 1;
@@ -121,7 +127,10 @@ class TransitionController {
        if (mCollectingTransition != null) {
            throw new IllegalStateException("Simultaneous transitions not supported yet.");
        }
        mCollectingTransition = new Transition(type, flags, this, mAtm.mWindowManager.mSyncEngine);
        // Distinguish change type because the response time is usually expected to be not too long.
        final long timeoutMs = type == TRANSIT_CHANGE ? CHANGE_TIMEOUT_MS : DEFAULT_TIMEOUT_MS;
        mCollectingTransition = new Transition(type, flags, timeoutMs, this,
                mAtm.mWindowManager.mSyncEngine);
        ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, "Creating Transition: %s",
                mCollectingTransition);
        dispatchLegacyAppTransitionPending();
Loading