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

Commit 3fe5798c authored by Nick Chameyev's avatar Nick Chameyev Committed by Android (Google) Code Review
Browse files

Merge "Add simulate extra notifications measure delay debug flag" into main

parents 918378f0 8f8d6e26
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -564,6 +564,13 @@ object Flags {
    val ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS =
        unreleasedFlag("enable_unfold_status_bar_animations")

    // TODO(b/316157842): Tracking Bug
    // Adds extra delay to notifications measure
    @Keep
    @JvmField
    val ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE =
        unreleasedFlag("enable_notifications_simulate_slow_measure")

    // TODO(b259590361): Tracking bug
    val EXPERIMENTAL_FLAG = unreleasedFlag("exp_flag_release")

+25 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.os.Trace;
import android.util.AttributeSet;
import android.util.FloatProperty;
@@ -272,6 +273,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private final RefactorFlag mInlineReplyAnimation =
            RefactorFlag.forView(Flags.NOTIFICATION_INLINE_REPLY_ANIMATION);

    private static final boolean mSimulateSlowMeasure = Compile.IS_DEBUG && RefactorFlag.forView(
            Flags.ENABLE_NOTIFICATIONS_SIMULATE_SLOW_MEASURE).isEnabled();
    private static final String SLOW_MEASURE_SIMULATE_DELAY_PROPERTY =
            "persist.notifications.extra_measure_delay_ms";
    private static final int SLOW_MEASURE_SIMULATE_DELAY_MS = mSimulateSlowMeasure ?
            SystemProperties.getInt(SLOW_MEASURE_SIMULATE_DELAY_PROPERTY, 150) : 0;

    // Listener will be called when receiving a long click event.
    // Use #setLongPressPosition to optionally assign positional data with the long press.
    private LongPressListener mLongPressListener;
@@ -1879,9 +1887,26 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                    + "heightMeasureSpec=" + MeasureSpec.toString(heightMeasureSpec) + ")");
        }
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        if (Compile.IS_DEBUG && mSimulateSlowMeasure) {
            simulateExtraMeasureDelay();
        }
        Trace.endSection();
    }

    private void simulateExtraMeasureDelay() {
        // Add extra delay in a notification row instead of NotificationStackScrollLayout
        // to make sure that when the measure cache is used we won't add this delay
        try {
            Trace.beginSection("ExtraDebugMeasureDelay");
            Thread.sleep(SLOW_MEASURE_SIMULATE_DELAY_MS);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } finally {
            Trace.endSection();
        }
    }

    /**
     * Generates and appends "(MessagingStyle)" type tag to passed string for tracing.
     */