Merge "Make sure to extend insets frame when the bar layout with cutout" into tm-qpr-dev
This commit is contained in:
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
import static android.view.Gravity.DISPLAY_CLIP_HORIZONTAL;
|
|
||||||
import static android.view.Gravity.DISPLAY_CLIP_VERTICAL;
|
|
||||||
import static android.view.InsetsState.ITYPE_IME;
|
import static android.view.InsetsState.ITYPE_IME;
|
||||||
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
|
||||||
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
import static android.view.InsetsState.ITYPE_STATUS_BAR;
|
||||||
@@ -275,17 +273,9 @@ public class WindowLayout {
|
|||||||
Gravity.applyDisplay(attrs.gravity, outDisplayFrame, outFrame);
|
Gravity.applyDisplay(attrs.gravity, outDisplayFrame, outFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extendedByCutout && !displayCutoutSafe.contains(outFrame)) {
|
if (extendedByCutout) {
|
||||||
mTempRect.set(outFrame);
|
extendFrameByCutout(attrs.gravity, displayCutoutSafe, outDisplayFrame, outFrame,
|
||||||
|
|
||||||
// Move the frame into displayCutoutSafe.
|
|
||||||
final int clipFlags = DISPLAY_CLIP_VERTICAL | DISPLAY_CLIP_HORIZONTAL;
|
|
||||||
Gravity.applyDisplay(attrs.gravity & ~clipFlags, displayCutoutSafe,
|
|
||||||
mTempRect);
|
mTempRect);
|
||||||
|
|
||||||
if (mTempRect.intersect(outDisplayFrame)) {
|
|
||||||
outFrame.union(mTempRect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "computeFrames " + attrs.getTitle()
|
if (DEBUG) Log.d(TAG, "computeFrames " + attrs.getTitle()
|
||||||
@@ -301,6 +291,21 @@ public class WindowLayout {
|
|||||||
+ " requestedVisibilities=" + requestedVisibilities);
|
+ " requestedVisibilities=" + requestedVisibilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void extendFrameByCutout(int gravity, Rect displayCutoutSafe,
|
||||||
|
Rect displayFrame, Rect inOutFrame, Rect tempRect) {
|
||||||
|
if (displayCutoutSafe.contains(inOutFrame)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tempRect.set(inOutFrame);
|
||||||
|
|
||||||
|
// Move the frame into displayCutoutSafe.
|
||||||
|
Gravity.applyDisplay(0 /* gravity */, displayCutoutSafe, tempRect);
|
||||||
|
|
||||||
|
if (tempRect.intersect(displayFrame)) {
|
||||||
|
inOutFrame.union(tempRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void computeSurfaceSize(WindowManager.LayoutParams attrs, Rect maxBounds,
|
public static void computeSurfaceSize(WindowManager.LayoutParams attrs, Rect maxBounds,
|
||||||
int requestedWidth, int requestedHeight, Rect winFrame, boolean dragResizing,
|
int requestedWidth, int requestedHeight, Rect winFrame, boolean dragResizing,
|
||||||
Point outSurfaceSize) {
|
Point outSurfaceSize) {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
|
|||||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
|
||||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP;
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP;
|
||||||
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
|
||||||
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
|
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
|
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
|
||||||
@@ -1166,7 +1167,8 @@ public class DisplayPolicy {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
calculateInsetsFrame(displayFrames, win, inOutFrame,
|
calculateInsetsFrame(displayFrames, win, inOutFrame,
|
||||||
provider.source, provider.insetsSize
|
provider.source, provider.insetsSize,
|
||||||
|
lp.privateFlags, lp.gravity
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1241,21 +1243,25 @@ public class DisplayPolicy {
|
|||||||
provider.insetsSize != null
|
provider.insetsSize != null
|
||||||
? (displayFrames, windowContainer, inOutFrame) -> {
|
? (displayFrames, windowContainer, inOutFrame) -> {
|
||||||
inOutFrame.inset(win.mGivenContentInsets);
|
inOutFrame.inset(win.mGivenContentInsets);
|
||||||
|
final LayoutParams lp =
|
||||||
|
win.mAttrs.forRotation(displayFrames.mRotation);
|
||||||
final InsetsFrameProvider ifp =
|
final InsetsFrameProvider ifp =
|
||||||
win.mAttrs.forRotation(displayFrames.mRotation)
|
lp.providedInsets[index];
|
||||||
.providedInsets[index];
|
|
||||||
calculateInsetsFrame(displayFrames, windowContainer,
|
calculateInsetsFrame(displayFrames, windowContainer,
|
||||||
inOutFrame, ifp.source, ifp.insetsSize);
|
inOutFrame, ifp.source, ifp.insetsSize,
|
||||||
|
lp.privateFlags, lp.gravity);
|
||||||
} : null;
|
} : null;
|
||||||
final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
|
final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
|
||||||
provider.imeInsetsSize != null
|
provider.imeInsetsSize != null
|
||||||
? (displayFrames, windowContainer, inOutFrame) -> {
|
? (displayFrames, windowContainer, inOutFrame) -> {
|
||||||
inOutFrame.inset(win.mGivenContentInsets);
|
inOutFrame.inset(win.mGivenContentInsets);
|
||||||
|
final LayoutParams lp =
|
||||||
|
win.mAttrs.forRotation(displayFrames.mRotation);
|
||||||
final InsetsFrameProvider ifp =
|
final InsetsFrameProvider ifp =
|
||||||
win.mAttrs.forRotation(displayFrames.mRotation)
|
lp.providedInsets[index];
|
||||||
.providedInsets[index];
|
|
||||||
calculateInsetsFrame(displayFrames, windowContainer,
|
calculateInsetsFrame(displayFrames, windowContainer,
|
||||||
inOutFrame, ifp.source, ifp.imeInsetsSize);
|
inOutFrame, ifp.source, ifp.imeInsetsSize,
|
||||||
|
lp.privateFlags, lp.gravity);
|
||||||
} : null;
|
} : null;
|
||||||
mDisplayContent.setInsetProvider(provider.type, win, frameProvider,
|
mDisplayContent.setInsetProvider(provider.type, win, frameProvider,
|
||||||
imeFrameProvider);
|
imeFrameProvider);
|
||||||
@@ -1267,11 +1273,15 @@ public class DisplayPolicy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void calculateInsetsFrame(DisplayFrames df, WindowContainer container, Rect inOutFrame,
|
private void calculateInsetsFrame(DisplayFrames df, WindowContainer container, Rect inOutFrame,
|
||||||
int source, Insets insetsSize) {
|
int source, Insets insetsSize, @LayoutParams.PrivateFlags int privateFlags,
|
||||||
|
int windowGravity) {
|
||||||
|
boolean extendByCutout = false;
|
||||||
if (source == InsetsFrameProvider.SOURCE_DISPLAY) {
|
if (source == InsetsFrameProvider.SOURCE_DISPLAY) {
|
||||||
inOutFrame.set(df.mUnrestricted);
|
inOutFrame.set(df.mUnrestricted);
|
||||||
} else if (source == InsetsFrameProvider.SOURCE_CONTAINER_BOUNDS) {
|
} else if (source == InsetsFrameProvider.SOURCE_CONTAINER_BOUNDS) {
|
||||||
inOutFrame.set(container.getBounds());
|
inOutFrame.set(container.getBounds());
|
||||||
|
} else {
|
||||||
|
extendByCutout = (privateFlags & PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT) != 0;
|
||||||
}
|
}
|
||||||
if (insetsSize == null) {
|
if (insetsSize == null) {
|
||||||
return;
|
return;
|
||||||
@@ -1289,6 +1299,11 @@ public class DisplayPolicy {
|
|||||||
} else {
|
} else {
|
||||||
inOutFrame.setEmpty();
|
inOutFrame.setEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extendByCutout) {
|
||||||
|
WindowLayout.extendFrameByCutout(windowGravity, df.mDisplayCutoutSafe,
|
||||||
|
df.mUnrestricted, inOutFrame, sTmpRect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@WindowManagerPolicy.AltBarPosition
|
@WindowManagerPolicy.AltBarPosition
|
||||||
|
|||||||
Reference in New Issue
Block a user