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

Commit a3316397 authored by Lyn Han's avatar Lyn Han
Browse files

Add dumpsys logs to debug lockscreen stack height

Bug: 250686317
Test: adb shell dumpsys activity service com.android.systemui | grep computeHeight
Change-Id: I02b64fa00c8a97b008981eaca3735f54102e8f26
parent 28ba402d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5083,6 +5083,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            println(pw, "intrinsicPadding", mIntrinsicPadding);
            println(pw, "topPadding", mTopPadding);
            println(pw, "bottomPadding", mBottomPadding);
            mNotificationStackSizeCalculator.dump(pw, args);
        });
        pw.println();
        pw.println("Contents:");
+25 −7
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.util.Compile
import com.android.systemui.util.children
import java.io.PrintWriter
import javax.inject.Inject
import kotlin.math.max
import kotlin.math.min
@@ -53,6 +54,8 @@ constructor(
    @Main private val resources: Resources
) {

    private lateinit var lastComputeHeightLog : String

    /**
     * Maximum # notifications to show on Keyguard; extras will be collapsed in an overflow shelf.
     * If there are exactly 1 + mMaxKeyguardNotifications, and they fit in the available space
@@ -114,7 +117,9 @@ constructor(
        shelfIntrinsicHeight: Float
    ): Int {
        log { "\n" }
        val stackHeightSequence = computeHeightPerNotificationLimit(stack, shelfIntrinsicHeight)

        val stackHeightSequence = computeHeightPerNotificationLimit(stack, shelfIntrinsicHeight,
            /* computeHeight= */ false)

        var maxNotifications =
            stackHeightSequence.lastIndexWhile { heightResult ->
@@ -157,18 +162,21 @@ constructor(
        shelfIntrinsicHeight: Float
    ): Float {
        log { "\n" }
        lastComputeHeightLog = ""
        val heightPerMaxNotifications =
            computeHeightPerNotificationLimit(stack, shelfIntrinsicHeight)
            computeHeightPerNotificationLimit(stack, shelfIntrinsicHeight,
                    /* computeHeight= */ true)

        val (notificationsHeight, shelfHeightWithSpaceBefore) =
            heightPerMaxNotifications.elementAtOrElse(maxNotifications) {
                heightPerMaxNotifications.last() // Height with all notifications visible.
            }
        log {
            "computeHeight(maxNotifications=$maxNotifications," +
        lastComputeHeightLog += "\ncomputeHeight(maxNotifications=$maxNotifications," +
                "shelfIntrinsicHeight=$shelfIntrinsicHeight) -> " +
                "${notificationsHeight + shelfHeightWithSpaceBefore}" +
                " = ($notificationsHeight + $shelfHeightWithSpaceBefore)"
        log {
            lastComputeHeightLog
        }
        return notificationsHeight + shelfHeightWithSpaceBefore
    }
@@ -184,7 +192,8 @@ constructor(

    private fun computeHeightPerNotificationLimit(
        stack: NotificationStackScrollLayout,
        shelfHeight: Float
        shelfHeight: Float,
        computeHeight: Boolean
    ): Sequence<StackHeight> = sequence {
        log { "computeHeightPerNotificationLimit" }

@@ -213,9 +222,14 @@ constructor(
                            currentIndex = firstViewInShelfIndex)
                    spaceBeforeShelf + shelfHeight
                }
            log {
                "i=$i notificationsHeight=$notifications " +

            val currentLog = "computeHeight | i=$i notificationsHeight=$notifications " +
                "shelfHeightWithSpaceBefore=$shelfWithSpaceBefore"
            if (computeHeight) {
                lastComputeHeightLog += "\n" + currentLog
            }
            log {
                currentLog
            }
            yield(
                StackHeight(
@@ -260,6 +274,10 @@ constructor(
        return size
    }

    fun dump(pw: PrintWriter, args: Array<out String>) {
        pw.println("NotificationStackSizeCalculator lastComputeHeightLog = $lastComputeHeightLog")
    }

    private fun ExpandableView.isShowable(onLockscreen: Boolean): Boolean {
        if (visibility == GONE || hasNoContentHeight()) return false
        if (onLockscreen) {