From 0488e47548fd13deaf34cd212f621f59ce27b441 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Wed, 19 Oct 2022 19:52:26 +0800 Subject: [PATCH] Clean up null check for mBackNavigationController Only need to check when calling startBackNavigation. Bug: 131727607 Test: build/flash Change-Id: Ib6b92a4019070bc711e7a1ea9462eaf2d404df42 --- .../android/server/wm/ActivityTaskManagerService.java | 11 ++--------- .../android/server/wm/BackNavigationController.java | 11 +++++++---- .../com/android/server/wm/RootWindowContainer.java | 7 ++----- .../com/android/server/wm/WallpaperController.java | 7 ++----- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 416d54649931a..ecc43f7b938b1 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -460,7 +460,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { KeyguardController mKeyguardController; private final ClientLifecycleManager mLifecycleManager; - @Nullable final BackNavigationController mBackNavigationController; private TaskChangeNotificationController mTaskChangeNotificationController; @@ -847,8 +846,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mTaskOrganizerController = mWindowOrganizerController.mTaskOrganizerController; mTaskFragmentOrganizerController = mWindowOrganizerController.mTaskFragmentOrganizerController; - mBackNavigationController = BackNavigationController.isEnabled() - ? new BackNavigationController() : null; + mBackNavigationController = new BackNavigationController(); } public void onSystemReady() { @@ -1031,9 +1029,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mLockTaskController.setWindowManager(wm); mTaskSupervisor.setWindowManager(wm); mRootWindowContainer.setWindowManager(wm); - if (mBackNavigationController != null) { - mBackNavigationController.setWindowManager(wm); - } + mBackNavigationController.setWindowManager(wm); } } @@ -1852,9 +1848,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { IWindowFocusObserver observer, BackAnimationAdapter adapter) { mAmInternal.enforceCallingPermission(START_TASKS_FROM_RECENTS, "startBackNavigation()"); - if (mBackNavigationController == null) { - return null; - } return mBackNavigationController.startBackNavigation(observer, adapter); } diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java index 30399ed15f7e5..1cb83f120a172 100644 --- a/services/core/java/com/android/server/wm/BackNavigationController.java +++ b/services/core/java/com/android/server/wm/BackNavigationController.java @@ -65,12 +65,12 @@ class BackNavigationController { // TODO (b/241808055) Find a appropriate time to remove during refactor // Execute back animation with legacy transition system. Temporary flag for easier debugging. static final boolean ENABLE_SHELL_TRANSITIONS = WindowManagerService.sEnableShellTransitions; + /** - * Returns true if the back predictability feature is enabled + * true if the back predictability feature is enabled */ - static boolean isEnabled() { - return SystemProperties.getInt("persist.wm.debug.predictive_back", 1) != 0; - } + static final boolean sPredictBackEnable = + SystemProperties.getBoolean("persist.wm.debug.predictive_back", true); static boolean isScreenshotEnabled() { return SystemProperties.getInt("persist.wm.debug.predictive_back_screenshot", 0) != 0; @@ -88,6 +88,9 @@ class BackNavigationController { @Nullable BackNavigationInfo startBackNavigation( IWindowFocusObserver observer, BackAnimationAdapter adapter) { + if (!sPredictBackEnable) { + return null; + } final WindowManagerService wmService = mWindowManagerService; mFocusObserver = observer; diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index d8b5d781c0a2c..0ed48357c645e 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -840,11 +840,8 @@ class RootWindowContainer extends WindowContainer if (recentsAnimationController != null) { recentsAnimationController.checkAnimationReady(defaultDisplay.mWallpaperController); } - final BackNavigationController backNavigationController = - mWmService.mAtmService.mBackNavigationController; - if (backNavigationController != null) { - backNavigationController.checkAnimationReady(defaultDisplay.mWallpaperController); - } + mWmService.mAtmService.mBackNavigationController + .checkAnimationReady(defaultDisplay.mWallpaperController); for (int displayNdx = 0; displayNdx < mChildren.size(); ++displayNdx) { final DisplayContent displayContent = mChildren.get(displayNdx); diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index 81d67952afaef..6522d93d52679 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -239,8 +239,7 @@ class WallpaperController { private boolean isBackNavigationTarget(WindowState w) { // The window is in animating by back navigation and set to show wallpaper. - final BackNavigationController controller = mService.mAtmService.mBackNavigationController; - return controller != null && controller.isWallpaperVisible(w); + return mService.mAtmService.mBackNavigationController.isWallpaperVisible(w); } /** @@ -831,9 +830,7 @@ class WallpaperController { // If there was a pending back navigation animation that would show wallpaper, start // the animation due to it was skipped in previous surface placement. - if (mService.mAtmService.mBackNavigationController != null) { - mService.mAtmService.mBackNavigationController.startAnimation(); - } + mService.mAtmService.mBackNavigationController.startAnimation(); return true; } return false;