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

Commit 36fe7e72 authored by Jernej Virag's avatar Jernej Virag Committed by Android (Google) Code Review
Browse files

Merge "Restrict size of custom views on SysUI side as well" into main

parents d44863c7 7ee73ee1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -583,6 +583,7 @@ java_library {
        "documents-ui-compat-config",
        "calendar-provider-compat-config",
        "contacts-provider-platform-compat-config",
        "SystemUI-core-compat-config",
    ] + select(soong_config_variable("ANDROID", "release_crashrecovery_module"), {
        "true": [],
        default: [
+9 −0
Original line number Diff line number Diff line
@@ -207,6 +207,8 @@ filegroup {
        "tests/src/**/systemui/statusbar/notification/row/NotificationConversationInfoTest.java",
        "tests/src/**/systemui/statusbar/notification/row/NotificationGutsManagerWithScenesTest.kt",
        "tests/src/**/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapperTest.kt",
        "tests/src/**/systemui/statusbar/notification/row/NotificationCustomContentMemoryVerifierTest.java",
        "tests/src/**/systemui/statusbar/notification/row/NotificationCustomContentMemoryVerifierDisabledTest.java",
        "tests/src/**/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java",
        "tests/src/**/systemui/statusbar/phone/CentralSurfacesImplTest.java",
        "tests/src/**/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java",
@@ -553,6 +555,11 @@ android_library {
    },
}

platform_compat_config {
    name: "SystemUI-core-compat-config",
    src: ":SystemUI-core",
}

filegroup {
    name: "AAA-src",
    srcs: ["tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java"],
@@ -755,6 +762,7 @@ android_library {
        "kosmos",
        "testables",
        "androidx.test.rules",
        "platform-compat-test-rules",
    ],
    libs: [
        "android.test.runner.stubs.system",
@@ -889,6 +897,7 @@ android_robolectric_test {
    static_libs: [
        "RoboTestLibraries",
        "androidx.compose.runtime_runtime",
        "platform-compat-test-rules",
    ],
    libs: [
        "android.test.runner.impl",
+4 −0
Original line number Diff line number Diff line
@@ -643,6 +643,10 @@ public final class NotificationEntry extends ListEntry {
        return row.isMediaRow();
    }

    public boolean containsCustomViews() {
        return getSbn().getNotification().containsCustomViews();
    }

    public void resetUserExpansion() {
        if (row != null) row.resetUserExpansion();
    }
+9 −5
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.util.children

/** Walks view hiearchy of a given notification to estimate its memory use. */
internal object NotificationMemoryViewWalker {
object NotificationMemoryViewWalker {

    private const val TAG = "NotificationMemory"

@@ -26,9 +26,13 @@ internal object NotificationMemoryViewWalker {
        private var softwareBitmaps = 0

        fun addSmallIcon(smallIconUse: Int) = apply { smallIcon += smallIconUse }

        fun addLargeIcon(largeIconUse: Int) = apply { largeIcon += largeIconUse }

        fun addSystem(systemIconUse: Int) = apply { systemIcons += systemIconUse }

        fun addStyle(styleUse: Int) = apply { style += styleUse }

        fun addSoftwareBitmapPenalty(softwareBitmapUse: Int) = apply {
            softwareBitmaps += softwareBitmapUse
        }
@@ -67,14 +71,14 @@ internal object NotificationMemoryViewWalker {
                    getViewUsage(ViewType.PRIVATE_EXPANDED_VIEW, row.privateLayout?.expandedChild),
                    getViewUsage(
                        ViewType.PRIVATE_CONTRACTED_VIEW,
                        row.privateLayout?.contractedChild
                        row.privateLayout?.contractedChild,
                    ),
                    getViewUsage(ViewType.PRIVATE_HEADS_UP_VIEW, row.privateLayout?.headsUpChild),
                    getViewUsage(
                        ViewType.PUBLIC_VIEW,
                        row.publicLayout?.expandedChild,
                        row.publicLayout?.contractedChild,
                        row.publicLayout?.headsUpChild
                        row.publicLayout?.headsUpChild,
                    ),
                )
                .filterNotNull()
@@ -107,14 +111,14 @@ internal object NotificationMemoryViewWalker {
            row.publicLayout?.expandedChild,
            row.publicLayout?.contractedChild,
            row.publicLayout?.headsUpChild,
            seenObjects = seenObjects
            seenObjects = seenObjects,
        )
    }

    private fun getViewUsage(
        type: ViewType,
        vararg rootViews: View?,
        seenObjects: HashSet<Int> = hashSetOf()
        seenObjects: HashSet<Int> = hashSetOf(),
    ): NotificationViewUsage? {
        val usageBuilder = lazy { UsageBuilder() }
        rootViews.forEach { rootView ->
+7 −0
Original line number Diff line number Diff line
@@ -901,6 +901,13 @@ public class NotificationContentInflater implements NotificationRowContentBinder
        if (!satisfiesMinHeightRequirement(view, entry, resources)) {
            return "inflated notification does not meet minimum height requirement";
        }

        if (NotificationCustomContentMemoryVerifier.requiresImageViewMemorySizeCheck(entry)) {
            if (!NotificationCustomContentMemoryVerifier.satisfiesMemoryLimits(view, entry)) {
                return "inflated notification does not meet maximum memory size requirement";
            }
        }

        return null;
    }

Loading