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

Commit c58ffb98 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Use separate flag to track always_seq_id on wear" into main

parents 372a8aff 1a4ef990
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ import android.view.WindowRelayoutResult;
import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;

import com.android.window.flags.Flags;

import java.util.Objects;

/**
@@ -67,7 +65,7 @@ public class WindowStateResizeItem extends WindowStateTransactionItem {
        } else {
            mLayout.activityWindowInfo = null;
        }
        mReportDraw = Flags.alwaysSeqIdLayout() ? false : reportDraw;
        mReportDraw = reportDraw;
        mForceLayout = forceLayout;
        mDisplayId = displayId;
        mLayout.syncSeqId = syncSeqId;
+11 −10
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.flags.Flags.disableDrawWakeLock;

import static com.android.window.flags.Flags.alwaysSeqIdLayout;

import android.animation.AnimationHandler;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -215,6 +213,8 @@ public abstract class WallpaperService extends Service {
    // TODO(b/272527315): remove this flag once shouldZoomOutWallpaper can be used instead.
    private boolean mIsWearOs;

    private boolean mAlwaysSeqId;

    /**
     * This change disables the {@code DRAW_WAKE_LOCK}, an internal wakelock acquired per-frame
     * duration display DOZE. It was added to allow animation during AOD. This wakelock consumes
@@ -497,7 +497,7 @@ public abstract class WallpaperService extends Service {
                    boolean forceLayout, int displayId, boolean syncWithBuffers,
                    boolean dragResizing) {
                final Message msg;
                if (Flags.alwaysSeqIdLayout()) {
                if (mAlwaysSeqId) {
                    msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED, layout.syncSeqId,
                            layout.mergedConfiguration);
                    int latestSeqId = mIWallpaperEngine.mPendingSeqId.get();
@@ -1249,7 +1249,7 @@ public abstract class WallpaperService extends Service {
            final boolean typeChanged = mType != mSurfaceHolder.getRequestedType();
            final boolean flagsChanged = mCurWindowFlags != mWindowFlags ||
                    mCurWindowPrivateFlags != mWindowPrivateFlags;
            final boolean reportDraw = Flags.alwaysSeqIdLayout() ? seqId > mSeqId : false;
            final boolean reportDraw = mAlwaysSeqId ? seqId > mSeqId : false;
            redrawNeeded = redrawNeeded || reportDraw;
            if (forceRelayout || creating || surfaceCreating || formatChanged || sizeChanged
                    || typeChanged || flagsChanged || redrawNeeded
@@ -1333,7 +1333,7 @@ public abstract class WallpaperService extends Service {
                        mLayout.surfaceInsets.set(0, 0, 0, 0);
                    }
                    final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, 0, Flags.alwaysSeqIdLayout() ? seqId : 0,
                            View.VISIBLE, 0, 0, mAlwaysSeqId ? seqId : 0,
                            mRelayoutResult, mSurfaceControl);
                    final Rect outMaxBounds = mMergedConfiguration.getMergedConfiguration()
                            .windowConfiguration.getMaxBounds();
@@ -1342,7 +1342,7 @@ public abstract class WallpaperService extends Service {
                                + maxBounds + " -> " + outMaxBounds);
                        mSurfaceHolder.mSurfaceLock.unlock();
                        mDrawingAllowed = false;
                        if (Flags.alwaysSeqIdLayout()) {
                        if (mAlwaysSeqId) {
                            mCaller.sendMessage(mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
                                    seqId));
                        } else {
@@ -1573,7 +1573,7 @@ public abstract class WallpaperService extends Service {
                    } finally {
                        mIsCreating = false;
                        mSurfaceCreated = true;
                        if (Flags.alwaysSeqIdLayout()) {
                        if (mAlwaysSeqId) {
                            if (reportDraw) {
                                mSession.finishDrawing(mWindow, null /* postDrawTransaction */,
                                        seqId);
