summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-04-13 01:53:07 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-04-13 01:53:07 +0000
commit36d012ca1c17999bb3ab80f8b5e3cf631be2c3c9 (patch)
tree137c036b0194b065c3108d164335a9efcff4dabf
parentec839b2eb8cf7c34935a2f0cce085cfd9701c719 (diff)
parent72e2997f31cfdfe7c2b1f41538480e8e5137463e (diff)
Merge "Extend providedInternalInsets to be type specific" into tm-dev
-rw-r--r--core/java/android/view/WindowManager.java55
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java7
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java63
4 files changed, 93 insertions, 33 deletions
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 8e9f9d9fb4f3..cfe44bbbf3c6 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -3590,12 +3590,13 @@ public interface WindowManager extends ViewManager {
/**
* If specified, the insets provided by this window will be our window frame minus the
- * insets specified by providedInternalInsets. This should not be used together with
- * {@link WindowState#mGivenContentInsets}. If both of them are set, both will be applied.
+ * insets specified by providedInternalInsets for each type. This should not be used
+ * together with {@link WindowState#mGivenContentInsets}. If both of them are set, both will
+ * be applied.
*
* @hide
*/
- public Insets providedInternalInsets = Insets.NONE;
+ public Insets[] providedInternalInsets;
/**
* If specified, the insets provided by this window for the IME will be our window frame
@@ -3603,7 +3604,7 @@ public interface WindowManager extends ViewManager {
*
* @hide
*/
- public Insets providedInternalImeInsets = Insets.NONE;
+ public Insets[] providedInternalImeInsets;
/**
* If specified, the frame that used to calculate relative {@link RoundedCorner} will be
@@ -3989,8 +3990,18 @@ public interface WindowManager extends ViewManager {
} else {
out.writeInt(0);
}
- providedInternalInsets.writeToParcel(out, 0 /* parcelableFlags */);
- providedInternalImeInsets.writeToParcel(out, 0 /* parcelableFlags */);
+ if (providedInternalInsets != null) {
+ out.writeInt(providedInternalInsets.length);
+ out.writeTypedArray(providedInternalInsets, 0 /* parcelableFlags */);
+ } else {
+ out.writeInt(0);
+ }
+ if (providedInternalImeInsets != null) {
+ out.writeInt(providedInternalImeInsets.length);
+ out.writeTypedArray(providedInternalImeInsets, 0 /* parcelableFlags */);
+ } else {
+ out.writeInt(0);
+ }
out.writeBoolean(insetsRoundedCornerFrame);
if (paramsForRotation != null) {
checkNonRecursiveParams();
@@ -4070,8 +4081,16 @@ public interface WindowManager extends ViewManager {
providesInsetsTypes = new int[insetsTypesLength];
in.readIntArray(providesInsetsTypes);
}
- providedInternalInsets = Insets.CREATOR.createFromParcel(in);
- providedInternalImeInsets = Insets.CREATOR.createFromParcel(in);
+ int providedInternalInsetsLength = in.readInt();
+ if (providedInternalInsetsLength > 0) {
+ providedInternalInsets = new Insets[providedInternalInsetsLength];
+ in.readTypedArray(providedInternalInsets, Insets.CREATOR);
+ }
+ int providedInternalImeInsetsLength = in.readInt();
+ if (providedInternalImeInsetsLength > 0) {
+ providedInternalImeInsets = new Insets[providedInternalImeInsetsLength];
+ in.readTypedArray(providedInternalImeInsets, Insets.CREATOR);
+ }
insetsRoundedCornerFrame = in.readBoolean();
int paramsForRotationLength = in.readInt();
if (paramsForRotationLength > 0) {
@@ -4374,12 +4393,12 @@ public interface WindowManager extends ViewManager {
changes |= LAYOUT_CHANGED;
}
- if (!providedInternalInsets.equals(o.providedInternalInsets)) {
+ if (!Arrays.equals(providedInternalInsets, o.providedInternalInsets)) {
providedInternalInsets = o.providedInternalInsets;
changes |= LAYOUT_CHANGED;
}
- if (!providedInternalImeInsets.equals(o.providedInternalImeInsets)) {
+ if (!Arrays.equals(providedInternalImeInsets, o.providedInternalImeInsets)) {
providedInternalImeInsets = o.providedInternalImeInsets;
changes |= LAYOUT_CHANGED;
}
@@ -4590,13 +4609,21 @@ public interface WindowManager extends ViewManager {
sb.append(InsetsState.typeToString(providesInsetsTypes[i]));
}
}
- if (!providedInternalInsets.equals(Insets.NONE)) {
+ if (providedInternalInsets != null) {
+ sb.append(System.lineSeparator());
sb.append(" providedInternalInsets=");
- sb.append(providedInternalInsets);
+ for (int i = 0; i < providedInternalInsets.length; ++i) {
+ if (i > 0) sb.append(' ');
+ sb.append((providedInternalInsets[i]));
+ }
}
- if (!providedInternalImeInsets.equals(Insets.NONE)) {
+ if (providedInternalImeInsets != null) {
+ sb.append(System.lineSeparator());
sb.append(" providedInternalImeInsets=");
- sb.append(providedInternalImeInsets);
+ for (int i = 0; i < providedInternalImeInsets.length; ++i) {
+ if (i > 0) sb.append(' ');
+ sb.append((providedInternalImeInsets[i]));
+ }
}
if (insetsRoundedCornerFrame) {
sb.append(" insetsRoundedCornerFrame=");
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
index 32299f5643db..5bd81a42a814 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
@@ -86,6 +86,7 @@ public class WindowManagerWrapper {
public static final int ITYPE_RIGHT_TAPPABLE_ELEMENT = InsetsState.ITYPE_RIGHT_TAPPABLE_ELEMENT;
public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT =
InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
+ public static final int ITYPE_SIZE = InsetsState.SIZE;
public static final int ANIMATION_DURATION_RESIZE = InsetsController.ANIMATION_DURATION_RESIZE;
public static final Interpolator RESIZE_INTERPOLATOR = InsetsController.RESIZE_INTERPOLATOR;
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
index 0f45a7562d0c..72488f3dc823 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java
@@ -83,6 +83,7 @@ import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
+import android.view.InsetsState;
import android.view.InsetsState.InternalInsetsType;
import android.view.InsetsVisibilities;
import android.view.KeyEvent;
@@ -1558,10 +1559,12 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
| WindowManager.LayoutParams.FLAG_SLIPPERY,
PixelFormat.TRANSLUCENT);
lp.gravity = gravity;
+ lp.providedInternalInsets = new Insets[InsetsState.SIZE];
if (insetsHeight != -1) {
- lp.providedInternalInsets = Insets.of(0, height - insetsHeight, 0, 0);
+ lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] =
+ Insets.of(0, height - insetsHeight, 0, 0);
} else {
- lp.providedInternalInsets = Insets.NONE;
+ lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] = null;
}
lp.token = new Binder();
lp.accessibilityTitle = mContext.getString(R.string.nav_bar);
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 566ed6076526..eaf82b625f71 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -1146,8 +1146,13 @@ public class DisplayPolicy {
mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, win,
(displayFrames, windowContainer, inOutFrame) -> {
if (!mNavButtonForcedVisible) {
- inOutFrame.inset(win.getLayoutingAttrs(
- displayFrames.mRotation).providedInternalInsets);
+ final Insets[] providedInternalInsets = win.getLayoutingAttrs(
+ displayFrames.mRotation).providedInternalInsets;
+ if (providedInternalInsets != null
+ && providedInternalInsets.length > ITYPE_NAVIGATION_BAR
+ && providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) {
+ inOutFrame.inset(providedInternalInsets[ITYPE_NAVIGATION_BAR]);
+ }
inOutFrame.inset(win.mGivenContentInsets);
}
},
@@ -1193,13 +1198,16 @@ public class DisplayPolicy {
if (attrs.providesInsetsTypes != null) {
for (@InternalInsetsType int insetsType : attrs.providesInsetsTypes) {
final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
- !attrs.providedInternalImeInsets.equals(Insets.NONE)
- ? (displayFrames, windowContainer, inOutFrame) -> {
- inOutFrame.inset(win.getLayoutingAttrs(
- displayFrames.mRotation)
- .providedInternalImeInsets);
- }
- : null;
+ (displayFrames, windowContainer, inOutFrame) -> {
+ final Insets[] providedInternalImeInsets =
+ win.getLayoutingAttrs(displayFrames.mRotation)
+ .providedInternalImeInsets;
+ if (providedInternalImeInsets != null
+ && providedInternalImeInsets.length > insetsType
+ && providedInternalImeInsets[insetsType] != null) {
+ inOutFrame.inset(providedInternalImeInsets[insetsType]);
+ }
+ };
switch (insetsType) {
case ITYPE_STATUS_BAR:
mStatusBarAlt = win;
@@ -1220,8 +1228,13 @@ public class DisplayPolicy {
}
mDisplayContent.setInsetProvider(insetsType, win, (displayFrames,
windowContainer, inOutFrame) -> {
- inOutFrame.inset(win.getLayoutingAttrs(
- displayFrames.mRotation).providedInternalInsets);
+ final Insets[] providedInternalInsets = win.getLayoutingAttrs(
+ displayFrames.mRotation).providedInternalInsets;
+ if (providedInternalInsets != null
+ && providedInternalInsets.length > insetsType
+ && providedInternalInsets[insetsType] != null) {
+ inOutFrame.inset(providedInternalInsets[insetsType]);
+ }
inOutFrame.inset(win.mGivenContentInsets);
}, imeFrameProvider);
mInsetsSourceWindowsExceptIme.add(win);
@@ -1937,15 +1950,23 @@ public class DisplayPolicy {
&& lp.paramsForRotation[rotation] != null) {
lp = lp.paramsForRotation[rotation];
}
+ final Insets providedInternalInsets;
+ if (lp.providedInternalInsets != null
+ && lp.providedInternalInsets.length > ITYPE_NAVIGATION_BAR
+ && lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) {
+ providedInternalInsets = lp.providedInternalInsets[ITYPE_NAVIGATION_BAR];
+ } else {
+ providedInternalInsets = Insets.NONE;
+ }
if (position == NAV_BAR_LEFT) {
- if (lp.width > lp.providedInternalInsets.right) {
- return lp.width - lp.providedInternalInsets.right;
+ if (lp.width > providedInternalInsets.right) {
+ return lp.width - providedInternalInsets.right;
} else {
return 0;
}
} else if (position == NAV_BAR_RIGHT) {
- if (lp.width > lp.providedInternalInsets.left) {
- return lp.width - lp.providedInternalInsets.left;
+ if (lp.width > providedInternalInsets.left) {
+ return lp.width - providedInternalInsets.left;
} else {
return 0;
}
@@ -1994,10 +2015,18 @@ public class DisplayPolicy {
return 0;
}
LayoutParams lp = mNavigationBar.getLayoutingAttrs(rotation);
- if (lp.height < lp.providedInternalInsets.top) {
+ final Insets providedInternalInsets;
+ if (lp.providedInternalInsets != null
+ && lp.providedInternalInsets.length > ITYPE_NAVIGATION_BAR
+ && lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) {
+ providedInternalInsets = lp.providedInternalInsets[ITYPE_NAVIGATION_BAR];
+ } else {
+ providedInternalInsets = Insets.NONE;
+ }
+ if (lp.height < providedInternalInsets.top) {
return 0;
}
- return lp.height - lp.providedInternalInsets.top;
+ return lp.height - providedInternalInsets.top;
}
/**