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

Commit 6be1d671 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role)
Browse files

[automerger] Make safe label more safe am: 2263da95 am: 05086b10 am: 77f44906 am: 46f45633

Change-Id: I49cbda7a4d9643808cc9c164970a6ee630b2233c
parents 0d7979fb 46f45633
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@ import java.util.Comparator;
 */
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;

    /**
     * Public name of this item. From the "android:name" attribute.
     */
@@ -173,7 +176,8 @@ public class PackageItemInfo {
        // If the label contains new line characters it may push the UI
        // down to hide a part of it. Labels shouldn't have new line
        // characters, so just truncate at the first time one is seen.
        final int labelLength = labelStr.length();
        final int labelLength = Math.min(labelStr.length(), MAX_SAFE_LABEL_LENGTH);
        final StringBuffer sb = new StringBuffer(labelLength);
        int offset = 0;
        while (offset < labelLength) {
            final int codePoint = labelStr.codePointAt(offset);
@@ -185,14 +189,19 @@ public class PackageItemInfo {
                break;
            }
            // replace all non-break space to " " in order to be trimmed
            final int charCount = Character.charCount(codePoint);
            if (type == Character.SPACE_SEPARATOR) {
                labelStr = labelStr.substring(0, offset) + " " + labelStr.substring(offset +
                        Character.charCount(codePoint));
                sb.append(' ');
            } else {
                sb.append(labelStr.charAt(offset));
                if (charCount == 2) {
                    sb.append(labelStr.charAt(offset + 1));
                }
            }
            offset += Character.charCount(codePoint);
            offset += charCount;
        }

        labelStr = labelStr.trim();
        labelStr = sb.toString().trim();
        if (labelStr.isEmpty()) {
            return packageName;
        }