diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt index d05c3385e982e..6287857e7be97 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt @@ -37,6 +37,7 @@ import kotlin.properties.Delegates.notNull private const val TAG = "NotifStackSizeCalc" private val DEBUG = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG) +private val SPEW = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE) /** Calculates number of notifications to display and the height of the notification stack. */ @SysUISingleton @@ -87,9 +88,10 @@ constructor( // Could be < 0 if the space available is less than the shelf size. Returns 0 in this case. maxNotifications = max(0, maxNotifications) log { + val sequence = if (SPEW) " stackHeightSequence=${stackHeightSequence.toList()}" else "" "computeMaxKeyguardNotifications(" + "availableSpace=$totalAvailableSpace" + - " shelfHeight=$shelfIntrinsicHeight) -> $maxNotifications" + " shelfHeight=$shelfIntrinsicHeight) -> $maxNotifications$sequence" } return maxNotifications } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index a9725db32ee9d..9afdfd6511307 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -192,6 +192,7 @@ import com.android.systemui.statusbar.policy.KeyguardUserSwitcherView; import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener; import com.android.systemui.statusbar.window.StatusBarWindowStateController; import com.android.systemui.unfold.SysUIUnfoldComponent; +import com.android.systemui.util.Compile; import com.android.systemui.util.LargeScreenUtils; import com.android.systemui.util.ListenerSet; import com.android.systemui.util.Utils; @@ -216,7 +217,8 @@ import javax.inject.Provider; @CentralSurfacesComponent.CentralSurfacesScope public class NotificationPanelViewController extends PanelViewController { - private static final boolean DEBUG_LOGCAT = Log.isLoggable(TAG, Log.DEBUG); + private static final boolean DEBUG_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG); + private static final boolean SPEW_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE); private static final boolean DEBUG_DRAWABLE = false; /** @@ -1294,6 +1296,8 @@ public class NotificationPanelViewController extends PanelViewController { private void updateMaxDisplayedNotifications(boolean recompute) { if (recompute) { mMaxAllowedKeyguardNotifications = Math.max(computeMaxKeyguardNotifications(), 1); + } else { + if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request"); } if (mKeyguardShowing && !mKeyguardBypassController.getBypassEnabled()) { @@ -1546,6 +1550,19 @@ public class NotificationPanelViewController extends PanelViewController { mNotificationStackScrollLayoutController.getHeight() - staticTopPadding - bottomPadding; + + if (SPEW_LOGCAT) { + Log.d(TAG, "getSpaceForLockscreenNotifications()" + + " availableSpace=" + availableSpace + + " NSSL.height=" + mNotificationStackScrollLayoutController.getHeight() + + " NSSL.top=" + mNotificationStackScrollLayoutController.getTop() + + " staticTopPadding=" + staticTopPadding + + " bottomPadding=" + bottomPadding + + " lockIconPadding=" + lockIconPadding + + " mIndicationBottomPadding=" + mIndicationBottomPadding + + " mAmbientIndicationBottomPadding=" + mAmbientIndicationBottomPadding + ); + } return availableSpace; } @@ -1554,7 +1571,12 @@ public class NotificationPanelViewController extends PanelViewController { */ @VisibleForTesting int computeMaxKeyguardNotifications() { - if (mAmbientState.getFractionToShade() > 0 || mAmbientState.getDozeAmount() > 0) { + if (mAmbientState.getFractionToShade() > 0) { + if (SPEW_LOGCAT) { + Log.v(TAG, "Internally skipping computeMaxKeyguardNotifications()" + + " fractionToShade=" + mAmbientState.getFractionToShade() + ); + } return mMaxAllowedKeyguardNotifications; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java index fa9161a19cb1a..f599e3b12c57e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java @@ -577,20 +577,9 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { .isEqualTo(-1); } - @Test - public void computeMaxKeyguardNotifications_dozeAmountNotZero_returnsExistingMax() { - when(mAmbientState.getDozeAmount()).thenReturn(0.5f); - mNotificationPanelViewController.setMaxDisplayedNotifications(-1); - - // computeMaxKeyguardNotifications sets maxAllowed to 0 at minimum if it updates the value - assertThat(mNotificationPanelViewController.computeMaxKeyguardNotifications()) - .isEqualTo(-1); - } - @Test public void computeMaxKeyguardNotifications_noTransition_updatesMax() { when(mAmbientState.getFractionToShade()).thenReturn(0f); - when(mAmbientState.getDozeAmount()).thenReturn(0f); mNotificationPanelViewController.setMaxDisplayedNotifications(-1); // computeMaxKeyguardNotifications sets maxAllowed to 0 at minimum if it updates the value