Loading core/java/android/content/pm/parsing/component/ParsedAttribution.java +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public class ParsedAttribution implements Parcelable { public static final int MAX_ATTRIBUTION_TAG_LEN = 50; /** Maximum amount of attributions per package */ private static final int MAX_NUM_ATTRIBUTIONS = 10000; private static final int MAX_NUM_ATTRIBUTIONS = 1000; /** Tag of the attribution */ public final @NonNull String tag; Loading core/java/android/os/PersistableBundle.java +37 −0 Original line number Diff line number Diff line Loading @@ -283,6 +283,43 @@ public final class PersistableBundle extends BaseBundle implements Cloneable, Pa XmlUtils.writeMapXml(mMap, out, this); } /** * Checks whether all keys and values are within the given character limit. * Note: Maximum character limit of String that can be saved to XML as part of bundle is 65535. * Otherwise IOException is thrown. * @param limit length of String keys and values in the PersistableBundle, including nested * PersistableBundles to check against. * * @hide */ public boolean isBundleContentsWithinLengthLimit(int limit) { unparcel(); if (mMap == null) { return true; } for (int i = 0; i < mMap.size(); i++) { if (mMap.keyAt(i) != null && mMap.keyAt(i).length() > limit) { return false; } final Object value = mMap.valueAt(i); if (value instanceof String && ((String) value).length() > limit) { return false; } else if (value instanceof String[]) { String[] stringArray = (String[]) value; for (int j = 0; j < stringArray.length; j++) { if (stringArray[j] != null && stringArray[j].length() > limit) { return false; } } } else if (value instanceof PersistableBundle && !((PersistableBundle) value).isBundleContentsWithinLengthLimit(limit)) { return false; } } return true; } /** @hide */ static class MyReadMapCallback implements XmlUtils.ReadMapCallback { @Override Loading core/java/android/os/UserManager.java +19 −4 Original line number Diff line number Diff line Loading @@ -93,6 +93,21 @@ public class UserManager { private Boolean mIsManagedProfileCached; private Boolean mIsProfileCached; /** Maximum length of username. * @hide */ public static final int MAX_USER_NAME_LENGTH = 100; /** Maximum length of user property String value. * @hide */ public static final int MAX_ACCOUNT_STRING_LENGTH = 500; /** Maximum length of account options String values. * @hide */ public static final int MAX_ACCOUNT_OPTIONS_LENGTH = 1000; /** * User type representing a {@link UserHandle#USER_SYSTEM system} user that is a human user. * This type of user cannot be created; it can only pre-exist on first boot. Loading Loading @@ -3185,15 +3200,15 @@ public class UserManager { * time, the preferred user name and account information are used by the setup process for that * user. * * @param userName Optional name to assign to the user. * @param userName Optional name to assign to the user. Character limit is 100. * @param accountName Optional account name that will be used by the setup wizard to initialize * the user. * the user. Character limit is 500. * @param accountType Optional account type for the account to be created. This is required * if the account name is specified. * if the account name is specified. Character limit is 500. * @param accountOptions Optional bundle of data to be passed in during account creation in the * new user via {@link AccountManager#addAccount(String, String, String[], * Bundle, android.app.Activity, android.accounts.AccountManagerCallback, * Handler)}. * Handler)}. Character limit is 1000. * @return An Intent that can be launched from an Activity. * @see #USER_CREATION_FAILED_NOT_PERMITTED * @see #USER_CREATION_FAILED_NO_MORE_USERS Loading core/java/com/android/internal/app/ConfirmUserCreationActivity.java +12 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,14 @@ public class ConfirmUserCreationActivity extends AlertActivity if (cantCreateUser) { setResult(UserManager.USER_CREATION_FAILED_NOT_PERMITTED); return null; } else if (!(isUserPropertyWithinLimit(mUserName, UserManager.MAX_USER_NAME_LENGTH) && isUserPropertyWithinLimit(mAccountName, UserManager.MAX_ACCOUNT_STRING_LENGTH) && isUserPropertyWithinLimit(mAccountType, UserManager.MAX_ACCOUNT_STRING_LENGTH)) || (mAccountOptions != null && !mAccountOptions.isBundleContentsWithinLengthLimit( UserManager.MAX_ACCOUNT_OPTIONS_LENGTH))) { setResult(UserManager.USER_CREATION_FAILED_NOT_PERMITTED); Log.i(TAG, "User properties must not exceed their character limits"); return null; } else if (cantCreateAnyMoreUsers) { setResult(UserManager.USER_CREATION_FAILED_NO_MORE_USERS); return null; Loading Loading @@ -141,4 +149,8 @@ public class ConfirmUserCreationActivity extends AlertActivity } finish(); } private boolean isUserPropertyWithinLimit(String property, int limit) { return property == null || property.length() <= limit; } } core/java/com/android/internal/widget/LockPatternUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -1353,8 +1353,8 @@ public class LockPatternUtils { } public boolean isUserInLockdown(int userId) { return getStrongAuthForUser(userId) == StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; return (getStrongAuthForUser(userId) & StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN) != 0; } private static class WrappedCallback extends ICheckCredentialProgressCallback.Stub { Loading Loading
core/java/android/content/pm/parsing/component/ParsedAttribution.java +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public class ParsedAttribution implements Parcelable { public static final int MAX_ATTRIBUTION_TAG_LEN = 50; /** Maximum amount of attributions per package */ private static final int MAX_NUM_ATTRIBUTIONS = 10000; private static final int MAX_NUM_ATTRIBUTIONS = 1000; /** Tag of the attribution */ public final @NonNull String tag; Loading
core/java/android/os/PersistableBundle.java +37 −0 Original line number Diff line number Diff line Loading @@ -283,6 +283,43 @@ public final class PersistableBundle extends BaseBundle implements Cloneable, Pa XmlUtils.writeMapXml(mMap, out, this); } /** * Checks whether all keys and values are within the given character limit. * Note: Maximum character limit of String that can be saved to XML as part of bundle is 65535. * Otherwise IOException is thrown. * @param limit length of String keys and values in the PersistableBundle, including nested * PersistableBundles to check against. * * @hide */ public boolean isBundleContentsWithinLengthLimit(int limit) { unparcel(); if (mMap == null) { return true; } for (int i = 0; i < mMap.size(); i++) { if (mMap.keyAt(i) != null && mMap.keyAt(i).length() > limit) { return false; } final Object value = mMap.valueAt(i); if (value instanceof String && ((String) value).length() > limit) { return false; } else if (value instanceof String[]) { String[] stringArray = (String[]) value; for (int j = 0; j < stringArray.length; j++) { if (stringArray[j] != null && stringArray[j].length() > limit) { return false; } } } else if (value instanceof PersistableBundle && !((PersistableBundle) value).isBundleContentsWithinLengthLimit(limit)) { return false; } } return true; } /** @hide */ static class MyReadMapCallback implements XmlUtils.ReadMapCallback { @Override Loading
core/java/android/os/UserManager.java +19 −4 Original line number Diff line number Diff line Loading @@ -93,6 +93,21 @@ public class UserManager { private Boolean mIsManagedProfileCached; private Boolean mIsProfileCached; /** Maximum length of username. * @hide */ public static final int MAX_USER_NAME_LENGTH = 100; /** Maximum length of user property String value. * @hide */ public static final int MAX_ACCOUNT_STRING_LENGTH = 500; /** Maximum length of account options String values. * @hide */ public static final int MAX_ACCOUNT_OPTIONS_LENGTH = 1000; /** * User type representing a {@link UserHandle#USER_SYSTEM system} user that is a human user. * This type of user cannot be created; it can only pre-exist on first boot. Loading Loading @@ -3185,15 +3200,15 @@ public class UserManager { * time, the preferred user name and account information are used by the setup process for that * user. * * @param userName Optional name to assign to the user. * @param userName Optional name to assign to the user. Character limit is 100. * @param accountName Optional account name that will be used by the setup wizard to initialize * the user. * the user. Character limit is 500. * @param accountType Optional account type for the account to be created. This is required * if the account name is specified. * if the account name is specified. Character limit is 500. * @param accountOptions Optional bundle of data to be passed in during account creation in the * new user via {@link AccountManager#addAccount(String, String, String[], * Bundle, android.app.Activity, android.accounts.AccountManagerCallback, * Handler)}. * Handler)}. Character limit is 1000. * @return An Intent that can be launched from an Activity. * @see #USER_CREATION_FAILED_NOT_PERMITTED * @see #USER_CREATION_FAILED_NO_MORE_USERS Loading
core/java/com/android/internal/app/ConfirmUserCreationActivity.java +12 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,14 @@ public class ConfirmUserCreationActivity extends AlertActivity if (cantCreateUser) { setResult(UserManager.USER_CREATION_FAILED_NOT_PERMITTED); return null; } else if (!(isUserPropertyWithinLimit(mUserName, UserManager.MAX_USER_NAME_LENGTH) && isUserPropertyWithinLimit(mAccountName, UserManager.MAX_ACCOUNT_STRING_LENGTH) && isUserPropertyWithinLimit(mAccountType, UserManager.MAX_ACCOUNT_STRING_LENGTH)) || (mAccountOptions != null && !mAccountOptions.isBundleContentsWithinLengthLimit( UserManager.MAX_ACCOUNT_OPTIONS_LENGTH))) { setResult(UserManager.USER_CREATION_FAILED_NOT_PERMITTED); Log.i(TAG, "User properties must not exceed their character limits"); return null; } else if (cantCreateAnyMoreUsers) { setResult(UserManager.USER_CREATION_FAILED_NO_MORE_USERS); return null; Loading Loading @@ -141,4 +149,8 @@ public class ConfirmUserCreationActivity extends AlertActivity } finish(); } private boolean isUserPropertyWithinLimit(String property, int limit) { return property == null || property.length() <= limit; } }
core/java/com/android/internal/widget/LockPatternUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -1353,8 +1353,8 @@ public class LockPatternUtils { } public boolean isUserInLockdown(int userId) { return getStrongAuthForUser(userId) == StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; return (getStrongAuthForUser(userId) & StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN) != 0; } private static class WrappedCallback extends ICheckCredentialProgressCallback.Stub { Loading