Handle multi-window for inset hint

am: 23bf5462f0

* commit '23bf5462f05b33ce4390d8370520e43b74dbec09':
  Handle multi-window for inset hint

Change-Id: I67d202891330ba78b6fbe62510261cc7f1449b42
This commit is contained in:
Jorim Jaggi
2016-05-16 23:27:56 +00:00
committed by android-build-merger
3 changed files with 45 additions and 7 deletions

View File

@@ -938,7 +938,11 @@ public interface WindowManagerPolicy {
* be correct. * be correct.
* *
* @param attrs The LayoutParams of the window. * @param attrs The LayoutParams of the window.
* @param rotation Rotation of the display. * @param taskBounds The bounds of the task this window is on or {@code null} if no task is
* associated with the window.
* @param displayRotation Rotation of the display.
* @param displayWidth The width of the display.
* @param displayHeight The height of the display.
* @param outContentInsets The areas covered by system windows, expressed as positive insets. * @param outContentInsets The areas covered by system windows, expressed as positive insets.
* @param outStableInsets The areas covered by stable system windows irrespective of their * @param outStableInsets The areas covered by stable system windows irrespective of their
* current visibility. Expressed as positive insets. * current visibility. Expressed as positive insets.
@@ -946,8 +950,9 @@ public interface WindowManagerPolicy {
* @return Whether to always consume the navigation bar. * @return Whether to always consume the navigation bar.
* See {@link #isNavBarForcedShownLw(WindowState)}. * See {@link #isNavBarForcedShownLw(WindowState)}.
*/ */
public boolean getInsetHintLw(WindowManager.LayoutParams attrs, int rotation, public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
Rect outContentInsets, Rect outStableInsets, Rect outOutsets); int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets,
Rect outStableInsets, Rect outOutsets);
/** /**
* Called when layout of the windows is finished. After this function has * Called when layout of the windows is finished. After this function has

View File

@@ -553,6 +553,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final Rect mTmpStableFrame = new Rect(); static final Rect mTmpStableFrame = new Rect();
static final Rect mTmpNavigationFrame = new Rect(); static final Rect mTmpNavigationFrame = new Rect();
static final Rect mTmpOutsetFrame = new Rect(); static final Rect mTmpOutsetFrame = new Rect();
private static final Rect mTmpRect = new Rect();
WindowState mTopFullscreenOpaqueWindowState; WindowState mTopFullscreenOpaqueWindowState;
WindowState mTopFullscreenOpaqueOrDimmingWindowState; WindowState mTopFullscreenOpaqueOrDimmingWindowState;
@@ -3797,8 +3798,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
@Override @Override
public boolean getInsetHintLw(WindowManager.LayoutParams attrs, int displayRotation, public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
Rect outContentInsets, Rect outStableInsets, Rect outOutsets) { int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets,
Rect outStableInsets, Rect outOutsets) {
final int fl = PolicyControl.getWindowFlags(null, attrs); final int fl = PolicyControl.getWindowFlags(null, attrs);
final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs); final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs);
final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility); final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility);
@@ -3852,6 +3854,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
outStableInsets.set(mStableLeft, mStableTop, outStableInsets.set(mStableLeft, mStableTop,
availRight - mStableRight, availBottom - mStableBottom); availRight - mStableRight, availBottom - mStableBottom);
if (taskBounds != null) {
calculateRelevantTaskInsets(taskBounds, outContentInsets,
displayWidth, displayHeight);
calculateRelevantTaskInsets(taskBounds, outStableInsets,
displayWidth, displayHeight);
}
return mForceShowSystemBars; return mForceShowSystemBars;
} }
outContentInsets.setEmpty(); outContentInsets.setEmpty();
@@ -3859,6 +3867,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return mForceShowSystemBars; return mForceShowSystemBars;
} }
/**
* For any given task bounds, the insets relevant for these bounds given the insets relevant
* for the entire display.
*/
private void calculateRelevantTaskInsets(Rect taskBounds, Rect inOutInsets, int displayWidth,
int displayHeight) {
mTmpRect.set(0, 0, displayWidth, displayHeight);
mTmpRect.inset(inOutInsets);
mTmpRect.intersect(taskBounds);
int leftInset = mTmpRect.left - taskBounds.left;
int topInset = mTmpRect.top - taskBounds.top;
int rightInset = taskBounds.right - mTmpRect.right;
int bottomInset = taskBounds.bottom - mTmpRect.bottom;
inOutInsets.set(leftInset, topInset, rightInset, bottomInset);
}
private boolean shouldUseOutsets(WindowManager.LayoutParams attrs, int fl) { private boolean shouldUseOutsets(WindowManager.LayoutParams attrs, int fl) {
return attrs.type == TYPE_WALLPAPER || (fl & (WindowManager.LayoutParams.FLAG_FULLSCREEN return attrs.type == TYPE_WALLPAPER || (fl & (WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN)) != 0; | WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN)) != 0;

View File

@@ -2117,8 +2117,17 @@ public class WindowManagerService extends IWindowManager.Stub
} }
if (displayContent.isDefaultDisplay) { if (displayContent.isDefaultDisplay) {
if (mPolicy.getInsetHintLw(win.mAttrs, mRotation, outContentInsets, outStableInsets, final DisplayInfo displayInfo = displayContent.getDisplayInfo();
outOutsets)) { final Rect taskBounds;
if (atoken != null && atoken.mTask != null) {
taskBounds = mTmpRect;
atoken.mTask.getBounds(mTmpRect);
} else {
taskBounds = null;
}
if (mPolicy.getInsetHintLw(win.mAttrs, taskBounds, mRotation,
displayInfo.logicalWidth, displayInfo.logicalHeight, outContentInsets,
outStableInsets, outOutsets)) {
res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_NAV_BAR; res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_NAV_BAR;
} }
} else { } else {