Loading packages/SystemUI/src/com/android/systemui/flags/RefactorFlag.kt +12 −13 Original line number Diff line number Diff line Loading @@ -22,11 +22,11 @@ import com.android.systemui.Dependency /** * This class promotes best practices for flag guarding System UI view refactors. * * [isEnabled] allows changing an implementation. * * [assertDisabled] allows authors to flag code as being "dead" when the flag gets enabled and * * [assertInLegacyMode] allows authors to flag code as being "dead" when the flag gets enabled and * ensure that it is not being invoked accidentally in the post-flag refactor. * * [expectEnabled] allows authors to guard new code with a "safe" alternative when invoked on * flag-disabled builds, but with a check that should crash eng builds or tests when the * expectation is violated. * * [isUnexpectedlyInLegacyMode] allows authors to guard new code with a "safe" alternative when * invoked on flag-disabled builds, but with a check that should crash eng builds or tests when * the expectation is violated. * * The constructors require that you provide a [FeatureFlags] instance. If you're using this in a * View class, it's acceptable to ue the [forView] constructor methods, which do not require one, Loading Loading @@ -60,13 +60,13 @@ private constructor( * Example usage: * ``` * public void setController(NotificationShelfController notificationShelfController) { * mShelfRefactor.assertDisabled(); * mShelfRefactor.assertInLegacyMode(); * mController = notificationShelfController; * } * ```` */ fun assertDisabled() = check(!isEnabled) { "Code path not supported when $flagName is enabled." } fun assertInLegacyMode() = check(!isEnabled) { "Legacy code path not supported when $flagName is enabled." } /** * Called to ensure code is only run when the flag is enabled. This protects users from the Loading @@ -76,18 +76,17 @@ private constructor( * Example usage: * ``` * public void setShelfIcons(NotificationIconContainer icons) { * if (mShelfRefactor.expectEnabled()) { * if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; * mShelfIcons = icons; * } * } * ``` */ fun expectEnabled(): Boolean { fun isUnexpectedlyInLegacyMode(): Boolean { if (!isEnabled) { val message = "Code path not supported when $flagName is disabled." val message = "New code path expects $flagName to be enabled." Log.wtf(TAG, message, Exception(message)) } return isEnabled return !isEnabled } companion object { Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +7 −7 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St public void bind(AmbientState ambientState, NotificationStackScrollLayoutController hostLayoutController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mAmbientState = ambientState; mHostLayoutController = hostLayoutController; hostLayoutController.setOnNotificationRemovedListener((child, isTransferInProgress) -> { Loading @@ -143,7 +143,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout, NotificationRoundnessManager roundnessManager) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mAmbientState = ambientState; mHostLayout = hostLayout; mRoundnessManager = roundnessManager; Loading Loading @@ -964,7 +964,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St @Override public void onStateChanged(int newState) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mStatusBarState = newState; updateInteractiveness(); } Loading Loading @@ -1022,17 +1022,17 @@ public class NotificationShelf extends ActivatableNotificationView implements St } public void setController(NotificationShelfController notificationShelfController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mController = notificationShelfController; } public void setCanModifyColorOfNotifications(boolean canModifyColorOfNotifications) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mCanModifyColorOfNotifications = canModifyColorOfNotifications; } public void setCanInteract(boolean canInteract) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mCanInteract = canInteract; updateInteractiveness(); } Loading @@ -1050,7 +1050,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St } public void requestRoundnessResetFor(ExpandableView child) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; child.requestRoundnessReset(SHELF_SCROLL); } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconAreaControllerViewBinderWrapperImpl.kt +10 −11 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ constructor( NotificationShelfViewBinderWrapperControllerImpl.unsupported override fun setShelfIcons(icons: NotificationIconContainer) { if (shelfRefactor.expectEnabled()) { if (shelfRefactor.isUnexpectedlyInLegacyMode()) return NotificationIconContainerViewBinder.bind( icons, shelfIconsViewModel, Loading @@ -178,7 +178,6 @@ constructor( ) shelfIcons = icons } } override fun onDensityOrFontScaleChanged(context: Context) { updateIconLayoutParams(context) Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +4 −4 Original line number Diff line number Diff line Loading @@ -2735,7 +2735,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable * @param listener callback for notification removed */ public void setOnNotificationRemovedListener(OnNotificationRemovedListener listener) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mOnNotificationRemovedListener = listener; } Loading Loading @@ -4982,12 +4982,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @Nullable public ExpandableView getShelf() { if (!mShelfRefactor.expectEnabled()) return null; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return null; return mShelf; } public void setShelf(NotificationShelf shelf) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; int index = -1; if (mShelf != null) { index = indexOfChild(mShelf); Loading @@ -5001,7 +5001,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } public void setShelfController(NotificationShelfController notificationShelfController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); int index = -1; if (mShelf != null) { index = indexOfChild(mShelf); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +3 −3 Original line number Diff line number Diff line Loading @@ -1431,7 +1431,7 @@ public class NotificationStackScrollLayoutController { } public void setShelfController(NotificationShelfController notificationShelfController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mView.setShelfController(notificationShelfController); } Loading Loading @@ -1644,12 +1644,12 @@ public class NotificationStackScrollLayoutController { } public void setShelf(NotificationShelf shelf) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mView.setShelf(shelf); } public int getShelfHeight() { if (!mShelfRefactor.expectEnabled()) { if (mShelfRefactor.isUnexpectedlyInLegacyMode()) { return 0; } ExpandableView shelf = mView.getShelf(); Loading Loading
packages/SystemUI/src/com/android/systemui/flags/RefactorFlag.kt +12 −13 Original line number Diff line number Diff line Loading @@ -22,11 +22,11 @@ import com.android.systemui.Dependency /** * This class promotes best practices for flag guarding System UI view refactors. * * [isEnabled] allows changing an implementation. * * [assertDisabled] allows authors to flag code as being "dead" when the flag gets enabled and * * [assertInLegacyMode] allows authors to flag code as being "dead" when the flag gets enabled and * ensure that it is not being invoked accidentally in the post-flag refactor. * * [expectEnabled] allows authors to guard new code with a "safe" alternative when invoked on * flag-disabled builds, but with a check that should crash eng builds or tests when the * expectation is violated. * * [isUnexpectedlyInLegacyMode] allows authors to guard new code with a "safe" alternative when * invoked on flag-disabled builds, but with a check that should crash eng builds or tests when * the expectation is violated. * * The constructors require that you provide a [FeatureFlags] instance. If you're using this in a * View class, it's acceptable to ue the [forView] constructor methods, which do not require one, Loading Loading @@ -60,13 +60,13 @@ private constructor( * Example usage: * ``` * public void setController(NotificationShelfController notificationShelfController) { * mShelfRefactor.assertDisabled(); * mShelfRefactor.assertInLegacyMode(); * mController = notificationShelfController; * } * ```` */ fun assertDisabled() = check(!isEnabled) { "Code path not supported when $flagName is enabled." } fun assertInLegacyMode() = check(!isEnabled) { "Legacy code path not supported when $flagName is enabled." } /** * Called to ensure code is only run when the flag is enabled. This protects users from the Loading @@ -76,18 +76,17 @@ private constructor( * Example usage: * ``` * public void setShelfIcons(NotificationIconContainer icons) { * if (mShelfRefactor.expectEnabled()) { * if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; * mShelfIcons = icons; * } * } * ``` */ fun expectEnabled(): Boolean { fun isUnexpectedlyInLegacyMode(): Boolean { if (!isEnabled) { val message = "Code path not supported when $flagName is disabled." val message = "New code path expects $flagName to be enabled." Log.wtf(TAG, message, Exception(message)) } return isEnabled return !isEnabled } companion object { Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +7 −7 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St public void bind(AmbientState ambientState, NotificationStackScrollLayoutController hostLayoutController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mAmbientState = ambientState; mHostLayoutController = hostLayoutController; hostLayoutController.setOnNotificationRemovedListener((child, isTransferInProgress) -> { Loading @@ -143,7 +143,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout, NotificationRoundnessManager roundnessManager) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mAmbientState = ambientState; mHostLayout = hostLayout; mRoundnessManager = roundnessManager; Loading Loading @@ -964,7 +964,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St @Override public void onStateChanged(int newState) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mStatusBarState = newState; updateInteractiveness(); } Loading Loading @@ -1022,17 +1022,17 @@ public class NotificationShelf extends ActivatableNotificationView implements St } public void setController(NotificationShelfController notificationShelfController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mController = notificationShelfController; } public void setCanModifyColorOfNotifications(boolean canModifyColorOfNotifications) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mCanModifyColorOfNotifications = canModifyColorOfNotifications; } public void setCanInteract(boolean canInteract) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mCanInteract = canInteract; updateInteractiveness(); } Loading @@ -1050,7 +1050,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St } public void requestRoundnessResetFor(ExpandableView child) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; child.requestRoundnessReset(SHELF_SCROLL); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconAreaControllerViewBinderWrapperImpl.kt +10 −11 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ constructor( NotificationShelfViewBinderWrapperControllerImpl.unsupported override fun setShelfIcons(icons: NotificationIconContainer) { if (shelfRefactor.expectEnabled()) { if (shelfRefactor.isUnexpectedlyInLegacyMode()) return NotificationIconContainerViewBinder.bind( icons, shelfIconsViewModel, Loading @@ -178,7 +178,6 @@ constructor( ) shelfIcons = icons } } override fun onDensityOrFontScaleChanged(context: Context) { updateIconLayoutParams(context) Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +4 −4 Original line number Diff line number Diff line Loading @@ -2735,7 +2735,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable * @param listener callback for notification removed */ public void setOnNotificationRemovedListener(OnNotificationRemovedListener listener) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mOnNotificationRemovedListener = listener; } Loading Loading @@ -4982,12 +4982,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @Nullable public ExpandableView getShelf() { if (!mShelfRefactor.expectEnabled()) return null; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return null; return mShelf; } public void setShelf(NotificationShelf shelf) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; int index = -1; if (mShelf != null) { index = indexOfChild(mShelf); Loading @@ -5001,7 +5001,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } public void setShelfController(NotificationShelfController notificationShelfController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); int index = -1; if (mShelf != null) { index = indexOfChild(mShelf); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +3 −3 Original line number Diff line number Diff line Loading @@ -1431,7 +1431,7 @@ public class NotificationStackScrollLayoutController { } public void setShelfController(NotificationShelfController notificationShelfController) { mShelfRefactor.assertDisabled(); mShelfRefactor.assertInLegacyMode(); mView.setShelfController(notificationShelfController); } Loading Loading @@ -1644,12 +1644,12 @@ public class NotificationStackScrollLayoutController { } public void setShelf(NotificationShelf shelf) { if (!mShelfRefactor.expectEnabled()) return; if (mShelfRefactor.isUnexpectedlyInLegacyMode()) return; mView.setShelf(shelf); } public int getShelfHeight() { if (!mShelfRefactor.expectEnabled()) { if (mShelfRefactor.isUnexpectedlyInLegacyMode()) { return 0; } ExpandableView shelf = mView.getShelf(); Loading