From b344c542bf422bd0cafab0c8a7ec4a361efe78e7 Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Thu, 13 Oct 2022 20:37:19 +0000 Subject: [PATCH] [SB Refactor] Update the flags to be mobile-specific and wifi-specific. Bug: 238425913 Test: Verify I can enable just the new wifi icon or just the new mobile icons Change-Id: I1606b4355c949a12b2e65b023338ac39dee3e3bf --- .../src/com/android/systemui/flags/Flags.java | 20 ++++++++++-- .../phone/StatusBarIconController.java | 10 +++--- .../phone/StatusBarIconControllerImpl.java | 8 ++--- .../pipeline/StatusBarPipelineFlags.kt | 32 +++++++------------ .../viewmodel/LocationBasedWifiViewModel.kt | 2 +- 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.java b/packages/SystemUI/src/com/android/systemui/flags/Flags.java index 027187c889b43..d0f731622bf16 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.java +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.java @@ -207,14 +207,30 @@ public class Flags { public static final ReleasedFlag STATUS_BAR_LETTERBOX_APPEARANCE = new ReleasedFlag(603, false); - // TODO(b/254512623): Tracking Bug + /** + * @deprecated replaced by mobile and wifi specific flags. + * + * TODO(b/254512623): Tracking Bug + */ + @Deprecated public static final UnreleasedFlag NEW_STATUS_BAR_PIPELINE_BACKEND = new UnreleasedFlag(604, false); - // TODO(b/254512660): Tracking Bug + /** + * @deprecated replaced by mobile and wifi specific flags. + * + * TODO(b/254512660): Tracking Bug + */ + @Deprecated public static final UnreleasedFlag NEW_STATUS_BAR_PIPELINE_FRONTEND = new UnreleasedFlag(605, false); + public static final UnreleasedFlag NEW_STATUS_BAR_MOBILE_ICONS = + new UnreleasedFlag(606, false); + + public static final UnreleasedFlag NEW_STATUS_BAR_WIFI_ICON = + new UnreleasedFlag(607, false); + /***************************************/ // 700 - dialer/calls // TODO(b/254512734): Tracking Bug diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java index ece7ee0ec98a4..86f6ff850409c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java @@ -372,7 +372,7 @@ public interface StatusBarIconController { mIconSize = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.status_bar_icon_size); - if (statusBarPipelineFlags.isNewPipelineFrontendEnabled()) { + if (statusBarPipelineFlags.useNewMobileIcons()) { // This starts the flow for the new pipeline, and will notify us of changes mMobileIconsViewModel = mobileUiAdapter.createMobileIconsViewModel(); MobileIconsBinder.bind(mGroup, mMobileIconsViewModel); @@ -451,7 +451,7 @@ public interface StatusBarIconController { @VisibleForTesting protected StatusIconDisplayable addWifiIcon(int index, String slot, WifiIconState state) { final BaseStatusBarFrameLayout view; - if (mStatusBarPipelineFlags.isNewPipelineFrontendEnabled()) { + if (mStatusBarPipelineFlags.useNewWifiIcon()) { view = onCreateModernStatusBarWifiView(slot); // When [ModernStatusBarWifiView] is created, it will automatically apply the // correct view state so we don't need to call applyWifiState. @@ -474,9 +474,9 @@ public interface StatusBarIconController { String slot, MobileIconState state ) { - if (mStatusBarPipelineFlags.isNewPipelineFrontendEnabled()) { + if (mStatusBarPipelineFlags.useNewMobileIcons()) { throw new IllegalStateException("Attempting to add a mobile icon while the new " - + "pipeline is enabled is not supported"); + + "icons are enabled is not supported"); } // Use the `subId` field as a key to query for the correct context @@ -497,7 +497,7 @@ public interface StatusBarIconController { String slot, int subId ) { - if (!mStatusBarPipelineFlags.isNewPipelineFrontendEnabled()) { + if (!mStatusBarPipelineFlags.useNewMobileIcons()) { throw new IllegalStateException("Attempting to add a mobile icon using the new" + "pipeline, but the enabled flag is false."); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java index e106b9e327ef4..31e960ad7d696 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconControllerImpl.java @@ -224,9 +224,9 @@ public class StatusBarIconControllerImpl implements Tunable, */ @Override public void setMobileIcons(String slot, List iconStates) { - if (mStatusBarPipelineFlags.isNewPipelineFrontendEnabled()) { + if (mStatusBarPipelineFlags.useNewMobileIcons()) { Log.d(TAG, "ignoring old pipeline callbacks, because the new " - + "pipeline frontend is enabled"); + + "icons are enabled"); return; } Slot mobileSlot = mStatusBarIconList.getSlot(slot); @@ -249,9 +249,9 @@ public class StatusBarIconControllerImpl implements Tunable, @Override public void setNewMobileIconSubIds(List subIds) { - if (!mStatusBarPipelineFlags.isNewPipelineFrontendEnabled()) { + if (!mStatusBarPipelineFlags.useNewMobileIcons()) { Log.d(TAG, "ignoring new pipeline callback, " - + "since the frontend is disabled"); + + "since the new icons are disabled"); return; } Slot mobileSlot = mStatusBarIconList.getSlot("mobile"); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/StatusBarPipelineFlags.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/StatusBarPipelineFlags.kt index 9b8b6434827ed..06cd12dd1a0d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/StatusBarPipelineFlags.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/StatusBarPipelineFlags.kt @@ -24,29 +24,19 @@ import javax.inject.Inject /** All flagging methods related to the new status bar pipeline (see b/238425913). */ @SysUISingleton class StatusBarPipelineFlags @Inject constructor(private val featureFlags: FeatureFlags) { - /** - * Returns true if we should run the new pipeline backend. - * - * The new pipeline backend hooks up to all our external callbacks, logs those callback inputs, - * and logs the output state. - */ - fun isNewPipelineBackendEnabled(): Boolean = - featureFlags.isEnabled(Flags.NEW_STATUS_BAR_PIPELINE_BACKEND) + /** 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) + + /** 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) + + // TODO(b/238425913): Add flags to only run the mobile backend or wifi backend so we get the + // logging without getting the UI effects. /** - * Returns true if we should run the new pipeline frontend *and* backend. - * - * The new pipeline frontend will use the outputted state from the new backend and will make the - * correct changes to the UI. - */ - fun isNewPipelineFrontendEnabled(): Boolean = - isNewPipelineBackendEnabled() && - featureFlags.isEnabled(Flags.NEW_STATUS_BAR_PIPELINE_FRONTEND) - - /** - * Returns true if we should apply some coloring to icons that were rendered with the new + * Returns true if we should apply some coloring to the wifi icon that was rendered with the new * pipeline to help with debugging. */ - // For now, just always apply the debug coloring if we've enabled frontend rendering. - fun useNewPipelineDebugColoring(): Boolean = isNewPipelineFrontendEnabled() + // For now, just always apply the debug coloring if we've enabled the new icon. + fun useWifiDebugColoring(): Boolean = useNewWifiIcon() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/LocationBasedWifiViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/LocationBasedWifiViewModel.kt index e23f8c7e97e07..cc6a375c40f19 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/LocationBasedWifiViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/LocationBasedWifiViewModel.kt @@ -48,7 +48,7 @@ abstract class LocationBasedWifiViewModel( /** The color that should be used to tint the icon. */ val tint: Flow = flowOf( - if (statusBarPipelineFlags.useNewPipelineDebugColoring()) { + if (statusBarPipelineFlags.useWifiDebugColoring()) { debugTint } else { DEFAULT_TINT