Skip to content

Commit 4e01c59

Browse files
deepanshu-Android Git Automerger
authored andcommitted
am 6ebeefa: am 904d771: am 7b561be: am 09c3c2e: am ba31d62: am db94ea9: am f970d2c: am 79c3f67: am 206c691: am 72cf03a: am 3a544a8: resolved conflicts for merge of a232a68 to jb-mr1.1-docs
* commit '6ebeefa04cb3c360d8028eb77e60bacf8a800cb1': Fix SystemProperties in LayoutLib.
2 parents c08203c + 6ebeefa commit 4e01c59

3 files changed

Lines changed: 107 additions & 49 deletions

File tree

tools/layoutlib/bridge/src/android/os/Build_Delegate.java

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright (C) 2014 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.os;
18+
19+
import com.android.layoutlib.bridge.Bridge;
20+
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
21+
22+
import java.util.Map;
23+
24+
/**
25+
* Delegate implementing the native methods of android.os.SystemProperties.
26+
*
27+
* Through the layoutlib_create tool, the original native methods of SystemProperties have been
28+
* replaced by calls to methods of the same name in this delegate class.
29+
*
30+
* Because it's a stateless class to start with, there's no need to keep a {@code DelegateManager}
31+
* around to map int to instance of the delegate.
32+
*/
33+
public class SystemProperties_Delegate {
34+
35+
@LayoutlibDelegate
36+
/*package*/ static String native_get(String key) {
37+
return native_get(key, null);
38+
}
39+
40+
@LayoutlibDelegate
41+
/*package*/ static String native_get(String key, String def) {
42+
Map<String, String> properties = Bridge.getPlatformProperties();
43+
String value = properties.get(key);
44+
if (value != null) {
45+
return value;
46+
}
47+
48+
return def;
49+
}
50+
51+
@LayoutlibDelegate
52+
/*package*/ static int native_get_int(String key, int def) {
53+
Map<String, String> properties = Bridge.getPlatformProperties();
54+
String value = properties.get(key);
55+
if (value != null) {
56+
return Integer.decode(value);
57+
}
58+
59+
return def;
60+
}
61+
62+
@LayoutlibDelegate
63+
/*package*/ static long native_get_long(String key, long def) {
64+
Map<String, String> properties = Bridge.getPlatformProperties();
65+
String value = properties.get(key);
66+
if (value != null) {
67+
return Long.decode(value);
68+
}
69+
70+
return def;
71+
}
72+
73+
/**
74+
* Values 'n', 'no', '0', 'false' or 'off' are considered false.
75+
* Values 'y', 'yes', '1', 'true' or 'on' are considered true.
76+
*/
77+
@LayoutlibDelegate
78+
/*package*/ static boolean native_get_boolean(String key, boolean def) {
79+
Map<String, String> properties = Bridge.getPlatformProperties();
80+
String value = properties.get(key);
81+
82+
if ("n".equals(value) || "no".equals(value) || "0".equals(value) || "false".equals(value)
83+
|| "off".equals(value)) {
84+
return false;
85+
}
86+
//noinspection SimplifiableIfStatement
87+
if ("y".equals(value) || "yes".equals(value) || "1".equals(value) || "true".equals(value)
88+
|| "on".equals(value)) {
89+
return true;
90+
}
91+
92+
return def;
93+
}
94+
95+
@LayoutlibDelegate
96+
/*package*/ static void native_set(String key, String def) {
97+
Map<String, String> properties = Bridge.getPlatformProperties();
98+
properties.put(key, def);
99+
}
100+
101+
@LayoutlibDelegate
102+
/*package*/ static void native_add_change_callback() {
103+
// pass.
104+
}
105+
}
106+

tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public String[] getJavaPkgClasses() {
132132
"android.graphics.BitmapFactory#finishDecode",
133133
"android.os.Handler#sendMessageAtTime",
134134
"android.os.HandlerThread#run",
135-
"android.os.Build#getString",
136135
"android.text.format.DateFormat#is24HourFormat",
137136
"android.view.Choreographer#getRefreshRate",
138137
"android.view.Display#updateDisplayInfoLocked",
@@ -192,6 +191,7 @@ public String[] getJavaPkgClasses() {
192191
"android.graphics.Typeface",
193192
"android.graphics.Xfermode",
194193
"android.os.SystemClock",
194+
"android.os.SystemProperties",
195195
"android.text.AndroidBidi",
196196
"android.text.format.Time",
197197
"android.util.FloatMath",

0 commit comments

Comments
 (0)