From 2bb0736c6e125a50de650fd4e52dd8369765d288 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 28 Feb 2023 00:54:40 +0000 Subject: [PATCH] Enable usage-after-release tracking in the Shell - Fix one case where we're passing an invalid surface from SysUI to Launcher Bug: 266978825 Test: Presubmit Change-Id: I6a680f216ec44b75894d6a1934700935d22973db --- .../Shell/src/com/android/wm/shell/sysui/ShellInit.java | 2 ++ .../com/android/systemui/navigationbar/NavigationBar.java | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/sysui/ShellInit.java b/libs/WindowManager/Shell/src/com/android/wm/shell/sysui/ShellInit.java index ac52235375c47..2e2f569a52b8b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/sysui/ShellInit.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/sysui/ShellInit.java @@ -21,6 +21,7 @@ import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_INIT; import android.os.Build; import android.os.SystemClock; import android.util.Pair; +import android.view.SurfaceControl; import androidx.annotation.VisibleForTesting; @@ -75,6 +76,7 @@ public class ShellInit { @VisibleForTesting public void init() { ProtoLog.v(WM_SHELL_INIT, "Initializing Shell Components: %d", mInitCallbacks.size()); + SurfaceControl.setDebugUsageAfterRelease(true); // Init in order of registration for (int i = 0; i < mInitCallbacks.size(); i++) { final Pair info = mInitCallbacks.get(i); diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index d5d73258bb086..8e0050b827ca8 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -1007,7 +1007,11 @@ public class NavigationBar extends ViewController implements private void notifyNavigationBarSurface() { ViewRootImpl viewRoot = mView.getViewRootImpl(); - SurfaceControl surface = viewRoot != null ? viewRoot.getSurfaceControl() : null; + SurfaceControl surface = viewRoot != null + && viewRoot.getSurfaceControl() != null + && viewRoot.getSurfaceControl().isValid() + ? viewRoot.getSurfaceControl() + : null; mOverviewProxyService.onNavigationBarSurfaceChanged(surface); }