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

Commit a214862c authored by Yining Liu's avatar Yining Liu
Browse files

Clean up flag notification_async_hybrid_view_inflation 1

The impact of this flag is particularly wide, so breaking down the flag
removal by method for code robustness and easier review. This change
cleans the isUnexpectedlyInLegacyMode() method of flag-helper class.

Clean up flag:
com.android.systemui.notification_async_hybrid_view_inflation

Bug: 409612328
Test: SingleLineViewInflaterTest, SingleLineViewBinderTest,
NotifUiAdjustmentProviderTest
Flag: EXEMPT flag cleanup

Change-Id: I7f9ee62d63882e2767830bf4a4e5d2b30185f95d
parent ed5111ee
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.app.Flags;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.graphics.drawable.Icon;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
@@ -202,7 +201,6 @@ public class HybridConversationNotificationView extends HybridNotificationView {
     *                           either an instance of SingleIcon or FacePile
     */
    public void setAvatar(@NonNull ConversationAvatar conversationAvatar) {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return;
        if (conversationAvatar instanceof SingleIcon) {
            SingleIcon avatar = (SingleIcon) conversationAvatar;
            if (mConversationFacePile != null) mConversationFacePile.setVisibility(GONE);
@@ -255,7 +253,6 @@ public class HybridConversationNotificationView extends HybridNotificationView {
            CharSequence conversationSenderName,
            @Nullable CharSequence summarization
    ) {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return;
        if (!TextUtils.isEmpty(summarization)) {
            mConversationSenderName.setVisibility(GONE);
            contentText = summarization;
+0 −1
Original line number Diff line number Diff line
@@ -620,7 +620,6 @@ public class NotificationContentView extends FrameLayout implements Notification
     * @param child single-line content view to set
     */
    public void setSingleLineView(@Nullable HybridNotificationView child) {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return;
        if (mSingleLineView != null) {
            mOnContentViewInactiveListeners.remove(mSingleLineView);
            mSingleLineView.animate().cancel();
+0 −21
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.logKey
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE
import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_SINGLE_LINE
import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation
import com.android.systemui.statusbar.notification.row.ui.viewmodel.ConversationAvatar
import com.android.systemui.statusbar.notification.row.ui.viewmodel.ConversationData
import com.android.systemui.statusbar.notification.row.ui.viewmodel.FacePile
@@ -68,9 +67,6 @@ object SingleLineViewInflater {
        redactText: Boolean,
        summarization: CharSequence?,
    ): SingleLineViewModel {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) {
            return SingleLineViewModel(null, null, null)
        }
        peopleHelper.init(systemUiContext)

        var titleText = HybridGroupManager.resolveTitle(notification)
@@ -170,9 +166,6 @@ object SingleLineViewInflater {
    private fun MessagingStyle.loadConversationTextData(
        systemUiContext: Context
    ): ConversationTextData? {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) {
            return null
        }
        var conversationText: CharSequence?

        if (messages.isEmpty()) {
@@ -212,9 +205,6 @@ object SingleLineViewInflater {
        senderName: CharSequence?,
        systemUiContext: Context,
    ): CharSequence {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) {
            return ""
        }
        return if (isGroupConversation) {
            systemUiContext.resources.getString(R.string.conversation_title_fallback_group_chat)
        } else {
@@ -234,9 +224,6 @@ object SingleLineViewInflater {
        message: MessagingStyle.Message,
        context: Context,
    ): CharSequence? {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) {
            return null
        }
        // If the message is not an image message, just return empty, the back-up text for showing
        // will be SingleLineViewModel.contentText
        if (!message.isImageMessage()) return null
@@ -271,9 +258,6 @@ object SingleLineViewInflater {
        messages: List<MessagingStyle.Message>,
        historicMessages: List<MessagingStyle.Message>,
    ): List<MutableList<MessagingStyle.Message>> {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) {
            return listOf()
        }
        if (messages.isEmpty() && historicMessages.isEmpty()) return listOf()
        var currentGroup: MutableList<MessagingStyle.Message>? = null
        var currentSenderKey: CharSequence? = null
@@ -301,9 +285,6 @@ object SingleLineViewInflater {
        isGroupConversation: Boolean,
        systemUiContext: Context,
    ): ConversationAvatar {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) {
            return SingleIcon(null)
        }
        val userKey = user.getKeyOrName()
        var conversationIcon: Icon? = shortcutIcon
        var conversationText: CharSequence? = conversationTitle
@@ -416,7 +397,6 @@ object SingleLineViewInflater {
        context: Context,
        logger: NotificationRowContentBinderLogger,
    ): HybridNotificationView? {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return null
        return if ((reinflateFlags and FLAG_CONTENT_VIEW_SINGLE_LINE) == 0) {
            null
        } else {
@@ -431,7 +411,6 @@ object SingleLineViewInflater {
        context: Context,
        logger: NotificationRowContentBinderLogger,
    ): HybridNotificationView? {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return null

        logger.logInflateSingleLine(entry.logKey, reinflateFlags, isConversation)
        logger.logAsyncTaskProgress(entry.logKey, "inflating single-line content view")
+0 −9
Original line number Diff line number Diff line
@@ -34,15 +34,6 @@ object AsyncHybridViewInflation {
    inline val isEnabled
        get() = Flags.notificationAsyncHybridViewInflation()

    /**
     * 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 disabled. This will throw an exception if
     * the flag is enabled to ensure that the refactor author catches issues in testing.
+1 −4
Original line number Diff line number Diff line
@@ -18,21 +18,18 @@ package com.android.systemui.statusbar.notification.row.ui.viewbinder

import com.android.systemui.statusbar.notification.row.HybridConversationNotificationView
import com.android.systemui.statusbar.notification.row.HybridNotificationView
import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation
import com.android.systemui.statusbar.notification.row.ui.viewmodel.SingleLineViewModel

object SingleLineViewBinder {
    @JvmStatic
    fun bind(viewModel: SingleLineViewModel?, view: HybridNotificationView?) {
        if (view is HybridConversationNotificationView) {
            if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return

            viewModel?.conversationData?.avatar?.let { view.setAvatar(it) }
            view.setText(
                viewModel?.titleText,
                viewModel?.contentText,
                viewModel?.conversationData?.conversationSenderName,
                viewModel?.conversationData?.summarization
                viewModel?.conversationData?.summarization,
            )
        } else {
            // bind the title and content text views