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

Commit f6f1b05b authored by Jeff DeCew's avatar Jeff DeCew
Browse files

For teamfooders, do not collapse the shade when collecting a bugreport from global actions.

Bug: 241419610
Test: CentralSurfacesImplTest
Change-Id: I18d291bf920574866553b208d2d4278e945860fb
parent 5acc7d26
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -308,6 +308,10 @@ public class Flags {
    // 1700 - clipboard
    public static final UnreleasedFlag CLIPBOARD_OVERLAY_REFACTOR = new UnreleasedFlag(1700);

    // 1800 - shade container
    public static final UnreleasedFlag LEAVE_SHADE_OPEN_FOR_BUGREPORT =
            new UnreleasedFlag(1800, true);

    // Pay no attention to the reflection behind the curtain.
    // ========================== Curtain ==========================
    // |                                                           |
+5 −4
Original line number Diff line number Diff line
@@ -1016,8 +1016,9 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
                            Log.w(TAG, "Bugreport handler could not be launched");
                            mIActivityManager.requestInteractiveBugReport();
                        }
                        // Close shade so user sees the activity
                        mCentralSurfacesOptional.ifPresent(CentralSurfaces::collapseShade);
                        // Maybe close shade (depends on a flag) so user sees the activity
                        mCentralSurfacesOptional.ifPresent(
                                CentralSurfaces::collapseShadeForBugreport);
                    } catch (RemoteException e) {
                    }
                }
@@ -1036,8 +1037,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
                mMetricsLogger.action(MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL);
                mUiEventLogger.log(GlobalActionsEvent.GA_BUGREPORT_LONG_PRESS);
                mIActivityManager.requestFullBugReport();
                // Close shade so user sees the activity
                mCentralSurfacesOptional.ifPresent(CentralSurfaces::collapseShade);
                // Maybe close shade (depends on a flag) so user sees the activity
                mCentralSurfacesOptional.ifPresent(CentralSurfaces::collapseShadeForBugreport);
            } catch (RemoteException e) {
            }
            return false;
+3 −0
Original line number Diff line number Diff line
@@ -455,6 +455,9 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn

    void collapseShade();

    /** Collapse the shade, but conditional on a flag specific to the trigger of a bugreport. */
    void collapseShadeForBugreport();

    int getWakefulnessState();

    boolean isScreenFullyOff();
+12 −0
Original line number Diff line number Diff line
@@ -885,6 +885,11 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
            mBubblesOptional.get().setExpandListener(mBubbleExpandListener);
        }

        // Do not restart System UI when the bugreport flag changes.
        mFeatureFlags.addListener(Flags.LEAVE_SHADE_OPEN_FOR_BUGREPORT, event -> {
            event.requestNoRestart();
        });

        mStatusBarSignalPolicy.init();
        mKeyguardIndicationController.init();

@@ -3580,6 +3585,13 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        }
    }

    @Override
    public void collapseShadeForBugreport() {
        if (!mFeatureFlags.isEnabled(Flags.LEAVE_SHADE_OPEN_FOR_BUGREPORT)) {
            collapseShade();
        }
    }

    @VisibleForTesting
    final WakefulnessLifecycle.Observer mWakefulnessObserver = new WakefulnessLifecycle.Observer() {
        @Override
+60 −5
Original line number Diff line number Diff line
@@ -98,7 +98,8 @@ import com.android.systemui.classifier.FalsingManagerFake;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.FakeFeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -271,7 +272,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
    @Mock private OngoingCallController mOngoingCallController;
    @Mock private StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager;
    @Mock private LockscreenShadeTransitionController mLockscreenTransitionController;
    @Mock private FeatureFlags mFeatureFlags;
    @Mock private NotificationVisibilityProvider mVisibilityProvider;
    @Mock private WallpaperManager mWallpaperManager;
    @Mock private IWallpaperManager mIWallpaperManager;
@@ -296,9 +296,10 @@ public class CentralSurfacesImplTest extends SysuiTestCase {

    private ShadeController mShadeController;
    private final FakeSystemClock mFakeSystemClock = new FakeSystemClock();
    private FakeExecutor mMainExecutor = new FakeExecutor(mFakeSystemClock);
    private FakeExecutor mUiBgExecutor = new FakeExecutor(mFakeSystemClock);
    private InitController mInitController = new InitController();
    private final FakeExecutor mMainExecutor = new FakeExecutor(mFakeSystemClock);
    private final FakeExecutor mUiBgExecutor = new FakeExecutor(mFakeSystemClock);
    private final FakeFeatureFlags mFeatureFlags = new FakeFeatureFlags();
    private final InitController mInitController = new InitController();
    private final DumpManager mDumpManager = new DumpManager();

    @Before
@@ -1016,6 +1017,60 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
        verify(mStatusBarKeyguardViewManager).updateResources();
    }

    @Test
    public void collapseShade_callsAnimateCollapsePanels_whenExpanded() {
        // GIVEN the shade is expanded
        mCentralSurfaces.setPanelExpanded(true);
        mCentralSurfaces.setBarStateForTest(StatusBarState.SHADE);

        // WHEN collapseShade is called
        mCentralSurfaces.collapseShade();

        // VERIFY that animateCollapsePanels is called
        verify(mShadeController).animateCollapsePanels();
    }

    @Test
    public void collapseShade_doesNotCallAnimateCollapsePanels_whenCollapsed() {
        // GIVEN the shade is collapsed
        mCentralSurfaces.setPanelExpanded(false);
        mCentralSurfaces.setBarStateForTest(StatusBarState.SHADE);

        // WHEN collapseShade is called
        mCentralSurfaces.collapseShade();

        // VERIFY that animateCollapsePanels is NOT called
        verify(mShadeController, never()).animateCollapsePanels();
    }

    @Test
    public void collapseShadeForBugReport_callsAnimateCollapsePanels_whenFlagDisabled() {
        // GIVEN the shade is expanded & flag enabled
        mCentralSurfaces.setPanelExpanded(true);
        mCentralSurfaces.setBarStateForTest(StatusBarState.SHADE);
        mFeatureFlags.set(Flags.LEAVE_SHADE_OPEN_FOR_BUGREPORT, false);

        // WHEN collapseShadeForBugreport is called
        mCentralSurfaces.collapseShadeForBugreport();

        // VERIFY that animateCollapsePanels is called
        verify(mShadeController).animateCollapsePanels();
    }

    @Test
    public void collapseShadeForBugReport_doesNotCallAnimateCollapsePanels_whenFlagEnabled() {
        // GIVEN the shade is expanded & flag enabled
        mCentralSurfaces.setPanelExpanded(true);
        mCentralSurfaces.setBarStateForTest(StatusBarState.SHADE);
        mFeatureFlags.set(Flags.LEAVE_SHADE_OPEN_FOR_BUGREPORT, true);

        // WHEN collapseShadeForBugreport is called
        mCentralSurfaces.collapseShadeForBugreport();

        // VERIFY that animateCollapsePanels is called
        verify(mShadeController, never()).animateCollapsePanels();
    }

    @Test
    public void deviceStateChange_unfolded_shadeOpen_setsLeaveOpenOnKeyguardHide() {
        when(mKeyguardStateController.isShowing()).thenReturn(false);