diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2014-08-02 13:31:30 -0700 |
---|---|---|
committer | Deepanshu Gupta <deepanshu@google.com> | 2014-08-05 21:13:00 +0000 |
commit | 0c5cd96522bae516a43d79d9014e93bca4727785 (patch) | |
tree | 6dc87e871b3f57425db547c94dae529899a2df9b /tools/layoutlib/bridge | |
parent | 45aab0eb8f479b9967e7c3c43d0342412fb49b57 (diff) | |
download | frameworks_base-0c5cd96522bae516a43d79d9014e93bca4727785.zip frameworks_base-0c5cd96522bae516a43d79d9014e93bca4727785.tar.gz frameworks_base-0c5cd96522bae516a43d79d9014e93bca4727785.tar.bz2 |
Add SystemProperties native method implementations.
Bug: http://b.android.com/73046
Change-Id: Ia695e7beb81f426509b646cfd929201f7e0a4ade
Diffstat (limited to 'tools/layoutlib/bridge')
-rw-r--r-- | tools/layoutlib/bridge/src/android/os/SystemProperties_Delegate.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/layoutlib/bridge/src/android/os/SystemProperties_Delegate.java b/tools/layoutlib/bridge/src/android/os/SystemProperties_Delegate.java index 1e7564e..af0c456 100644 --- a/tools/layoutlib/bridge/src/android/os/SystemProperties_Delegate.java +++ b/tools/layoutlib/bridge/src/android/os/SystemProperties_Delegate.java @@ -48,4 +48,58 @@ public class SystemProperties_Delegate { return def; } + @LayoutlibDelegate + /*package*/ static int native_get_int(String key, int def) { + Map<String, String> properties = Bridge.getPlatformProperties(); + String value = properties.get(key); + if (value != null) { + return Integer.decode(value); + } + + return def; + } + + @LayoutlibDelegate + /*package*/ static long native_get_long(String key, long def) { + Map<String, String> properties = Bridge.getPlatformProperties(); + String value = properties.get(key); + if (value != null) { + return Long.decode(value); + } + + return def; + } + + /** + * Values 'n', 'no', '0', 'false' or 'off' are considered false. + * Values 'y', 'yes', '1', 'true' or 'on' are considered true. + */ + @LayoutlibDelegate + /*package*/ static boolean native_get_boolean(String key, boolean def) { + Map<String, String> properties = Bridge.getPlatformProperties(); + String value = properties.get(key); + + if ("n".equals(value) || "no".equals(value) || "0".equals(value) || "false".equals(value) + || "off".equals(value)) { + return false; + } + //noinspection SimplifiableIfStatement + if ("y".equals(value) || "yes".equals(value) || "1".equals(value) || "true".equals(value) + || "on".equals(value)) { + return true; + } + + return def; + } + + @LayoutlibDelegate + /*package*/ static void native_set(String key, String def) { + Map<String, String> properties = Bridge.getPlatformProperties(); + properties.put(key, def); + } + + @LayoutlibDelegate + /*package*/ static void native_add_change_callback() { + // pass. + } } |