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

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

Merge "[CS] Move LkscrnShadeTransitionCtlr to ShadeInteractor#isShadeEnabled." into udc-qpr-dev

parents f362367f 130bf1e2
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -17,38 +17,52 @@
package com.android.systemui.shade.domain.interactor

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.data.repository.KeyguardRepository
import com.android.systemui.statusbar.disableflags.data.repository.DisableFlagsRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.UserSetupRepository
import com.android.systemui.statusbar.policy.DeviceProvisionedController
import com.android.systemui.user.domain.interactor.UserInteractor
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn

/** Business logic for shade interactions. */
@SysUISingleton
class ShadeInteractor
@Inject
constructor(
    @Application scope: CoroutineScope,
    disableFlagsRepository: DisableFlagsRepository,
    keyguardRepository: KeyguardRepository,
    userSetupRepository: UserSetupRepository,
    deviceProvisionedController: DeviceProvisionedController,
    userInteractor: UserInteractor,
) {
    /** Emits true if the shade is currently allowed and false otherwise. */
    val isShadeEnabled: StateFlow<Boolean> =
        disableFlagsRepository.disableFlags
            .map { it.isShadeEnabled() }
            .stateIn(scope, SharingStarted.Eagerly, initialValue = false)

    /** Emits true if the shade can be expanded from QQS to QS and false otherwise. */
    val isExpandToQsEnabled: Flow<Boolean> =
        combine(
            disableFlagsRepository.disableFlags,
            isShadeEnabled,
            keyguardRepository.isDozing,
            userSetupRepository.isUserSetupFlow,
        ) { disableFlags, isDozing, isUserSetup ->
        ) { disableFlags, isShadeEnabled, isDozing, isUserSetup ->
            deviceProvisionedController.isDeviceProvisioned &&
                // Disallow QS during setup if it's a simple user switcher. (The user intends to
                // use the lock screen user switcher, QS is not needed.)
                (isUserSetup || !userInteractor.isSimpleUserSwitcher) &&
                disableFlags.isShadeEnabled() &&
                isShadeEnabled &&
                disableFlags.isQuickSettingsEnabled() &&
                !isDozing
        }
+3 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.shade.ShadeViewController
import com.android.systemui.shade.data.repository.ShadeRepository
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
@@ -76,6 +77,7 @@ class LockscreenShadeTransitionController @Inject constructor(
    dumpManager: DumpManager,
    qsTransitionControllerFactory: LockscreenShadeQsTransitionController.Factory,
    private val shadeRepository: ShadeRepository,
    private val shadeInteractor: ShadeInteractor,
    private val powerInteractor: PowerInteractor,
) : Dumpable {
    private var pulseHeight: Float = 0f
@@ -558,7 +560,7 @@ class LockscreenShadeTransitionController @Inject constructor(
        animationHandler: ((Long) -> Unit)? = null,
        cancelAction: Runnable? = null
    ) {
        if (centralSurfaces.isShadeDisabled) {
        if (!shadeInteractor.isShadeEnabled.value) {
            cancelAction?.run()
            logger.logShadeDisabledOnGoToLockedShade()
            return
+0 −10
Original line number Diff line number Diff line
@@ -203,8 +203,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {

    int getStatusBarHeight();

    boolean isShadeDisabled();

    boolean isLaunchingActivityOverLockscreen();

    void onKeyguardViewManagerStatesUpdated();
@@ -380,14 +378,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {

    void resendMessage(Object msg);

    int getDisabled1();

    void setDisabled1(int disabled);

    int getDisabled2();

    void setDisabled2(int disabled);

    void setLastCameraLaunchSource(int source);

    void setLaunchCameraOnFinishedGoingToSleep(boolean launch);
+8 −13
Original line number Diff line number Diff line
@@ -111,6 +111,9 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
    private static final VibrationAttributes HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES =
            VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK);

    private int mDisabled1;
    private int mDisabled2;

    @Inject
    CentralSurfacesCommandQueueCallbacks(
            CentralSurfaces centralSurfaces,
@@ -256,22 +259,14 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba
            return;
        }

        int state2BeforeAdjustment = state2;
        state2 = mRemoteInputQuickSettingsDisabler.adjustDisableFlags(state2);
        Log.d(CentralSurfaces.TAG,
                mDisableFlagsLogger.getDisableFlagsString(
                        /* new= */ new DisableFlagsLogger.DisableState(
                                state1, state2BeforeAdjustment),
                        /* newStateAfterLocalModification= */ new DisableFlagsLogger.DisableState(
                                state1, state2)));

        final int old1 = mCentralSurfaces.getDisabled1();
        final int old1 = mDisabled1;
        final int diff1 = state1 ^ old1;
        mCentralSurfaces.setDisabled1(state1);
        mDisabled1 = state1;

        final int old2 = mCentralSurfaces.getDisabled2();
        state2 = mRemoteInputQuickSettingsDisabler.adjustDisableFlags(state2);
        final int old2 = mDisabled2;
        final int diff2 = state2 ^ old2;
        mCentralSurfaces.setDisabled2(state2);
        mDisabled2 = state2;

        if ((diff1 & StatusBarManager.DISABLE_EXPAND) != 0) {
            if ((state1 & StatusBarManager.DISABLE_EXPAND) != 0) {
+0 −30
Original line number Diff line number Diff line
@@ -361,26 +361,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        mMessageRouter.sendMessage(msg);
    }

    @Override
    public int getDisabled1() {
        return mDisabled1;
    }

    @Override
    public void setDisabled1(int disabled) {
        mDisabled1 = disabled;
    }

    @Override
    public int getDisabled2() {
        return mDisabled2;
    }

    @Override
    public void setDisabled2(int disabled) {
        mDisabled2 = disabled;
    }

    @Override
    public void setLastCameraLaunchSource(int source) {
        mLastCameraLaunchSource = source;
@@ -527,11 +507,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {

    private CentralSurfacesComponent mCentralSurfacesComponent;

    // Flags for disabling the status bar
    // Two variables because the first one evidently ran out of room for new flags.
    private int mDisabled1 = 0;
    private int mDisabled2 = 0;

    /**
     * This keeps track of whether we have (or haven't) registered the predictive back callback.
     * Since we can have visible -> visible transitions, we need to avoid
@@ -1721,11 +1696,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        return mStatusBarWindowController.getStatusBarHeight();
    }

    @Override
    public boolean isShadeDisabled() {
        return (mDisabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) != 0;
    }

    private void updateReportRejectedTouchVisibility() {
        if (mReportRejectedTouch == null) {
            return;
Loading