summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tiger Huang <tigerhuang@google.com> 2020-05-06 01:02:31 +0800
committer Tiger Huang <tigerhuang@google.com> 2020-05-07 14:01:38 +0800
commitfbfc3abfde1e59c7e2b78b217be3d74e263a4843 (patch)
tree5b873f9529dd8bc28b994c2fed1da5cda6eb7867
parent28382c8f84e410285ca594b43f296e78526461fd (diff)
Prevent unnecessary updateRequestedState
If the client didn't change any insets, we don't need to update the requested state while receiving controls. The requested state at the server side can still be up-to-date for free. This CL also sends the requested state to window manager if the local state is not the same as the dispatched state. Fix: 155752039 Test: atest InsetsControllerTest Change-Id: I676a88d3ef823d8717d03e80261e6e7a5f7e8c5f
-rw-r--r--core/java/android/view/InsetsController.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index a135b0ca148b..dde331885297 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -667,7 +667,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
if (hideTypes[0] != 0) {
applyAnimation(hideTypes[0], false /* show */, false /* fromIme */);
}
- if (hasControl) {
+ if (hasControl && mRequestedState.getSourcesCount() > 0) {
// We might have changed our requested visibilities while we don't have the control,
// so we need to update our requested state once we have control. Otherwise, our
// requested state at the server side might be incorrect.
@@ -1065,9 +1065,16 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
if (consumer.getControl() != null) {
final InsetsSource localSource = mState.getSource(type);
if (!localSource.equals(mRequestedState.peekSource(type))) {
+ // Our requested state is stale. Update it here and send it to window manager.
mRequestedState.addSource(new InsetsSource(localSource));
changed = true;
}
+ if (!localSource.equals(mLastDispatchedState.peekSource(type))) {
+ // The server state is not what we expected. This can happen while we don't have
+ // the control. Since we have the control now, we need to send our request again
+ // to modify the server state.
+ changed = true;
+ }
}
}
if (!changed) {