@@ -2795,7 +2795,7 @@ public abstract class WallpaperService extends Service {
                case MSG_VISIBILITY_CHANGED:
                    if (DEBUG) Log.v(TAG, "Visibility change in " + mEngine
                            + ": " + message.arg1);
                    mEngine.mVisSeqId = alwaysSeqIdLayout()
                    mEngine.mVisSeqId = mAlwaysSeqId
                            ? Math.max(message.arg2, mEngine.mVisSeqId) : -1;
                    mEngine.doVisibilityChanged(message.arg1 != 0);
                    break;
@@ -2879,7 +2879,7 @@ public abstract class WallpaperService extends Service {
            // The config can be null when retrying for a changed config from relayout, otherwise
            // it is from IWindow#resized which always sends non-null config.
            final boolean fromResized = config != null;
            if (!Flags.alwaysSeqIdLayout()) {
            if (!mAlwaysSeqId) {
                final boolean reportDraw = seqId != 0;
                final int pendingCount = fromResized ? mPendingResizeCount.decrementAndGet() : -1;
                if (reportDraw) {
@@ -2911,7 +2911,7 @@ public abstract class WallpaperService extends Service {
                }
                mEngine.mMergedConfiguration.setTo(config);
            }
            if (Flags.alwaysSeqIdLayout()) {
            if (mAlwaysSeqId) {
                mEngine.updateSurface(true /* forceRelayout */, seqId, false /* redrawNeeded */);
            } else {
                mEngine.updateSurface(true /* forceRelayout */, -1 /* seqId */, mReportDraw);
@@ -2976,6 +2976,7 @@ public abstract class WallpaperService extends Service {
        mBackgroundThread.start();
        mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
        mIsWearOs = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
        mAlwaysSeqId = mIsWearOs ? Flags.alwaysSeqIdLayoutWear() : Flags.alwaysSeqIdLayout();
        super.onCreate();
        Trace.endSection();
    }
+22 −10
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
import static com.android.text.flags.Flags.disableHandwritingInitiatorForIme;
import static com.android.window.flags.Flags.alwaysSeqIdLayout;
import static com.android.window.flags.Flags.alwaysSeqIdLayoutWear;
import static com.android.window.flags.Flags.enableWindowContextResourcesUpdateOnConfigChange;
import static com.android.window.flags.Flags.predictiveBackSwipeEdgeNoneApi;
import static com.android.window.flags.Flags.reduceChangedExclusionRectsMsgs;
@@ -775,6 +776,16 @@ public final class ViewRootImpl implements ViewParent,
    int mSyncSeqId = 0;
    int mLastSyncSeqId = 0;
    /** @hide */
    public static final class NoPreloadHolder {
        public static final boolean sAlwaysSeqId;
        static {
            sAlwaysSeqId = ActivityThread.currentActivityThread().getApplication()
                    .getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)
                    ? alwaysSeqIdLayoutWear() : alwaysSeqIdLayout();
        }
    }
    private boolean mUpdateSurfaceNeeded;
    boolean mFullRedrawNeeded;
    boolean mNewSurfaceNeeded;
@@ -2297,7 +2308,7 @@ public final class ViewRootImpl implements ViewParent,
        final boolean displayChanged = mDisplay.getDisplayId() != displayId;
        final boolean compatScaleChanged = mTmpFrames.compatScale != compatScale;
        final boolean dragResizingChanged = mPendingDragResizing != dragResizing;
        if (alwaysSeqIdLayout()) {
        if (NoPreloadHolder.sAlwaysSeqId) {
            reportDraw = seqId > mSeqId;
        }
        if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
@@ -2343,7 +2354,7 @@ public final class ViewRootImpl implements ViewParent,
        mForceNextWindowRelayout |= forceLayout;
        mSeqId = seqId > mSeqId ? seqId : mSeqId;
        if (alwaysSeqIdLayout()) {
        if (NoPreloadHolder.sAlwaysSeqId) {
            if (syncWithBuffers) {
                mSyncSeqId = seqId > mSyncSeqId ? seqId : mSyncSeqId;
            }
@@ -3849,7 +3860,7 @@ public final class ViewRootImpl implements ViewParent,
                        == RELAYOUT_RES_CANCEL_AND_REDRAW;
                cancelReason = "relayout";
                final boolean dragResizing = mPendingDragResizing;
                if (alwaysSeqIdLayout()) {
                if (NoPreloadHolder.sAlwaysSeqId) {
                    if (mSeqId > mLastSeqId) {
                        mLastSeqId = mSeqId;
                        reportNextDraw("relayout");
@@ -4212,7 +4223,8 @@ public final class ViewRootImpl implements ViewParent,
            // traversal. So we don't know if the sync is complete that we can continue to draw.
            // Here invokes cancelDraw to obtain the information.
            try {
                cancelDraw = mWindowSession.cancelDraw(mWindow, alwaysSeqIdLayout() ? mSeqId : 0);
                cancelDraw = mWindowSession.cancelDraw(mWindow,
                        NoPreloadHolder.sAlwaysSeqId ? mSeqId : 0);
                cancelReason = "wm_sync";
                if (DEBUG_BLAST) {
                    Log.d(mTag, "cancelDraw returned " + cancelDraw);
@@ -4602,8 +4614,8 @@ public final class ViewRootImpl implements ViewParent,
            return;
        }
        final int seqId = alwaysSeqIdLayout() ? mSeqId : mSyncSeqId;
        if (alwaysSeqIdLayout()) {
        final int seqId = NoPreloadHolder.sAlwaysSeqId ? mSeqId : mSyncSeqId;
        if (NoPreloadHolder.sAlwaysSeqId) {
            // If WM asks for a redraw or sync without actually changing config, we won't have run
            // relayout but still need to track that we have drawn the associated frame.
            mLastSeqId = Math.max(mSeqId, mLastSeqId);
@@ -9563,7 +9575,7 @@ public final class ViewRootImpl implements ViewParent,
        if ((mViewFrameInfo.flags & FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED) == 0
                && mWindowAttributes.type != TYPE_APPLICATION_STARTING
                && mSyncSeqId <= mLastSyncSeqId
                && (mSeqId <= mLastSeqId || !alwaysSeqIdLayout())
                && (mSeqId <= mLastSeqId || !NoPreloadHolder.sAlwaysSeqId)
                && winConfigFromAm.diff(winConfigFromWm, false /* compareUndefined */) == 0) {
            final InsetsState state = mInsetsController.getState();
            final Rect displayCutoutSafe = mTempRect;
@@ -9633,7 +9645,7 @@ public final class ViewRootImpl implements ViewParent,
        final int requestedHeight = (int) (measuredHeight * appScale + 0.5f);
        int relayoutResult = 0;
        mRelayoutSeq++;
        final int seqId = alwaysSeqIdLayout() ? mSeqId : mLastSyncSeqId;
        final int seqId = NoPreloadHolder.sAlwaysSeqId ? mSeqId : mLastSyncSeqId;
        if (relayoutAsync) {
            mWindowSession.relayoutAsync(mWindow, params,
                    requestedWidth, requestedHeight, viewVisibility,
@@ -9655,7 +9667,7 @@ public final class ViewRootImpl implements ViewParent,
                }
            }
            final int maybeSyncSeqId = mRelayoutResult.syncSeqId;
            if (maybeSyncSeqId > (alwaysSeqIdLayout() ? mSyncSeqId : 0)) {
            if (maybeSyncSeqId > (NoPreloadHolder.sAlwaysSeqId ? mSyncSeqId : 0)) {
                mSyncSeqId = maybeSyncSeqId;
            }
@@ -10305,7 +10317,7 @@ public final class ViewRootImpl implements ViewParent,
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private void dispatchResized(WindowRelayoutResult layout, boolean reportDraw,
            boolean forceLayout, int displayId, boolean syncWithBuffers, boolean dragResizing) {
        Message msg = mHandler.obtainMessage((reportDraw && !alwaysSeqIdLayout())
        Message msg = mHandler.obtainMessage((reportDraw && !NoPreloadHolder.sAlwaysSeqId)
                ? MSG_RESIZED_REPORT : MSG_RESIZED);
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = layout;
+6 −0
Original line number Diff line number Diff line
@@ -498,3 +498,9 @@ flag {
    bug: "294925498"
}

flag {
    name: "always_seq_id_layout_wear"
    namespace: "windowing_frontend"
    description: "Use seq-id for all client config changes (wearOS)"
    bug: "385976595"
}
+5 −15
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.view.WindowRelayoutResult;
import android.view.inputmethod.ImeTracker;

import com.android.internal.os.IResultReceiver;
import com.android.window.flags.Flags;

import java.io.IOException;

@@ -53,22 +52,13 @@ public class BaseIWindow extends IWindow.Stub {
    @Override
    public void resized(WindowRelayoutResult layout, boolean reportDraw, boolean forceLayout,
            int displayId, boolean syncWithBuffers, boolean dragResizing) {
        if (Flags.alwaysSeqIdLayout()) {
            if (layout.syncSeqId > mLastSeqId) {
        if (layout.syncSeqId > mLastSeqId || reportDraw) {
            mLastSeqId = layout.syncSeqId;
            try {
                mSession.finishDrawing(this, null /* postDrawTransaction */, layout.syncSeqId);
            } catch (RemoteException e) {
            }
        }
        } else {
            if (reportDraw) {
                try {
                    mSession.finishDrawing(this, null /* postDrawTransaction */, layout.syncSeqId);
                } catch (RemoteException e) {
                }
            }
        }
    }

    @Override
Loading