Merge "Revert "Keep runtime insets types during layout"" into sc-dev am: 5b401d84d9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13406015

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4065960ab9cfbbbdd96cc93a6660974125613b5c
This commit is contained in:
Yunfan Chen
2021-01-28 05:33:27 +00:00
committed by Automerger Merge Worker
10 changed files with 128 additions and 156 deletions

View File

@@ -106,9 +106,7 @@ public class InsetsState implements Parcelable {
public static final int ITYPE_NAVIGATION_BAR = 1; public static final int ITYPE_NAVIGATION_BAR = 1;
public static final int ITYPE_CAPTION_BAR = 2; public static final int ITYPE_CAPTION_BAR = 2;
// The always visible types are visible to all windows regardless of the z-order. public static final int ITYPE_TOP_GESTURES = 3;
public static final int FIRST_ALWAYS_VISIBLE_TYPE = 3;
public static final int ITYPE_TOP_GESTURES = FIRST_ALWAYS_VISIBLE_TYPE;
public static final int ITYPE_BOTTOM_GESTURES = 4; public static final int ITYPE_BOTTOM_GESTURES = 4;
public static final int ITYPE_LEFT_GESTURES = 5; public static final int ITYPE_LEFT_GESTURES = 5;
public static final int ITYPE_RIGHT_GESTURES = 6; public static final int ITYPE_RIGHT_GESTURES = 6;
@@ -119,16 +117,15 @@ public class InsetsState implements Parcelable {
public static final int ITYPE_LEFT_MANDATORY_GESTURES = 9; public static final int ITYPE_LEFT_MANDATORY_GESTURES = 9;
public static final int ITYPE_RIGHT_MANDATORY_GESTURES = 10; public static final int ITYPE_RIGHT_MANDATORY_GESTURES = 10;
public static final int ITYPE_LEFT_DISPLAY_CUTOUT = 11; public static final int ITYPE_LEFT_TAPPABLE_ELEMENT = 11;
public static final int ITYPE_TOP_DISPLAY_CUTOUT = 12; public static final int ITYPE_TOP_TAPPABLE_ELEMENT = 12;
public static final int ITYPE_RIGHT_DISPLAY_CUTOUT = 13; public static final int ITYPE_RIGHT_TAPPABLE_ELEMENT = 13;
public static final int ITYPE_BOTTOM_DISPLAY_CUTOUT = 14; public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT = 14;
public static final int LAST_ALWAYS_VISIBLE_TYPE = ITYPE_BOTTOM_DISPLAY_CUTOUT;
public static final int ITYPE_LEFT_TAPPABLE_ELEMENT = 15; public static final int ITYPE_LEFT_DISPLAY_CUTOUT = 15;
public static final int ITYPE_TOP_TAPPABLE_ELEMENT = 16; public static final int ITYPE_TOP_DISPLAY_CUTOUT = 16;
public static final int ITYPE_RIGHT_TAPPABLE_ELEMENT = 17; public static final int ITYPE_RIGHT_DISPLAY_CUTOUT = 17;
public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT = 18; public static final int ITYPE_BOTTOM_DISPLAY_CUTOUT = 18;
/** Input method window. */ /** Input method window. */
public static final int ITYPE_IME = 19; public static final int ITYPE_IME = 19;
@@ -184,18 +181,6 @@ public class InsetsState implements Parcelable {
set(copy, copySources); set(copy, copySources);
} }
/**
* Mirror the always visible sources from the other state. They will share the same object for
* the always visible types.
*
* @param other the state to mirror the mirrored sources from.
*/
public void mirrorAlwaysVisibleInsetsSources(InsetsState other) {
for (int type = FIRST_ALWAYS_VISIBLE_TYPE; type <= LAST_ALWAYS_VISIBLE_TYPE; type++) {
mSources[type] = other.mSources[type];
}
}
/** /**
* Calculates {@link WindowInsets} based on the current source configuration. * Calculates {@link WindowInsets} based on the current source configuration.
* *

View File

@@ -669,9 +669,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
// Used in updating override configurations // Used in updating override configurations
private final Configuration mTempConfig = new Configuration(); private final Configuration mTempConfig = new Configuration();
// Used in performing layout, to record the insets provided by other windows above the current // Used in performing layout
// window. private boolean mTmpWindowsBehindIme;
private InsetsState mTmpAboveInsetsState = new InsetsState();
/** /**
* Used to prevent recursions when calling * Used to prevent recursions when calling
@@ -770,11 +769,17 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
+ " parentHidden=" + w.isParentWindowHidden()); + " parentHidden=" + w.isParentWindowHidden());
} }
// Sets mAboveInsets for each window. Windows behind the window providing the insets can // Sets mBehindIme for each window. Windows behind IME can get IME insets.
// receive the insets. if (w.mBehindIme != mTmpWindowsBehindIme) {
if (!w.mAboveInsetsState.equals(mTmpAboveInsetsState)) { w.mBehindIme = mTmpWindowsBehindIme;
w.mAboveInsetsState.set(mTmpAboveInsetsState); if (getInsetsStateController().getRawInsetsState().getSourceOrDefaultVisibility(
mWinInsetsChanged.add(w); ITYPE_IME)) {
// If IME is invisible, behind IME or not doesn't make the insets different.
mWinInsetsChanged.add(w);
}
}
if (w == mInputMethodWindow) {
mTmpWindowsBehindIme = true;
} }
// If this view is GONE, then skip it -- keep the current frame, and let the caller know // If this view is GONE, then skip it -- keep the current frame, and let the caller know
@@ -810,16 +815,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
+ " mContainingFrame=" + w.getContainingFrame() + " mContainingFrame=" + w.getContainingFrame()
+ " mDisplayFrame=" + w.getDisplayFrame()); + " mDisplayFrame=" + w.getDisplayFrame());
} }
provideInsetsByWindow(w);
}; };
private void provideInsetsByWindow(WindowState w) {
for (int i = 0; i < w.mProvidedInsetsSources.size(); i++) {
final InsetsSource providedSource = w.mProvidedInsetsSources.valueAt(i);
mTmpAboveInsetsState.addSource(providedSource);
}
}
private final Consumer<WindowState> mPerformLayoutAttached = w -> { private final Consumer<WindowState> mPerformLayoutAttached = w -> {
if (w.mLayoutAttached) { if (w.mLayoutAttached) {
if (DEBUG_LAYOUT) Slog.v(TAG, "2ND PASS " + w + " mHaveFrame=" + w.mHaveFrame if (DEBUG_LAYOUT) Slog.v(TAG, "2ND PASS " + w + " mHaveFrame=" + w.mHaveFrame
@@ -4272,20 +4269,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
+ " dh=" + mDisplayInfo.logicalHeight); + " dh=" + mDisplayInfo.logicalHeight);
} }
// Used to indicate that we have processed the insets windows. This needs to be after
// beginLayoutLw to ensure the raw insets state display related info is initialized.
final InsetsState rawInsetsState = getInsetsStateController().getRawInsetsState();
mTmpAboveInsetsState = new InsetsState();
mTmpAboveInsetsState.setDisplayFrame(rawInsetsState.getDisplayFrame());
mTmpAboveInsetsState.setDisplayCutout(rawInsetsState.getDisplayCutout());
mTmpAboveInsetsState.mirrorAlwaysVisibleInsetsSources(rawInsetsState);
int seq = mLayoutSeq + 1; int seq = mLayoutSeq + 1;
if (seq < 0) seq = 0; if (seq < 0) seq = 0;
mLayoutSeq = seq; mLayoutSeq = seq;
mTmpInitial = initial; mTmpInitial = initial;
// Used to indicate that we have processed the IME window.
mTmpWindowsBehindIme = false;
// First perform layout of any root windows (not attached to another window). // First perform layout of any root windows (not attached to another window).
forAllWindows(mPerformLayout, true /* traverseTopToBottom */); forAllWindows(mPerformLayout, true /* traverseTopToBottom */);

