diff options
author | Sergey Ten <sergey.ten6@t-mobile.com> | 2009-05-26 07:01:39 -0700 |
---|---|---|
committer | Josh Guilfoyle <Josh.Guilfoyle@T-Mobile.com> | 2009-07-29 19:58:09 -0700 |
commit | 3d7071acc1b75e70c0f3e98dabb65c55ba589a71 (patch) | |
tree | 0d6947e921fe9bbeb50594b78fa80ca64eb1c3e2 /core/java/android/os | |
parent | 556daac7990a33f74a0059c3d804bf0f589e2248 (diff) | |
download | frameworks_base-3d7071acc1b75e70c0f3e98dabb65c55ba589a71.zip frameworks_base-3d7071acc1b75e70c0f3e98dabb65c55ba589a71.tar.gz frameworks_base-3d7071acc1b75e70c0f3e98dabb65c55ba589a71.tar.bz2 |
Implement efficient way of creating/handling custom themes.
Diffstat (limited to 'core/java/android/os')
-rw-r--r-- | core/java/android/os/SystemProperties.java | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/core/java/android/os/SystemProperties.java b/core/java/android/os/SystemProperties.java index c3ae3c2..dc0c444 100644 --- a/core/java/android/os/SystemProperties.java +++ b/core/java/android/os/SystemProperties.java @@ -140,4 +140,49 @@ public class SystemProperties } native_set(key, val); } -} + + /** + * Get the value for the given key. + * @return def string if the key isn't found + */ + public static String getLongString(String key, String def) { + if (key.length() + 1 > PROP_NAME_MAX) { + throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); + } + int chunks = getInt(key + '0', 0); + if (chunks == 0) { + return def; + } + StringBuffer sb = new StringBuffer(); + for (int i = 1; i <= chunks; i++) { + sb.append(native_get(key + Integer.toString(i))); + } + return sb.toString(); + } + + /** + * Set the value for the given key. + * @throws IllegalArgumentException if the key exceeds 32 characters + */ + public static void setLongString(String key, String val) { + if (key.length() + 1 > PROP_NAME_MAX) { + throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX); + } + int chunks = 0; + if (val != null && val.length() > 0) { + chunks = 1 + val.length() / (PROP_VALUE_MAX + 1); + } + native_set(key + '0', Integer.toString(chunks)); + if (chunks > 0) { + for (int i = 1, start = 0; i <= chunks; i++) { + int end = start + PROP_VALUE_MAX; + if (end > val.length()) { + end = val.length(); + } + native_set(key + Integer.toString(i), val.substring(start, end)); + start = end; + } + } + } + +}
\ No newline at end of file |