diff options
| author | 2025-01-27 12:35:52 -0800 | |
|---|---|---|
| committer | 2025-01-27 15:43:44 -0800 | |
| commit | 53ae17354570828e92bca15d22d17795741e6792 (patch) | |
| tree | c3b130c323187cd46f5c4432b6cdda73dd9cdde7 | |
| parent | 173c1d15cec298a3c6840e9ce67e2d806f8d858d (diff) | |
Helper class to read flag: notification_bundle_ui
Bug: 391680205
Change-Id: I4badb503e617f4cda53029208be44cfc43691bbd
Test: EXEMPT new flag def
Flag: com.android.systemui.notification_bundle_ui
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/NotificationBundleUi.kt | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/NotificationBundleUi.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/NotificationBundleUi.kt new file mode 100644 index 000000000000..72372319009c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/NotificationBundleUi.kt @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.systemui.statusbar.notification.shared + +import com.android.systemui.Flags +import com.android.systemui.flags.FlagToken +import com.android.systemui.flags.RefactorFlagUtils + +/** Helper for reading or using the notification bundle ui flag state. */ +@Suppress("NOTHING_TO_INLINE") +object NotificationBundleUi { + /** The aconfig flag name */ + const val FLAG_NAME = Flags.FLAG_NOTIFICATION_BUNDLE_UI + + /** A token used for dependency declaration */ + val token: FlagToken + get() = FlagToken(FLAG_NAME, isEnabled) + + /** Is the refactor enabled */ + @JvmStatic + inline val isEnabled + get() = Flags.notificationBundleUi() + + /** + * Called to ensure code is only run when the flag is enabled. This protects users from the + * unintended behaviors caused by accidentally running new logic, while also crashing on an eng + * build to ensure that the refactor author catches issues in testing. + */ + @JvmStatic + inline fun isUnexpectedlyInLegacyMode() = + RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME) + + /** + * Called to ensure code is only run when the flag is enabled. This will throw an exception if + * the flag is not enabled to ensure that the refactor author catches issues in testing. + * Caution!! Using this check incorrectly will cause crashes in nextfood builds! + */ + @JvmStatic + inline fun assertInNewMode() = RefactorFlagUtils.assertInNewMode(isEnabled, FLAG_NAME) + + /** + * Called to ensure code is only run when the flag is disabled. This will throw an exception if + * the flag is enabled to ensure that the refactor author catches issues in testing. + */ + @JvmStatic + inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME) +}
\ No newline at end of file |