diff --git a/packages/SystemUI/plugin/src/com/android/systemui/flags/Flags.java b/packages/SystemUI/plugin/src/com/android/systemui/flags/Flags.java index 17b13a235805a..fa60bc9d747dd 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/flags/Flags.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/flags/Flags.java @@ -23,14 +23,74 @@ import java.util.Map; /** * List of {@link Flag} objects for use in SystemUI. * - * Flag Ids are integers. They must be unique. + * Flag Ids are integers. + * Ids must be unique. This is enforced in a unit test. + * Ids need not be sequential. Flags can "claim" a chunk of ids for flags in related featurs with + * a comment. This is purely for organizational purposes. * * On public release builds, flags will always return their default value. There is no way to * change their value on release builds. + * + * See {@link FeatureFlagManager} for instructions on flipping the flags via adb. */ public class Flags { - public static final BooleanFlag THE_FIRST_FLAG = new BooleanFlag(1, false); + public static final BooleanFlag TEAMFOOD = new BooleanFlag(1, false); + /***************************************/ + // 100 - notification + public static final BooleanFlag NEW_NOTIFICATION_PIPELINE = + new BooleanFlag(100, true); + + public static final BooleanFlag NEW_NOTIFICATION_PIPELINE_RENDERING = + new BooleanFlag(101, false); + + public static final BooleanFlag NOTIFICATION_UPDATES = + new BooleanFlag(102, true); + + /***************************************/ + // 200 - keyguard/lockscreen + public static final BooleanFlag KEYGUARD_LAYOUT = + new BooleanFlag(200, true); + + public static final BooleanFlag LOCKSCREEN_ANIMATIONS = + new BooleanFlag(201, true); + + public static final BooleanFlag NEW_UNLOCK_SWIPE_ANIMATION = + new BooleanFlag(202, true); + + /***************************************/ + // 300 - power menu + public static final BooleanFlag POWER_MENU_LITE = + new BooleanFlag(300, true); + + /***************************************/ + // 400 - smartspace + public static final BooleanFlag SMARTSPACE_DEDUPING = + new BooleanFlag(400, true); + + public static final BooleanFlag SMARTSPACE_SHARED_ELEMENT_TRANSITION_ENABLED = + new BooleanFlag(401, false); + + /***************************************/ + // 500 - quick settings + public static final BooleanFlag NEW_USER_SWITCHER = + new BooleanFlag(500, true); + + /***************************************/ + // 600- status bar + public static final BooleanFlag COMBINED_STATUS_BAR_SIGNAL_ICONS = + new BooleanFlag(501, false); + + /***************************************/ + // 700 - dialer/calls + public static final BooleanFlag ONGOING_CALL_STATUS_BAR_CHIP = + new BooleanFlag(600, true); + + public static final BooleanFlag ONGOING_CALL_IN_IMMERSIVE = + new BooleanFlag(601, true); + + public static final BooleanFlag ONGOING_CALL_IN_IMMERSIVE_CHIP_TAP = + new BooleanFlag(602, true); // Pay no attention to the reflection behind the curtain. // ========================== Curtain ========================== diff --git a/packages/SystemUI/res/values/flags.xml b/packages/SystemUI/res/values/flags.xml index db7a0ec89a4e0..2a70645e49ec0 100644 --- a/packages/SystemUI/res/values/flags.xml +++ b/packages/SystemUI/res/values/flags.xml @@ -18,45 +18,18 @@ false - true - false - true - true false - - true - - - true - false - - false - - true - false - true - - true - - true - false - true - - false - - true diff --git a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java index 2e30e7f92e2c9..5eff0e67640fd 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java +++ b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java @@ -33,7 +33,7 @@ import javax.inject.Inject; /** * Class to manage simple DeviceConfig-based feature flags. * - * See {@link FeatureFlagReader} for instructions on defining and flipping flags. + * See {@link Flags} for instructions on defining new flags. */ @SysUISingleton public class FeatureFlags { @@ -87,58 +87,61 @@ public class FeatureFlags { } public boolean isNewNotifPipelineEnabled() { - return mFlagReader.isEnabled(R.bool.flag_notification_pipeline2); + return isEnabled(Flags.NEW_NOTIFICATION_PIPELINE); } public boolean isNewNotifPipelineRenderingEnabled() { - return mFlagReader.isEnabled(R.bool.flag_notification_pipeline2_rendering); + return isEnabled(Flags.NEW_NOTIFICATION_PIPELINE_RENDERING); } /** */ public boolean useNewLockscreenAnimations() { - return mFlagReader.isEnabled(R.bool.flag_lockscreen_animations); + return isEnabled(Flags.LOCKSCREEN_ANIMATIONS); } public boolean isPeopleTileEnabled() { + // TODO(b/202860494): different resource overlays have different values. return mFlagReader.isEnabled(R.bool.flag_conversations); } public boolean isMonetEnabled() { + // TODO(b/202860494): used in wallpaper picker. Always true, maybe delete. return mFlagReader.isEnabled(R.bool.flag_monet); } public boolean isPMLiteEnabled() { - return mFlagReader.isEnabled(R.bool.flag_pm_lite); + return isEnabled(Flags.POWER_MENU_LITE); } public boolean isChargingRippleEnabled() { + // TODO(b/202860494): different resource overlays have different values. return mFlagReader.isEnabled(R.bool.flag_charging_ripple); } public boolean isOngoingCallStatusBarChipEnabled() { - return mFlagReader.isEnabled(R.bool.flag_ongoing_call_status_bar_chip); + return isEnabled(Flags.ONGOING_CALL_STATUS_BAR_CHIP); } public boolean isOngoingCallInImmersiveEnabled() { - return isOngoingCallStatusBarChipEnabled() - && mFlagReader.isEnabled(R.bool.flag_ongoing_call_in_immersive); + return isOngoingCallStatusBarChipEnabled() && isEnabled(Flags.ONGOING_CALL_IN_IMMERSIVE); } public boolean isOngoingCallInImmersiveChipTapEnabled() { return isOngoingCallInImmersiveEnabled() - && mFlagReader.isEnabled(R.bool.flag_ongoing_call_in_immersive_chip_tap); + && isEnabled(Flags.ONGOING_CALL_IN_IMMERSIVE_CHIP_TAP); } public boolean isSmartspaceEnabled() { + // TODO(b/202860494): different resource overlays have different values. return mFlagReader.isEnabled(R.bool.flag_smartspace); } public boolean isSmartspaceDedupingEnabled() { - return isSmartspaceEnabled() && mFlagReader.isEnabled(R.bool.flag_smartspace_deduping); + return isSmartspaceEnabled() && isEnabled(Flags.SMARTSPACE_DEDUPING); } public boolean isNewKeyguardSwipeAnimationEnabled() { - return mFlagReader.isEnabled(R.bool.flag_new_unlock_swipe_animation); + return isEnabled(Flags.NEW_UNLOCK_SWIPE_ANIMATION); } public boolean isKeyguardQsUserDetailsShortcutEnabled() { @@ -146,12 +149,12 @@ public class FeatureFlags { } public boolean isSmartSpaceSharedElementTransitionEnabled() { - return mFlagReader.isEnabled(R.bool.flag_smartspace_shared_element_transition); + return isEnabled(Flags.SMARTSPACE_SHARED_ELEMENT_TRANSITION_ENABLED); } /** Whether or not to use the provider model behavior for the status bar icons */ public boolean isCombinedStatusBarSignalIconsEnabled() { - return mFlagReader.isEnabled(R.bool.flag_combined_status_bar_signal_icons); + return isEnabled(Flags.COMBINED_STATUS_BAR_SIGNAL_ICONS); } /** System setting for provider model behavior */ @@ -163,7 +166,7 @@ public class FeatureFlags { * Use the new version of the user switcher */ public boolean useNewUserSwitcher() { - return mFlagReader.isEnabled(R.bool.flag_new_user_switcher); + return isEnabled(Flags.NEW_USER_SWITCHER); } /** static method for the system setting */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java index b7d721e1e93fc..3a37fb44b33a7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java @@ -41,8 +41,11 @@ import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; import com.android.internal.annotations.VisibleForTesting; +import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; +import com.android.systemui.flags.FeatureFlags; +import com.android.systemui.flags.Flags; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.statusbar.AlphaOptimizedImageView; import com.android.systemui.statusbar.notification.collection.NotificationEntry; @@ -305,7 +308,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl final int showDismissSetting = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.SHOW_NEW_NOTIF_DISMISS, -1); final boolean newFlowHideShelf = showDismissSetting == -1 - ? mContext.getResources().getBoolean(R.bool.flag_notif_updates) + ? Dependency.get(FeatureFlags.class).isEnabled(Flags.NOTIFICATION_UPDATES) : showDismissSetting == 1; if (newFlowHideShelf) { return; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java index 135b7df4db9ef..1cb5e6267fbf7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManager.java @@ -21,6 +21,8 @@ import android.util.MathUtils; import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; +import com.android.systemui.flags.FeatureFlags; +import com.android.systemui.flags.Flags; import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableView; @@ -39,6 +41,7 @@ public class NotificationRoundnessManager { private final ExpandableView[] mLastInSectionViews; private final ExpandableView[] mTmpFirstInSectionViews; private final ExpandableView[] mTmpLastInSectionViews; + private final FeatureFlags mFeatureFlags; private boolean mExpanded; private HashSet mAnimatedChildren; private Runnable mRoundingChangedCallback; @@ -52,7 +55,10 @@ public class NotificationRoundnessManager { private ExpandableView mViewAfterSwipedView = null; @Inject - NotificationRoundnessManager(NotificationSectionsFeatureManager sectionsFeatureManager) { + NotificationRoundnessManager( + NotificationSectionsFeatureManager sectionsFeatureManager, + FeatureFlags featureFlags) { + mFeatureFlags = featureFlags; int numberOfSections = sectionsFeatureManager.getNumberOfBuckets(); mFirstInSectionViews = new ExpandableView[numberOfSections]; mLastInSectionViews = new ExpandableView[numberOfSections]; @@ -118,9 +124,8 @@ public class NotificationRoundnessManager { void setViewsAffectedBySwipe( ExpandableView viewBefore, ExpandableView viewSwiped, - ExpandableView viewAfter, - boolean cornerAnimationsEnabled) { - if (!cornerAnimationsEnabled) { + ExpandableView viewAfter) { + if (!mFeatureFlags.isEnabled(Flags.NOTIFICATION_UPDATES)) { return; } final boolean animate = true; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 562d7ea60d930..1c05d25d95aa6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -5299,10 +5299,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } } mController.getNoticationRoundessManager() - .setViewsAffectedBySwipe((ExpandableView) viewBefore, + .setViewsAffectedBySwipe( + (ExpandableView) viewBefore, (ExpandableView) viewSwiped, - (ExpandableView) viewAfter, - getResources().getBoolean(R.bool.flag_notif_updates)); + (ExpandableView) viewAfter); updateFirstAndLastBackgroundViews(); requestDisallowInterceptTouchEvent(true); @@ -5314,8 +5314,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable void onSwipeEnd() { updateFirstAndLastBackgroundViews(); mController.getNoticationRoundessManager() - .setViewsAffectedBySwipe(null, null, null, - getResources().getBoolean(R.bool.flag_notif_updates)); + .setViewsAffectedBySwipe(null, null, null); // Round bottom corners for notification right before shelf. mShelf.updateAppearance(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java index d3c1dc9db218b..3c84c0193aacf 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationRoundnessManagerTest.java @@ -32,6 +32,7 @@ import androidx.test.filters.SmallTest; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; +import com.android.systemui.flags.FeatureFlags; import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; @@ -43,6 +44,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; import org.mockito.MockitoAnnotations; import java.util.HashSet; @@ -57,6 +59,8 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase { private Runnable mRoundnessCallback = mock(Runnable.class); private ExpandableNotificationRow mFirst; private ExpandableNotificationRow mSecond; + @Mock + private FeatureFlags mFeatureFlags; private float mSmallRadiusRatio; @Before @@ -66,7 +70,8 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase { mSmallRadiusRatio = resources.getDimension(R.dimen.notification_corner_radius_small) / resources.getDimension(R.dimen.notification_corner_radius); mRoundnessManager = new NotificationRoundnessManager( - new NotificationSectionsFeatureManager(new DeviceConfigProxy(), mContext)); + new NotificationSectionsFeatureManager(new DeviceConfigProxy(), mContext), + mFeatureFlags); allowTestableLooperAsMainThread(); NotificationTestHelper testHelper = new NotificationTestHelper( mContext,