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

Commit 08045c4b authored by Rhed Jao's avatar Rhed Jao Committed by Android Build Coastguard Worker
Browse files

DO NOT MERGE Apply a maximum char count to the load label api

The system is overwhelmed by an enormous label string returned by
the load label api. This cl truncates the label string if it exceeds
the maximum safe length.

Also update the max safe label length to 1000 characters, which is
enough.

Bug: 67013844
Test: atest PackageManagerTest
Change-Id: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
Merged-in: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
(cherry picked from commit b55d314f)
parent 38a939d1
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class PackageItemInfo {

    private static final float MAX_LABEL_SIZE_PX = 500f;
    /** The maximum length of a safe label, in characters */
    private static final int MAX_SAFE_LABEL_LENGTH = 50000;
    private static final int MAX_SAFE_LABEL_LENGTH = 1000;

    private static volatile boolean sForceSafeLabels = false;

@@ -191,7 +191,9 @@ public class PackageItemInfo {
        if (sForceSafeLabels) {
            return loadSafeLabel(pm);
        } else {
            return loadUnsafeLabel(pm);
            // Trims the label string to the MAX_SAFE_LABEL_LENGTH. This is to prevent that the
            // system is overwhelmed by an enormous string returned by the application.
            return TextUtils.trimToSize(loadUnsafeLabel(pm), MAX_SAFE_LABEL_LENGTH);
        }
    }