Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 576786cf authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes I945cb746,I1c5784bc into main

* changes:
  [CS] Have ShadeController notify DejankUtils not CentralSurfaces.
  [CS] Fetch LS/shade visible status from interactor to clear notif effect
parents d2b850dd a523d505
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -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);
    }
+14 −1
Original line number Diff line number Diff line
@@ -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) {
+4 −20
Original line number Diff line number Diff line
@@ -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.
@@ -1087,11 +1087,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
     */    @VisibleForTesting
    void initShadeVisibilityListener() {
        mShadeController.setVisibilityListener(new ShadeController.ShadeVisibilityListener() {
            @Override
            public void visibilityChanged(boolean visible) {
                onShadeVisibilityChanged(visible);
            }

            @Override
            public void expandedVisibleChanged(boolean expandedVisible) {
                if (expandedVisible) {
@@ -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();
                    }
+2 −0
Original line number Diff line number Diff line
@@ -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())