summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-03-30 11:45:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-30 11:45:54 +0000
commitc322ed217389dda3287a294bedad636ed687e56d (patch)
treee6514a43bfef9de5c03713545ec14b4bcbe291b8 /core/java
parent99960a5f79eaa690d63c8f7e9d3d98bd35b0a5c7 (diff)
parent49b9f6c67c777898f4f956a433a11292174e37b9 (diff)
Merge "Fix flickers when changing control" into rvc-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/InsetsController.java5
-rw-r--r--core/java/android/view/InsetsSourceConsumer.java12
-rw-r--r--core/java/android/view/PendingInsetsController.java8
-rw-r--r--core/java/android/view/WindowInsetsController.java8
-rw-r--r--core/java/com/android/internal/policy/DecorView.java23
5 files changed, 40 insertions, 16 deletions
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index 40a460dfece0..ae115f631424 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -456,6 +456,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
return mState;
}
+ @Override
+ public boolean isRequestedVisible(int type) {
+ return getSourceConsumer(type).isRequestedVisible();
+ }
+
public InsetsState getLastDispatchedState() {
return mLastDispachedState;
}
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index f36621c0a49e..360195df6625 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -112,12 +112,12 @@ public class InsetsSourceConsumer {
hideTypes[0] |= toPublicType(getType());
}
} else {
- // We are gaining control, but don't need to run an animation.
- // However make sure that the leash visibility is still up to date.
- if (applyLocalVisibilityOverride()) {
- mController.notifyVisibilityChanged();
- }
- applyHiddenToControl();
+ // We are gaining control, but don't need to run an animation.
+ // However make sure that the leash visibility is still up to date.
+ if (applyLocalVisibilityOverride()) {
+ mController.notifyVisibilityChanged();
+ applyHiddenToControl();
+ }
}
}
if (lastControl != null) {
diff --git a/core/java/android/view/PendingInsetsController.java b/core/java/android/view/PendingInsetsController.java
index a106b2c4726d..0283ada0dd40 100644
--- a/core/java/android/view/PendingInsetsController.java
+++ b/core/java/android/view/PendingInsetsController.java
@@ -108,6 +108,14 @@ public class PendingInsetsController implements WindowInsetsController {
}
@Override
+ public boolean isRequestedVisible(int type) {
+
+ // Method is only used once real insets controller is attached, so no need to traverse
+ // requests here.
+ return InsetsState.getDefaultVisibility(type);
+ }
+
+ @Override
public void addOnControllableInsetsChangedListener(
OnControllableInsetsChangedListener listener) {
if (mReplayedInsetsController != null) {
diff --git a/core/java/android/view/WindowInsetsController.java b/core/java/android/view/WindowInsetsController.java
index 439223cf568b..3d348efc7f0f 100644
--- a/core/java/android/view/WindowInsetsController.java
+++ b/core/java/android/view/WindowInsetsController.java
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
import android.graphics.Insets;
import android.inputmethodservice.InputMethodService;
import android.os.CancellationSignal;
+import android.view.InsetsState.InternalInsetsType;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
import android.view.animation.Interpolator;
@@ -226,6 +227,13 @@ public interface WindowInsetsController {
InsetsState getState();
/**
+ * @return Whether the specified insets source is currently requested to be visible by the
+ * application.
+ * @hide
+ */
+ boolean isRequestedVisible(@InternalInsetsType int type);
+
+ /**
* Adds a {@link OnControllableInsetsChangedListener} to the window insets controller.
*
* @param listener The listener to add.
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index d2508f3616e4..71cf5cad316e 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -120,6 +120,7 @@ import com.android.internal.widget.DecorCaptionView;
import com.android.internal.widget.FloatingToolbar;
import java.util.List;
+import java.util.function.Function;
/** @hide */
public class DecorView extends FrameLayout implements RootViewSurfaceTaker, WindowCallbacks {
@@ -1101,7 +1102,6 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
int sysUiVisibility = attrs.systemUiVisibility | getWindowSystemUiVisibility();
final WindowInsetsController controller = getWindowInsetsController();
- final InsetsState state = controller != null ? controller.getState() : null;
// IME is an exceptional floating window that requires color view.
final boolean isImeWindow =
@@ -1151,7 +1151,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
calculateNavigationBarColor(), mWindow.mNavigationBarDividerColor, navBarSize,
navBarToRightEdge || navBarToLeftEdge, navBarToLeftEdge,
0 /* sideInset */, animate && !disallowAnimate,
- mForceWindowDrawsBarBackgrounds, state);
+ mForceWindowDrawsBarBackgrounds, controller);
boolean oldDrawLegacy = mDrawLegacyNavigationBarBackground;
mDrawLegacyNavigationBarBackground = mNavigationColorViewState.visible
&& (mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0;
@@ -1172,7 +1172,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
calculateStatusBarColor(), 0, mLastTopInset,
false /* matchVertical */, statusBarNeedsLeftInset, statusBarSideInset,
animate && !disallowAnimate,
- mForceWindowDrawsBarBackgrounds, state);
+ mForceWindowDrawsBarBackgrounds, controller);
if (mHasCaption) {
final int captionColor = calculateStatusBarColor();
@@ -1193,7 +1193,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
// SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION to indicate whether the app wants to handle it by
// themselves.
boolean hideNavigation = (sysUiVisibility & SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0
- || !(state == null || state.getSource(ITYPE_NAVIGATION_BAR).isVisible());
+ || !(controller == null || controller.isRequestedVisible(ITYPE_NAVIGATION_BAR));
boolean forceConsumingNavBar = (mForceWindowDrawsBarBackgrounds
&& (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0
&& (sysUiVisibility & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0
@@ -1214,7 +1214,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
// fullscreen, as othrewise we can expect the app to handle it.
boolean fullscreen = (sysUiVisibility & SYSTEM_UI_FLAG_FULLSCREEN) != 0
|| (attrs.flags & FLAG_FULLSCREEN) != 0
- || !(state == null || state.getSource(ITYPE_STATUS_BAR).isVisible());
+ || !(controller == null || controller.isRequestedVisible(ITYPE_STATUS_BAR));
boolean consumingStatusBar = (sysUiVisibility & SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == 0
&& (attrs.flags & FLAG_LAYOUT_IN_SCREEN) == 0
&& (attrs.flags & FLAG_LAYOUT_INSET_DECOR) == 0
@@ -1354,10 +1354,12 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
*/
private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color,
int dividerColor, int size, boolean verticalBar, boolean seascape, int sideMargin,
- boolean animate, boolean force, InsetsState insetsState) {
+ boolean animate, boolean force, WindowInsetsController controller) {
state.present = ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
? state.attributes.isPresent(sysUiVis, mWindow.getAttributes().flags, force)
- : state.attributes.isPresent(insetsState, mWindow.getAttributes().flags, force);
+ : state.attributes.isPresent(
+ controller.isRequestedVisible(state.attributes.insetsType),
+ mWindow.getAttributes().flags, force);
boolean show = state.attributes.isVisible(state.present, color,
mWindow.getAttributes().flags, force);
boolean showView = show && !isResizing() && !mHasCaption && size > 0;
@@ -2624,8 +2626,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
|| force);
}
- public boolean isPresent(InsetsState state, int windowFlags, boolean force) {
- return (state == null || state.getSource(insetsType).isVisible())
+ public boolean isPresent(boolean requestedVisible, int windowFlags, boolean force) {
+ return requestedVisible
&& ((windowFlags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0 || force);
}
@@ -2642,7 +2644,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
}
public boolean isVisible(InsetsState state, int color, int windowFlags, boolean force) {
- final boolean present = isPresent(state, windowFlags, force);
+ final boolean present = isPresent(state.getSource(insetsType).isVisible(), windowFlags,
+ force);
return isVisible(present, color, windowFlags, force);
}
}