blob: 5faab36039866d50613ca0ae9752c30744f4771d [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
17package android.os;
18
Doug Zongkerad2171a2011-06-14 11:07:24 -070019import com.android.internal.telephony.TelephonyProperties;
20
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021/**
22 * Information about the current build, extracted from system properties.
23 */
24public class Build {
25 /** Value used for when a build property is unknown. */
Ficus Kirkpatrick71de7852010-01-08 13:10:51 -080026 public static final String UNKNOWN = "unknown";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027
28 /** Either a changelist number, or a label like "M4-rc20". */
29 public static final String ID = getString("ro.build.id");
30
31 /** A build ID string meant for displaying to the user */
32 public static final String DISPLAY = getString("ro.build.display.id");
33
34 /** The name of the overall product. */
35 public static final String PRODUCT = getString("ro.product.name");
36
37 /** The name of the industrial design. */
38 public static final String DEVICE = getString("ro.product.device");
39
40 /** The name of the underlying board, like "goldfish". */
41 public static final String BOARD = getString("ro.product.board");
42
Dianne Hackbornb1811182009-05-21 15:45:42 -070043 /** The name of the instruction set (CPU type + ABI convention) of native code. */
44 public static final String CPU_ABI = getString("ro.product.cpu.abi");
45
Ficus Kirkpatrickfa9cafa2010-01-06 17:37:13 -080046 /** The name of the second instruction set (CPU type + ABI convention) of native code. */
47 public static final String CPU_ABI2 = getString("ro.product.cpu.abi2");
48
Dianne Hackbornd62ad4f2009-05-19 19:06:25 -070049 /** The manufacturer of the product/hardware. */
50 public static final String MANUFACTURER = getString("ro.product.manufacturer");
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 /** The brand (e.g., carrier) the software is customized for, if any. */
53 public static final String BRAND = getString("ro.product.brand");
54
55 /** The end-user-visible name for the end product. */
56 public static final String MODEL = getString("ro.product.model");
57
Doug Zongker74885ef2010-02-02 17:39:26 -080058 /** The system bootloader version number. */
Dan Egnor42471dd2010-01-07 17:25:22 -080059 public static final String BOOTLOADER = getString("ro.bootloader");
60
Doug Zongkerad2171a2011-06-14 11:07:24 -070061 /**
62 * The radio firmware version number.
63 *
64 * @deprecated The radio firmware version is frequently not
65 * available when this class is initialized, leading to a blank or
66 * "unknown" value for this string. Use
67 * {@link #getRadioVersion} instead.
68 */
69 @Deprecated
70 public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
Dan Egnor42471dd2010-01-07 17:25:22 -080071
Doug Zongker74885ef2010-02-02 17:39:26 -080072 /** The name of the hardware (from the kernel command line or /proc). */
73 public static final String HARDWARE = getString("ro.hardware");
Dan Egnor42471dd2010-01-07 17:25:22 -080074
Doug Zongker7d2e3df2010-08-11 16:58:04 -070075 /** A hardware serial number, if available. Alphanumeric only, case-insensitive. */
76 public static final String SERIAL = getString("ro.serialno");
77
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080078 /** Various version strings. */
79 public static class VERSION {
80 /**
81 * The internal value used by the underlying source control to
82 * represent this build. E.g., a perforce changelist number
83 * or a git hash.
84 */
85 public static final String INCREMENTAL = getString("ro.build.version.incremental");
86
87 /**
88 * The user-visible version string. E.g., "1.0" or "3.4b5".
89 */
90 public static final String RELEASE = getString("ro.build.version.release");
91
92 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -070093 * The user-visible SDK version of the framework in its raw String
94 * representation; use {@link #SDK_INT} instead.
95 *
96 * @deprecated Use {@link #SDK_INT} to easily get this as an integer.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -070098 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 public static final String SDK = getString("ro.build.version.sdk");
Dianne Hackborn851a5412009-05-08 12:06:44 -0700100
101 /**
102 * The user-visible SDK version of the framework; its possible
103 * values are defined in {@link Build.VERSION_CODES}.
104 */
105 public static final int SDK_INT = SystemProperties.getInt(
106 "ro.build.version.sdk", 0);
107
108 /**
109 * The current development codename, or the string "REL" if this is
110 * a release build.
111 */
112 public static final String CODENAME = getString("ro.build.version.codename");
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800113
114 /**
115 * The SDK version to use when accessing resources.
116 * Use the current SDK version code. If we are a development build,
117 * also allow the previous SDK version + 1.
118 * @hide
119 */
120 public static final int RESOURCES_SDK_INT = SDK_INT
121 + ("REL".equals(CODENAME) ? 0 : 1);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800122 }
123
Dianne Hackborn851a5412009-05-08 12:06:44 -0700124 /**
125 * Enumeration of the currently known SDK version codes. These are the
126 * values that can be found in {@link VERSION#SDK}. Version numbers
127 * increment monotonically with each official platform release.
128 */
129 public static class VERSION_CODES {
130 /**
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700131 * Magic version number for a current development build, which has
132 * not yet turned into an official release.
133 */
134 public static final int CUR_DEVELOPMENT = 10000;
135
136 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700137 * October 2008: The original, first, version of Android. Yay!
138 */
139 public static final int BASE = 1;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700140
Dianne Hackborn851a5412009-05-08 12:06:44 -0700141 /**
142 * February 2009: First Android update, officially called 1.1.
143 */
144 public static final int BASE_1_1 = 2;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700145
Dianne Hackborn851a5412009-05-08 12:06:44 -0700146 /**
147 * May 2009: Android 1.5.
148 */
149 public static final int CUPCAKE = 3;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700150
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700151 /**
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700152 * September 2009: Android 1.6.
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700153 *
154 * <p>Applications targeting this or a later release will get these
155 * new changes in behavior:</p>
156 * <ul>
157 * <li> They must explicitly request the
San Mehat5a3a77d2009-06-01 09:25:28 -0700158 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700159 * able to modify the contents of the SD card. (Apps targeting
160 * earlier versions will always request the permission.)
Dianne Hackbornfe77ec82009-08-12 16:53:56 -0700161 * <li> They must explicitly request the
162 * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be
163 * able to be able to retrieve phone state info. (Apps targeting
164 * earlier versions will always request the permission.)
165 * <li> They are assumed to support different screen densities and
166 * sizes. (Apps targeting earlier versions are assumed to only support
167 * medium density normal size screens unless otherwise indicated).
168 * They can still explicitly specify screen support either way with the
169 * supports-screens manifest tag.
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700170 * </ul>
171 */
Dianne Hackbornfe77ec82009-08-12 16:53:56 -0700172 public static final int DONUT = 4;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700173
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700174 /**
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700175 * November 2009: Android 2.0
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700176 *
177 * <p>Applications targeting this or a later release will get these
178 * new changes in behavior:</p>
179 * <ul>
180 * <li> The {@link android.app.Service#onStartCommand
181 * Service.onStartCommand} function will return the new
182 * {@link android.app.Service#START_STICKY} behavior instead of the
183 * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}.
Dianne Hackborn8d374262009-09-14 21:21:52 -0700184 * <li> The {@link android.app.Activity} class will now execute back
185 * key presses on the key up instead of key down, to be able to detect
186 * canceled presses from virtual keys.
Mike Cleron76097642009-09-25 17:53:56 -0700187 * <li> The {@link android.widget.TabWidget} class will use a new color scheme
188 * for tabs. In the new scheme, the foreground tab has a medium gray background
189 * the background tabs have a dark gray background.
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700190 * </ul>
191 */
Jeff Hamilton6dc3f4e2009-10-10 12:06:19 -0500192 public static final int ECLAIR = 5;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700193
194 /**
Dianne Hackborn17787762009-11-12 16:11:36 -0800195 * December 2009: Android 2.0.1
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700196 */
Dianne Hackborn17787762009-11-12 16:11:36 -0800197 public static final int ECLAIR_0_1 = 6;
Dianne Hackborn23ef7b42009-11-18 18:20:39 -0800198
199 /**
200 * January 2010: Android 2.1
201 */
202 public static final int ECLAIR_MR1 = 7;
Adam Powell216bccf2010-02-01 15:03:17 -0800203
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700204 /**
205 * June 2010: Android 2.2
206 */
Adam Powell216bccf2010-02-01 15:03:17 -0800207 public static final int FROYO = 8;
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700208
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700209 /**
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800210 * November 2010: Android 2.3
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700211 */
Dianne Hackborn4fa1a222010-10-18 13:10:49 -0700212 public static final int GINGERBREAD = 9;
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800213
214 /**
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700215 * February 2011: Android 2.3.3.
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800216 */
217 public static final int GINGERBREAD_MR1 = 10;
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700218
219 /**
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700220 * February 2011: Android 3.0.
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700221 *
222 * <p>Applications targeting this or a later release will get these
223 * new changes in behavior:</p>
224 * <ul>
Dianne Hackborn3e6d50c2010-08-23 18:30:44 -0700225 * <li> The default theme for applications is now dark holographic:
226 * {@link android.R.style#Theme_Holo}.
Dianne Hackborn0aae2d42010-12-07 23:51:29 -0800227 * <li> The activity lifecycle has changed slightly as per
228 * {@link android.app.Activity}.
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800229 * <li> When an application requires a permission to access one of
Dianne Hackborn6c2c5fc2011-01-18 17:02:33 -0800230 * its components (activity, receiver, service, provider), this
231 * permission is no longer enforced when the application wants to
232 * access its own component. This means it can require a permission
233 * on a component that it does not itself hold and still access that
234 * component.
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700235 * </ul>
236 */
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800237 public static final int HONEYCOMB = 11;
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700238
239 /**
Dianne Hackborna8138732011-05-12 15:45:21 -0700240 * May 2011: Android 3.1.
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700241 */
242 public static final int HONEYCOMB_MR1 = 12;
Dianne Hackborna8138732011-05-12 15:45:21 -0700243
244 /**
Dianne Hackborn426431a2011-06-09 11:29:08 -0700245 * June 2011: Android 3.2.
Dianne Hackborne6676352011-06-01 16:51:20 -0700246 *
247 * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve
248 * screen compatibility mode, etc.</p>
249 *
250 * <p>As of this version, applications that don't say whether they
251 * support XLARGE screens will be assumed to do so only if they target
252 * {@link #HONEYCOMB} or later; it had been {@link #GINGERBREAD} or
253 * later. Applications that don't support a screen size at least as
254 * large as the current screen will provide the user with a UI to
255 * switch them in to screen size compatibility mode.</p>
Dianne Hackborne289bff2011-06-13 19:33:22 -0700256 *
257 * <p>This version introduces new screen size resource qualifiers
258 * based on the screen size in dp: see
259 * {@link android.content.res.Configuration#screenWidthDp},
260 * {@link android.content.res.Configuration#screenHeightDp}, and
261 * {@link android.content.res.Configuration#smallestScreenWidthDp}.
262 * Supplying these in &lt;supports-screens&gt; as per
263 * {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp},
264 * {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp}, and
265 * {@link android.content.pm.ApplicationInfo#largestWidthLimitDp} is
266 * preferred over the older screen size buckets and for older devices
267 * the appropriate buckets will be inferred from them.</p>
268 *
269 * <p>New {@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT}
270 * and {@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE}
271 * features are introduced in this release. Applications that target
272 * previous platform versions are assumed to require both portrait and
273 * landscape support in the device; when targeting Honeycomb MR1 or
274 * greater the application is responsible for specifying any specific
275 * orientation it requires.</p>
Dianne Hackborna8138732011-05-12 15:45:21 -0700276 */
Dianne Hackborn426431a2011-06-09 11:29:08 -0700277 public static final int HONEYCOMB_MR2 = 13;
Dianne Hackborn3fc982f2011-03-30 16:20:26 -0700278
279 /**
Dianne Hackborn0784cfb2011-09-14 13:48:15 -0700280 * Android 4.0.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700281 *
282 * <p>Applications targeting this or a later release will get these
283 * new changes in behavior:</p>
284 * <ul>
Dianne Hackborn9d0e37e2011-09-22 12:58:54 -0700285 * <li> For devices without a dedicated menu key, the software compatibility
286 * menu key will not be shown even on phones. By targeting Ice Cream Sandwich
287 * or later, your UI must always have its own menu UI affordance if needed,
288 * on both tablets and phones. The ActionBar will take care of this for you.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700289 * <li> 2d drawing hardware acceleration is now turned on by default.
290 * You can use
291 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
292 * to turn it off if needed, although this is strongly discouraged since
293 * it will result in poor performance on larger screen devices.
Adam Powell6e90a362011-08-14 16:48:32 -0700294 * <li> The default theme for applications is now the "device default" theme:
295 * {@link android.R.style#Theme_DeviceDefault}. This may be the
296 * holo dark theme or a different dark theme defined by the specific device.
297 * The {@link android.R.style#Theme_Holo} family must not be modified
298 * for a device to be considered compatible. Applications that explicitly
299 * request a theme from the Holo family will be guaranteed that these themes
300 * will not change character within the same platform version. Applications
301 * that wish to blend in with the device should use a theme from the
302 * {@link android.R.style#Theme_DeviceDefault} family.
Dianne Hackborn9d0e37e2011-09-22 12:58:54 -0700303 * <li> Managed cursors can now throw an exception if you directly close
304 * the cursor yourself without stopping the management of it; previously failures
305 * would be silently ignored.
306 * <li> The fadingEdge attribute on views will be ignored (fading edges is no
307 * longer a standard part of the UI). A new requiresFadingEdge attribute allows
308 * applications to still force fading edges on for special cases.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700309 * </ul>
Dianne Hackborn3fc982f2011-03-30 16:20:26 -0700310 */
Dianne Hackborn0784cfb2011-09-14 13:48:15 -0700311 public static final int ICE_CREAM_SANDWICH = 14;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700312 }
313
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800314 /** The type of build, like "user" or "eng". */
315 public static final String TYPE = getString("ro.build.type");
316
317 /** Comma-separated tags describing the build, like "unsigned,debug". */
318 public static final String TAGS = getString("ro.build.tags");
319
320 /** A string that uniquely identifies this build. Do not attempt to parse this value. */
321 public static final String FINGERPRINT = getString("ro.build.fingerprint");
322
323 // The following properties only make sense for internal engineering builds.
324 public static final long TIME = getLong("ro.build.date.utc") * 1000;
325 public static final String USER = getString("ro.build.user");
326 public static final String HOST = getString("ro.build.host");
327
Doug Zongkerad2171a2011-06-14 11:07:24 -0700328 /**
329 * Returns the version string for the radio firmware. May return
330 * null (if, for instance, the radio is not currently on).
331 */
332 public static String getRadioVersion() {
333 return SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION, null);
334 }
335
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800336 private static String getString(String property) {
337 return SystemProperties.get(property, UNKNOWN);
338 }
339
340 private static long getLong(String property) {
341 try {
342 return Long.parseLong(SystemProperties.get(property));
343 } catch (NumberFormatException e) {
344 return -1;
345 }
346 }
347}