diff options
4 files changed, 20 insertions, 24 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java index 447a15d34c05..2c4b0b990e6d 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java @@ -178,9 +178,6 @@ public interface ShadeController extends CoreStartable { /** Listens for shade visibility changes. */ interface ShadeVisibilityListener { - /** Called when the visibility of the shade changes. */ - void visibilityChanged(boolean visible); - /** Called when shade expanded and visible state changed. */ void expandedVisibleChanged(boolean expandedVisible); } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java index 367449b9d59d..fdc7eecd9b15 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java @@ -24,6 +24,7 @@ import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.WindowManagerGlobal; +import com.android.systemui.DejankUtils; import com.android.systemui.assist.AssistManager; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; @@ -75,6 +76,7 @@ public final class ShadeControllerImpl implements ShadeController { private final ArrayList<Runnable> mPostCollapseRunnables = new ArrayList<>(); private boolean mExpandedVisible; + private boolean mLockscreenOrShadeVisible; private NotificationPresenter mPresenter; private NotificationShadeWindowViewController mNotificationShadeWindowViewController; @@ -399,8 +401,19 @@ public final class ShadeControllerImpl implements ShadeController { } private void notifyVisibilityChanged(boolean visible) { - mShadeVisibilityListener.visibilityChanged(visible); mWindowRootViewVisibilityInteractor.setIsLockscreenOrShadeVisible(visible); + if (mLockscreenOrShadeVisible != visible) { + mLockscreenOrShadeVisible = visible; + if (visible) { + // It would be best if this could be done as a side effect of listening to the + // [WindowRootViewVisibilityInteractor.isLockscreenOrShadeVisible] flow inside + // NotificationShadeWindowViewController. However, there's no guarantee that the + // flow will emit in the same frame as when the visibility changed, and we want the + // DejankUtils to be notified immediately, so we do it immediately here. + DejankUtils.notifyRendererOfExpensiveFrame( + getNotificationShadeWindowView(), "onShadeVisibilityChanged"); + } + } } private void notifyExpandedVisibleChanged(boolean expandedVisible) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 31762220a5dd..2f7c29960a59 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -236,6 +236,8 @@ import com.android.wm.shell.bubbles.Bubbles; import com.android.wm.shell.startingsurface.SplashscreenContentDrawer; import com.android.wm.shell.startingsurface.StartingSurface; +import dagger.Lazy; + import java.io.PrintWriter; import java.io.StringWriter; import java.util.List; @@ -247,8 +249,6 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; -import dagger.Lazy; - /** * A class handling initialization and coordination between some of the key central surfaces in * System UI: The notification shade, the keyguard (lockscreen), and the status bar. @@ -1088,11 +1088,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { void initShadeVisibilityListener() { mShadeController.setVisibilityListener(new ShadeController.ShadeVisibilityListener() { @Override - public void visibilityChanged(boolean visible) { - onShadeVisibilityChanged(visible); - } - - @Override public void expandedVisibleChanged(boolean expandedVisible) { if (expandedVisible) { setInteracting(StatusBarManager.WINDOW_STATUS_BAR, true); @@ -2915,8 +2910,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { protected boolean mDeviceInteractive; - protected boolean mVisible; - protected DevicePolicyManager mDevicePolicyManager; private final PowerManager mPowerManager; protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @@ -3034,16 +3027,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { afterKeyguardGone); } - private void onShadeVisibilityChanged(boolean visible) { - if (mVisible != visible) { - mVisible = visible; - if (visible) { - DejankUtils.notifyRendererOfExpensiveFrame( - getNotificationShadeWindowView(), "onShadeVisibilityChanged"); - } - } - } - private void clearNotificationEffects() { try { mBarService.clearNotificationEffects(); @@ -3202,7 +3185,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { // down on the lockscreen), clear notification LED, vibration, // ringing. // Other transitions are covered in WindowRootViewVisibilityInteractor. - if (mVisible && (newState == StatusBarState.SHADE_LOCKED + if (mWindowRootViewVisibilityInteractor.isLockscreenOrShadeVisible().getValue() + && (newState == StatusBarState.SHADE_LOCKED || mStatusBarStateController.goingToFullShade())) { clearNotificationEffects(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt index b5841a9de150..215f8b1c462f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeControllerImplTest.kt @@ -17,6 +17,7 @@ package com.android.systemui.shade import android.testing.AndroidTestingRunner +import android.testing.TestableLooper.RunWithLooper import android.view.Display import android.view.WindowManager import androidx.test.filters.SmallTest @@ -54,6 +55,7 @@ import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) +@RunWithLooper(setAsMainLooper = true) @SmallTest class ShadeControllerImplTest : SysuiTestCase() { private val executor = FakeExecutor(FakeSystemClock()) |