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

Commit d4f4d007 authored by Chris Li's avatar Chris Li
Browse files

Send ActivityWindowInfo through WindowStateResizeItem

IWindow#resized can also lead to Activity#onConfigurationChanged if the
resized window is an app window. Thus, we need to update the
ActivityWindowInfo as well.

Bug: 287582673
Bug: 329084449
Test: atest FrameworksCoreTests:ClientTransactionItemTest
Change-Id: Ie320481c928a03f00d42b3cbc1ebeddefadad15b
parent 14190d24
Loading
Loading
Loading
Loading
+32 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.annotation.Nullable;
import android.app.ActivityThread;
import android.app.ClientTransactionHandler;
import android.content.Context;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.Trace;
@@ -32,6 +33,7 @@ import android.util.Log;
import android.util.MergedConfiguration;
import android.view.IWindow;
import android.view.InsetsState;
import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;

import java.util.Objects;
@@ -55,6 +57,14 @@ public class WindowStateResizeItem extends ClientTransactionItem {
    private int mSyncSeqId;
    private boolean mDragResizing;

    /** {@code null} if this is not an Activity window. */
    @Nullable
    private IBinder mActivityToken;

    /** {@code null} if this is not an Activity window. */
    @Nullable
    private ActivityWindowInfo mActivityWindowInfo;

    @Override
    public void execute(@NonNull ClientTransactionHandler client,
            @NonNull PendingTransactionActions pendingActions) {
@@ -65,7 +75,8 @@ public class WindowStateResizeItem extends ClientTransactionItem {
        }
        try {
            mWindow.resized(mFrames, mReportDraw, mConfiguration, mInsetsState, mForceLayout,
                    mAlwaysConsumeSystemBars, mDisplayId, mSyncSeqId, mDragResizing);
                    mAlwaysConsumeSystemBars, mDisplayId, mSyncSeqId, mDragResizing,
                    mActivityWindowInfo);
        } catch (RemoteException e) {
            // Should be a local call.
            // An exception could happen if the process is restarted. It is safe to ignore since
@@ -78,6 +89,7 @@ public class WindowStateResizeItem extends ClientTransactionItem {
    @Nullable
    @Override
    public Context getContextToUpdate(@NonNull ClientTransactionHandler client) {
        // TODO(b/260873529): dispatch for mActivityToken as well.
        // WindowStateResizeItem may update the global config with #mConfiguration.
        return ActivityThread.currentApplication();
    }
@@ -91,7 +103,8 @@ public class WindowStateResizeItem extends ClientTransactionItem {
            @NonNull ClientWindowFrames frames, boolean reportDraw,
            @NonNull MergedConfiguration configuration, @NonNull InsetsState insetsState,
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int syncSeqId,
            boolean dragResizing) {
            boolean dragResizing, @Nullable IBinder activityToken,
            @Nullable ActivityWindowInfo activityWindowInfo) {
        WindowStateResizeItem instance =
                ObjectPool.obtain(WindowStateResizeItem.class);
        if (instance == null) {
@@ -107,6 +120,10 @@ public class WindowStateResizeItem extends ClientTransactionItem {
        instance.mDisplayId = displayId;
        instance.mSyncSeqId = syncSeqId;
        instance.mDragResizing = dragResizing;
        instance.mActivityToken = activityToken;
        instance.mActivityWindowInfo = activityWindowInfo != null
                ? new ActivityWindowInfo(activityWindowInfo)
                : null;

        return instance;
    }
@@ -123,6 +140,8 @@ public class WindowStateResizeItem extends ClientTransactionItem {
        mDisplayId = INVALID_DISPLAY;
        mSyncSeqId = -1;
        mDragResizing = false;
        mActivityToken = null;
        mActivityWindowInfo = null;
        ObjectPool.recycle(this);
    }

@@ -141,6 +160,8 @@ public class WindowStateResizeItem extends ClientTransactionItem {
        dest.writeInt(mDisplayId);
        dest.writeInt(mSyncSeqId);
        dest.writeBoolean(mDragResizing);
        dest.writeStrongBinder(mActivityToken);
        dest.writeTypedObject(mActivityWindowInfo, flags);
    }

    /** Reads from Parcel. */
@@ -155,6 +176,8 @@ public class WindowStateResizeItem extends ClientTransactionItem {
        mDisplayId = in.readInt();
        mSyncSeqId = in.readInt();
        mDragResizing = in.readBoolean();
        mActivityToken = in.readStrongBinder();
        mActivityWindowInfo = in.readTypedObject(ActivityWindowInfo.CREATOR);
    }

    public static final @NonNull Creator<WindowStateResizeItem> CREATOR = new Creator<>() {
@@ -185,7 +208,9 @@ public class WindowStateResizeItem extends ClientTransactionItem {
                && mAlwaysConsumeSystemBars == other.mAlwaysConsumeSystemBars
                && mDisplayId == other.mDisplayId
                && mSyncSeqId == other.mSyncSeqId
                && mDragResizing == other.mDragResizing;
                && mDragResizing == other.mDragResizing
                && Objects.equals(mActivityToken, other.mActivityToken)
                && Objects.equals(mActivityWindowInfo, other.mActivityWindowInfo);
    }

    @Override
@@ -201,6 +226,8 @@ public class WindowStateResizeItem extends ClientTransactionItem {
        result = 31 * result + mDisplayId;
        result = 31 * result + mSyncSeqId;
        result = 31 * result + (mDragResizing ? 1 : 0);
        result = 31 * result + Objects.hashCode(mActivityToken);
        result = 31 * result + Objects.hashCode(mActivityWindowInfo);
        return result;
    }

@@ -209,6 +236,8 @@ public class WindowStateResizeItem extends ClientTransactionItem {
        return "WindowStateResizeItem{window=" + mWindow
                + ", reportDrawn=" + mReportDraw
                + ", configuration=" + mConfiguration
                + ", activityToken=" + mActivityToken
                + ", activityWindowInfo=" + mActivityWindowInfo
                + "}";
    }

+3 −1
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ import android.view.WindowInsets;
import android.view.WindowLayout;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;
import android.window.ScreenCapture;

@@ -459,7 +460,8 @@ public abstract class WallpaperService extends Service {
            public void resized(ClientWindowFrames frames, boolean reportDraw,
                    MergedConfiguration mergedConfiguration, InsetsState insetsState,
                    boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
                    int syncSeqId, boolean dragResizing) {
                    int syncSeqId, boolean dragResizing,
                    @Nullable ActivityWindowInfo activityWindowInfo) {
                Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
                        reportDraw ? 1 : 0,
                        mergedConfiguration);
+3 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.view.IScrollCaptureResponseListener;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.inputmethod.ImeTracker;
import android.window.ActivityWindowInfo;
import android.window.ClientWindowFrames;

import com.android.internal.os.IResultReceiver;
@@ -61,7 +62,8 @@ oneway interface IWindow {
    void resized(in ClientWindowFrames frames, boolean reportDraw,
            in MergedConfiguration newMergedConfiguration, in InsetsState insetsState,
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
            int syncSeqId, boolean dragResizing);
            int syncSeqId, boolean dragResizing,
            in @nullable ActivityWindowInfo activityWindowInfo);

    /**
     * Called when this window retrieved control over a specified set of insets sources.
+1 −4
Original line number Diff line number Diff line
@@ -11100,7 +11100,7 @@ public final class ViewRootImpl implements ViewParent,
        public void resized(ClientWindowFrames frames, boolean reportDraw,
                MergedConfiguration mergedConfiguration, InsetsState insetsState,
                boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int syncSeqId,
                boolean dragResizing) {
                boolean dragResizing, @Nullable ActivityWindowInfo activityWindowInfo) {
            final boolean isFromResizeItem = mIsFromResizeItem;
            mIsFromResizeItem = false;
            // Although this is a AIDL method, it will only be triggered in local process through
@@ -11109,9 +11109,6 @@ public final class ViewRootImpl implements ViewParent,
            if (viewAncestor == null) {
                return;
            }
            // TODO(b/26595351): update WindowStateResizeItem
            final ActivityWindowInfo activityWindowInfo = viewAncestor
                    .mLastReportedActivityWindowInfo;
            if (insetsState.isSourceOrDefaultVisible(ID_IME, Type.ime())) {
                ImeTracing.getInstance().triggerClientDump("ViewRootImpl.W#resized",
                        viewAncestor.getInsetsController().getHost().getInputMethodManager(),
+1 −1
Original line number Diff line number Diff line
@@ -638,7 +638,7 @@ public class WindowlessWindowManager implements IWindowSession {
                mTmpConfig.setConfiguration(mConfiguration, mConfiguration);
                s.mClient.resized(mTmpFrames, false /* reportDraw */, mTmpConfig, state,
                        false /* forceLayout */, false /* alwaysConsumeSystemBars */, s.mDisplayId,
                        Integer.MAX_VALUE, false /* dragResizing */);
                        Integer.MAX_VALUE, false /* dragResizing */, null /* activityWindowInfo */);
            } catch (RemoteException e) {
                // Too bad
            }
Loading