Merge "Remove outFrame from the parameters of addWindow" into sc-dev
This commit is contained in:
@@ -19,14 +19,12 @@ package android.wm;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.perftests.utils.ManualBenchmarkState;
|
||||
import android.perftests.utils.ManualBenchmarkState.ManualBenchmarkTest;
|
||||
import android.perftests.utils.PerfManualStatusReporter;
|
||||
import android.view.Display;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.IWindowSession;
|
||||
import android.view.InputChannel;
|
||||
import android.view.InsetsSourceControl;
|
||||
@@ -85,9 +83,6 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
|
||||
private static class TestWindow extends BaseIWindow {
|
||||
final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams();
|
||||
final InsetsState mRequestedVisibility = new InsetsState();
|
||||
final Rect mOutFrame = new Rect();
|
||||
final DisplayCutout.ParcelableWrapper mOutDisplayCutout =
|
||||
new DisplayCutout.ParcelableWrapper();
|
||||
final InsetsState mOutInsetsState = new InsetsState();
|
||||
final InsetsSourceControl[] mOutControls = new InsetsSourceControl[0];
|
||||
|
||||
@@ -107,7 +102,7 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
|
||||
|
||||
long startTime = SystemClock.elapsedRealtimeNanos();
|
||||
session.addToDisplay(this, mLayoutParams, View.VISIBLE,
|
||||
Display.DEFAULT_DISPLAY, mRequestedVisibility, mOutFrame, inputChannel,
|
||||
Display.DEFAULT_DISPLAY, mRequestedVisibility, inputChannel,
|
||||
mOutInsetsState, mOutControls);
|
||||
final long elapsedTimeNsOfAdd = SystemClock.elapsedRealtimeNanos() - startTime;
|
||||
state.addExtraResult("add", elapsedTimeNsOfAdd);
|
||||
|
||||
@@ -880,8 +880,8 @@ public abstract class WallpaperService extends Service {
|
||||
InputChannel inputChannel = new InputChannel();
|
||||
|
||||
if (mSession.addToDisplay(mWindow, mLayout, View.VISIBLE,
|
||||
mDisplay.getDisplayId(), mInsetsState, mWinFrames.frame,
|
||||
inputChannel, mInsetsState, mTempControls) < 0) {
|
||||
mDisplay.getDisplayId(), mInsetsState, inputChannel, mInsetsState,
|
||||
mTempControls) < 0) {
|
||||
Log.w(TAG, "Failed to add window while updating wallpaper surface.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ import java.util.List;
|
||||
interface IWindowSession {
|
||||
int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
|
||||
in int viewVisibility, in int layerStackId, in InsetsState requestedVisibility,
|
||||
out Rect outFrame, out InputChannel outInputChannel, out InsetsState insetsState,
|
||||
out InputChannel outInputChannel, out InsetsState insetsState,
|
||||
out InsetsSourceControl[] activeControls);
|
||||
int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
|
||||
in int viewVisibility, in int layerStackId, in int userId,
|
||||
in InsetsState requestedVisibility, out Rect outFrame, out InputChannel outInputChannel,
|
||||
in InsetsState requestedVisibility, out InputChannel outInputChannel,
|
||||
out InsetsState insetsState, out InsetsSourceControl[] activeControls);
|
||||
int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
|
||||
in int viewVisibility, in int layerStackId, out InsetsState insetsState);
|
||||
|
||||
@@ -138,6 +138,7 @@ import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.sysprop.DisplayProperties;
|
||||
import android.util.AndroidRuntimeException;
|
||||
import android.util.ArraySet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
@@ -157,6 +158,7 @@ import android.view.View.AttachInfo;
|
||||
import android.view.View.FocusDirection;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.Window.OnContentApplyWindowInsetsListener;
|
||||
import android.view.WindowInsets.Side.InsetsSide;
|
||||
import android.view.WindowInsets.Type;
|
||||
import android.view.WindowInsets.Type.InsetsType;
|
||||
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
|
||||
@@ -926,6 +928,33 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(b/161810301): Make this private after window layout is moved to the client side.
|
||||
public static void computeWindowBounds(WindowManager.LayoutParams attrs, InsetsState state,
|
||||
Rect displayFrame, Rect outBounds) {
|
||||
final @InsetsType int typesToFit = attrs.getFitInsetsTypes();
|
||||
final @InsetsSide int sidesToFit = attrs.getFitInsetsSides();
|
||||
final ArraySet<Integer> types = InsetsState.toInternalType(typesToFit);
|
||||
final Rect df = displayFrame;
|
||||
Insets insets = Insets.of(0, 0, 0, 0);
|
||||
for (int i = types.size() - 1; i >= 0; i--) {
|
||||
final InsetsSource source = state.peekSource(types.valueAt(i));
|
||||
if (source == null) {
|
||||
continue;
|
||||
}
|
||||
insets = Insets.max(insets, source.calculateInsets(
|
||||
df, attrs.isFitInsetsIgnoringVisibility()));
|
||||
}
|
||||
final int left = (sidesToFit & WindowInsets.Side.LEFT) != 0 ? insets.left : 0;
|
||||
final int top = (sidesToFit & WindowInsets.Side.TOP) != 0 ? insets.top : 0;
|
||||
final int right = (sidesToFit & WindowInsets.Side.RIGHT) != 0 ? insets.right : 0;
|
||||
final int bottom = (sidesToFit & WindowInsets.Side.BOTTOM) != 0 ? insets.bottom : 0;
|
||||
outBounds.set(df.left + left, df.top + top, df.right - right, df.bottom - bottom);
|
||||
}
|
||||
|
||||
private Configuration getConfiguration() {
|
||||
return mContext.getResources().getConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* We have one child
|
||||
*/
|
||||
@@ -1057,18 +1086,15 @@ public final class ViewRootImpl implements ViewParent,
|
||||
controlInsetsForCompatibility(mWindowAttributes);
|
||||
res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes,
|
||||
getHostVisibility(), mDisplay.getDisplayId(), userId,
|
||||
mInsetsController.getRequestedVisibility(), mTmpFrames.frame,
|
||||
inputChannel, mTempInsets, mTempControls);
|
||||
mInsetsController.getRequestedVisibility(), inputChannel, mTempInsets,
|
||||
mTempControls);
|
||||
if (mTranslator != null) {
|
||||
mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);
|
||||
mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
|
||||
}
|
||||
setFrame(mTmpFrames.frame);
|
||||
} catch (RemoteException e) {
|
||||
mAdded = false;
|
||||
mView = null;
|
||||
mAttachInfo.mRootView = null;
|
||||
inputChannel = null;
|
||||
mFallbackEventHandler.setView(null);
|
||||
unscheduleTraversals();
|
||||
setAccessibilityFocus(null, null);
|
||||
@@ -1084,6 +1110,9 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mPendingAlwaysConsumeSystemBars = mAttachInfo.mAlwaysConsumeSystemBars;
|
||||
mInsetsController.onStateChanged(mTempInsets);
|
||||
mInsetsController.onControlsChanged(mTempControls);
|
||||
computeWindowBounds(mWindowAttributes, mInsetsController.getState(),
|
||||
getConfiguration().windowConfiguration.getBounds(), mTmpFrames.frame);
|
||||
setFrame(mTmpFrames.frame);
|
||||
if (DEBUG_LAYOUT) Log.v(mTag, "Added window " + mWindow);
|
||||
if (res < WindowManagerGlobal.ADD_OKAY) {
|
||||
mAttachInfo.mRootView = null;
|
||||
@@ -1357,7 +1386,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
|
||||
private int getNightMode() {
|
||||
return mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
return getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
}
|
||||
|
||||
private void updateForceDarkMode() {
|
||||
@@ -2333,7 +2362,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
|
||||
/* package */ WindowInsets getWindowInsets(boolean forceConstruct) {
|
||||
if (mLastWindowInsets == null || forceConstruct) {
|
||||
final Configuration config = mContext.getResources().getConfiguration();
|
||||
final Configuration config = getConfiguration();
|
||||
mLastWindowInsets = mInsetsController.calculateInsets(
|
||||
config.isScreenRound(), mAttachInfo.mAlwaysConsumeSystemBars,
|
||||
mWindowAttributes.type, config.windowConfiguration.getWindowingMode(),
|
||||
@@ -2469,7 +2498,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mFullRedrawNeeded = true;
|
||||
mLayoutRequested = true;
|
||||
|
||||
final Configuration config = mContext.getResources().getConfiguration();
|
||||
final Configuration config = getConfiguration();
|
||||
if (shouldUseDisplaySize(lp)) {
|
||||
// NOTE -- system code, won't try to do compat mode.
|
||||
Point size = new Point();
|
||||
@@ -4762,7 +4791,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
// TODO: Centralize this sanitization? Why do we let setting bad modes?
|
||||
// Alternatively, can we just let HWUI figure it out? Do we need to care here?
|
||||
if (!mContext.getResources().getConfiguration().isScreenWideColorGamut()) {
|
||||
if (!getConfiguration().isScreenWideColorGamut()) {
|
||||
colorMode = ActivityInfo.COLOR_MODE_DEFAULT;
|
||||
}
|
||||
mAttachInfo.mThreadedRenderer.setColorMode(colorMode);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class WindowlessWindowManager implements IWindowSession {
|
||||
*/
|
||||
@Override
|
||||
public int addToDisplay(IWindow window, WindowManager.LayoutParams attrs,
|
||||
int viewVisibility, int displayId, InsetsState requestedVisibility, Rect outFrame,
|
||||
int viewVisibility, int displayId, InsetsState requestedVisibility,
|
||||
InputChannel outInputChannel, InsetsState outInsetsState,
|
||||
InsetsSourceControl[] outActiveControls) {
|
||||
final SurfaceControl.Builder b = new SurfaceControl.Builder(mSurfaceSession)
|
||||
@@ -171,10 +171,10 @@ public class WindowlessWindowManager implements IWindowSession {
|
||||
@Override
|
||||
public int addToDisplayAsUser(IWindow window, WindowManager.LayoutParams attrs,
|
||||
int viewVisibility, int displayId, int userId, InsetsState requestedVisibility,
|
||||
Rect outFrame, InputChannel outInputChannel, InsetsState outInsetsState,
|
||||
InputChannel outInputChannel, InsetsState outInsetsState,
|
||||
InsetsSourceControl[] outActiveControls) {
|
||||
return addToDisplay(window, attrs, viewVisibility, displayId, requestedVisibility,
|
||||
outFrame, outInputChannel, outInsetsState, outActiveControls);
|
||||
outInputChannel, outInsetsState, outActiveControls);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -220,9 +220,8 @@ public class TaskSnapshotWindow {
|
||||
final InputChannel tmpInputChannel = new InputChannel();
|
||||
mainExecutor.execute(() -> {
|
||||
try {
|
||||
final int res = session.addToDisplay(window, layoutParams, View.GONE,
|
||||
displayId, mTmpInsetsState, tmpFrames.frame, tmpInputChannel,
|
||||
mTmpInsetsState, mTempControls);
|
||||
final int res = session.addToDisplay(window, layoutParams, View.GONE, displayId,
|
||||
mTmpInsetsState, tmpInputChannel, mTmpInsetsState, mTempControls);
|
||||
if (res < 0) {
|
||||
Slog.w(TAG, "Failed to add snapshot starting window res=" + res);
|
||||
return;
|
||||
|
||||
@@ -37,6 +37,7 @@ import static android.view.InsetsState.ITYPE_RIGHT_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||
import static android.view.InsetsState.ITYPE_TOP_GESTURES;
|
||||
import static android.view.InsetsState.ITYPE_TOP_TAPPABLE_ELEMENT;
|
||||
import static android.view.ViewRootImpl.computeWindowBounds;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
|
||||
@@ -128,7 +129,6 @@ import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.util.ArraySet;
|
||||
import android.util.PrintWriterPrinter;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -142,8 +142,6 @@ import android.view.InsetsState.InternalInsetsType;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.WindowInsets.Side;
|
||||
import android.view.WindowInsets.Side.InsetsSide;
|
||||
import android.view.WindowInsets.Type;
|
||||
import android.view.WindowInsets.Type.InsetsType;
|
||||
import android.view.WindowInsetsController.Appearance;
|
||||
@@ -1395,29 +1393,15 @@ public class DisplayPolicy {
|
||||
*
|
||||
* @param attrs The LayoutParams of the window.
|
||||
* @param windowToken The token of the window.
|
||||
* @param outFrame The frame of the window.
|
||||
* @param outInsetsState The insets state of this display from the client's perspective.
|
||||
* @param localClient Whether the client is from the our process.
|
||||
* @return Whether to always consume the system bars.
|
||||
* See {@link #areSystemBarsForcedShownLw(WindowState)}.
|
||||
*/
|
||||
boolean getLayoutHint(LayoutParams attrs, WindowToken windowToken, Rect outFrame,
|
||||
InsetsState outInsetsState, boolean localClient) {
|
||||
final boolean isFixedRotationTransforming =
|
||||
windowToken != null && windowToken.isFixedRotationTransforming();
|
||||
final ActivityRecord activity = windowToken != null ? windowToken.asActivityRecord() : null;
|
||||
final Task task = activity != null ? activity.getTask() : null;
|
||||
final Rect taskBounds = isFixedRotationTransforming
|
||||
// Use token (activity) bounds if it is rotated because its task is not rotated.
|
||||
? windowToken.getBounds()
|
||||
: (task != null ? task.getBounds() : null);
|
||||
boolean getLayoutHint(LayoutParams attrs, WindowToken windowToken, InsetsState outInsetsState,
|
||||
boolean localClient) {
|
||||
final InsetsState state =
|
||||
mDisplayContent.getInsetsPolicy().getInsetsForWindowMetrics(attrs);
|
||||
computeWindowBounds(attrs, state, windowToken, outFrame);
|
||||
if (taskBounds != null) {
|
||||
outFrame.intersect(taskBounds);
|
||||
}
|
||||
|
||||
final boolean inSizeCompatMode = WindowState.inSizeCompatMode(attrs, windowToken);
|
||||
outInsetsState.set(state, inSizeCompatMode || localClient);
|
||||
if (inSizeCompatMode) {
|
||||
@@ -1558,28 +1542,6 @@ public class DisplayPolicy {
|
||||
return !notFocusableForIm;
|
||||
}
|
||||
|
||||
private void computeWindowBounds(WindowManager.LayoutParams attrs, InsetsState state,
|
||||
@Nullable WindowToken windowToken, Rect outBounds) {
|
||||
final @InsetsType int typesToFit = attrs.getFitInsetsTypes();
|
||||
final @InsetsSide int sidesToFit = attrs.getFitInsetsSides();
|
||||
final ArraySet<Integer> types = InsetsState.toInternalType(typesToFit);
|
||||
final Rect df = windowToken != null ? windowToken.getBounds() : state.getDisplayFrame();
|
||||
Insets insets = Insets.of(0, 0, 0, 0);
|
||||
for (int i = types.size() - 1; i >= 0; i--) {
|
||||
final InsetsSource source = state.peekSource(types.valueAt(i));
|
||||
if (source == null) {
|
||||
continue;
|
||||
}
|
||||
insets = Insets.max(insets, source.calculateInsets(
|
||||
df, attrs.isFitInsetsIgnoringVisibility()));
|
||||
}
|
||||
final int left = (sidesToFit & Side.LEFT) != 0 ? insets.left : 0;
|
||||
final int top = (sidesToFit & Side.TOP) != 0 ? insets.top : 0;
|
||||
final int right = (sidesToFit & Side.RIGHT) != 0 ? insets.right : 0;
|
||||
final int bottom = (sidesToFit & Side.BOTTOM) != 0 ? insets.bottom : 0;
|
||||
outBounds.set(df.left + left, df.top + top, df.right - right, df.bottom - bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called for each window attached to the window manager as layout is proceeding. The
|
||||
* implementation of this function must take care of setting the window's frame, either here or
|
||||
@@ -1620,7 +1582,7 @@ public class DisplayPolicy {
|
||||
final boolean layoutInsetDecor = (fl & FLAG_LAYOUT_INSET_DECOR) == FLAG_LAYOUT_INSET_DECOR;
|
||||
|
||||
final InsetsState state = win.getInsetsState();
|
||||
computeWindowBounds(attrs, state, win.mToken, df);
|
||||
computeWindowBounds(attrs, state, win.mToken.getBounds(), df);
|
||||
if (attached == null) {
|
||||
pf.set(df);
|
||||
if ((pfl & PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME) != 0) {
|
||||
|
||||
@@ -192,32 +192,30 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient {
|
||||
|
||||
@Override
|
||||
public int addToDisplay(IWindow window, WindowManager.LayoutParams attrs,
|
||||
int viewVisibility, int displayId, InsetsState requestedVisibility, Rect outFrame,
|
||||
int viewVisibility, int displayId, InsetsState requestedVisibility,
|
||||
InputChannel outInputChannel, InsetsState outInsetsState,
|
||||
InsetsSourceControl[] outActiveControls) {
|
||||
return mService.addWindow(this, window, attrs, viewVisibility, displayId,
|
||||
UserHandle.getUserId(mUid), requestedVisibility, outFrame, outInputChannel,
|
||||
outInsetsState, outActiveControls);
|
||||
UserHandle.getUserId(mUid), requestedVisibility, outInputChannel, outInsetsState,
|
||||
outActiveControls);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int addToDisplayAsUser(IWindow window, WindowManager.LayoutParams attrs,
|
||||
int viewVisibility, int displayId, int userId, InsetsState requestedVisibility,
|
||||
Rect outFrame, InputChannel outInputChannel, InsetsState outInsetsState,
|
||||
InputChannel outInputChannel, InsetsState outInsetsState,
|
||||
InsetsSourceControl[] outActiveControls) {
|
||||
return mService.addWindow(this, window, attrs, viewVisibility, displayId, userId,
|
||||
requestedVisibility, outFrame, outInputChannel, outInsetsState,
|
||||
outActiveControls);
|
||||
requestedVisibility, outInputChannel, outInsetsState, outActiveControls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addToDisplayWithoutInputChannel(IWindow window, WindowManager.LayoutParams attrs,
|
||||
int viewVisibility, int displayId, InsetsState outInsetsState) {
|
||||
return mService.addWindow(this, window, attrs, viewVisibility, displayId,
|
||||
UserHandle.getUserId(mUid), mDummyRequestedVisibility,
|
||||
new Rect() /* outFrame */, null /* outInputChannel */, outInsetsState,
|
||||
mDummyControls);
|
||||
UserHandle.getUserId(mUid), mDummyRequestedVisibility, null /* outInputChannel */,
|
||||
outInsetsState, mDummyControls);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -226,9 +226,8 @@ class TaskSnapshotSurface implements StartingSurface {
|
||||
}
|
||||
int displayId = activity.getDisplayContent().getDisplayId();
|
||||
try {
|
||||
final int res = session.addToDisplay(window, layoutParams,
|
||||
View.GONE, displayId, mTmpInsetsState, tmpFrames.frame,
|
||||
null /* outInputChannel */, mTmpInsetsState, mTempControls);
|
||||
final int res = session.addToDisplay(window, layoutParams, View.GONE, displayId,
|
||||
mTmpInsetsState, null /* outInputChannel */, mTmpInsetsState, mTempControls);
|
||||
if (res < 0) {
|
||||
Slog.w(TAG, "Failed to add snapshot starting window res=" + res);
|
||||
return null;
|
||||
|
||||
@@ -1488,7 +1488,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
|
||||
public int addWindow(Session session, IWindow client, LayoutParams attrs, int viewVisibility,
|
||||
int displayId, int requestUserId, InsetsState requestedVisibility, Rect outFrame,
|
||||
int displayId, int requestUserId, InsetsState requestedVisibility,
|
||||
InputChannel outInputChannel, InsetsState outInsetsState,
|
||||
InsetsSourceControl[] outActiveControls) {
|
||||
Arrays.fill(outActiveControls, null);
|
||||
@@ -1830,7 +1830,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
prepareNoneTransitionForRelaunching(activity);
|
||||
}
|
||||
|
||||
if (displayPolicy.getLayoutHint(win.mAttrs, token, outFrame, outInsetsState,
|
||||
if (displayPolicy.getLayoutHint(win.mAttrs, token, outInsetsState,
|
||||
win.isClientLocal())) {
|
||||
res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS;
|
||||
}
|
||||
@@ -8556,8 +8556,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
+ "could not be found!");
|
||||
}
|
||||
final WindowToken windowToken = dc.getWindowToken(attrs.token);
|
||||
return dc.getDisplayPolicy().getLayoutHint(attrs, windowToken,
|
||||
mTmpRect /* outFrame */, outInsetsState, fromLocal);
|
||||
return dc.getDisplayPolicy().getLayoutHint(attrs, windowToken, outInsetsState,
|
||||
fromLocal);
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(origId);
|
||||
|
||||
@@ -1715,9 +1715,8 @@ public class ActivityRecordTests extends WindowTestsBase {
|
||||
doReturn(WindowManagerGlobal.ADD_STARTING_NOT_NEEDED).when(session).addToDisplay(
|
||||
any() /* window */, any() /* attrs */,
|
||||
anyInt() /* viewVisibility */, anyInt() /* displayId */,
|
||||
any() /* requestedVisibility */, any() /* outFrame */,
|
||||
any() /* outInputChannel */, any() /* outInsetsState */,
|
||||
any() /* outActiveControls */);
|
||||
any() /* requestedVisibility */, any() /* outInputChannel */,
|
||||
any() /* outInsetsState */, any() /* outActiveControls */);
|
||||
mAtm.mWindowManager.mStartingSurfaceController
|
||||
.createTaskSnapshotSurface(activity, snapshot);
|
||||
} catch (RemoteException ignored) {
|
||||
|
||||
@@ -55,7 +55,6 @@ import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.testng.Assert.expectThrows;
|
||||
|
||||
import android.app.WindowConfiguration;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
@@ -673,77 +672,13 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
|
||||
public void layoutHint_appWindow() {
|
||||
mWindow.mAttrs.setFitInsetsTypes(0);
|
||||
|
||||
final Rect outFrame = new Rect();
|
||||
final DisplayCutout.ParcelableWrapper outDisplayCutout =
|
||||
new DisplayCutout.ParcelableWrapper();
|
||||
final InsetsState outState = new InsetsState();
|
||||
|
||||
mDisplayPolicy.getLayoutHint(mWindow.mAttrs, null /* windowToken */, outFrame,
|
||||
outState, true /* localClient */);
|
||||
|
||||
assertThat(outFrame, is(outState.getDisplayFrame()));
|
||||
assertThat(outDisplayCutout, is(new DisplayCutout.ParcelableWrapper()));
|
||||
assertThat(outState.getSource(ITYPE_STATUS_BAR).getFrame(),
|
||||
is(new Rect(0, 0, DISPLAY_WIDTH, STATUS_BAR_HEIGHT)));
|
||||
assertThat(outState.getSource(ITYPE_NAVIGATION_BAR).getFrame(),
|
||||
is(new Rect(0, DISPLAY_HEIGHT - NAV_BAR_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void layoutHint_appWindowInTask() {
|
||||
mWindow.mAttrs.setFitInsetsTypes(0);
|
||||
|
||||
final Rect taskBounds = new Rect(100, 100, 200, 200);
|
||||
final Task task = mWindow.getTask();
|
||||
// Force the bounds because the task may resolve different bounds from Task#setBounds.
|
||||
task.getWindowConfiguration().setBounds(taskBounds);
|
||||
|
||||
final Rect outFrame = new Rect();
|
||||
final DisplayCutout.ParcelableWrapper outDisplayCutout =
|
||||
new DisplayCutout.ParcelableWrapper();
|
||||
final InsetsState outState = new InsetsState();
|
||||
|
||||
mDisplayPolicy.getLayoutHint(mWindow.mAttrs, mWindow.mToken, outFrame, outState,
|
||||
mDisplayPolicy.getLayoutHint(mWindow.mAttrs, null /* windowToken */, outState,
|
||||
true /* localClient */);
|
||||
|
||||
assertThat(outFrame, is(taskBounds));
|
||||
assertThat(outDisplayCutout, is(new DisplayCutout.ParcelableWrapper()));
|
||||
assertThat(outState.getSource(ITYPE_STATUS_BAR).getFrame(),
|
||||
is(new Rect(0, 0, DISPLAY_WIDTH, STATUS_BAR_HEIGHT)));
|
||||
assertThat(outState.getSource(ITYPE_NAVIGATION_BAR).getFrame(),
|
||||
is(new Rect(0, DISPLAY_HEIGHT - NAV_BAR_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void layoutHint_appWindowInTask_outsideContentFrame() {
|
||||
mWindow.mAttrs.setFitInsetsTypes(0);
|
||||
|
||||
final InsetsState state =
|
||||
mDisplayContent.getInsetsStateController().getRawInsetsState();
|
||||
final Rect contentFrame = new Rect(state.getDisplayFrame());
|
||||
contentFrame.inset(state.calculateInsets(contentFrame, Type.systemBars(),
|
||||
false /* ignoreVisibility */));
|
||||
|
||||
// Task is in the nav bar area (usually does not happen, but this is similar enough to
|
||||
// the possible overlap with the IME)
|
||||
final Rect taskBounds = new Rect(100, contentFrame.bottom + 1,
|
||||
200, contentFrame.bottom + 10);
|
||||
|
||||
final Task task = mWindow.getTask();
|
||||
// Make the task floating.
|
||||
task.setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM);
|
||||
// Force the bounds because the task may resolve different bounds from Task#setBounds.
|
||||
task.getWindowConfiguration().setBounds(taskBounds);
|
||||
|
||||
final Rect outFrame = new Rect();
|
||||
final DisplayCutout.ParcelableWrapper outDisplayCutout =
|
||||
new DisplayCutout.ParcelableWrapper();
|
||||
final InsetsState outState = new InsetsState();
|
||||
|
||||
mDisplayPolicy.getLayoutHint(mWindow.mAttrs, mWindow.mToken, outFrame, outState,
|
||||
true /* localClient */);
|
||||
|
||||
assertThat(outFrame, is(taskBounds));
|
||||
assertThat(outDisplayCutout, is(new DisplayCutout.ParcelableWrapper()));
|
||||
assertThat(outState.getSource(ITYPE_STATUS_BAR).getFrame(),
|
||||
is(new Rect(0, 0, DISPLAY_WIDTH, STATUS_BAR_HEIGHT)));
|
||||
|
||||
@@ -145,7 +145,7 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
|
||||
|
||||
assertThat(surface).isNotNull();
|
||||
verify(session).addToDisplay(any(), argThat(this::isTrustedOverlay), anyInt(), anyInt(),
|
||||
any(), any(), any(), any(), any());
|
||||
any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user