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

Commit 550ebb1a authored by Jeroen Dhollander's avatar Jeroen Dhollander Committed by Android (Google) Code Review
Browse files

Merge "DPMS: Enforce max byte length not character length" into main

parents edfbc2b0 3de731a1
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -22,7 +22,9 @@ import android.os.Parcelable;
import android.os.PersistableBundle;

import com.android.internal.util.Preconditions;
import com.android.modules.utils.ModifiedUtf8;

import java.io.UTFDataFormatException;
import java.util.ArrayDeque;
import java.util.Queue;

@@ -33,8 +35,6 @@ import java.util.Queue;
 */
public class PolicySizeVerifier {

    // Binary XML serializer doesn't support longer strings
    public static final int MAX_POLICY_STRING_LENGTH = 65535;
    // FrameworkParsingPackageUtils#MAX_FILE_NAME_SIZE, Android packages are used in dir names.
    public static final int MAX_PACKAGE_NAME_LENGTH = 223;

@@ -47,8 +47,11 @@ public class PolicySizeVerifier {
     * Throw if string argument is too long to be serialized.
     */
    public static void enforceMaxStringLength(String str, String argName) {
        Preconditions.checkArgument(
                str.length() <= MAX_POLICY_STRING_LENGTH, argName + " loo long");
        try {
            long len = ModifiedUtf8.countBytes(str, /* throw error if too long */ true);
        } catch (UTFDataFormatException e) {
            throw new IllegalArgumentException(argName + " too long");
        }
    }

    /**