Merge "Remove the name length limit for system properties." am: c657b769ab
am: 6f00e6e977
Change-Id: If2daf92e3b7aed37832aa0787a2c689d8bdedd97
This commit is contained in:
@@ -35,7 +35,6 @@ public class SystemProperties {
|
|||||||
private static final String TAG = "SystemProperties";
|
private static final String TAG = "SystemProperties";
|
||||||
private static final boolean TRACK_KEY_ACCESS = false;
|
private static final boolean TRACK_KEY_ACCESS = false;
|
||||||
|
|
||||||
public static final int PROP_NAME_MAX = 31;
|
|
||||||
public static final int PROP_VALUE_MAX = 91;
|
public static final int PROP_VALUE_MAX = 91;
|
||||||
|
|
||||||
private static final ArrayList<Runnable> sChangeCallbacks = new ArrayList<Runnable>();
|
private static final ArrayList<Runnable> sChangeCallbacks = new ArrayList<Runnable>();
|
||||||
@@ -82,12 +81,8 @@ public class SystemProperties {
|
|||||||
/**
|
/**
|
||||||
* Get the value for the given key.
|
* Get the value for the given key.
|
||||||
* @return an empty string if the key isn't found
|
* @return an empty string if the key isn't found
|
||||||
* @throws IllegalArgumentException if the key exceeds 32 characters
|
|
||||||
*/
|
*/
|
||||||
public static String get(String key) {
|
public static String get(String key) {
|
||||||
if (key.length() > PROP_NAME_MAX) {
|
|
||||||
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
|
|
||||||
}
|
|
||||||
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
||||||
return native_get(key);
|
return native_get(key);
|
||||||
}
|
}
|
||||||
@@ -95,12 +90,8 @@ public class SystemProperties {
|
|||||||
/**
|
/**
|
||||||
* Get the value for the given key.
|
* Get the value for the given key.
|
||||||
* @return if the key isn't found, return def if it isn't null, or an empty string otherwise
|
* @return if the key isn't found, return def if it isn't null, or an empty string otherwise
|
||||||
* @throws IllegalArgumentException if the key exceeds 32 characters
|
|
||||||
*/
|
*/
|
||||||
public static String get(String key, String def) {
|
public static String get(String key, String def) {
|
||||||
if (key.length() > PROP_NAME_MAX) {
|
|
||||||
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
|
|
||||||
}
|
|
||||||
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
||||||
return native_get(key, def);
|
return native_get(key, def);
|
||||||
}
|
}
|
||||||
@@ -111,12 +102,8 @@ public class SystemProperties {
|
|||||||
* @param def a default value to return
|
* @param def a default value to return
|
||||||
* @return the key parsed as an integer, or def if the key isn't found or
|
* @return the key parsed as an integer, or def if the key isn't found or
|
||||||
* cannot be parsed
|
* cannot be parsed
|
||||||
* @throws IllegalArgumentException if the key exceeds 32 characters
|
|
||||||
*/
|
*/
|
||||||
public static int getInt(String key, int def) {
|
public static int getInt(String key, int def) {
|
||||||
if (key.length() > PROP_NAME_MAX) {
|
|
||||||
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
|
|
||||||
}
|
|
||||||
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
||||||
return native_get_int(key, def);
|
return native_get_int(key, def);
|
||||||
}
|
}
|
||||||
@@ -127,12 +114,8 @@ public class SystemProperties {
|
|||||||
* @param def a default value to return
|
* @param def a default value to return
|
||||||
* @return the key parsed as a long, or def if the key isn't found or
|
* @return the key parsed as a long, or def if the key isn't found or
|
||||||
* cannot be parsed
|
* cannot be parsed
|
||||||
* @throws IllegalArgumentException if the key exceeds 32 characters
|
|
||||||
*/
|
*/
|
||||||
public static long getLong(String key, long def) {
|
public static long getLong(String key, long def) {
|
||||||
if (key.length() > PROP_NAME_MAX) {
|
|
||||||
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
|
|
||||||
}
|
|
||||||
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
||||||
return native_get_long(key, def);
|
return native_get_long(key, def);
|
||||||
}
|
}
|
||||||
@@ -148,25 +131,17 @@ public class SystemProperties {
|
|||||||
* @param def a default value to return
|
* @param def a default value to return
|
||||||
* @return the key parsed as a boolean, or def if the key isn't found or is
|
* @return the key parsed as a boolean, or def if the key isn't found or is
|
||||||
* not able to be parsed as a boolean.
|
* not able to be parsed as a boolean.
|
||||||
* @throws IllegalArgumentException if the key exceeds 32 characters
|
|
||||||
*/
|
*/
|
||||||
public static boolean getBoolean(String key, boolean def) {
|
public static boolean getBoolean(String key, boolean def) {
|
||||||
if (key.length() > PROP_NAME_MAX) {
|
|
||||||
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
|
|
||||||
}
|
|
||||||
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
if (TRACK_KEY_ACCESS) onKeyAccess(key);
|
||||||
return native_get_boolean(key, def);
|
return native_get_boolean(key, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value for the given key.
|
* Set the value for the given key.
|
||||||
* @throws IllegalArgumentException if the key exceeds 32 characters
|
|
||||||
* @throws IllegalArgumentException if the value exceeds 92 characters
|
* @throws IllegalArgumentException if the value exceeds 92 characters
|
||||||
*/
|
*/
|
||||||
public static void set(String key, String val) {
|
public static void set(String key, String val) {
|
||||||
if (key.length() > PROP_NAME_MAX) {
|
|
||||||
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
|
|
||||||
}
|
|
||||||
if (val != null && val.length() > PROP_VALUE_MAX) {
|
if (val != null && val.length() > PROP_VALUE_MAX) {
|
||||||
throw new IllegalArgumentException("val.length > " +
|
throw new IllegalArgumentException("val.length > " +
|
||||||
PROP_VALUE_MAX);
|
PROP_VALUE_MAX);
|
||||||
|
|||||||
@@ -80,9 +80,7 @@ public class PackageManagerServiceCompilerMapping {
|
|||||||
try {
|
try {
|
||||||
// Check that the system property name is legal.
|
// Check that the system property name is legal.
|
||||||
String sysPropName = getSystemPropertyName(reason);
|
String sysPropName = getSystemPropertyName(reason);
|
||||||
if (sysPropName == null ||
|
if (sysPropName == null || sysPropName.isEmpty()) {
|
||||||
sysPropName.isEmpty() ||
|
|
||||||
sysPropName.length() > SystemProperties.PROP_NAME_MAX) {
|
|
||||||
throw new IllegalStateException("Reason system property name \"" +
|
throw new IllegalStateException("Reason system property name \"" +
|
||||||
sysPropName +"\" for reason " + REASON_STRINGS[reason]);
|
sysPropName +"\" for reason " + REASON_STRINGS[reason]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3931,9 +3931,8 @@ public class TelephonyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property.length() > SystemProperties.PROP_NAME_MAX
|
if (propVal.length() > SystemProperties.PROP_VALUE_MAX) {
|
||||||
|| propVal.length() > SystemProperties.PROP_VALUE_MAX) {
|
Rlog.d(TAG, "setTelephonyProperty: property too long phoneId=" + phoneId +
|
||||||
Rlog.d(TAG, "setTelephonyProperty: property to long phoneId=" + phoneId +
|
|
||||||
" property=" + property + " value: " + value + " propVal=" + propVal);
|
" property=" + property + " value: " + value + " propVal=" + propVal);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user