blob: e9f13eb5e501647abb7a4177fc85e1394545086c [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
Jeff Sharkey55687722014-04-09 18:07:19 -070019import android.text.TextUtils;
Jeff Sharkeybdd44912014-04-11 16:30:14 -070020import android.util.Slog;
Jeff Sharkey55687722014-04-09 18:07:19 -070021
Doug Zongkerad2171a2011-06-14 11:07:24 -070022import com.android.internal.telephony.TelephonyProperties;
Narayan Kamatheff258c2014-09-30 13:20:57 +010023import dalvik.system.VMRuntime;
Doug Zongkerad2171a2011-06-14 11:07:24 -070024
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025/**
26 * Information about the current build, extracted from system properties.
27 */
28public class Build {
Jeff Sharkeybdd44912014-04-11 16:30:14 -070029 private static final String TAG = "Build";
30
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031 /** Value used for when a build property is unknown. */
Ficus Kirkpatrick71de7852010-01-08 13:10:51 -080032 public static final String UNKNOWN = "unknown";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033
34 /** Either a changelist number, or a label like "M4-rc20". */
35 public static final String ID = getString("ro.build.id");
36
37 /** A build ID string meant for displaying to the user */
38 public static final String DISPLAY = getString("ro.build.display.id");
39
40 /** The name of the overall product. */
41 public static final String PRODUCT = getString("ro.product.name");
42
43 /** The name of the industrial design. */
44 public static final String DEVICE = getString("ro.product.device");
45
46 /** The name of the underlying board, like "goldfish". */
47 public static final String BOARD = getString("ro.product.board");
48
Narayan Kamath1adf4002014-07-12 11:46:37 +010049 /**
50 * The name of the instruction set (CPU type + ABI convention) of native code.
51 *
52 * @deprecated Use {@link #SUPPORTED_ABIS} instead.
53 */
54 @Deprecated
Narayan Kamatheff258c2014-09-30 13:20:57 +010055 public static final String CPU_ABI;
Dianne Hackbornb1811182009-05-21 15:45:42 -070056
Narayan Kamath1adf4002014-07-12 11:46:37 +010057 /**
58 * The name of the second instruction set (CPU type + ABI convention) of native code.
59 *
60 * @deprecated Use {@link #SUPPORTED_ABIS} instead.
61 */
62 @Deprecated
Narayan Kamatheff258c2014-09-30 13:20:57 +010063 public static final String CPU_ABI2;
Ficus Kirkpatrickfa9cafa2010-01-06 17:37:13 -080064
Dianne Hackbornd62ad4f2009-05-19 19:06:25 -070065 /** The manufacturer of the product/hardware. */
66 public static final String MANUFACTURER = getString("ro.product.manufacturer");
67
Dirk Dougherty491b40d2013-10-29 18:33:29 -070068 /** The consumer-visible brand with which the product/hardware will be associated, if any. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 public static final String BRAND = getString("ro.product.brand");
70
71 /** The end-user-visible name for the end product. */
72 public static final String MODEL = getString("ro.product.model");
73
Doug Zongker74885ef2010-02-02 17:39:26 -080074 /** The system bootloader version number. */
Dan Egnor42471dd2010-01-07 17:25:22 -080075 public static final String BOOTLOADER = getString("ro.bootloader");
76
Doug Zongkerad2171a2011-06-14 11:07:24 -070077 /**
78 * The radio firmware version number.
79 *
80 * @deprecated The radio firmware version is frequently not
81 * available when this class is initialized, leading to a blank or
82 * "unknown" value for this string. Use
83 * {@link #getRadioVersion} instead.
84 */
85 @Deprecated
86 public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
Dan Egnor42471dd2010-01-07 17:25:22 -080087
Doug Zongker74885ef2010-02-02 17:39:26 -080088 /** The name of the hardware (from the kernel command line or /proc). */
89 public static final String HARDWARE = getString("ro.hardware");
Dan Egnor42471dd2010-01-07 17:25:22 -080090
Doug Zongker7d2e3df2010-08-11 16:58:04 -070091 /** A hardware serial number, if available. Alphanumeric only, case-insensitive. */
92 public static final String SERIAL = getString("ro.serialno");
Ramin Zaghi1378aba2014-02-28 15:03:19 +000093
94 /**
Narayan Kamath0f206a12014-04-12 11:41:13 +010095 * An ordered list of ABIs supported by this device. The most preferred ABI is the first
96 * element in the list.
97 *
98 * See {@link #SUPPORTED_32_BIT_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
Ramin Zaghi1378aba2014-02-28 15:03:19 +000099 */
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100100 public static final String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ",");
Ramin Zaghi1378aba2014-02-28 15:03:19 +0000101
Narayan Kamath0f206a12014-04-12 11:41:13 +0100102 /**
103 * An ordered list of <b>32 bit</b> ABIs supported by this device. The most preferred ABI
104 * is the first element in the list.
105 *
106 * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
Narayan Kamath0f206a12014-04-12 11:41:13 +0100107 */
Torne (Richard Coles)da8c0372014-05-14 16:17:26 +0100108 public static final String[] SUPPORTED_32_BIT_ABIS =
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100109 getStringList("ro.product.cpu.abilist32", ",");
Narayan Kamath0f206a12014-04-12 11:41:13 +0100110
111 /**
112 * An ordered list of <b>64 bit</b> ABIs supported by this device. The most preferred ABI
113 * is the first element in the list.
114 *
115 * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_32_BIT_ABIS}.
Narayan Kamath0f206a12014-04-12 11:41:13 +0100116 */
Torne (Richard Coles)da8c0372014-05-14 16:17:26 +0100117 public static final String[] SUPPORTED_64_BIT_ABIS =
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100118 getStringList("ro.product.cpu.abilist64", ",");
Narayan Kamath0f206a12014-04-12 11:41:13 +0100119
120
Narayan Kamatheff258c2014-09-30 13:20:57 +0100121 static {
122 /*
123 * Adjusts CPU_ABI and CPU_ABI2 depending on whether or not a given process is 64 bit.
124 * 32 bit processes will always see 32 bit ABIs in these fields for backward
125 * compatibility.
126 */
127 final String[] abiList;
128 if (VMRuntime.getRuntime().is64Bit()) {
129 abiList = SUPPORTED_64_BIT_ABIS;
130 } else {
131 abiList = SUPPORTED_32_BIT_ABIS;
132 }
133
134 CPU_ABI = abiList[0];
135 if (abiList.length > 1) {
136 CPU_ABI2 = abiList[1];
137 } else {
138 CPU_ABI2 = "";
139 }
140 }
141
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800142 /** Various version strings. */
143 public static class VERSION {
144 /**
145 * The internal value used by the underlying source control to
146 * represent this build. E.g., a perforce changelist number
147 * or a git hash.
148 */
149 public static final String INCREMENTAL = getString("ro.build.version.incremental");
150
151 /**
152 * The user-visible version string. E.g., "1.0" or "3.4b5".
153 */
154 public static final String RELEASE = getString("ro.build.version.release");
155
156 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700157 * The user-visible SDK version of the framework in its raw String
158 * representation; use {@link #SDK_INT} instead.
159 *
160 * @deprecated Use {@link #SDK_INT} to easily get this as an integer.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800161 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700162 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163 public static final String SDK = getString("ro.build.version.sdk");
Dianne Hackborn851a5412009-05-08 12:06:44 -0700164
165 /**
166 * The user-visible SDK version of the framework; its possible
167 * values are defined in {@link Build.VERSION_CODES}.
168 */
169 public static final int SDK_INT = SystemProperties.getInt(
170 "ro.build.version.sdk", 0);
171
172 /**
173 * The current development codename, or the string "REL" if this is
174 * a release build.
175 */
176 public static final String CODENAME = getString("ro.build.version.codename");
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800177
Dianne Hackbornffcda102014-04-24 13:06:27 -0700178 private static final String[] ALL_CODENAMES
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100179 = getStringList("ro.build.version.all_codenames", ",");
Dianne Hackbornffcda102014-04-24 13:06:27 -0700180
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800181 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800182 * @hide
183 */
Dianne Hackbornffcda102014-04-24 13:06:27 -0700184 public static final String[] ACTIVE_CODENAMES = "REL".equals(ALL_CODENAMES[0])
185 ? new String[0] : ALL_CODENAMES;
186
187 /**
188 * The SDK version to use when accessing resources.
189 * Use the current SDK version code. For every active development codename
190 * we are operating under, we bump the assumed resource platform version by 1.
191 * @hide
192 */
193 public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194 }
195
Dianne Hackborn851a5412009-05-08 12:06:44 -0700196 /**
197 * Enumeration of the currently known SDK version codes. These are the
198 * values that can be found in {@link VERSION#SDK}. Version numbers
199 * increment monotonically with each official platform release.
200 */
201 public static class VERSION_CODES {
202 /**
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700203 * Magic version number for a current development build, which has
204 * not yet turned into an official release.
205 */
206 public static final int CUR_DEVELOPMENT = 10000;
207
208 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700209 * October 2008: The original, first, version of Android. Yay!
210 */
211 public static final int BASE = 1;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700212
Dianne Hackborn851a5412009-05-08 12:06:44 -0700213 /**
214 * February 2009: First Android update, officially called 1.1.
215 */
216 public static final int BASE_1_1 = 2;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700217
Dianne Hackborn851a5412009-05-08 12:06:44 -0700218 /**
219 * May 2009: Android 1.5.
220 */
221 public static final int CUPCAKE = 3;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700222
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700223 /**
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700224 * September 2009: Android 1.6.
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700225 *
226 * <p>Applications targeting this or a later release will get these
227 * new changes in behavior:</p>
228 * <ul>
229 * <li> They must explicitly request the
San Mehat5a3a77d2009-06-01 09:25:28 -0700230 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700231 * able to modify the contents of the SD card. (Apps targeting
232 * earlier versions will always request the permission.)
Dianne Hackbornfe77ec82009-08-12 16:53:56 -0700233 * <li> They must explicitly request the
234 * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be
235 * able to be able to retrieve phone state info. (Apps targeting
236 * earlier versions will always request the permission.)
237 * <li> They are assumed to support different screen densities and
238 * sizes. (Apps targeting earlier versions are assumed to only support
239 * medium density normal size screens unless otherwise indicated).
240 * They can still explicitly specify screen support either way with the
241 * supports-screens manifest tag.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700242 * <li> {@link android.widget.TabHost} will use the new dark tab
243 * background design.
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700244 * </ul>
245 */
Dianne Hackbornfe77ec82009-08-12 16:53:56 -0700246 public static final int DONUT = 4;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700247
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700248 /**
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700249 * November 2009: Android 2.0
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700250 *
251 * <p>Applications targeting this or a later release will get these
252 * new changes in behavior:</p>
253 * <ul>
254 * <li> The {@link android.app.Service#onStartCommand
255 * Service.onStartCommand} function will return the new
256 * {@link android.app.Service#START_STICKY} behavior instead of the
257 * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}.
Dianne Hackborn8d374262009-09-14 21:21:52 -0700258 * <li> The {@link android.app.Activity} class will now execute back
259 * key presses on the key up instead of key down, to be able to detect
260 * canceled presses from virtual keys.
Mike Cleron76097642009-09-25 17:53:56 -0700261 * <li> The {@link android.widget.TabWidget} class will use a new color scheme
262 * for tabs. In the new scheme, the foreground tab has a medium gray background
263 * the background tabs have a dark gray background.
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700264 * </ul>
265 */
Jeff Hamilton6dc3f4e2009-10-10 12:06:19 -0500266 public static final int ECLAIR = 5;
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700267
268 /**
Dianne Hackborn17787762009-11-12 16:11:36 -0800269 * December 2009: Android 2.0.1
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700270 */
Dianne Hackborn17787762009-11-12 16:11:36 -0800271 public static final int ECLAIR_0_1 = 6;
Dianne Hackborn23ef7b42009-11-18 18:20:39 -0800272
273 /**
274 * January 2010: Android 2.1
275 */
276 public static final int ECLAIR_MR1 = 7;
Adam Powell216bccf2010-02-01 15:03:17 -0800277
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700278 /**
279 * June 2010: Android 2.2
280 */
Adam Powell216bccf2010-02-01 15:03:17 -0800281 public static final int FROYO = 8;
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700282
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700283 /**
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800284 * November 2010: Android 2.3
Dianne Hackborn81e92762011-10-09 16:00:21 -0700285 *
286 * <p>Applications targeting this or a later release will get these
287 * new changes in behavior:</p>
288 * <ul>
289 * <li> The application's notification icons will be shown on the new
290 * dark status bar background, so must be visible in this situation.
291 * </ul>
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700292 */
Dianne Hackborn4fa1a222010-10-18 13:10:49 -0700293 public static final int GINGERBREAD = 9;
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800294
295 /**
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700296 * February 2011: Android 2.3.3.
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800297 */
298 public static final int GINGERBREAD_MR1 = 10;
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700299
300 /**
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700301 * February 2011: Android 3.0.
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700302 *
303 * <p>Applications targeting this or a later release will get these
304 * new changes in behavior:</p>
305 * <ul>
Dianne Hackborn3e6d50c2010-08-23 18:30:44 -0700306 * <li> The default theme for applications is now dark holographic:
307 * {@link android.R.style#Theme_Holo}.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700308 * <li> On large screen devices that do not have a physical menu
309 * button, the soft (compatibility) menu is disabled.
Dianne Hackborn0aae2d42010-12-07 23:51:29 -0800310 * <li> The activity lifecycle has changed slightly as per
311 * {@link android.app.Activity}.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700312 * <li> An application will crash if it does not call through
313 * to the super implementation of its
314 * {@link android.app.Activity#onPause Activity.onPause()} method.
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800315 * <li> When an application requires a permission to access one of
Dianne Hackborn6c2c5fc2011-01-18 17:02:33 -0800316 * its components (activity, receiver, service, provider), this
317 * permission is no longer enforced when the application wants to
318 * access its own component. This means it can require a permission
319 * on a component that it does not itself hold and still access that
320 * component.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700321 * <li> {@link android.content.Context#getSharedPreferences
322 * Context.getSharedPreferences()} will not automatically reload
323 * the preferences if they have changed on storage, unless
324 * {@link android.content.Context#MODE_MULTI_PROCESS} is used.
325 * <li> {@link android.view.ViewGroup#setMotionEventSplittingEnabled}
326 * will default to true.
327 * <li> {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH}
328 * is enabled by default on windows.
329 * <li> {@link android.widget.PopupWindow#isSplitTouchEnabled()
330 * PopupWindow.isSplitTouchEnabled()} will return true by default.
331 * <li> {@link android.widget.GridView} and {@link android.widget.ListView}
332 * will use {@link android.view.View#setActivated View.setActivated}
333 * for selected items if they do not implement {@link android.widget.Checkable}.
334 * <li> {@link android.widget.Scroller} will be constructed with
335 * "flywheel" behavior enabled by default.
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700336 * </ul>
337 */
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800338 public static final int HONEYCOMB = 11;
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700339
340 /**
Dianne Hackborna8138732011-05-12 15:45:21 -0700341 * May 2011: Android 3.1.
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700342 */
343 public static final int HONEYCOMB_MR1 = 12;
Dianne Hackborna8138732011-05-12 15:45:21 -0700344
345 /**
Dianne Hackborn426431a2011-06-09 11:29:08 -0700346 * June 2011: Android 3.2.
Dianne Hackborne6676352011-06-01 16:51:20 -0700347 *
348 * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve
349 * screen compatibility mode, etc.</p>
350 *
351 * <p>As of this version, applications that don't say whether they
352 * support XLARGE screens will be assumed to do so only if they target
353 * {@link #HONEYCOMB} or later; it had been {@link #GINGERBREAD} or
354 * later. Applications that don't support a screen size at least as
355 * large as the current screen will provide the user with a UI to
356 * switch them in to screen size compatibility mode.</p>
Dianne Hackborne289bff2011-06-13 19:33:22 -0700357 *
358 * <p>This version introduces new screen size resource qualifiers
359 * based on the screen size in dp: see
360 * {@link android.content.res.Configuration#screenWidthDp},
361 * {@link android.content.res.Configuration#screenHeightDp}, and
362 * {@link android.content.res.Configuration#smallestScreenWidthDp}.
363 * Supplying these in &lt;supports-screens&gt; as per
364 * {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp},
365 * {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp}, and
366 * {@link android.content.pm.ApplicationInfo#largestWidthLimitDp} is
367 * preferred over the older screen size buckets and for older devices
368 * the appropriate buckets will be inferred from them.</p>
369 *
Dianne Hackborn81e92762011-10-09 16:00:21 -0700370 * <p>Applications targeting this or a later release will get these
371 * new changes in behavior:</p>
372 * <ul>
373 * <li><p>New {@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT}
Dianne Hackborne289bff2011-06-13 19:33:22 -0700374 * and {@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE}
Dianne Hackborn81e92762011-10-09 16:00:21 -0700375 * features were introduced in this release. Applications that target
Dianne Hackborne289bff2011-06-13 19:33:22 -0700376 * previous platform versions are assumed to require both portrait and
377 * landscape support in the device; when targeting Honeycomb MR1 or
378 * greater the application is responsible for specifying any specific
379 * orientation it requires.</p>
Dianne Hackborn81e92762011-10-09 16:00:21 -0700380 * <li><p>{@link android.os.AsyncTask} will use the serial executor
381 * by default when calling {@link android.os.AsyncTask#execute}.</p>
382 * <li><p>{@link android.content.pm.ActivityInfo#configChanges
383 * ActivityInfo.configChanges} will have the
384 * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE} and
385 * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE}
386 * bits set; these need to be cleared for older applications because
387 * some developers have done absolute comparisons against this value
388 * instead of correctly masking the bits they are interested in.
389 * </ul>
Dianne Hackborna8138732011-05-12 15:45:21 -0700390 */
Dianne Hackborn426431a2011-06-09 11:29:08 -0700391 public static final int HONEYCOMB_MR2 = 13;
Dianne Hackborn3fc982f2011-03-30 16:20:26 -0700392
393 /**
Dianne Hackbornf35fe232011-11-01 19:25:20 -0700394 * October 2011: Android 4.0.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700395 *
396 * <p>Applications targeting this or a later release will get these
397 * new changes in behavior:</p>
398 * <ul>
Dianne Hackborn9d0e37e2011-09-22 12:58:54 -0700399 * <li> For devices without a dedicated menu key, the software compatibility
400 * menu key will not be shown even on phones. By targeting Ice Cream Sandwich
401 * or later, your UI must always have its own menu UI affordance if needed,
402 * on both tablets and phones. The ActionBar will take care of this for you.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700403 * <li> 2d drawing hardware acceleration is now turned on by default.
404 * You can use
405 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
406 * to turn it off if needed, although this is strongly discouraged since
407 * it will result in poor performance on larger screen devices.
Adam Powell6e90a362011-08-14 16:48:32 -0700408 * <li> The default theme for applications is now the "device default" theme:
409 * {@link android.R.style#Theme_DeviceDefault}. This may be the
410 * holo dark theme or a different dark theme defined by the specific device.
411 * The {@link android.R.style#Theme_Holo} family must not be modified
412 * for a device to be considered compatible. Applications that explicitly
413 * request a theme from the Holo family will be guaranteed that these themes
414 * will not change character within the same platform version. Applications
415 * that wish to blend in with the device should use a theme from the
416 * {@link android.R.style#Theme_DeviceDefault} family.
Dianne Hackborn9d0e37e2011-09-22 12:58:54 -0700417 * <li> Managed cursors can now throw an exception if you directly close
418 * the cursor yourself without stopping the management of it; previously failures
419 * would be silently ignored.
420 * <li> The fadingEdge attribute on views will be ignored (fading edges is no
421 * longer a standard part of the UI). A new requiresFadingEdge attribute allows
422 * applications to still force fading edges on for special cases.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700423 * <li> {@link android.content.Context#bindService Context.bindService()}
424 * will not automatically add in {@link android.content.Context#BIND_WAIVE_PRIORITY}.
425 * <li> App Widgets will have standard padding automatically added around
426 * them, rather than relying on the padding being baked into the widget itself.
427 * <li> An exception will be thrown if you try to change the type of a
428 * window after it has been added to the window manager. Previously this
429 * would result in random incorrect behavior.
430 * <li> {@link android.view.animation.AnimationSet} will parse out
431 * the duration, fillBefore, fillAfter, repeatMode, and startOffset
432 * XML attributes that are defined.
433 * <li> {@link android.app.ActionBar#setHomeButtonEnabled
434 * ActionBar.setHomeButtonEnabled()} is false by default.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700435 * </ul>
Dianne Hackborn3fc982f2011-03-30 16:20:26 -0700436 */
Dianne Hackborn0784cfb2011-09-14 13:48:15 -0700437 public static final int ICE_CREAM_SANDWICH = 14;
Dianne Hackbornf35fe232011-11-01 19:25:20 -0700438
439 /**
Dianne Hackborn81e92762011-10-09 16:00:21 -0700440 * December 2011: Android 4.0.3.
Dianne Hackbornf35fe232011-11-01 19:25:20 -0700441 */
442 public static final int ICE_CREAM_SANDWICH_MR1 = 15;
Dianne Hackborn81e92762011-10-09 16:00:21 -0700443
444 /**
Dianne Hackborn435cdb42012-07-30 17:36:43 -0700445 * June 2012: Android 4.1.
Dianne Hackborn65696252012-03-05 18:49:21 -0800446 *
447 * <p>Applications targeting this or a later release will get these
448 * new changes in behavior:</p>
449 * <ul>
Dianne Hackborn636fd522012-06-05 17:38:50 -0700450 * <li> You must explicitly request the {@link android.Manifest.permission#READ_CALL_LOG}
451 * and/or {@link android.Manifest.permission#WRITE_CALL_LOG} permissions;
452 * access to the call log is no longer implicitly provided through
453 * {@link android.Manifest.permission#READ_CONTACTS} and
454 * {@link android.Manifest.permission#WRITE_CONTACTS}.
455 * <li> {@link android.widget.RemoteViews} will throw an exception if
456 * setting an onClick handler for views being generated by a
457 * {@link android.widget.RemoteViewsService} for a collection container;
458 * previously this just resulted in a warning log message.
459 * <li> New {@link android.app.ActionBar} policy for embedded tabs:
460 * embedded tabs are now always stacked in the action bar when in portrait
461 * mode, regardless of the size of the screen.
462 * <li> {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs(boolean)
463 * WebSettings.setAllowFileAccessFromFileURLs} and
464 * {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs(boolean)
465 * WebSettings.setAllowUniversalAccessFromFileURLs} default to false.
Dianne Hackborn65696252012-03-05 18:49:21 -0800466 * <li> Calls to {@link android.content.pm.PackageManager#setComponentEnabledSetting
467 * PackageManager.setComponentEnabledSetting} will now throw an
468 * IllegalArgumentException if the given component class name does not
469 * exist in the application's manifest.
Dianne Hackborn636fd522012-06-05 17:38:50 -0700470 * <li> {@link android.nfc.NfcAdapter#setNdefPushMessage
471 * NfcAdapter.setNdefPushMessage},
472 * {@link android.nfc.NfcAdapter#setNdefPushMessageCallback
473 * NfcAdapter.setNdefPushMessageCallback} and
474 * {@link android.nfc.NfcAdapter#setOnNdefPushCompleteCallback
475 * NfcAdapter.setOnNdefPushCompleteCallback} will throw
476 * IllegalStateException if called after the Activity has been destroyed.
477 * <li> Accessibility services must require the new
478 * {@link android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE} permission or
479 * they will not be available for use.
480 * <li> {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
481 * AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} must be set
482 * for unimportant views to be included in queries.
Dianne Hackborn65696252012-03-05 18:49:21 -0800483 * </ul>
Dianne Hackborn81e92762011-10-09 16:00:21 -0700484 */
Dianne Hackbornfa61f0b2012-05-09 21:49:38 -0700485 public static final int JELLY_BEAN = 16;
Dianne Hackborn435cdb42012-07-30 17:36:43 -0700486
487 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700488 * November 2012: Android 4.2, Moar jelly beans!
Nick Kralevichf097b162012-07-28 12:43:48 -0700489 *
490 * <p>Applications targeting this or a later release will get these
491 * new changes in behavior:</p>
492 * <ul>
493 * <li>Content Providers: The default value of {@code android:exported} is now
494 * {@code false}. See
Nick Kralevich2caec6c2012-08-08 11:33:17 -0700495 * <a href="{@docRoot}guide/topics/manifest/provider-element.html#exported">
Nick Kralevichf097b162012-07-28 12:43:48 -0700496 * the android:exported section</a> in the provider documentation for more details.</li>
Dianne Hackbornfc494742012-09-27 16:15:42 -0700497 * <li>{@link android.view.View#getLayoutDirection() View.getLayoutDirection()}
498 * can return different values than {@link android.view.View#LAYOUT_DIRECTION_LTR}
499 * based on the locale etc.
500 * <li> {@link android.webkit.WebView#addJavascriptInterface(Object, String)
501 * WebView.addJavascriptInterface} requires explicit annotations on methods
502 * for them to be accessible from Javascript.
Nick Kralevichf097b162012-07-28 12:43:48 -0700503 * </ul>
Dianne Hackborn435cdb42012-07-30 17:36:43 -0700504 */
505 public static final int JELLY_BEAN_MR1 = 17;
Nick Kralevicha985c3b2013-01-09 16:03:14 -0800506
507 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700508 * July 2013: Android 4.3, the revenge of the beans.
Nick Kralevicha985c3b2013-01-09 16:03:14 -0800509 */
Dianne Hackbornd2eeed62013-04-22 13:04:28 -0700510 public static final int JELLY_BEAN_MR2 = 18;
Dianne Hackborn5d2bfa12013-03-05 10:28:34 -0800511
512 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700513 * October 2013: Android 4.4, KitKat, another tasty treat.
Dianne Hackborn221ea892013-08-04 16:50:16 -0700514 *
515 * <p>Applications targeting this or a later release will get these
516 * new changes in behavior:</p>
517 * <ul>
Dianne Hackborn6bc37892013-10-03 11:05:14 -0700518 * <li> The default result of {android.preference.PreferenceActivity#isValidFragment
519 * PreferenceActivity.isValueFragment} becomes false instead of true.</li>
520 * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have
521 * JS URLs evaluated directly and any result of the evaluation will not replace
522 * the current page content. Apps targetting KITKAT or later that load a JS URL will
523 * have the result of that URL replace the content of the current page</li>
524 * <li> {@link android.app.AlarmManager#set AlarmManager.set} becomes interpreted as
525 * an inexact value, to give the system more flexibility in scheduling alarms.</li>
526 * <li> {@link android.content.Context#getSharedPreferences(String, int)
527 * Context.getSharedPreferences} no longer allows a null name.</li>
528 * <li> {@link android.widget.RelativeLayout} changes to compute wrapped content
529 * margins correctly.</li>
530 * <li> {@link android.app.ActionBar}'s window content overlay is allowed to be
531 * drawn.</li>
Jeff Sharkey3ec2f602013-10-29 12:21:23 -0700532 * <li>The {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
533 * permission is now always enforced.</li>
534 * <li>Access to package-specific external storage directories belonging
535 * to the calling app no longer requires the
536 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} or
537 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE}
538 * permissions.</li>
Dianne Hackborn221ea892013-08-04 16:50:16 -0700539 * </ul>
Dianne Hackborn5d2bfa12013-03-05 10:28:34 -0800540 */
Dianne Hackborn6bc37892013-10-03 11:05:14 -0700541 public static final int KITKAT = 19;
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700542
543 /**
Justin Koh78b94de2014-05-13 15:48:42 -0700544 * Android 4.4W: KitKat for watches, snacks on the run.
545 *
546 * <p>Applications targeting this or a later release will get these
547 * new changes in behavior:</p>
548 * <ul>
549 * <li>{@link android.app.AlertDialog} might not have a default background if the theme does
550 * not specify one.</li>
551 * </ul>
Jeff Brown1c3f3322014-04-16 13:15:22 -0700552 */
Justin Koh78b94de2014-05-13 15:48:42 -0700553 public static final int KITKAT_WATCH = 20;
Jeff Brown047f3c72014-04-16 14:18:49 -0700554
555 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700556 * Temporary until we completely switch to {@link #LOLLIPOP}.
557 */
558 public static final int L = 21;
559
560 /**
561 * Lollipop. A flat one with beautiful shadows. But still tasty.
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700562 *
563 * <p>Applications targeting this or a later release will get these
564 * new changes in behavior:</p>
565 * <ul>
566 * <li> {@link android.content.Context#bindService Context.bindService} now
Michael Wright5b5def52014-04-11 13:37:50 -0700567 * requires an explicit Intent, and will throw an exception if given an implicit
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700568 * Intent.</li>
569 * </ul>
570 */
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700571 public static final int LOLLIPOP = 21;
Dianne Hackborn3b696882014-10-16 18:14:12 -0700572
573 /**
574 * Lollipop with an extra sugar coating on the outside!
575 */
576 public static final int LOLLIPOP_MR1 = 22;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700577 }
578
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800579 /** The type of build, like "user" or "eng". */
580 public static final String TYPE = getString("ro.build.type");
581
582 /** Comma-separated tags describing the build, like "unsigned,debug". */
583 public static final String TAGS = getString("ro.build.tags");
584
585 /** A string that uniquely identifies this build. Do not attempt to parse this value. */
Jeff Sharkey55687722014-04-09 18:07:19 -0700586 public static final String FINGERPRINT = deriveFingerprint();
587
588 /**
589 * Some devices split the fingerprint components between multiple
590 * partitions, so we might derive the fingerprint at runtime.
591 */
592 private static String deriveFingerprint() {
593 String finger = SystemProperties.get("ro.build.fingerprint");
594 if (TextUtils.isEmpty(finger)) {
595 finger = getString("ro.product.brand") + '/' +
596 getString("ro.product.name") + '/' +
597 getString("ro.product.device") + ':' +
598 getString("ro.build.version.release") + '/' +
599 getString("ro.build.id") + '/' +
600 getString("ro.build.version.incremental") + ':' +
601 getString("ro.build.type") + '/' +
602 getString("ro.build.tags");
603 }
604 return finger;
605 }
606
607 /**
608 * Ensure that raw fingerprint system property is defined. If it was derived
609 * dynamically by {@link #deriveFingerprint()} this is where we push the
610 * derived value into the property service.
611 *
612 * @hide
613 */
614 public static void ensureFingerprintProperty() {
615 if (TextUtils.isEmpty(SystemProperties.get("ro.build.fingerprint"))) {
Jeff Sharkeybdd44912014-04-11 16:30:14 -0700616 try {
617 SystemProperties.set("ro.build.fingerprint", FINGERPRINT);
618 } catch (IllegalArgumentException e) {
619 Slog.e(TAG, "Failed to set fingerprint property", e);
620 }
Jeff Sharkey55687722014-04-09 18:07:19 -0700621 }
622 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800623
624 // The following properties only make sense for internal engineering builds.
625 public static final long TIME = getLong("ro.build.date.utc") * 1000;
626 public static final String USER = getString("ro.build.user");
627 public static final String HOST = getString("ro.build.host");
628
Doug Zongkerad2171a2011-06-14 11:07:24 -0700629 /**
Jeff Brown89101cd92011-10-27 21:24:54 -0700630 * Returns true if we are running a debug build such as "user-debug" or "eng".
631 * @hide
632 */
633 public static final boolean IS_DEBUGGABLE =
634 SystemProperties.getInt("ro.debuggable", 0) == 1;
635
636 /**
Doug Zongkerad2171a2011-06-14 11:07:24 -0700637 * Returns the version string for the radio firmware. May return
638 * null (if, for instance, the radio is not currently on).
639 */
640 public static String getRadioVersion() {
641 return SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION, null);
642 }
643
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800644 private static String getString(String property) {
645 return SystemProperties.get(property, UNKNOWN);
646 }
647
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100648 private static String[] getStringList(String property, String separator) {
649 String value = SystemProperties.get(property);
650 if (value.isEmpty()) {
651 return new String[0];
652 } else {
653 return value.split(separator);
654 }
655 }
656
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800657 private static long getLong(String property) {
658 try {
659 return Long.parseLong(SystemProperties.get(property));
660 } catch (NumberFormatException e) {
661 return -1;
662 }
663 }
664}