View File

@@ -152,7 +152,6 @@ class InsetsSourceProvider {
// animate-out as new one animates-in. // animate-out as new one animates-in.
mWin.cancelAnimation(); mWin.cancelAnimation();
mWin.mPendingPositionChanged = null; mWin.mPendingPositionChanged = null;
mWin.mProvidedInsetsSources.remove(mSource.getType());
} }
ProtoLog.d(WM_DEBUG_IME, "InsetsSource setWin %s", win); ProtoLog.d(WM_DEBUG_IME, "InsetsSource setWin %s", win);
mWin = win; mWin = win;
@@ -162,14 +161,11 @@ class InsetsSourceProvider {
setServerVisible(false); setServerVisible(false);
mSource.setFrame(new Rect()); mSource.setFrame(new Rect());
mSource.setVisibleFrame(null); mSource.setVisibleFrame(null);
} else { } else if (mControllable) {
mWin.mProvidedInsetsSources.put(mSource.getType(), mSource); mWin.setControllableInsetProvider(this);
if (mControllable) { if (mPendingControlTarget != null) {
mWin.setControllableInsetProvider(this); updateControlForTarget(mPendingControlTarget, true /* force */);
if (mPendingControlTarget != null) { mPendingControlTarget = null;
updateControlForTarget(mPendingControlTarget, true /* force */);
mPendingControlTarget = null;
}
} }
} }
} }

