From 3a6efea23b5b8e8bbcd7e6df620ce4cb3d8d4a88 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Sat, 18 Dec 2021 13:45:22 +0000 Subject: [PATCH] Convert NSSL debug props to FeatureFlags Test: switch flags with the Flag Flipper Change-Id: Ia59006aa9e1e6baa6834106ebf707c3f896b860c --- .../src/com/android/systemui/flags/Flags.java | 6 +++ .../stack/NotificationStackScrollLayout.java | 50 +++++++++---------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.java b/packages/SystemUI/src/com/android/systemui/flags/Flags.java index 4e852a8714177..dd4736fe130da 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.java +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.java @@ -52,6 +52,12 @@ public class Flags { public static final ResourceBooleanFlag NOTIFICATION_SHADE_DRAG = new ResourceBooleanFlag(104, R.bool.config_enableNotificationShadeDrag); + public static final BooleanFlag NSSL_DEBUG_LINES = + new BooleanFlag(105, false); + + public static final BooleanFlag NSSL_DEBUG_REMOVE_ANIMATION = + new BooleanFlag(106, false); + /***************************************/ // 200 - keyguard/lockscreen public static final BooleanFlag KEYGUARD_LAYOUT = 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 79b05c9107051..2ac1daf0632e7 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 @@ -43,7 +43,6 @@ import android.graphics.Path; import android.graphics.PointF; import android.graphics.Rect; import android.os.Bundle; -import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; import android.util.AttributeSet; @@ -80,6 +79,8 @@ import com.android.systemui.Dumpable; import com.android.systemui.ExpandHelper; 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.NotificationSwipeActionHelper; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.EmptyShadeView; @@ -132,14 +133,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable public static final float BACKGROUND_ALPHA_DIMMED = 0.7f; private static final String TAG = "StackScroller"; - // Usage: - // adb shell setprop persist.debug.nssl true && adb reboot - private static final boolean DEBUG = SystemProperties.getBoolean("persist.debug.nssl", - false /* default */); - // TODO(b/187291379) disable again before release - private static final boolean DEBUG_REMOVE_ANIMATION = SystemProperties.getBoolean( - "persist.debug.nssl.dismiss", false /* default */); - // Delay in milli-seconds before shade closes for clear all. private final int DELAY_BEFORE_SHADE_CLOSE = 200; private boolean mShadeNeedsToClose = false; @@ -192,7 +185,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private float mInitialTouchX; private float mInitialTouchY; + private final boolean mDebugLines; private Paint mDebugPaint; + /** Used to track the Y positions that were already used to draw debug text labels. */ + private Set mDebugTextUsedYPositions; + private final boolean mDebugRemoveAnimation; + private int mContentHeight; private int mIntrinsicContentHeight; private int mCollapsedSize; @@ -569,6 +567,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable public NotificationStackScrollLayout(Context context, AttributeSet attrs) { super(context, attrs, 0, 0); Resources res = getResources(); + FeatureFlags featureFlags = Dependency.get(FeatureFlags.class); + mDebugLines = featureFlags.isEnabled(Flags.NSSL_DEBUG_LINES); + mDebugRemoveAnimation = featureFlags.isEnabled(Flags.NSSL_DEBUG_REMOVE_ANIMATION); mSectionsManager = Dependency.get(NotificationSectionsManager.class); mScreenOffAnimationController = Dependency.get(ScreenOffAnimationController.class); @@ -591,10 +592,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable res.getBoolean(R.bool.config_drawNotificationBackground); setOutlineProvider(mOutlineProvider); - boolean willDraw = mShouldDrawNotificationBackground || DEBUG; + boolean willDraw = mShouldDrawNotificationBackground || mDebugLines; setWillNotDraw(!willDraw); mBackgroundPaint.setAntiAlias(true); - if (DEBUG) { + if (mDebugLines) { mDebugPaint = new Paint(); mDebugPaint.setColor(0xffff0000); mDebugPaint.setStrokeWidth(2); @@ -729,18 +730,17 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable drawHeadsUpBackground(canvas); } - if (DEBUG) { + if (mDebugLines) { onDrawDebug(canvas); } } - /** Used to track the Y positions that were already used to draw debug text labels. */ - private static final Set DEBUG_TEXT_USED_Y_POSITIONS = - DEBUG ? new HashSet<>() : Collections.emptySet(); - private void onDrawDebug(Canvas canvas) { - DEBUG_TEXT_USED_Y_POSITIONS.clear(); - + if (mDebugTextUsedYPositions == null) { + mDebugTextUsedYPositions = new HashSet<>(); + } else { + mDebugTextUsedYPositions.clear(); + } int y = mTopPadding; drawDebugInfo(canvas, y, Color.RED, /* label= */ "mTopPadding"); @@ -776,10 +776,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private int computeDebugYTextPosition(int lineY) { int textY = lineY; - while (DEBUG_TEXT_USED_Y_POSITIONS.contains(textY)) { + while (mDebugTextUsedYPositions.contains(textY)) { textY = (int) (textY + mDebugPaint.getTextSize()); } - DEBUG_TEXT_USED_Y_POSITIONS.add(textY); + mDebugTextUsedYPositions.add(textY); return textY; } @@ -2702,14 +2702,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER) boolean generateRemoveAnimation(ExpandableView child) { String key = ""; - if (DEBUG_REMOVE_ANIMATION) { + if (mDebugRemoveAnimation) { if (child instanceof ExpandableNotificationRow) { key = ((ExpandableNotificationRow) child).getEntry().getKey(); } Log.d(TAG, "generateRemoveAnimation " + key); } if (removeRemovedChildFromHeadsUpChangeAnimations(child)) { - if (DEBUG_REMOVE_ANIMATION) { + if (mDebugRemoveAnimation) { Log.d(TAG, "removedBecauseOfHeadsUp " + key); } mAddedHeadsUpChildren.remove(child); @@ -2720,7 +2720,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mClearTransientViewsWhenFinished.add(child); return true; } - if (DEBUG_REMOVE_ANIMATION) { + if (mDebugRemoveAnimation) { Log.d(TAG, "generateRemove " + key + "\nmIsExpanded " + mIsExpanded + "\nmAnimationsEnabled " + mAnimationsEnabled @@ -2728,7 +2728,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable } if (mIsExpanded && mAnimationsEnabled && !isChildInInvisibleGroup(child)) { if (!mChildrenToAddAnimated.contains(child)) { - if (DEBUG_REMOVE_ANIMATION) { + if (mDebugRemoveAnimation) { Log.d(TAG, "needsAnimation = true " + key); } // Generate Animations @@ -3227,7 +3227,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable ignoreChildren); mAnimationEvents.add(event); mSwipedOutViews.remove(child); - if (DEBUG_REMOVE_ANIMATION) { + if (mDebugRemoveAnimation) { String key = ""; if (child instanceof ExpandableNotificationRow) { key = ((ExpandableNotificationRow) child).getEntry().getKey();