summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java2
-rw-r--r--apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java2
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java2
-rw-r--r--core/java/android/view/IWindowSession.aidl6
-rw-r--r--core/java/android/view/InsetsSourceControl.aidl1
-rw-r--r--core/java/android/view/InsetsSourceControl.java48
-rw-r--r--core/java/android/view/ViewRootImpl.java11
-rw-r--r--core/java/android/view/WindowlessWindowManager.java6
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java2
-rw-r--r--services/core/java/com/android/server/wm/Session.java8
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java14
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java4
12 files changed, 78 insertions, 28 deletions
diff --git a/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java b/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java
index fb62920681de..b0da7d1e2870 100644
--- a/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java
+++ b/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java
@@ -127,7 +127,7 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase
final ClientWindowFrames mOutFrames = new ClientWindowFrames();
final MergedConfiguration mOutMergedConfiguration = new MergedConfiguration();
final InsetsState mOutInsetsState = new InsetsState();
- final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
+ final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
final IWindow mWindow;
final View mView;
final WindowManager.LayoutParams mParams;
diff --git a/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java b/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java
index cc74a5294f9d..b87e42e31da3 100644
--- a/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java
+++ b/apct-tests/perftests/windowmanager/src/android/wm/WindowAddRemovePerfTest.java
@@ -86,7 +86,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams();
final int mRequestedVisibleTypes = WindowInsets.Type.defaultVisible();
final InsetsState mOutInsetsState = new InsetsState();
- final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
+ final InsetsSourceControl.Array mOutControls = new InsetsSourceControl.Array();
final Rect mOutAttachedFrame = new Rect();
final float[] mOutSizeCompatScale = { 1f };
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 0eab81c03259..44afb89e1ccc 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -252,7 +252,7 @@ public abstract class WallpaperService extends Service {
final Rect mDispatchedStableInsets = new Rect();
DisplayCutout mDispatchedDisplayCutout = DisplayCutout.NO_CUTOUT;
final InsetsState mInsetsState = new InsetsState();
- final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0];
+ final InsetsSourceControl.Array mTempControls = new InsetsSourceControl.Array();
final MergedConfiguration mMergedConfiguration = new MergedConfiguration();
final Bundle mSyncSeqIdBundle = new Bundle();
private final Point mSurfaceSize = new Point();
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index e4d878a59c11..943d64ab986c 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -49,12 +49,12 @@ interface IWindowSession {
int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
in int viewVisibility, in int layerStackId, int requestedVisibleTypes,
out InputChannel outInputChannel, out InsetsState insetsState,
- out InsetsSourceControl[] activeControls, out Rect attachedFrame,
+ out InsetsSourceControl.Array activeControls, out Rect attachedFrame,
out float[] sizeCompatScale);
int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
in int viewVisibility, in int layerStackId, in int userId, int requestedVisibleTypes,
out InputChannel outInputChannel, out InsetsState insetsState,
- out InsetsSourceControl[] activeControls, out Rect attachedFrame,
+ out InsetsSourceControl.Array activeControls, out Rect attachedFrame,
out float[] sizeCompatScale);
int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
in int viewVisibility, in int layerStackId, out InsetsState insetsState,
@@ -91,7 +91,7 @@ interface IWindowSession {
int requestedWidth, int requestedHeight, int viewVisibility,
int flags, int seq, int lastSyncSeqId, out ClientWindowFrames outFrames,
out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
- out InsetsState insetsState, out InsetsSourceControl[] activeControls,
+ out InsetsState insetsState, out InsetsSourceControl.Array activeControls,
out Bundle bundle);
/**
diff --git a/core/java/android/view/InsetsSourceControl.aidl b/core/java/android/view/InsetsSourceControl.aidl
index 755bf456658d..7301ee761522 100644
--- a/core/java/android/view/InsetsSourceControl.aidl
+++ b/core/java/android/view/InsetsSourceControl.aidl
@@ -17,3 +17,4 @@
package android.view;
parcelable InsetsSourceControl;
+parcelable InsetsSourceControl.Array;
diff --git a/core/java/android/view/InsetsSourceControl.java b/core/java/android/view/InsetsSourceControl.java
index 610cfe40ebce..c849cb5bfe2b 100644
--- a/core/java/android/view/InsetsSourceControl.java
+++ b/core/java/android/view/InsetsSourceControl.java
@@ -257,4 +257,52 @@ public class InsetsSourceControl implements Parcelable {
}
proto.end(token);
}
+
+ /**
+ * Used to obtain the array from the argument of a binder call. In this way, the length of the
+ * array can be dynamic.
+ */
+ public static class Array implements Parcelable {
+
+ private @Nullable InsetsSourceControl[] mControls;
+
+ public Array() {
+ }
+
+ public Array(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public void set(@Nullable InsetsSourceControl[] controls) {
+ mControls = controls;
+ }
+
+ public @Nullable InsetsSourceControl[] get() {
+ return mControls;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public void readFromParcel(Parcel in) {
+ mControls = in.createTypedArray(InsetsSourceControl.CREATOR);
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeTypedArray(mControls, flags);
+ }
+
+ public static final @NonNull Creator<Array> CREATOR = new Creator<>() {
+ public Array createFromParcel(Parcel in) {
+ return new Array(in);
+ }
+
+ public Array[] newArray(int size) {
+ return new Array[size];
+ }
+ };
+ }
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index c0f4731aeaf4..c4da009efaf3 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -23,7 +23,6 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InsetsState.ITYPE_IME;
-import static android.view.InsetsState.SIZE;
import static android.view.View.PFLAG_DRAW_ANIMATION;
import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
@@ -705,7 +704,7 @@ public final class ViewRootImpl implements ViewParent,
private int mRelayoutSeq;
private final Rect mWinFrameInScreen = new Rect();
private final InsetsState mTempInsets = new InsetsState();
- private final InsetsSourceControl[] mTempControls = new InsetsSourceControl[SIZE];
+ private final InsetsSourceControl.Array mTempControls = new InsetsSourceControl.Array();
private final WindowConfiguration mTempWinConfig = new WindowConfiguration();
private float mInvCompatScale = 1f;
final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
@@ -1264,7 +1263,7 @@ public final class ViewRootImpl implements ViewParent,
}
if (mTranslator != null) {
mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
- mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
+ mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls.get());
mTranslator.translateRectInScreenToAppWindow(attachedFrame);
}
mTmpFrames.attachedFrame = attachedFrame;
@@ -1288,7 +1287,7 @@ public final class ViewRootImpl implements ViewParent,
(res & WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS) != 0;
mPendingAlwaysConsumeSystemBars = mAttachInfo.mAlwaysConsumeSystemBars;
mInsetsController.onStateChanged(mTempInsets);
- mInsetsController.onControlsChanged(mTempControls);
+ mInsetsController.onControlsChanged(mTempControls.get());
final InsetsState state = mInsetsController.getState();
final Rect displayCutoutSafe = mTempRect;
state.getDisplayCutoutSafe(displayCutoutSafe);
@@ -8334,12 +8333,12 @@ public final class ViewRootImpl implements ViewParent,
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.displayFrame);
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.attachedFrame);
mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
- mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
+ mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls.get());
}
mInvCompatScale = 1f / mTmpFrames.compatScale;
CompatibilityInfo.applyOverrideScaleIfNeeded(mPendingMergedConfiguration);
mInsetsController.onStateChanged(mTempInsets);
- mInsetsController.onControlsChanged(mTempControls);
+ mInsetsController.onControlsChanged(mTempControls.get());
mPendingAlwaysConsumeSystemBars =
(relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;
diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java
index 4c95728548c5..edf33f15a9ca 100644
--- a/core/java/android/view/WindowlessWindowManager.java
+++ b/core/java/android/view/WindowlessWindowManager.java
@@ -148,7 +148,7 @@ public class WindowlessWindowManager implements IWindowSession {
public int addToDisplay(IWindow window, WindowManager.LayoutParams attrs,
int viewVisibility, int displayId, @InsetsType int requestedVisibleTypes,
InputChannel outInputChannel, InsetsState outInsetsState,
- InsetsSourceControl[] outActiveControls, Rect outAttachedFrame,
+ InsetsSourceControl.Array outActiveControls, Rect outAttachedFrame,
float[] outSizeCompatScale) {
final SurfaceControl.Builder b = new SurfaceControl.Builder(mSurfaceSession)
.setFormat(attrs.format)
@@ -200,7 +200,7 @@ public class WindowlessWindowManager implements IWindowSession {
public int addToDisplayAsUser(IWindow window, WindowManager.LayoutParams attrs,
int viewVisibility, int displayId, int userId, @InsetsType int requestedVisibleTypes,
InputChannel outInputChannel, InsetsState outInsetsState,
- InsetsSourceControl[] outActiveControls, Rect outAttachedFrame,
+ InsetsSourceControl.Array outActiveControls, Rect outAttachedFrame,
float[] outSizeCompatScale) {
return addToDisplay(window, attrs, viewVisibility, displayId, requestedVisibleTypes,
outInputChannel, outInsetsState, outActiveControls, outAttachedFrame,
@@ -290,7 +290,7 @@ public class WindowlessWindowManager implements IWindowSession {
int requestedWidth, int requestedHeight, int viewFlags, int flags, int seq,
int lastSyncSeqId, ClientWindowFrames outFrames,
MergedConfiguration outMergedConfiguration, SurfaceControl outSurfaceControl,
- InsetsState outInsetsState, InsetsSourceControl[] outActiveControls,
+ InsetsState outInsetsState, InsetsSourceControl.Array outActiveControls,
Bundle outSyncSeqIdBundle) {
final State state;
synchronized (this) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java
index 65da757b1396..a05ed4f24a08 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/TaskSnapshotWindow.java
@@ -111,7 +111,7 @@ public class TaskSnapshotWindow {
final SurfaceControl surfaceControl = new SurfaceControl();
final ClientWindowFrames tmpFrames = new ClientWindowFrames();
- final InsetsSourceControl[] tmpControls = new InsetsSourceControl[0];
+ final InsetsSourceControl.Array tmpControls = new InsetsSourceControl.Array();
final MergedConfiguration tmpMergedConfiguration = new MergedConfiguration();
final TaskDescription taskDescription;
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 17b463febc13..b5c82a8f46fd 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -118,7 +118,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
private float mLastReportedAnimatorScale;
private String mPackageName;
private String mRelayoutTag;
- private final InsetsSourceControl[] mDummyControls = new InsetsSourceControl[0];
+ private final InsetsSourceControl.Array mDummyControls = new InsetsSourceControl.Array();
final boolean mSetsUnrestrictedKeepClearAreas;
public Session(WindowManagerService service, IWindowSessionCallback callback) {
@@ -198,7 +198,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
public int addToDisplay(IWindow window, WindowManager.LayoutParams attrs,
int viewVisibility, int displayId, @InsetsType int requestedVisibleTypes,
InputChannel outInputChannel, InsetsState outInsetsState,
- InsetsSourceControl[] outActiveControls, Rect outAttachedFrame,
+ InsetsSourceControl.Array outActiveControls, Rect outAttachedFrame,
float[] outSizeCompatScale) {
return mService.addWindow(this, window, attrs, viewVisibility, displayId,
UserHandle.getUserId(mUid), requestedVisibleTypes, outInputChannel, outInsetsState,
@@ -209,7 +209,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
public int addToDisplayAsUser(IWindow window, WindowManager.LayoutParams attrs,
int viewVisibility, int displayId, int userId, @InsetsType int requestedVisibleTypes,
InputChannel outInputChannel, InsetsState outInsetsState,
- InsetsSourceControl[] outActiveControls, Rect outAttachedFrame,
+ InsetsSourceControl.Array outActiveControls, Rect outAttachedFrame,
float[] outSizeCompatScale) {
return mService.addWindow(this, window, attrs, viewVisibility, displayId, userId,
requestedVisibleTypes, outInputChannel, outInsetsState, outActiveControls,
@@ -246,7 +246,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
int requestedWidth, int requestedHeight, int viewFlags, int flags, int seq,
int lastSyncSeqId, ClientWindowFrames outFrames,
MergedConfiguration mergedConfiguration, SurfaceControl outSurfaceControl,
- InsetsState outInsetsState, InsetsSourceControl[] outActiveControls,
+ InsetsState outInsetsState, InsetsSourceControl.Array outActiveControls,
Bundle outSyncSeqIdBundle) {
if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from "
+ Binder.getCallingPid());
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 2c8b844f9468..60b9f4b4117e 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1423,9 +1423,9 @@ public class WindowManagerService extends IWindowManager.Stub
public int addWindow(Session session, IWindow client, LayoutParams attrs, int viewVisibility,
int displayId, int requestUserId, @InsetsType int requestedVisibleTypes,
InputChannel outInputChannel, InsetsState outInsetsState,
- InsetsSourceControl[] outActiveControls, Rect outAttachedFrame,
+ InsetsSourceControl.Array outActiveControls, Rect outAttachedFrame,
float[] outSizeCompatScale) {
- Arrays.fill(outActiveControls, null);
+ outActiveControls.set(null);
int[] appOp = new int[1];
final boolean isRoundedCornerOverlay = (attrs.privateFlags
& PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0;
@@ -2215,10 +2215,10 @@ public class WindowManagerService extends IWindowManager.Stub
int requestedWidth, int requestedHeight, int viewVisibility, int flags, int seq,
int lastSyncSeqId, ClientWindowFrames outFrames,
MergedConfiguration outMergedConfiguration, SurfaceControl outSurfaceControl,
- InsetsState outInsetsState, InsetsSourceControl[] outActiveControls,
+ InsetsState outInsetsState, InsetsSourceControl.Array outActiveControls,
Bundle outSyncIdBundle) {
if (outActiveControls != null) {
- Arrays.fill(outActiveControls, null);
+ outActiveControls.set(null);
}
int result = 0;
boolean configChanged = false;
@@ -2590,11 +2590,12 @@ public class WindowManagerService extends IWindowManager.Stub
return result;
}
- private void getInsetsSourceControls(WindowState win, InsetsSourceControl[] outControls) {
+ private void getInsetsSourceControls(WindowState win, InsetsSourceControl.Array outArray) {
final InsetsSourceControl[] controls =
win.getDisplayContent().getInsetsStateController().getControlsForDispatch(win);
if (controls != null) {
- final int length = Math.min(controls.length, outControls.length);
+ final int length = controls.length;
+ final InsetsSourceControl[] outControls = new InsetsSourceControl[length];
for (int i = 0; i < length; i++) {
// We will leave the critical section before returning the leash to the client,
// so we need to copy the leash to prevent others release the one that we are
@@ -2607,6 +2608,7 @@ public class WindowManagerService extends IWindowManager.Stub
outControls[i].setParcelableFlags(PARCELABLE_WRITE_RETURN_VALUE);
}
}
+ outArray.set(outControls);
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
index 3d777f81579b..cac7745a5e86 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
@@ -214,7 +214,7 @@ public class WindowManagerServiceTests extends WindowTestsBase {
final MergedConfiguration outConfig = new MergedConfiguration();
final SurfaceControl outSurfaceControl = new SurfaceControl();
final InsetsState outInsetsState = new InsetsState();
- final InsetsSourceControl[] outControls = new InsetsSourceControl[0];
+ final InsetsSourceControl.Array outControls = new InsetsSourceControl.Array();
final Bundle outBundle = new Bundle();
mWm.relayoutWindow(win.mSession, win.mClient, win.mAttrs, w, h, View.GONE, 0, 0, 0,
outFrames, outConfig, outSurfaceControl, outInsetsState, outControls, outBundle);
@@ -351,7 +351,7 @@ public class WindowManagerServiceTests extends WindowTestsBase {
mWm.addWindow(session, new TestIWindow(), params, View.VISIBLE, DEFAULT_DISPLAY,
UserHandle.USER_SYSTEM, WindowInsets.Type.defaultVisible(), null, new InsetsState(),
- new InsetsSourceControl[0], new Rect(), new float[1]);
+ new InsetsSourceControl.Array(), new Rect(), new float[1]);
verify(mWm.mWindowContextListenerController, never()).registerWindowContainerListener(any(),
any(), anyInt(), anyInt(), any());