View File

@@ -104,8 +104,6 @@ class InsetsStateController {
* visible to the target. e.g., the source which represents the target window itself, and the * visible to the target. e.g., the source which represents the target window itself, and the
* IME source when the target is above IME. We also need to exclude certain types of insets * IME source when the target is above IME. We also need to exclude certain types of insets
* source for client within specific windowing modes. * source for client within specific windowing modes.
* This is to get the insets for a window layout on the screen. If the window is not there, use
* the {@link #getInsetsForWindowMetrics} to get insets instead.
* *
* @param target The window associate with the perspective. * @param target The window associate with the perspective.
* @return The state stripped of the necessary information. * @return The state stripped of the necessary information.
@@ -119,7 +117,7 @@ class InsetsStateController {
final @InternalInsetsType int type = provider != null final @InternalInsetsType int type = provider != null
? provider.getSource().getType() : ITYPE_INVALID; ? provider.getSource().getType() : ITYPE_INVALID;
return getInsetsForTarget(type, target.getWindowingMode(), target.isAlwaysOnTop(), return getInsetsForTarget(type, target.getWindowingMode(), target.isAlwaysOnTop(),
target.mAboveInsetsState); isAboveIme(target));
} }
InsetsState getInsetsForWindowMetrics(@NonNull WindowManager.LayoutParams attrs) { InsetsState getInsetsForWindowMetrics(@NonNull WindowManager.LayoutParams attrs) {
@@ -134,7 +132,19 @@ class InsetsStateController {
final @WindowingMode int windowingMode = token != null final @WindowingMode int windowingMode = token != null
? token.getWindowingMode() : WINDOWING_MODE_UNDEFINED; ? token.getWindowingMode() : WINDOWING_MODE_UNDEFINED;
final boolean alwaysOnTop = token != null && token.isAlwaysOnTop(); final boolean alwaysOnTop = token != null && token.isAlwaysOnTop();
return getInsetsForTarget(type, windowingMode, alwaysOnTop, mState); return getInsetsForTarget(type, windowingMode, alwaysOnTop, isAboveIme(token));
}
private boolean isAboveIme(WindowContainer target) {
final WindowState imeWindow = mDisplayContent.mInputMethodWindow;
if (target == null || imeWindow == null) {
return false;
}
if (target instanceof WindowState) {
final WindowState win = (WindowState) target;
return win.needsRelativeLayeringToIme() || !win.mBehindIme;
}
return false;
} }
private static @InternalInsetsType private static @InternalInsetsType
@@ -170,12 +180,11 @@ class InsetsStateController {
* @see #getInsetsForWindowMetrics * @see #getInsetsForWindowMetrics
*/ */
private InsetsState getInsetsForTarget(@InternalInsetsType int type, private InsetsState getInsetsForTarget(@InternalInsetsType int type,
@WindowingMode int windowingMode, boolean isAlwaysOnTop, InsetsState state) { @WindowingMode int windowingMode, boolean isAlwaysOnTop, boolean aboveIme) {
boolean stateCopied = false; InsetsState state = mState;
if (type != ITYPE_INVALID) { if (type != ITYPE_INVALID) {
state = new InsetsState(state); state = new InsetsState(state);
stateCopied = true;
state.removeSource(type); state.removeSource(type);
// Navigation bar doesn't get influenced by anything else // Navigation bar doesn't get influenced by anything else
@@ -210,15 +219,23 @@ class InsetsStateController {
if (WindowConfiguration.isFloating(windowingMode) if (WindowConfiguration.isFloating(windowingMode)
|| (windowingMode == WINDOWING_MODE_MULTI_WINDOW && isAlwaysOnTop)) { || (windowingMode == WINDOWING_MODE_MULTI_WINDOW && isAlwaysOnTop)) {
if (!stateCopied) { state = new InsetsState(state);
state = new InsetsState(state);
stateCopied = true;
}
state.removeSource(ITYPE_STATUS_BAR); state.removeSource(ITYPE_STATUS_BAR);
state.removeSource(ITYPE_NAVIGATION_BAR); state.removeSource(ITYPE_NAVIGATION_BAR);
state.removeSource(ITYPE_EXTRA_NAVIGATION_BAR); state.removeSource(ITYPE_EXTRA_NAVIGATION_BAR);
} }
if (aboveIme) {
InsetsSource imeSource = state.peekSource(ITYPE_IME);
if (imeSource != null && imeSource.isVisible()) {
imeSource = new InsetsSource(imeSource);
imeSource.setVisible(false);
imeSource.setFrame(0, 0, 0, 0);
state = new InsetsState(state);
state.addSource(imeSource);
}
}
return state; return state;
} }

View File

@@ -212,7 +212,6 @@ import android.os.Trace;
import android.os.WorkSource; import android.os.WorkSource;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.MergedConfiguration; import android.util.MergedConfiguration;
@@ -648,14 +647,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
boolean mSeamlesslyRotated = false; boolean mSeamlesslyRotated = false;
/** /**
* The insets state of sources provided by windows above the current window. * Indicates if this window is behind IME. Only windows behind IME can get insets from IME.
*/ */
InsetsState mAboveInsetsState = new InsetsState(); boolean mBehindIme = false;
/**
* The insets sources provided by this window.
*/
ArrayMap<Integer, InsetsSource> mProvidedInsetsSources = new ArrayMap<>();
/** /**
* Surface insets from the previous call to relayout(), used to track * Surface insets from the previous call to relayout(), used to track

View File

@@ -123,15 +123,6 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
updateDisplayFrames(); updateDisplayFrames();
} }
void addWindowWithRawInsetsState(WindowState win) {
addWindow(win);
// Without mPerformLayout in display content, the window cannot see any insets. Override the
// insets state with the global one.
final InsetsState insetsState =
win.getDisplayContent().getInsetsStateController().getRawInsetsState();
win.mAboveInsetsState = insetsState;
}
public void setRotation(int rotation, boolean includingWindows) { public void setRotation(int rotation, boolean includingWindows) {
mRotation = rotation; mRotation = rotation;
updateDisplayFrames(); updateDisplayFrames();
@@ -281,7 +272,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
@Test @Test
public void layoutWindowLw_fitStatusBars() { public void layoutWindowLw_fitStatusBars() {
mWindow.mAttrs.setFitInsetsTypes(Type.statusBars()); mWindow.mAttrs.setFitInsetsTypes(Type.statusBars());
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -292,7 +283,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
@Test @Test
public void layoutWindowLw_fitNavigationBars() { public void layoutWindowLw_fitNavigationBars() {
mWindow.mAttrs.setFitInsetsTypes(Type.navigationBars()); mWindow.mAttrs.setFitInsetsTypes(Type.navigationBars());
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -303,7 +294,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
@Test @Test
public void layoutWindowLw_fitAllSides() { public void layoutWindowLw_fitAllSides() {
mWindow.mAttrs.setFitInsetsSides(Side.all()); mWindow.mAttrs.setFitInsetsSides(Side.all());
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -314,7 +305,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
@Test @Test
public void layoutWindowLw_fitTopOnly() { public void layoutWindowLw_fitTopOnly() {
mWindow.mAttrs.setFitInsetsSides(Side.TOP); mWindow.mAttrs.setFitInsetsSides(Side.TOP);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -324,12 +315,11 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
@Test @Test
public void layoutWindowLw_fitInsetsIgnoringVisibility() { public void layoutWindowLw_fitInsetsIgnoringVisibility() {
final InsetsState state = final InsetsState state = mWindow.getInsetsState();
mDisplayContent.getInsetsStateController().getRawInsetsState();
state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false); state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
state.getSource(InsetsState.ITYPE_NAVIGATION_BAR).setVisible(false); state.getSource(InsetsState.ITYPE_NAVIGATION_BAR).setVisible(false);
mWindow.mAttrs.setFitInsetsIgnoringVisibility(true); mWindow.mAttrs.setFitInsetsIgnoringVisibility(true);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -339,12 +329,11 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
@Test @Test
public void layoutWindowLw_fitInsetsNotIgnoringVisibility() { public void layoutWindowLw_fitInsetsNotIgnoringVisibility() {
final InsetsState state = final InsetsState state = mWindow.getInsetsState();
mDisplayContent.getInsetsStateController().getRawInsetsState();
state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false); state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
state.getSource(InsetsState.ITYPE_NAVIGATION_BAR).setVisible(false); state.getSource(InsetsState.ITYPE_NAVIGATION_BAR).setVisible(false);
mWindow.mAttrs.setFitInsetsIgnoringVisibility(false); mWindow.mAttrs.setFitInsetsIgnoringVisibility(false);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -360,7 +349,8 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
state.getSource(InsetsState.ITYPE_IME).setFrame( state.getSource(InsetsState.ITYPE_IME).setFrame(
0, DISPLAY_HEIGHT - IME_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT); 0, DISPLAY_HEIGHT - IME_HEIGHT, DISPLAY_WIDTH, DISPLAY_HEIGHT);
mWindow.mAttrs.privateFlags |= PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME; mWindow.mAttrs.privateFlags |= PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME;
addWindowWithRawInsetsState(mWindow); mWindow.mBehindIme = true;
addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -374,7 +364,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.setFitInsetsTypes(Type.displayCutout()); mWindow.mAttrs.setFitInsetsTypes(Type.displayCutout());
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -389,7 +379,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -405,7 +395,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -421,7 +411,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -437,7 +427,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -452,7 +442,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -467,12 +457,11 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mDisplayContent.getInsetsStateController().getRawInsetsState() mWindow.getInsetsState().getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
final InsetsState requestedState = new InsetsState(); final InsetsState requestedState = new InsetsState();
requestedState.getSource(ITYPE_STATUS_BAR).setVisible(false); requestedState.getSource(ITYPE_STATUS_BAR).setVisible(false);
mWindow.updateRequestedVisibility(requestedState); mWindow.updateRequestedVisibility(requestedState);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -487,13 +476,12 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mDisplayContent.getInsetsStateController().getRawInsetsState() mWindow.getInsetsState().getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
final InsetsState requestedState = new InsetsState(); final InsetsState requestedState = new InsetsState();
requestedState.getSource(ITYPE_STATUS_BAR).setVisible(false); requestedState.getSource(ITYPE_STATUS_BAR).setVisible(false);
mWindow.updateRequestedVisibility(requestedState); mWindow.updateRequestedVisibility(requestedState);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -509,7 +497,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -525,7 +513,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -541,7 +529,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -557,7 +545,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.type = TYPE_APPLICATION_OVERLAY; mWindow.mAttrs.type = TYPE_APPLICATION_OVERLAY;
mWindow.mAttrs.width = DISPLAY_WIDTH; mWindow.mAttrs.width = DISPLAY_WIDTH;
mWindow.mAttrs.height = DISPLAY_HEIGHT; mWindow.mAttrs.height = DISPLAY_HEIGHT;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -574,7 +562,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -588,7 +576,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
mWindow.mAttrs.flags = mWindow.mAttrs.flags =
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -604,7 +592,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -620,7 +608,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -636,7 +624,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames); mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
@@ -650,7 +638,7 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.setFitInsetsTypes(0 /* types */); mWindow.mAttrs.setFitInsetsTypes(0 /* types */);
mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_NOTHING; mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_NOTHING;
addWindowWithRawInsetsState(mWindow); addWindow(mWindow);
final int forwardedInsetBottom = 50; final int forwardedInsetBottom = 50;
mDisplayPolicy.setForwardedInsets(Insets.of(0, 0, 0, forwardedInsetBottom)); mDisplayPolicy.setForwardedInsets(Insets.of(0, 0, 0, forwardedInsetBottom));
@@ -788,13 +776,9 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
public void testFixedRotationInsetsSourceFrame() { public void testFixedRotationInsetsSourceFrame() {
doReturn((mDisplayContent.getRotation() + 1) % 4).when(mDisplayContent) doReturn((mDisplayContent.getRotation() + 1) % 4).when(mDisplayContent)
.rotationForActivityInDifferentOrientation(eq(mWindow.mActivityRecord)); .rotationForActivityInDifferentOrientation(eq(mWindow.mActivityRecord));
mWindow.mAboveInsetsState.addSource(mDisplayContent.getInsetsStateController() final Rect frame = mWindow.getInsetsState().getSource(ITYPE_STATUS_BAR).getFrame();
.getRawInsetsState().peekSource(ITYPE_STATUS_BAR));
final Rect frame = mDisplayPolicy.getInsetsPolicy().getInsetsForWindow(mWindow)
.getSource(ITYPE_STATUS_BAR).getFrame();
mDisplayContent.rotateInDifferentOrientationIfNeeded(mWindow.mActivityRecord); mDisplayContent.rotateInDifferentOrientationIfNeeded(mWindow.mActivityRecord);
final Rect rotatedFrame = mDisplayPolicy.getInsetsPolicy().getInsetsForWindow(mWindow) final Rect rotatedFrame = mWindow.getInsetsState().getSource(ITYPE_STATUS_BAR).getFrame();
.getSource(ITYPE_STATUS_BAR).getFrame();
assertEquals(DISPLAY_WIDTH, frame.width()); assertEquals(DISPLAY_WIDTH, frame.width());
assertEquals(DISPLAY_HEIGHT, rotatedFrame.width()); assertEquals(DISPLAY_HEIGHT, rotatedFrame.width());

View File

@@ -300,7 +300,6 @@ public class DisplayPolicyTests extends WindowTestsBase {
displayPolicy.addWindowLw(mNavBarWindow, mNavBarWindow.mAttrs); displayPolicy.addWindowLw(mNavBarWindow, mNavBarWindow.mAttrs);
mNavBarWindow.getControllableInsetProvider().setServerVisible(true); mNavBarWindow.getControllableInsetProvider().setServerVisible(true);
final InsetsState state = mDisplayContent.getInsetsStateController().getRawInsetsState(); final InsetsState state = mDisplayContent.getInsetsStateController().getRawInsetsState();
mImeWindow.mAboveInsetsState = state;
mDisplayContent.mDisplayFrames = new DisplayFrames(mDisplayContent.getDisplayId(), mDisplayContent.mDisplayFrames = new DisplayFrames(mDisplayContent.getDisplayId(),
state, displayInfo, null /* displayCutout */); state, displayInfo, null /* displayCutout */);

View File

@@ -45,7 +45,6 @@ import static org.mockito.Mockito.verify;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.platform.test.annotations.Presubmit; import android.platform.test.annotations.Presubmit;
import android.view.InsetsSource;
import android.view.InsetsSourceControl; import android.view.InsetsSourceControl;
import android.view.InsetsState; import android.view.InsetsState;
@@ -273,6 +272,7 @@ public class InsetsPolicyTest extends WindowTestsBase {
final WindowState navBar = addNonFocusableWindow(TYPE_NAVIGATION_BAR, "navBar"); final WindowState navBar = addNonFocusableWindow(TYPE_NAVIGATION_BAR, "navBar");
navBar.setHasSurface(true); navBar.setHasSurface(true);
navBar.getControllableInsetProvider().setServerVisible(true); navBar.getControllableInsetProvider().setServerVisible(true);
final InsetsPolicy policy = spy(mDisplayContent.getInsetsPolicy()); final InsetsPolicy policy = spy(mDisplayContent.getInsetsPolicy());
doNothing().when(policy).startAnimation(anyBoolean(), any()); doNothing().when(policy).startAnimation(anyBoolean(), any());
@@ -337,14 +337,11 @@ public class InsetsPolicyTest extends WindowTestsBase {
@UseTestDisplay(addWindows = W_ACTIVITY) @UseTestDisplay(addWindows = W_ACTIVITY)
@Test @Test
public void testAbortTransientBars_bothCanBeAborted_appGetsBothRealControls() { public void testAbortTransientBars_bothCanBeAborted_appGetsBothRealControls() {
final InsetsSource statusBarSource = addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar") addNonFocusableWindow(TYPE_STATUS_BAR, "statusBar")
.getControllableInsetProvider().getSource(); .getControllableInsetProvider().getSource().setVisible(false);
final InsetsSource navBarSource = addNonFocusableWindow(TYPE_NAVIGATION_BAR, "navBar") addNonFocusableWindow(TYPE_NAVIGATION_BAR, "navBar")
.getControllableInsetProvider().getSource(); .getControllableInsetProvider().getSource().setVisible(false);
statusBarSource.setVisible(false);
navBarSource.setVisible(false);
mAppWindow.mAboveInsetsState.addSource(navBarSource);
mAppWindow.mAboveInsetsState.addSource(statusBarSource);
final InsetsPolicy policy = spy(mDisplayContent.getInsetsPolicy()); final InsetsPolicy policy = spy(mDisplayContent.getInsetsPolicy());
doNothing().when(policy).startAnimation(anyBoolean(), any()); doNothing().when(policy).startAnimation(anyBoolean(), any());
policy.updateBarControlTarget(mAppWindow); policy.updateBarControlTarget(mAppWindow);

View File

@@ -58,6 +58,25 @@ import org.junit.runner.RunWith;
@RunWith(WindowTestRunner.class) @RunWith(WindowTestRunner.class)
public class InsetsStateControllerTest extends WindowTestsBase { public class InsetsStateControllerTest extends WindowTestsBase {
@Test
public void testStripForDispatch_notOwn() {
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
getController().getSourceProvider(ITYPE_STATUS_BAR).setWindow(statusBar, null, null);
statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR));
assertNotNull(getController().getInsetsForWindow(app).peekSource(ITYPE_STATUS_BAR));
}
@Test
public void testStripForDispatch_own() {
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
mDisplayContent.getInsetsStateController().getSourceProvider(ITYPE_STATUS_BAR)
.setWindow(statusBar, null, null);
statusBar.setControllableInsetProvider(getController().getSourceProvider(ITYPE_STATUS_BAR));
final InsetsState state = getController().getInsetsForWindow(statusBar);
assertNull(state.peekSource(ITYPE_STATUS_BAR));
}
@Test @Test
public void testStripForDispatch_navBar() { public void testStripForDispatch_navBar() {
final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar"); final WindowState navBar = createWindow(null, TYPE_APPLICATION, "navBar");
@@ -123,15 +142,14 @@ public class InsetsStateControllerTest extends WindowTestsBase {
getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null); getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null);
final WindowState app1 = createWindow(null, TYPE_APPLICATION, "app1"); final WindowState app1 = createWindow(null, TYPE_APPLICATION, "app1");
final WindowState app2 = createWindow(null, TYPE_APPLICATION, "app2"); app1.mBehindIme = true;
app1.mAboveInsetsState.addSource(getController().getRawInsetsState().getSource(ITYPE_IME)); final WindowState app2 = createWindow(null, TYPE_APPLICATION, "app2");
app2.mBehindIme = false;
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true); getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
assertFalse(getController().getInsetsForWindow(app2).getSource(ITYPE_IME) assertFalse(getController().getInsetsForWindow(app2).getSource(ITYPE_IME).isVisible());
.isVisible()); assertTrue(getController().getInsetsForWindow(app1).getSource(ITYPE_IME).isVisible());
assertTrue(getController().getInsetsForWindow(app1).getSource(ITYPE_IME)
.isVisible());
} }
@UseTestDisplay(addWindows = W_INPUT_METHOD) @UseTestDisplay(addWindows = W_INPUT_METHOD)
@@ -140,8 +158,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null); getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null);
final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
app.mAboveInsetsState.getSource(ITYPE_IME).setVisible(true); app.mBehindIme = true;
app.mAboveInsetsState.getSource(ITYPE_IME).setFrame(mImeWindow.getFrame());
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true); getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
assertTrue(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible()); assertTrue(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible());
@@ -153,10 +170,10 @@ public class InsetsStateControllerTest extends WindowTestsBase {
getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null); getController().getSourceProvider(ITYPE_IME).setWindow(mImeWindow, null, null);
final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
app.mBehindIme = false;
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true); getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
assertFalse(getController().getInsetsForWindow(app).getSource(ITYPE_IME) assertFalse(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible());
.isVisible());
} }
@UseTestDisplay(addWindows = W_INPUT_METHOD) @UseTestDisplay(addWindows = W_INPUT_METHOD)
@@ -193,8 +210,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
// app won't get visible IME insets while above IME even when IME is visible. // app won't get visible IME insets while above IME even when IME is visible.
assertTrue(getController().getRawInsetsState().getSourceOrDefaultVisibility(ITYPE_IME)); assertTrue(getController().getRawInsetsState().getSourceOrDefaultVisibility(ITYPE_IME));
assertFalse(getController().getInsetsForWindow(app).getSource(ITYPE_IME) assertFalse(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible());
.isVisible());
// Reset invocation counter. // Reset invocation counter.
clearInvocations(app); clearInvocations(app);
@@ -203,8 +219,6 @@ public class InsetsStateControllerTest extends WindowTestsBase {
app.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE; app.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE;
mDisplayContent.computeImeTarget(true); mDisplayContent.computeImeTarget(true);
mDisplayContent.applySurfaceChangesTransaction(); mDisplayContent.applySurfaceChangesTransaction();
app.mAboveInsetsState.getSource(ITYPE_IME).setVisible(true);
app.mAboveInsetsState.getSource(ITYPE_IME).setFrame(mImeWindow.getFrame());
// Make sure app got notified. // Make sure app got notified.
verify(app, atLeast(1)).notifyInsetsChanged(); verify(app, atLeast(1)).notifyInsetsChanged();
@@ -220,8 +234,6 @@ public class InsetsStateControllerTest extends WindowTestsBase {
final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
final WindowState child = createWindow(app, TYPE_APPLICATION, "child"); final WindowState child = createWindow(app, TYPE_APPLICATION, "child");
app.mAboveInsetsState.set(getController().getRawInsetsState());
child.mAboveInsetsState.set(getController().getRawInsetsState());
child.mAttrs.flags |= FLAG_ALT_FOCUSABLE_IM; child.mAttrs.flags |= FLAG_ALT_FOCUSABLE_IM;
mDisplayContent.computeImeTarget(true); mDisplayContent.computeImeTarget(true);
@@ -230,8 +242,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true); getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
assertTrue(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible()); assertTrue(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible());
assertFalse(getController().getInsetsForWindow(child).getSource(ITYPE_IME) assertFalse(getController().getInsetsForWindow(child).getSource(ITYPE_IME).isVisible());
.isVisible());
} }
@UseTestDisplay(addWindows = W_INPUT_METHOD) @UseTestDisplay(addWindows = W_INPUT_METHOD)
@@ -241,7 +252,6 @@ public class InsetsStateControllerTest extends WindowTestsBase {
final WindowState app = createWindow(null, TYPE_APPLICATION, "app"); final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
final WindowState child = createWindow(app, TYPE_APPLICATION, "child"); final WindowState child = createWindow(app, TYPE_APPLICATION, "child");
app.mAboveInsetsState.addSource(getController().getRawInsetsState().peekSource(ITYPE_IME));
child.mAttrs.flags |= FLAG_NOT_FOCUSABLE; child.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
child.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); child.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
@@ -251,8 +261,7 @@ public class InsetsStateControllerTest extends WindowTestsBase {
getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true); getController().getRawInsetsState().setSourceVisible(ITYPE_IME, true);
assertTrue(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible()); assertTrue(getController().getInsetsForWindow(app).getSource(ITYPE_IME).isVisible());
assertFalse(getController().getInsetsForWindow(child).getSource(ITYPE_IME) assertFalse(getController().getInsetsForWindow(child).getSource(ITYPE_IME).isVisible());
.isVisible());
} }
@Test @Test

View File

@@ -275,7 +275,7 @@ public class WindowFrameTests extends WindowTestsBase {
imeSource.setFrame(imeFrame); imeSource.setFrame(imeFrame);
imeSource.setVisible(true); imeSource.setVisible(true);
w.updateRequestedVisibility(state); w.updateRequestedVisibility(state);
w.mAboveInsetsState.addSource(imeSource); w.mBehindIme = true;
// With no insets or system decor all the frames incoming from PhoneWindowManager // With no insets or system decor all the frames incoming from PhoneWindowManager
// are identical. // are identical.