summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRhed Jao <rhedjao@google.com>2021-08-11 03:39:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-08-11 03:39:57 +0000
commiteeb7b8088ad2b82953be31f7ed98e633a24e9e7e (patch)
tree39f53eb1c3e08e65d3cc0f98539bfe788e65e4ec
parent4cbe7fc6f8a1e3fe2cefe6811d359b13af483e68 (diff)
parent61722016377e992b5e2e63d5886684f8ac195c7e (diff)
downloadbase-eeb7b8088ad2b82953be31f7ed98e633a24e9e7e.tar.gz
Merge "DO NOT MERGE Apply a maximum char count to the load label api" into qt-dev
-rw-r--r--core/java/android/content/pm/PackageItemInfo.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/java/android/content/pm/PackageItemInfo.java b/core/java/android/content/pm/PackageItemInfo.java
index d0ab8f713de8..aa8e84262049 100644
--- a/core/java/android/content/pm/PackageItemInfo.java
+++ b/core/java/android/content/pm/PackageItemInfo.java
@@ -49,7 +49,7 @@ import java.util.Comparator;
*/
public class PackageItemInfo {
/** 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;
/** @hide */
public static final float DEFAULT_MAX_LABEL_SIZE_PX = 500f;
@@ -198,7 +198,9 @@ public class PackageItemInfo {
return loadSafeLabel(pm, DEFAULT_MAX_LABEL_SIZE_PX, SAFE_STRING_FLAG_TRIM
| SAFE_STRING_FLAG_FIRST_LINE);
} 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);
}
}