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

Commit ad742748 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB Refactor] Define flags that allow us to run the backend without

updating the UI.

Bug: 238425913
Test: set the _BACKEND flags on and verify that we get the logs but that
the icon comes from the old system
Test: set the _BACKEND flags off and verify that we don't get any logs
from the new system
Test: set the USE_NEW_ICONS flags on and verify that the icon comes from
the new system
Test: statusbar.pipeline tests

Change-Id: I7125da88dbb9da52fc8b22bb9ff34af0c13e290d
parent c1c24a6a
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -170,10 +170,18 @@ object Flags {
    @Deprecated("Replaced by mobile and wifi specific flags.")
    @Deprecated("Replaced by mobile and wifi specific flags.")
    val NEW_STATUS_BAR_PIPELINE_FRONTEND = UnreleasedFlag(605, teamfood = false)
    val NEW_STATUS_BAR_PIPELINE_FRONTEND = UnreleasedFlag(605, teamfood = false)


    // TODO(b/256614753): Tracking Bug
    val NEW_STATUS_BAR_MOBILE_ICONS = UnreleasedFlag(606)
    val NEW_STATUS_BAR_MOBILE_ICONS = UnreleasedFlag(606)


    // TODO(b/256614210): Tracking Bug
    val NEW_STATUS_BAR_WIFI_ICON = UnreleasedFlag(607)
    val NEW_STATUS_BAR_WIFI_ICON = UnreleasedFlag(607)


    // TODO(b/256614751): Tracking Bug
    val NEW_STATUS_BAR_MOBILE_ICONS_BACKEND = UnreleasedFlag(608)

    // TODO(b/256613548): Tracking Bug
    val NEW_STATUS_BAR_WIFI_ICON_BACKEND = UnreleasedFlag(609)

    // 700 - dialer/calls
    // 700 - dialer/calls
    // TODO(b/254512734): Tracking Bug
    // TODO(b/254512734): Tracking Bug
    val ONGOING_CALL_STATUS_BAR_CHIP = ReleasedFlag(700)
    val ONGOING_CALL_STATUS_BAR_CHIP = ReleasedFlag(700)
+6 −3
Original line number Original line Diff line number Diff line
@@ -382,15 +382,18 @@ public interface StatusBarIconController {
            mIconSize = mContext.getResources().getDimensionPixelSize(
            mIconSize = mContext.getResources().getDimensionPixelSize(
                    com.android.internal.R.dimen.status_bar_icon_size);
                    com.android.internal.R.dimen.status_bar_icon_size);


            if (statusBarPipelineFlags.useNewMobileIcons()) {
            if (statusBarPipelineFlags.runNewMobileIconsBackend()) {
                // This starts the flow for the new pipeline, and will notify us of changes
                // This starts the flow for the new pipeline, and will notify us of changes if
                // {@link StatusBarPipelineFlags#useNewMobileIcons} is also true.
                mMobileIconsViewModel = mobileUiAdapter.createMobileIconsViewModel();
                mMobileIconsViewModel = mobileUiAdapter.createMobileIconsViewModel();
                MobileIconsBinder.bind(mGroup, mMobileIconsViewModel);
                MobileIconsBinder.bind(mGroup, mMobileIconsViewModel);
            } else {
            } else {
                mMobileIconsViewModel = null;
                mMobileIconsViewModel = null;
            }
            }


            if (statusBarPipelineFlags.useNewWifiIcon()) {
            if (statusBarPipelineFlags.runNewWifiIconBackend()) {
                // This starts the flow for the new pipeline, and will notify us of changes if
                // {@link StatusBarPipelineFlags#useNewWifiIcon} is also true.
                mWifiViewModel = wifiUiAdapter.bindGroup(mGroup, location);
                mWifiViewModel = wifiUiAdapter.bindGroup(mGroup, location);
            } else {
            } else {
                mWifiViewModel = null;
                mWifiViewModel = null;
+17 −2
Original line number Original line Diff line number Diff line
@@ -27,11 +27,26 @@ class StatusBarPipelineFlags @Inject constructor(private val featureFlags: Featu
    /** True if we should display the mobile icons using the new status bar data pipeline. */
    /** True if we should display the mobile icons using the new status bar data pipeline. */
    fun useNewMobileIcons(): Boolean = featureFlags.isEnabled(Flags.NEW_STATUS_BAR_MOBILE_ICONS)
    fun useNewMobileIcons(): Boolean = featureFlags.isEnabled(Flags.NEW_STATUS_BAR_MOBILE_ICONS)


    /**
     * True if we should run the new mobile icons backend to get the logging.
     *
     * Does *not* affect whether we render the mobile icons using the new backend data. See
     * [useNewMobileIcons] for that.
     */
    fun runNewMobileIconsBackend(): Boolean =
        featureFlags.isEnabled(Flags.NEW_STATUS_BAR_MOBILE_ICONS_BACKEND) || useNewMobileIcons()

    /** True if we should display the wifi icon using the new status bar data pipeline. */
    /** True if we should display the wifi icon using the new status bar data pipeline. */
    fun useNewWifiIcon(): Boolean = featureFlags.isEnabled(Flags.NEW_STATUS_BAR_WIFI_ICON)
    fun useNewWifiIcon(): Boolean = featureFlags.isEnabled(Flags.NEW_STATUS_BAR_WIFI_ICON)


    // TODO(b/238425913): Add flags to only run the mobile backend or wifi backend so we get the
    /**
    //   logging without getting the UI effects.
     * True if we should run the new wifi icon backend to get the logging.
     *
     * Does *not* affect whether we render the wifi icon using the new backend data. See
     * [useNewWifiIcon] for that.
     */
    fun runNewWifiIconBackend(): Boolean =
        featureFlags.isEnabled(Flags.NEW_STATUS_BAR_WIFI_ICON_BACKEND) || useNewWifiIcon()


    /**
    /**
     * Returns true if we should apply some coloring to the wifi icon that was rendered with the new
     * Returns true if we should apply some coloring to the wifi icon that was rendered with the new
+10 −2
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.phone.StatusBarIconController.IconManager
import com.android.systemui.statusbar.phone.StatusBarIconController.IconManager
import com.android.systemui.statusbar.pipeline.StatusBarPipelineFlags
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MobileIconsViewModel
import javax.inject.Inject
import javax.inject.Inject
@@ -50,6 +51,7 @@ constructor(
    private val iconController: StatusBarIconController,
    private val iconController: StatusBarIconController,
    private val iconsViewModelFactory: MobileIconsViewModel.Factory,
    private val iconsViewModelFactory: MobileIconsViewModel.Factory,
    @Application scope: CoroutineScope,
    @Application scope: CoroutineScope,
    private val statusBarPipelineFlags: StatusBarPipelineFlags,
) {
) {
    private val mobileSubIds: Flow<List<Int>> =
    private val mobileSubIds: Flow<List<Int>> =
        interactor.filteredSubscriptions.mapLatest { infos ->
        interactor.filteredSubscriptions.mapLatest { infos ->
@@ -66,9 +68,15 @@ constructor(
    private val mobileSubIdsState: StateFlow<List<Int>> =
    private val mobileSubIdsState: StateFlow<List<Int>> =
        mobileSubIds
        mobileSubIds
            .onEach {
            .onEach {
                // Only notify the icon controller if we want to *render* the new icons.
                // Note that this flow may still run if
                // [statusBarPipelineFlags.runNewMobileIconsBackend] is true because we may want to
                // get the logging data without rendering.
                if (statusBarPipelineFlags.useNewMobileIcons()) {
                    // Notify the icon controller here so that it knows to add icons
                    // Notify the icon controller here so that it knows to add icons
                    iconController.setNewMobileIconSubIds(it)
                    iconController.setNewMobileIconSubIds(it)
                }
                }
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), listOf())
            .stateIn(scope, SharingStarted.WhileSubscribed(), listOf())


    /**
    /**
+7 −1
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.phone.StatusBarLocation
import com.android.systemui.statusbar.phone.StatusBarLocation
import com.android.systemui.statusbar.pipeline.StatusBarPipelineFlags
import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.LocationBasedWifiViewModel
import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.LocationBasedWifiViewModel
import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.WifiViewModel
import com.android.systemui.statusbar.pipeline.wifi.ui.viewmodel.WifiViewModel
import javax.inject.Inject
import javax.inject.Inject
@@ -43,6 +44,7 @@ class WifiUiAdapter
constructor(
constructor(
    private val iconController: StatusBarIconController,
    private val iconController: StatusBarIconController,
    private val wifiViewModel: WifiViewModel,
    private val wifiViewModel: WifiViewModel,
    private val statusBarPipelineFlags: StatusBarPipelineFlags,
) {
) {
    /**
    /**
     * Binds the container for all the status bar icons to a view model, so that we inflate the wifi
     * Binds the container for all the status bar icons to a view model, so that we inflate the wifi
@@ -67,7 +69,11 @@ constructor(
            repeatOnLifecycle(Lifecycle.State.STARTED) {
            repeatOnLifecycle(Lifecycle.State.STARTED) {
                launch {
                launch {
                    locationViewModel.wifiIcon.collect { wifiIcon ->
                    locationViewModel.wifiIcon.collect { wifiIcon ->
                        if (wifiIcon != null) {
                        // Only notify the icon controller if we want to *render* the new icon.
                        // Note that this flow may still run if
                        // [statusBarPipelineFlags.runNewWifiIconBackend] is true because we may
                        // want to get the logging data without rendering.
                        if (wifiIcon != null && statusBarPipelineFlags.useNewWifiIcon()) {
                            iconController.setNewWifiIcon()
                            iconController.setNewWifiIcon()
                        }
                        }
                    }
                    }
Loading