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.

Bug: 67013844
Test: atest PackageManagerTest
Change-Id: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
Merged-in: Ia4d768cc93a47cfb8b6f7c4b6dc73abd801809bd
This commit is contained in:
Rhed Jao
2021-07-30 15:52:05 +08:00
parent 69b752610f
commit 0015463fac

View File

@@ -207,7 +207,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);
}
}