summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shawn Lin <shawnlin@google.com> 2021-04-13 06:24:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-04-13 06:24:25 +0000
commit1aeb8f54f8601bfccf2a7fe384b661203781f62b (patch)
tree819e33514defa9dc0041772a080123303a5760c3
parentb6a266158d7966820e77ca38958203d64764ea00 (diff)
parentf8979c284a635948c3b54bdf5b97bbeb48e73b8f (diff)
Merge "Fixed the flickering of the nav bar" into sc-dev
-rw-r--r--services/core/java/com/android/server/wm/FadeRotationAnimationController.java11
-rw-r--r--services/core/java/com/android/server/wm/RecentsAnimationController.java30
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java31
3 files changed, 63 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/wm/FadeRotationAnimationController.java b/services/core/java/com/android/server/wm/FadeRotationAnimationController.java
index 5ee692806349..b14d4a1e4b5a 100644
--- a/services/core/java/com/android/server/wm/FadeRotationAnimationController.java
+++ b/services/core/java/com/android/server/wm/FadeRotationAnimationController.java
@@ -39,6 +39,9 @@ public class FadeRotationAnimationController extends FadeAnimationController {
private final Runnable mFrozenTimeoutRunnable;
private final WindowToken mNavBarToken;
+ /** A runnable which gets called when the {@link #show()} is called. */
+ private Runnable mOnShowRunnable;
+
public FadeRotationAnimationController(DisplayContent displayContent) {
super(displayContent);
mService = displayContent.mWmService;
@@ -81,6 +84,10 @@ public class FadeRotationAnimationController extends FadeAnimationController {
if (mFrozenTimeoutRunnable != null) {
mService.mH.removeCallbacks(mFrozenTimeoutRunnable);
}
+ if (mOnShowRunnable != null) {
+ mOnShowRunnable.run();
+ mOnShowRunnable = null;
+ }
}
/**
@@ -115,6 +122,10 @@ public class FadeRotationAnimationController extends FadeAnimationController {
return token == mNavBarToken || mTargetWindowTokens.contains(token);
}
+ void setOnShowRunnable(Runnable onShowRunnable) {
+ mOnShowRunnable = onShowRunnable;
+ }
+
@Override
public Animation getFadeInAnimation() {
if (mFrozenTimeoutRunnable != null) {
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index c1d5b5c98f57..129a6ce8e1d5 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -669,21 +669,33 @@ public class RecentsAnimationController implements DeathRecipient {
}
navWindow.setSurfaceTranslationY(0);
- if (navWindow.mToken == null) {
+ final WindowToken navToken = navWindow.mToken;
+ if (navToken == null) {
return;
}
final SurfaceControl.Transaction t = mDisplayContent.getPendingTransaction();
- final WindowContainer parent = navWindow.mToken.getParent();
- // Reparent the SurfaceControl of nav bar token back.
- t.reparent(navWindow.mToken.getSurfaceControl(), parent.getSurfaceControl());
-
+ final WindowContainer parent = navToken.getParent();
if (animate) {
- // Run fade-in animation to show navigation bar back to bottom of the display.
- final NavBarFadeAnimationController controller =
+ final NavBarFadeAnimationController navBarFadeAnimationController =
mDisplayContent.getDisplayPolicy().getNavBarFadeAnimationController();
- if (controller != null) {
- controller.fadeWindowToken(true);
+ final Runnable fadeInAnim = () -> {
+ // Reparent the SurfaceControl of nav bar token back.
+ t.reparent(navToken.getSurfaceControl(), parent.getSurfaceControl());
+ // Run fade-in animation to show navigation bar back to bottom of the display.
+ if (navBarFadeAnimationController != null) {
+ navBarFadeAnimationController.fadeWindowToken(true);
+ }
+ };
+ final FadeRotationAnimationController fadeRotationAnimationController =
+ mDisplayContent.getFadeRotationAnimationController();
+ if (fadeRotationAnimationController != null) {
+ fadeRotationAnimationController.setOnShowRunnable(fadeInAnim);
+ } else {
+ fadeInAnim.run();
}
+ } else {
+ // Reparent the SurfaceControl of nav bar token back.
+ t.reparent(navToken.getSurfaceControl(), parent.getSurfaceControl());
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
index 7d137bcb2cff..153fd3a68e82 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
@@ -567,6 +567,37 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
}
@Test
+ public void testFadeRotationAfterAttachAndBeforeRestore_notRestoreNavImmediately() {
+ setupForShouldAttachNavBarDuringTransition();
+ final ActivityRecord activity = createActivityRecord(mDefaultDisplay);
+ final ActivityRecord homeActivity = createHomeActivity();
+ initializeRecentsAnimationController(mController, homeActivity);
+
+ final WindowToken navToken = mDefaultDisplay.getDisplayPolicy().getNavigationBar().mToken;
+ final SurfaceControl.Transaction transaction = navToken.getPendingTransaction();
+
+ verify(mController.mStatusBar).setNavigationBarLumaSamplingEnabled(
+ mDefaultDisplay.mDisplayId, false);
+ verify(transaction).reparent(navToken.getSurfaceControl(), activity.getSurfaceControl());
+
+ final WindowContainer parent = navToken.getParent();
+ final NavBarFadeAnimationController navBarFadeAnimationController =
+ mDefaultDisplay.getDisplayPolicy().getNavBarFadeAnimationController();
+
+ FadeRotationAnimationController mockController =
+ mock(FadeRotationAnimationController.class);
+ doReturn(mockController).when(mDefaultDisplay).getFadeRotationAnimationController();
+
+ mController.cleanupAnimation(REORDER_MOVE_TO_TOP);
+ verify(mController.mStatusBar).setNavigationBarLumaSamplingEnabled(
+ mDefaultDisplay.mDisplayId, true);
+ verify(mockController).setOnShowRunnable(any());
+ verify(transaction, times(0)).reparent(navToken.getSurfaceControl(),
+ parent.getSurfaceControl());
+ verify(navBarFadeAnimationController, times(0)).fadeWindowToken(true);
+ }
+
+ @Test
public void testAttachNavBarInSplitScreenMode() {
setupForShouldAttachNavBarDuringTransition();
final ActivityRecord primary = createActivityRecordWithParentTask(mDefaultDisplay,