blob: 6de575960f48bfa274cf5221a00798ed768567ec [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
Svet Ganov37e43272016-09-09 16:01:32 -070019import android.Manifest;
20import android.annotation.RequiresPermission;
Svet Ganovae0e03a2016-02-25 18:22:10 -080021import android.annotation.SystemApi;
Dianne Hackborn337e01a2018-02-27 17:16:37 -080022import android.annotation.TestApi;
Dianne Hackborna47d0452017-11-21 15:04:57 -080023import android.app.Application;
Svet Ganov37e43272016-09-09 16:01:32 -070024import android.content.Context;
Jeff Sharkey55687722014-04-09 18:07:19 -070025import android.text.TextUtils;
Jeff Sharkeybdd44912014-04-11 16:30:14 -070026import android.util.Slog;
Dianne Hackborna47d0452017-11-21 15:04:57 -080027import android.view.View;
Jeff Sharkey55687722014-04-09 18:07:19 -070028
Doug Zongkerad2171a2011-06-14 11:07:24 -070029import com.android.internal.telephony.TelephonyProperties;
Jeff Sharkey2cffc7d2014-11-14 13:57:53 -080030
Narayan Kamatheff258c2014-09-30 13:20:57 +010031import dalvik.system.VMRuntime;
Doug Zongkerad2171a2011-06-14 11:07:24 -070032
Jeff Sharkey2cffc7d2014-11-14 13:57:53 -080033import java.util.Objects;
34
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035/**
36 * Information about the current build, extracted from system properties.
37 */
38public class Build {
Jeff Sharkeybdd44912014-04-11 16:30:14 -070039 private static final String TAG = "Build";
40
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041 /** Value used for when a build property is unknown. */
Ficus Kirkpatrick71de7852010-01-08 13:10:51 -080042 public static final String UNKNOWN = "unknown";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043
44 /** Either a changelist number, or a label like "M4-rc20". */
45 public static final String ID = getString("ro.build.id");
46
47 /** A build ID string meant for displaying to the user */
48 public static final String DISPLAY = getString("ro.build.display.id");
49
50 /** The name of the overall product. */
51 public static final String PRODUCT = getString("ro.product.name");
52
53 /** The name of the industrial design. */
54 public static final String DEVICE = getString("ro.product.device");
55
56 /** The name of the underlying board, like "goldfish". */
57 public static final String BOARD = getString("ro.product.board");
58
Narayan Kamath1adf4002014-07-12 11:46:37 +010059 /**
60 * The name of the instruction set (CPU type + ABI convention) of native code.
61 *
62 * @deprecated Use {@link #SUPPORTED_ABIS} instead.
63 */
64 @Deprecated
Narayan Kamatheff258c2014-09-30 13:20:57 +010065 public static final String CPU_ABI;
Dianne Hackbornb1811182009-05-21 15:45:42 -070066
Narayan Kamath1adf4002014-07-12 11:46:37 +010067 /**
68 * The name of the second instruction set (CPU type + ABI convention) of native code.
69 *
70 * @deprecated Use {@link #SUPPORTED_ABIS} instead.
71 */
72 @Deprecated
Narayan Kamatheff258c2014-09-30 13:20:57 +010073 public static final String CPU_ABI2;
Ficus Kirkpatrickfa9cafa2010-01-06 17:37:13 -080074
Dianne Hackbornd62ad4f2009-05-19 19:06:25 -070075 /** The manufacturer of the product/hardware. */
76 public static final String MANUFACTURER = getString("ro.product.manufacturer");
77
Dirk Dougherty491b40d2013-10-29 18:33:29 -070078 /** The consumer-visible brand with which the product/hardware will be associated, if any. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 public static final String BRAND = getString("ro.product.brand");
80
81 /** The end-user-visible name for the end product. */
82 public static final String MODEL = getString("ro.product.model");
83
Doug Zongker74885ef2010-02-02 17:39:26 -080084 /** The system bootloader version number. */
Dan Egnor42471dd2010-01-07 17:25:22 -080085 public static final String BOOTLOADER = getString("ro.bootloader");
86
Doug Zongkerad2171a2011-06-14 11:07:24 -070087 /**
88 * The radio firmware version number.
89 *
90 * @deprecated The radio firmware version is frequently not
91 * available when this class is initialized, leading to a blank or
92 * "unknown" value for this string. Use
93 * {@link #getRadioVersion} instead.
94 */
95 @Deprecated
96 public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
Dan Egnor42471dd2010-01-07 17:25:22 -080097
Doug Zongker74885ef2010-02-02 17:39:26 -080098 /** The name of the hardware (from the kernel command line or /proc). */
99 public static final String HARDWARE = getString("ro.hardware");
Dan Egnor42471dd2010-01-07 17:25:22 -0800100
Griff Hazend3c454d2016-03-25 07:30:34 -0700101 /**
102 * Whether this build was for an emulator device.
103 * @hide
104 */
105 public static final boolean IS_EMULATOR = getString("ro.kernel.qemu").equals("1");
106
Svet Ganov37e43272016-09-09 16:01:32 -0700107 /**
108 * A hardware serial number, if available. Alphanumeric only, case-insensitive.
Svet Ganov3bb5ea22017-11-15 19:00:09 -0800109 * For apps targeting SDK higher than {@link Build.VERSION_CODES#O_MR1} this
Svet Ganov37e43272016-09-09 16:01:32 -0700110 * field is set to {@link Build#UNKNOWN}.
111 *
112 * @deprecated Use {@link #getSerial()} instead.
113 **/
114 @Deprecated
115 // IMPORTANT: This field should be initialized via a function call to
116 // prevent its value being inlined in the app during compilation because
117 // we will later set it to the value based on the app's target SDK.
118 public static final String SERIAL = getString("no.such.thing");
119
120 /**
Kevin Hufnagled6ebb552017-05-16 16:48:10 -0700121 * Gets the hardware serial number, if available.
122 *
123 * <p class="note"><b>Note:</b> Root access may allow you to modify device identifiers, such as
124 * the hardware serial number. If you change these identifiers, you can use
125 * <a href="/training/articles/security-key-attestation.html">key attestation</a> to obtain
126 * proof of the device's original identifiers.
127 *
128 * @return The serial number if specified.
Svet Ganov37e43272016-09-09 16:01:32 -0700129 */
130 @RequiresPermission(Manifest.permission.READ_PHONE_STATE)
131 public static String getSerial() {
132 IDeviceIdentifiersPolicyService service = IDeviceIdentifiersPolicyService.Stub
133 .asInterface(ServiceManager.getService(Context.DEVICE_IDENTIFIERS_SERVICE));
134 try {
135 return service.getSerial();
136 } catch (RemoteException e) {
137 e.rethrowFromSystemServer();
138 }
139 return UNKNOWN;
140 }
Ramin Zaghi1378aba2014-02-28 15:03:19 +0000141
142 /**
Narayan Kamath0f206a12014-04-12 11:41:13 +0100143 * An ordered list of ABIs supported by this device. The most preferred ABI is the first
144 * element in the list.
145 *
146 * See {@link #SUPPORTED_32_BIT_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
Ramin Zaghi1378aba2014-02-28 15:03:19 +0000147 */
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100148 public static final String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ",");
Ramin Zaghi1378aba2014-02-28 15:03:19 +0000149
Narayan Kamath0f206a12014-04-12 11:41:13 +0100150 /**
151 * An ordered list of <b>32 bit</b> ABIs supported by this device. The most preferred ABI
152 * is the first element in the list.
153 *
154 * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}.
Narayan Kamath0f206a12014-04-12 11:41:13 +0100155 */
Torne (Richard Coles)da8c0372014-05-14 16:17:26 +0100156 public static final String[] SUPPORTED_32_BIT_ABIS =
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100157 getStringList("ro.product.cpu.abilist32", ",");
Narayan Kamath0f206a12014-04-12 11:41:13 +0100158
159 /**
160 * An ordered list of <b>64 bit</b> ABIs supported by this device. The most preferred ABI
161 * is the first element in the list.
162 *
163 * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_32_BIT_ABIS}.
Narayan Kamath0f206a12014-04-12 11:41:13 +0100164 */
Torne (Richard Coles)da8c0372014-05-14 16:17:26 +0100165 public static final String[] SUPPORTED_64_BIT_ABIS =
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100166 getStringList("ro.product.cpu.abilist64", ",");
Narayan Kamath0f206a12014-04-12 11:41:13 +0100167
168
Narayan Kamatheff258c2014-09-30 13:20:57 +0100169 static {
170 /*
171 * Adjusts CPU_ABI and CPU_ABI2 depending on whether or not a given process is 64 bit.
172 * 32 bit processes will always see 32 bit ABIs in these fields for backward
173 * compatibility.
174 */
175 final String[] abiList;
176 if (VMRuntime.getRuntime().is64Bit()) {
177 abiList = SUPPORTED_64_BIT_ABIS;
178 } else {
179 abiList = SUPPORTED_32_BIT_ABIS;
180 }
181
182 CPU_ABI = abiList[0];
183 if (abiList.length > 1) {
184 CPU_ABI2 = abiList[1];
185 } else {
186 CPU_ABI2 = "";
187 }
188 }
189
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190 /** Various version strings. */
191 public static class VERSION {
192 /**
193 * The internal value used by the underlying source control to
194 * represent this build. E.g., a perforce changelist number
195 * or a git hash.
196 */
197 public static final String INCREMENTAL = getString("ro.build.version.incremental");
198
199 /**
Daniel Colascioned1520aa2018-04-06 08:12:05 -0700200 * The user-visible version string. E.g., "1.0" or "3.4b5" or "bananas".
201 *
202 * This field is an opaque string. Do not assume that its value
203 * has any particular structure or that values of RELEASE from
204 * different releases can be somehow ordered.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 */
206 public static final String RELEASE = getString("ro.build.version.release");
207
208 /**
Dianne Hackbornc3f74492015-08-12 16:10:58 -0700209 * The base OS build the product is based on.
210 */
211 public static final String BASE_OS = SystemProperties.get("ro.build.version.base_os", "");
212
213 /**
214 * The user-visible security patch level.
215 */
216 public static final String SECURITY_PATCH = SystemProperties.get(
217 "ro.build.version.security_patch", "");
218
219 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700220 * The user-visible SDK version of the framework in its raw String
221 * representation; use {@link #SDK_INT} instead.
Andres Moralescb3fd692015-01-14 10:07:55 -0800222 *
Dianne Hackborn851a5412009-05-08 12:06:44 -0700223 * @deprecated Use {@link #SDK_INT} to easily get this as an integer.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800224 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700225 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800226 public static final String SDK = getString("ro.build.version.sdk");
Dianne Hackborn851a5412009-05-08 12:06:44 -0700227
228 /**
Jeff Sharkey28c660f2017-12-12 13:51:32 -0700229 * The SDK version of the software currently running on this hardware
230 * device. This value never changes while a device is booted, but it may
231 * increase when the hardware manufacturer provides an OTA update.
232 * <p>
233 * Possible values are defined in {@link Build.VERSION_CODES}.
234 *
235 * @see #FIRST_SDK_INT
Dianne Hackborn851a5412009-05-08 12:06:44 -0700236 */
237 public static final int SDK_INT = SystemProperties.getInt(
238 "ro.build.version.sdk", 0);
239
240 /**
Jeff Sharkey28c660f2017-12-12 13:51:32 -0700241 * The SDK version of the software that <em>initially</em> shipped on
242 * this hardware device. It <em>never</em> changes during the lifetime
243 * of the device, even when {@link #SDK_INT} increases due to an OTA
244 * update.
245 * <p>
246 * Possible values are defined in {@link Build.VERSION_CODES}.
247 *
248 * @see #SDK_INT
Jeff Sharkey1da8bb12018-03-26 12:50:54 -0600249 * @hide
Jeff Sharkey28c660f2017-12-12 13:51:32 -0700250 */
Jeff Sharkey1da8bb12018-03-26 12:50:54 -0600251 @TestApi
Jeff Sharkey28c660f2017-12-12 13:51:32 -0700252 public static final int FIRST_SDK_INT = SystemProperties
253 .getInt("ro.product.first_api_level", 0);
254
255 /**
Adam Powelle9600302015-05-06 18:13:09 -0700256 * The developer preview revision of a prerelease SDK. This value will always
257 * be <code>0</code> on production platform builds/devices.
258 *
259 * <p>When this value is nonzero, any new API added since the last
260 * officially published {@link #SDK_INT API level} is only guaranteed to be present
261 * on that specific preview revision. For example, an API <code>Activity.fooBar()</code>
262 * might be present in preview revision 1 but renamed or removed entirely in
263 * preview revision 2, which may cause an app attempting to call it to crash
264 * at runtime.</p>
265 *
266 * <p>Experimental apps targeting preview APIs should check this value for
267 * equality (<code>==</code>) with the preview SDK revision they were built for
268 * before using any prerelease platform APIs. Apps that detect a preview SDK revision
269 * other than the specific one they expect should fall back to using APIs from
270 * the previously published API level only to avoid unwanted runtime exceptions.
271 * </p>
272 */
273 public static final int PREVIEW_SDK_INT = SystemProperties.getInt(
274 "ro.build.version.preview_sdk", 0);
275
276 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700277 * The current development codename, or the string "REL" if this is
278 * a release build.
279 */
280 public static final String CODENAME = getString("ro.build.version.codename");
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800281
Dianne Hackbornffcda102014-04-24 13:06:27 -0700282 private static final String[] ALL_CODENAMES
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +0100283 = getStringList("ro.build.version.all_codenames", ",");
Dianne Hackbornffcda102014-04-24 13:06:27 -0700284
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800285 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800286 * @hide
287 */
Dianne Hackbornffcda102014-04-24 13:06:27 -0700288 public static final String[] ACTIVE_CODENAMES = "REL".equals(ALL_CODENAMES[0])
289 ? new String[0] : ALL_CODENAMES;
290
291 /**
292 * The SDK version to use when accessing resources.
293 * Use the current SDK version code. For every active development codename
294 * we are operating under, we bump the assumed resource platform version by 1.
295 * @hide
296 */
Dianne Hackborn337e01a2018-02-27 17:16:37 -0800297 @TestApi
Dianne Hackbornffcda102014-04-24 13:06:27 -0700298 public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length;
Przemyslaw Szczepaniak73b6bc82017-12-05 11:07:30 +0000299
300 /**
301 * The current lowest supported value of app target SDK. Applications targeting
Narayan Kamath91c361d2018-03-26 18:31:33 +0100302 * lower values may not function on devices running this SDK version. Its possible
303 * values are defined in {@link Build.VERSION_CODES}.
304 *
305 * @hide
Przemyslaw Szczepaniak73b6bc82017-12-05 11:07:30 +0000306 */
307 public static final int MIN_SUPPORTED_TARGET_SDK_INT = SystemProperties.getInt(
308 "ro.build.version.min_supported_target_sdk", 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800309 }
310
Dianne Hackborn851a5412009-05-08 12:06:44 -0700311 /**
312 * Enumeration of the currently known SDK version codes. These are the
313 * values that can be found in {@link VERSION#SDK}. Version numbers
314 * increment monotonically with each official platform release.
315 */
316 public static class VERSION_CODES {
317 /**
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700318 * Magic version number for a current development build, which has
319 * not yet turned into an official release.
320 */
Tobias Thierer8bacd9b2017-02-15 20:38:29 +0000321 public static final int CUR_DEVELOPMENT = VMRuntime.SDK_VERSION_CUR_DEVELOPMENT;
Andres Moralescb3fd692015-01-14 10:07:55 -0800322
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700323 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700324 * October 2008: The original, first, version of Android. Yay!
325 */
326 public static final int BASE = 1;
Andres Moralescb3fd692015-01-14 10:07:55 -0800327
Dianne Hackborn851a5412009-05-08 12:06:44 -0700328 /**
329 * February 2009: First Android update, officially called 1.1.
330 */
331 public static final int BASE_1_1 = 2;
Andres Moralescb3fd692015-01-14 10:07:55 -0800332
Dianne Hackborn851a5412009-05-08 12:06:44 -0700333 /**
334 * May 2009: Android 1.5.
335 */
336 public static final int CUPCAKE = 3;
Andres Moralescb3fd692015-01-14 10:07:55 -0800337
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700338 /**
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700339 * September 2009: Android 1.6.
Andres Moralescb3fd692015-01-14 10:07:55 -0800340 *
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700341 * <p>Applications targeting this or a later release will get these
342 * new changes in behavior:</p>
343 * <ul>
344 * <li> They must explicitly request the
San Mehat5a3a77d2009-06-01 09:25:28 -0700345 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700346 * able to modify the contents of the SD card. (Apps targeting
347 * earlier versions will always request the permission.)
Dianne Hackbornfe77ec82009-08-12 16:53:56 -0700348 * <li> They must explicitly request the
349 * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be
350 * able to be able to retrieve phone state info. (Apps targeting
351 * earlier versions will always request the permission.)
352 * <li> They are assumed to support different screen densities and
353 * sizes. (Apps targeting earlier versions are assumed to only support
354 * medium density normal size screens unless otherwise indicated).
355 * They can still explicitly specify screen support either way with the
356 * supports-screens manifest tag.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700357 * <li> {@link android.widget.TabHost} will use the new dark tab
358 * background design.
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700359 * </ul>
360 */
Dianne Hackbornfe77ec82009-08-12 16:53:56 -0700361 public static final int DONUT = 4;
Andres Moralescb3fd692015-01-14 10:07:55 -0800362
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700363 /**
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700364 * November 2009: Android 2.0
Andres Moralescb3fd692015-01-14 10:07:55 -0800365 *
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700366 * <p>Applications targeting this or a later release will get these
367 * new changes in behavior:</p>
368 * <ul>
369 * <li> The {@link android.app.Service#onStartCommand
370 * Service.onStartCommand} function will return the new
371 * {@link android.app.Service#START_STICKY} behavior instead of the
372 * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}.
Dianne Hackborn8d374262009-09-14 21:21:52 -0700373 * <li> The {@link android.app.Activity} class will now execute back
374 * key presses on the key up instead of key down, to be able to detect
375 * canceled presses from virtual keys.
Mike Cleron76097642009-09-25 17:53:56 -0700376 * <li> The {@link android.widget.TabWidget} class will use a new color scheme
377 * for tabs. In the new scheme, the foreground tab has a medium gray background
378 * the background tabs have a dark gray background.
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700379 * </ul>
380 */
Jeff Hamilton6dc3f4e2009-10-10 12:06:19 -0500381 public static final int ECLAIR = 5;
Andres Moralescb3fd692015-01-14 10:07:55 -0800382
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700383 /**
Dianne Hackborn17787762009-11-12 16:11:36 -0800384 * December 2009: Android 2.0.1
Dianne Hackborn0fa35912009-10-23 12:32:45 -0700385 */
Dianne Hackborn17787762009-11-12 16:11:36 -0800386 public static final int ECLAIR_0_1 = 6;
Andres Moralescb3fd692015-01-14 10:07:55 -0800387
Dianne Hackborn23ef7b42009-11-18 18:20:39 -0800388 /**
389 * January 2010: Android 2.1
390 */
391 public static final int ECLAIR_MR1 = 7;
Andres Moralescb3fd692015-01-14 10:07:55 -0800392
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700393 /**
394 * June 2010: Android 2.2
395 */
Adam Powell216bccf2010-02-01 15:03:17 -0800396 public static final int FROYO = 8;
Andres Moralescb3fd692015-01-14 10:07:55 -0800397
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700398 /**
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800399 * November 2010: Android 2.3
Dianne Hackborn81e92762011-10-09 16:00:21 -0700400 *
401 * <p>Applications targeting this or a later release will get these
402 * new changes in behavior:</p>
403 * <ul>
404 * <li> The application's notification icons will be shown on the new
405 * dark status bar background, so must be visible in this situation.
406 * </ul>
Dianne Hackborn3e03cfa2010-06-13 12:07:00 -0700407 */
Dianne Hackborn4fa1a222010-10-18 13:10:49 -0700408 public static final int GINGERBREAD = 9;
Andres Moralescb3fd692015-01-14 10:07:55 -0800409
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800410 /**
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700411 * February 2011: Android 2.3.3.
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800412 */
413 public static final int GINGERBREAD_MR1 = 10;
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700414
415 /**
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700416 * February 2011: Android 3.0.
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700417 *
418 * <p>Applications targeting this or a later release will get these
419 * new changes in behavior:</p>
420 * <ul>
Dianne Hackborn3e6d50c2010-08-23 18:30:44 -0700421 * <li> The default theme for applications is now dark holographic:
422 * {@link android.R.style#Theme_Holo}.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700423 * <li> On large screen devices that do not have a physical menu
424 * button, the soft (compatibility) menu is disabled.
Dianne Hackborn0aae2d42010-12-07 23:51:29 -0800425 * <li> The activity lifecycle has changed slightly as per
426 * {@link android.app.Activity}.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700427 * <li> An application will crash if it does not call through
428 * to the super implementation of its
429 * {@link android.app.Activity#onPause Activity.onPause()} method.
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800430 * <li> When an application requires a permission to access one of
Dianne Hackborn6c2c5fc2011-01-18 17:02:33 -0800431 * its components (activity, receiver, service, provider), this
432 * permission is no longer enforced when the application wants to
433 * access its own component. This means it can require a permission
434 * on a component that it does not itself hold and still access that
435 * component.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700436 * <li> {@link android.content.Context#getSharedPreferences
437 * Context.getSharedPreferences()} will not automatically reload
438 * the preferences if they have changed on storage, unless
439 * {@link android.content.Context#MODE_MULTI_PROCESS} is used.
440 * <li> {@link android.view.ViewGroup#setMotionEventSplittingEnabled}
441 * will default to true.
442 * <li> {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH}
443 * is enabled by default on windows.
444 * <li> {@link android.widget.PopupWindow#isSplitTouchEnabled()
445 * PopupWindow.isSplitTouchEnabled()} will return true by default.
446 * <li> {@link android.widget.GridView} and {@link android.widget.ListView}
447 * will use {@link android.view.View#setActivated View.setActivated}
448 * for selected items if they do not implement {@link android.widget.Checkable}.
449 * <li> {@link android.widget.Scroller} will be constructed with
450 * "flywheel" behavior enabled by default.
Dianne Hackbornb1ad5972010-08-02 17:30:33 -0700451 * </ul>
452 */
Dianne Hackborn9d97b632011-01-23 14:56:39 -0800453 public static final int HONEYCOMB = 11;
Andres Moralescb3fd692015-01-14 10:07:55 -0800454
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700455 /**
Dianne Hackborna8138732011-05-12 15:45:21 -0700456 * May 2011: Android 3.1.
Dianne Hackbornedf1fc62011-03-17 18:34:48 -0700457 */
458 public static final int HONEYCOMB_MR1 = 12;
Andres Moralescb3fd692015-01-14 10:07:55 -0800459
Dianne Hackborna8138732011-05-12 15:45:21 -0700460 /**
Dianne Hackborn426431a2011-06-09 11:29:08 -0700461 * June 2011: Android 3.2.
Dianne Hackborne6676352011-06-01 16:51:20 -0700462 *
463 * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve
464 * screen compatibility mode, etc.</p>
465 *
466 * <p>As of this version, applications that don't say whether they
467 * support XLARGE screens will be assumed to do so only if they target
468 * {@link #HONEYCOMB} or later; it had been {@link #GINGERBREAD} or
469 * later. Applications that don't support a screen size at least as
470 * large as the current screen will provide the user with a UI to
471 * switch them in to screen size compatibility mode.</p>
Dianne Hackborne289bff2011-06-13 19:33:22 -0700472 *
473 * <p>This version introduces new screen size resource qualifiers
474 * based on the screen size in dp: see
475 * {@link android.content.res.Configuration#screenWidthDp},
476 * {@link android.content.res.Configuration#screenHeightDp}, and
477 * {@link android.content.res.Configuration#smallestScreenWidthDp}.
478 * Supplying these in &lt;supports-screens&gt; as per
479 * {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp},
480 * {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp}, and
481 * {@link android.content.pm.ApplicationInfo#largestWidthLimitDp} is
482 * preferred over the older screen size buckets and for older devices
483 * the appropriate buckets will be inferred from them.</p>
484 *
Dianne Hackborn81e92762011-10-09 16:00:21 -0700485 * <p>Applications targeting this or a later release will get these
486 * new changes in behavior:</p>
487 * <ul>
488 * <li><p>New {@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT}
Dianne Hackborne289bff2011-06-13 19:33:22 -0700489 * and {@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE}
Dianne Hackborn81e92762011-10-09 16:00:21 -0700490 * features were introduced in this release. Applications that target
Dianne Hackborne289bff2011-06-13 19:33:22 -0700491 * previous platform versions are assumed to require both portrait and
492 * landscape support in the device; when targeting Honeycomb MR1 or
493 * greater the application is responsible for specifying any specific
494 * orientation it requires.</p>
Dianne Hackborn81e92762011-10-09 16:00:21 -0700495 * <li><p>{@link android.os.AsyncTask} will use the serial executor
496 * by default when calling {@link android.os.AsyncTask#execute}.</p>
497 * <li><p>{@link android.content.pm.ActivityInfo#configChanges
498 * ActivityInfo.configChanges} will have the
499 * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE} and
500 * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE}
501 * bits set; these need to be cleared for older applications because
502 * some developers have done absolute comparisons against this value
503 * instead of correctly masking the bits they are interested in.
504 * </ul>
Dianne Hackborna8138732011-05-12 15:45:21 -0700505 */
Dianne Hackborn426431a2011-06-09 11:29:08 -0700506 public static final int HONEYCOMB_MR2 = 13;
Dianne Hackborn3fc982f2011-03-30 16:20:26 -0700507
508 /**
Dianne Hackbornf35fe232011-11-01 19:25:20 -0700509 * October 2011: Android 4.0.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700510 *
511 * <p>Applications targeting this or a later release will get these
512 * new changes in behavior:</p>
513 * <ul>
Dianne Hackborn9d0e37e2011-09-22 12:58:54 -0700514 * <li> For devices without a dedicated menu key, the software compatibility
515 * menu key will not be shown even on phones. By targeting Ice Cream Sandwich
516 * or later, your UI must always have its own menu UI affordance if needed,
517 * on both tablets and phones. The ActionBar will take care of this for you.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700518 * <li> 2d drawing hardware acceleration is now turned on by default.
519 * You can use
520 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
521 * to turn it off if needed, although this is strongly discouraged since
522 * it will result in poor performance on larger screen devices.
Adam Powell6e90a362011-08-14 16:48:32 -0700523 * <li> The default theme for applications is now the "device default" theme:
524 * {@link android.R.style#Theme_DeviceDefault}. This may be the
525 * holo dark theme or a different dark theme defined by the specific device.
526 * The {@link android.R.style#Theme_Holo} family must not be modified
527 * for a device to be considered compatible. Applications that explicitly
528 * request a theme from the Holo family will be guaranteed that these themes
529 * will not change character within the same platform version. Applications
530 * that wish to blend in with the device should use a theme from the
531 * {@link android.R.style#Theme_DeviceDefault} family.
Dianne Hackborn9d0e37e2011-09-22 12:58:54 -0700532 * <li> Managed cursors can now throw an exception if you directly close
533 * the cursor yourself without stopping the management of it; previously failures
534 * would be silently ignored.
535 * <li> The fadingEdge attribute on views will be ignored (fading edges is no
536 * longer a standard part of the UI). A new requiresFadingEdge attribute allows
537 * applications to still force fading edges on for special cases.
Dianne Hackborn81e92762011-10-09 16:00:21 -0700538 * <li> {@link android.content.Context#bindService Context.bindService()}
539 * will not automatically add in {@link android.content.Context#BIND_WAIVE_PRIORITY}.
540 * <li> App Widgets will have standard padding automatically added around
541 * them, rather than relying on the padding being baked into the widget itself.
542 * <li> An exception will be thrown if you try to change the type of a
543 * window after it has been added to the window manager. Previously this
544 * would result in random incorrect behavior.
545 * <li> {@link android.view.animation.AnimationSet} will parse out
546 * the duration, fillBefore, fillAfter, repeatMode, and startOffset
547 * XML attributes that are defined.
548 * <li> {@link android.app.ActionBar#setHomeButtonEnabled
549 * ActionBar.setHomeButtonEnabled()} is false by default.
Dianne Hackborn2d6833b2011-06-24 16:04:19 -0700550 * </ul>
Dianne Hackborn3fc982f2011-03-30 16:20:26 -0700551 */
Dianne Hackborn0784cfb2011-09-14 13:48:15 -0700552 public static final int ICE_CREAM_SANDWICH = 14;
Dianne Hackbornf35fe232011-11-01 19:25:20 -0700553
554 /**
Dianne Hackborn81e92762011-10-09 16:00:21 -0700555 * December 2011: Android 4.0.3.
Dianne Hackbornf35fe232011-11-01 19:25:20 -0700556 */
557 public static final int ICE_CREAM_SANDWICH_MR1 = 15;
Dianne Hackborn81e92762011-10-09 16:00:21 -0700558
559 /**
Dianne Hackborn435cdb42012-07-30 17:36:43 -0700560 * June 2012: Android 4.1.
Dianne Hackborn65696252012-03-05 18:49:21 -0800561 *
562 * <p>Applications targeting this or a later release will get these
563 * new changes in behavior:</p>
564 * <ul>
Dianne Hackborn636fd522012-06-05 17:38:50 -0700565 * <li> You must explicitly request the {@link android.Manifest.permission#READ_CALL_LOG}
566 * and/or {@link android.Manifest.permission#WRITE_CALL_LOG} permissions;
567 * access to the call log is no longer implicitly provided through
568 * {@link android.Manifest.permission#READ_CONTACTS} and
569 * {@link android.Manifest.permission#WRITE_CONTACTS}.
570 * <li> {@link android.widget.RemoteViews} will throw an exception if
571 * setting an onClick handler for views being generated by a
572 * {@link android.widget.RemoteViewsService} for a collection container;
573 * previously this just resulted in a warning log message.
574 * <li> New {@link android.app.ActionBar} policy for embedded tabs:
575 * embedded tabs are now always stacked in the action bar when in portrait
576 * mode, regardless of the size of the screen.
577 * <li> {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs(boolean)
578 * WebSettings.setAllowFileAccessFromFileURLs} and
579 * {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs(boolean)
580 * WebSettings.setAllowUniversalAccessFromFileURLs} default to false.
Dianne Hackborn65696252012-03-05 18:49:21 -0800581 * <li> Calls to {@link android.content.pm.PackageManager#setComponentEnabledSetting
582 * PackageManager.setComponentEnabledSetting} will now throw an
583 * IllegalArgumentException if the given component class name does not
584 * exist in the application's manifest.
Dianne Hackborn636fd522012-06-05 17:38:50 -0700585 * <li> {@link android.nfc.NfcAdapter#setNdefPushMessage
586 * NfcAdapter.setNdefPushMessage},
587 * {@link android.nfc.NfcAdapter#setNdefPushMessageCallback
588 * NfcAdapter.setNdefPushMessageCallback} and
589 * {@link android.nfc.NfcAdapter#setOnNdefPushCompleteCallback
590 * NfcAdapter.setOnNdefPushCompleteCallback} will throw
591 * IllegalStateException if called after the Activity has been destroyed.
592 * <li> Accessibility services must require the new
593 * {@link android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE} permission or
594 * they will not be available for use.
595 * <li> {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
596 * AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} must be set
597 * for unimportant views to be included in queries.
Dianne Hackborn65696252012-03-05 18:49:21 -0800598 * </ul>
Dianne Hackborn81e92762011-10-09 16:00:21 -0700599 */
Dianne Hackbornfa61f0b2012-05-09 21:49:38 -0700600 public static final int JELLY_BEAN = 16;
Dianne Hackborn435cdb42012-07-30 17:36:43 -0700601
602 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700603 * November 2012: Android 4.2, Moar jelly beans!
Nick Kralevichf097b162012-07-28 12:43:48 -0700604 *
605 * <p>Applications targeting this or a later release will get these
606 * new changes in behavior:</p>
607 * <ul>
608 * <li>Content Providers: The default value of {@code android:exported} is now
609 * {@code false}. See
Nick Kralevich2caec6c2012-08-08 11:33:17 -0700610 * <a href="{@docRoot}guide/topics/manifest/provider-element.html#exported">
Nick Kralevichf097b162012-07-28 12:43:48 -0700611 * the android:exported section</a> in the provider documentation for more details.</li>
Dianne Hackbornfc494742012-09-27 16:15:42 -0700612 * <li>{@link android.view.View#getLayoutDirection() View.getLayoutDirection()}
613 * can return different values than {@link android.view.View#LAYOUT_DIRECTION_LTR}
614 * based on the locale etc.
615 * <li> {@link android.webkit.WebView#addJavascriptInterface(Object, String)
616 * WebView.addJavascriptInterface} requires explicit annotations on methods
617 * for them to be accessible from Javascript.
Nick Kralevichf097b162012-07-28 12:43:48 -0700618 * </ul>
Dianne Hackborn435cdb42012-07-30 17:36:43 -0700619 */
620 public static final int JELLY_BEAN_MR1 = 17;
Nick Kralevicha985c3b2013-01-09 16:03:14 -0800621
622 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700623 * July 2013: Android 4.3, the revenge of the beans.
Nick Kralevicha985c3b2013-01-09 16:03:14 -0800624 */
Dianne Hackbornd2eeed62013-04-22 13:04:28 -0700625 public static final int JELLY_BEAN_MR2 = 18;
Dianne Hackborn5d2bfa12013-03-05 10:28:34 -0800626
627 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700628 * October 2013: Android 4.4, KitKat, another tasty treat.
Dianne Hackborn221ea892013-08-04 16:50:16 -0700629 *
630 * <p>Applications targeting this or a later release will get these
Andrew Solovaya861ff72018-08-06 13:43:30 -0700631 * new changes in behavior. For more information about this release, see the
632 * <a href="/about/versions/kitkat/">Android KitKat overview</a>.</p>
Dianne Hackborn221ea892013-08-04 16:50:16 -0700633 * <ul>
Mark Dolinerd0646dc2014-08-27 16:04:02 -0700634 * <li> The default result of
635 * {@link android.preference.PreferenceActivity#isValidFragment(String)
Dianne Hackborn6bc37892013-10-03 11:05:14 -0700636 * PreferenceActivity.isValueFragment} becomes false instead of true.</li>
637 * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have
638 * JS URLs evaluated directly and any result of the evaluation will not replace
639 * the current page content. Apps targetting KITKAT or later that load a JS URL will
640 * have the result of that URL replace the content of the current page</li>
641 * <li> {@link android.app.AlarmManager#set AlarmManager.set} becomes interpreted as
642 * an inexact value, to give the system more flexibility in scheduling alarms.</li>
643 * <li> {@link android.content.Context#getSharedPreferences(String, int)
644 * Context.getSharedPreferences} no longer allows a null name.</li>
645 * <li> {@link android.widget.RelativeLayout} changes to compute wrapped content
646 * margins correctly.</li>
647 * <li> {@link android.app.ActionBar}'s window content overlay is allowed to be
648 * drawn.</li>
Jeff Sharkey3ec2f602013-10-29 12:21:23 -0700649 * <li>The {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
650 * permission is now always enforced.</li>
651 * <li>Access to package-specific external storage directories belonging
652 * to the calling app no longer requires the
653 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} or
654 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE}
655 * permissions.</li>
Dianne Hackborn221ea892013-08-04 16:50:16 -0700656 * </ul>
Dianne Hackborn5d2bfa12013-03-05 10:28:34 -0800657 */
Dianne Hackborn6bc37892013-10-03 11:05:14 -0700658 public static final int KITKAT = 19;
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700659
660 /**
Dianne Hackborne7a34352015-09-17 14:50:47 -0700661 * June 2014: Android 4.4W. KitKat for watches, snacks on the run.
Justin Koh78b94de2014-05-13 15:48:42 -0700662 *
663 * <p>Applications targeting this or a later release will get these
664 * new changes in behavior:</p>
665 * <ul>
666 * <li>{@link android.app.AlertDialog} might not have a default background if the theme does
667 * not specify one.</li>
668 * </ul>
Jeff Brown1c3f3322014-04-16 13:15:22 -0700669 */
Justin Koh78b94de2014-05-13 15:48:42 -0700670 public static final int KITKAT_WATCH = 20;
Jeff Brown047f3c72014-04-16 14:18:49 -0700671
672 /**
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700673 * Temporary until we completely switch to {@link #LOLLIPOP}.
Dianne Hackbornd3511d42014-10-16 17:48:30 -0700674 * @hide
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700675 */
676 public static final int L = 21;
677
678 /**
Dianne Hackborne7a34352015-09-17 14:50:47 -0700679 * November 2014: Lollipop. A flat one with beautiful shadows. But still tasty.
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700680 *
681 * <p>Applications targeting this or a later release will get these
Andrew Solovaya861ff72018-08-06 13:43:30 -0700682 * new changes in behavior. For more information about this release, see the
683 * <a href="/about/versions/lollipop/">Android Lollipop overview</a>.</p>
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700684 * <ul>
685 * <li> {@link android.content.Context#bindService Context.bindService} now
Michael Wright5b5def52014-04-11 13:37:50 -0700686 * requires an explicit Intent, and will throw an exception if given an implicit
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700687 * Intent.</li>
Dianne Hackbornd3511d42014-10-16 17:48:30 -0700688 * <li> {@link android.app.Notification.Builder Notification.Builder} will
689 * not have the colors of their various notification elements adjusted to better
690 * match the new material design look.</li>
691 * <li> {@link android.os.Message} will validate that a message is not currently
692 * in use when it is recycled.</li>
693 * <li> Hardware accelerated drawing in windows will be enabled automatically
694 * in most places.</li>
695 * <li> {@link android.widget.Spinner} throws an exception if attaching an
696 * adapter with more than one item type.</li>
697 * <li> If the app is a launcher, the launcher will be available to the user
698 * even when they are using corporate profiles (which requires that the app
699 * use {@link android.content.pm.LauncherApps} to correctly populate its
700 * apps UI).</li>
701 * <li> Calling {@link android.app.Service#stopForeground Service.stopForeground}
702 * with removeNotification false will modify the still posted notification so that
703 * it is no longer forced to be ongoing.</li>
704 * <li> A {@link android.service.dreams.DreamService} must require the
705 * {@link android.Manifest.permission#BIND_DREAM_SERVICE} permission to be usable.</li>
Dianne Hackborn10ad9822014-03-17 11:28:36 -0700706 * </ul>
707 */
Dianne Hackborn955d8d62014-10-07 20:17:19 -0700708 public static final int LOLLIPOP = 21;
Dianne Hackborn3b696882014-10-16 18:14:12 -0700709
710 /**
Dianne Hackborne7a34352015-09-17 14:50:47 -0700711 * March 2015: Lollipop with an extra sugar coating on the outside!
Andrew Solovaya861ff72018-08-06 13:43:30 -0700712 * For more information about this release, see the
713 * <a href="/about/versions/android-5.1">Android 5.1 APIs</a>.
Dianne Hackborn3b696882014-10-16 18:14:12 -0700714 */
715 public static final int LOLLIPOP_MR1 = 22;
Dianne Hackborn8bd95f12015-01-27 13:18:24 -0800716
717 /**
Dianne Hackborne7a34352015-09-17 14:50:47 -0700718 * M is for Marshmallow!
719 *
720 * <p>Applications targeting this or a later release will get these
Andrew Solovaya861ff72018-08-06 13:43:30 -0700721 * new changes in behavior. For more information about this release, see the
722 * <a href="/about/versions/marshmallow/">Android 6.0 Marshmallow overview</a>.</p>
Dianne Hackborne7a34352015-09-17 14:50:47 -0700723 * <ul>
724 * <li> Runtime permissions. Dangerous permissions are no longer granted at
725 * install time, but must be requested by the application at runtime through
726 * {@link android.app.Activity#requestPermissions}.</li>
727 * <li> Bluetooth and Wi-Fi scanning now requires holding the location permission.</li>
728 * <li> {@link android.app.AlarmManager#setTimeZone AlarmManager.setTimeZone} will fail if
729 * the given timezone is non-Olson.</li>
730 * <li> Activity transitions will only return shared
731 * elements mapped in the returned view hierarchy back to the calling activity.</li>
732 * <li> {@link android.view.View} allows a number of behaviors that may break
733 * existing apps: Canvas throws an exception if restore() is called too many times,
734 * widgets may return a hint size when returning UNSPECIFIED measure specs, and it
735 * will respect the attributes {@link android.R.attr#foreground},
736 * {@link android.R.attr#foregroundGravity}, {@link android.R.attr#foregroundTint}, and
737 * {@link android.R.attr#foregroundTintMode}.</li>
738 * <li> {@link android.view.MotionEvent#getButtonState MotionEvent.getButtonState}
739 * will no longer report {@link android.view.MotionEvent#BUTTON_PRIMARY}
740 * and {@link android.view.MotionEvent#BUTTON_SECONDARY} as synonyms for
741 * {@link android.view.MotionEvent#BUTTON_STYLUS_PRIMARY} and
742 * {@link android.view.MotionEvent#BUTTON_STYLUS_SECONDARY}.</li>
743 * <li> {@link android.widget.ScrollView} now respects the layout param margins
744 * when measuring.</li>
745 * </ul>
Dianne Hackborn8bd95f12015-01-27 13:18:24 -0800746 */
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -0700747 public static final int M = 23;
Wale Ogunwale79113102015-10-05 16:52:53 -0700748
749 /**
Dianne Hackbornb34cbed2016-08-09 13:18:21 -0700750 * N is for Nougat.
751 *
752 * <p>Applications targeting this or a later release will get these
Andrew Solovaya861ff72018-08-06 13:43:30 -0700753 * new changes in behavior. For more information about this release, see
754 * the <a href="/about/versions/nougat/">Android Nougat overview</a>.</p>
Dianne Hackbornb34cbed2016-08-09 13:18:21 -0700755 * <ul>
756 * <li> {@link android.app.DownloadManager.Request#setAllowedNetworkTypes
757 * DownloadManager.Request.setAllowedNetworkTypes}
758 * will disable "allow over metered" when specifying only
Dianne Hackborn5f1649e2016-08-09 18:00:31 -0700759 * {@link android.app.DownloadManager.Request#NETWORK_WIFI}.</li>
Dianne Hackbornb34cbed2016-08-09 13:18:21 -0700760 * <li> {@link android.app.DownloadManager} no longer allows access to raw
Dianne Hackborn5f1649e2016-08-09 18:00:31 -0700761 * file paths.</li>
Dianne Hackbornb34cbed2016-08-09 13:18:21 -0700762 * <li> {@link android.app.Notification.Builder#setShowWhen
763 * Notification.Builder.setShowWhen}
764 * must be called explicitly to have the time shown, and various other changes in
765 * {@link android.app.Notification.Builder Notification.Builder} to how notifications
766 * are shown.</li>
767 * <li>{@link android.content.Context#MODE_WORLD_READABLE} and
768 * {@link android.content.Context#MODE_WORLD_WRITEABLE} are no longer supported.</li>
769 * <li>{@link android.os.FileUriExposedException} will be thrown to applications.</li>
770 * <li>Applications will see global drag and drops as per
771 * {@link android.view.View#DRAG_FLAG_GLOBAL}.</li>
772 * <li>{@link android.webkit.WebView#evaluateJavascript WebView.evaluateJavascript}
773 * will not persist state from an empty WebView.</li>
774 * <li>{@link android.animation.AnimatorSet} will not ignore calls to end() before
775 * start().</li>
776 * <li>{@link android.app.AlarmManager#cancel(android.app.PendingIntent)
777 * AlarmManager.cancel} will throw a NullPointerException if given a null operation.</li>
778 * <li>{@link android.app.FragmentManager} will ensure fragments have been created
779 * before being placed on the back stack.</li>
780 * <li>{@link android.app.FragmentManager} restores fragments in
781 * {@link android.app.Fragment#onCreate Fragment.onCreate} rather than after the
782 * method returns.</li>
783 * <li>{@link android.R.attr#resizeableActivity} defaults to true.</li>
784 * <li>{@link android.graphics.drawable.AnimatedVectorDrawable} throws exceptions when
785 * opening invalid VectorDrawable animations.</li>
786 * <li>{@link android.view.ViewGroup.MarginLayoutParams} will no longer be dropped
787 * when converting between some types of layout params (such as
788 * {@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams} to
789 * {@link android.widget.RelativeLayout.LayoutParams RelativeLayout.LayoutParams}).</li>
790 * <li>Your application processes will not be killed when the device density changes.</li>
Vadim Tryshev06b9b602016-09-23 15:32:33 -0700791 * <li>Drag and drop. After a view receives the
792 * {@link android.view.DragEvent#ACTION_DRAG_ENTERED} event, when the drag shadow moves into
793 * a descendant view that can accept the data, the view receives the
794 * {@link android.view.DragEvent#ACTION_DRAG_EXITED} event and won’t receive
795 * {@link android.view.DragEvent#ACTION_DRAG_LOCATION} and
796 * {@link android.view.DragEvent#ACTION_DROP} events while the drag shadow is within that
797 * descendant view, even if the descendant view returns <code>false</code> from its handler
798 * for these events.</li>
Dianne Hackbornb34cbed2016-08-09 13:18:21 -0700799 * </ul>
Wale Ogunwale79113102015-10-05 16:52:53 -0700800 */
Adam Powell43ec62a2016-05-25 16:36:41 -0700801 public static final int N = 24;
Michael Wright863ae3e2016-06-29 15:47:16 +0100802
803 /**
Andrew Solovaya861ff72018-08-06 13:43:30 -0700804 * N MR1: Nougat++. For more information about this release, see
805 * <a href="/about/versions/nougat/android-7.1">Android 7.1 for
806 * Developers</a>.
Michael Wright863ae3e2016-06-29 15:47:16 +0100807 */
808 public static final int N_MR1 = 25;
Makoto Onuki864f4bd2016-11-02 11:11:32 -0700809
810 /**
811 * O.
Evan Rosky534de292017-06-23 09:45:38 -0700812 *
813 * <p>Applications targeting this or a later release will get these
Andrew Solovaya861ff72018-08-06 13:43:30 -0700814 * new changes in behavior. For more information about this release, see
815 * the <a href="/about/versions/oreo/">Android Oreo overview</a>.</p>
Evan Rosky534de292017-06-23 09:45:38 -0700816 * <ul>
Dianne Hackborna47d0452017-11-21 15:04:57 -0800817 * <li><a href="{@docRoot}about/versions/oreo/background.html">Background execution limits</a>
818 * are applied to the application.</li>
819 * <li>The behavior of AccountManager's
820 * {@link android.accounts.AccountManager#getAccountsByType},
821 * {@link android.accounts.AccountManager#getAccountsByTypeAndFeatures}, and
822 * {@link android.accounts.AccountManager#hasFeatures} has changed as documented there.</li>
823 * <li>{@link android.app.ActivityManager.RunningAppProcessInfo#IMPORTANCE_PERCEPTIBLE_PRE_26}
824 * is now returned as
825 * {@link android.app.ActivityManager.RunningAppProcessInfo#IMPORTANCE_PERCEPTIBLE}.</li>
826 * <li>The {@link android.app.NotificationManager} now requires the use of notification
827 * channels.</li>
828 * <li>Changes to the strict mode that are set in
829 * {@link Application#onCreate Application.onCreate} will no longer be clobbered after
830 * that function returns.</li>
831 * <li>A shared library apk with native code will have that native code included in
832 * the library path of its clients.</li>
833 * <li>{@link android.content.Context#getSharedPreferences Context.getSharedPreferences}
834 * in credential encrypted storage will throw an exception before the user is unlocked.</li>
835 * <li>Attempting to retrieve a {@link Context#FINGERPRINT_SERVICE} on a device that
836 * does not support that feature will now throw a runtime exception.</li>
837 * <li>{@link android.app.Fragment} will stop any active view animations when
838 * the fragment is stopped.</li>
839 * <li>Some compatibility code in Resources that attempts to use the default Theme
840 * the app may be using will be turned off, requiring the app to explicitly request
841 * resources with the right theme.</li>
842 * <li>{@link android.content.ContentResolver#notifyChange ContentResolver.notifyChange} and
843 * {@link android.content.ContentResolver#registerContentObserver
844 * ContentResolver.registerContentObserver}
845 * will throw a SecurityException if the caller does not have permission to access
846 * the provider (or the provider doesn't exit); otherwise the call will be silently
847 * ignored.</li>
848 * <li>{@link android.hardware.camera2.CameraDevice#createCaptureRequest
849 * CameraDevice.createCaptureRequest} will enable
850 * {@link android.hardware.camera2.CaptureRequest#CONTROL_ENABLE_ZSL} by default for
851 * still image capture.</li>
852 * <li>WallpaperManager's {@link android.app.WallpaperManager#getWallpaperFile},
853 * {@link android.app.WallpaperManager#getDrawable},
854 * {@link android.app.WallpaperManager#getFastDrawable},
855 * {@link android.app.WallpaperManager#peekDrawable}, and
856 * {@link android.app.WallpaperManager#peekFastDrawable} will throw an exception
857 * if you can not access the wallpaper.</li>
858 * <li>The behavior of
859 * {@link android.hardware.usb.UsbDeviceConnection#requestWait UsbDeviceConnection.requestWait}
860 * is modified as per the documentation there.</li>
861 * <li>{@link StrictMode.VmPolicy.Builder#detectAll StrictMode.VmPolicy.Builder.detectAll}
862 * will also enable {@link StrictMode.VmPolicy.Builder#detectContentUriWithoutPermission}
863 * and {@link StrictMode.VmPolicy.Builder#detectUntaggedSockets}.</li>
864 * <li>{@link StrictMode.ThreadPolicy.Builder#detectAll StrictMode.ThreadPolicy.Builder.detectAll}
865 * will also enable {@link StrictMode.ThreadPolicy.Builder#detectUnbufferedIo}.</li>
866 * <li>{@link android.provider.DocumentsContract}'s various methods will throw failure
867 * exceptions back to the caller instead of returning null.
868 * <li>{@link View#hasFocusable View.hasFocusable} now includes auto-focusable views.</li>
869 * <li>{@link android.view.SurfaceView} will no longer always change the underlying
870 * Surface object when something about it changes; apps need to look at the current
871 * state of the object to determine which things they are interested in have changed.</li>
872 * <li>{@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} must be
873 * used for overlay windows, other system overlay window types are not allowed.</li>
874 * <li>{@link android.view.ViewTreeObserver#addOnDrawListener
875 * ViewTreeObserver.addOnDrawListener} will throw an exception if called from within
876 * onDraw.</li>
877 * <li>{@link android.graphics.Canvas#setBitmap Canvas.setBitmap} will no longer preserve
878 * the current matrix and clip stack of the canvas.</li>
879 * <li>{@link android.widget.ListPopupWindow#setHeight ListPopupWindow.setHeight}
880 * will throw an exception if a negative height is supplied.</li>
881 * <li>{@link android.widget.TextView} will use internationalized input for numbers,
882 * dates, and times.</li>
883 * <li>{@link android.widget.Toast} must be used for showing toast windows; the toast
884 * window type can not be directly used.</li>
885 * <li>{@link android.net.wifi.WifiManager#getConnectionInfo WifiManager.getConnectionInfo}
886 * requires that the caller hold the location permission to return BSSID/SSID</li>
887 * <li>{@link android.net.wifi.p2p.WifiP2pManager#requestPeers WifiP2pManager.requestPeers}
888 * requires the caller hold the location permission.</li>
889 * <li>{@link android.R.attr#maxAspectRatio} defaults to 0, meaning there is no restriction
890 * on the app's maximum aspect ratio (so it can be stretched to fill larger screens).</li>
Evan Rosky534de292017-06-23 09:45:38 -0700891 * <li>{@link android.R.attr#focusable} defaults to a new state ({@code auto}) where it will
892 * inherit the value of {@link android.R.attr#clickable} unless explicitly overridden.</li>
893 * <li>A default theme-appropriate focus-state highlight will be supplied to all Views
894 * which don't provide a focus-state drawable themselves. This can be disabled by setting
895 * {@link android.R.attr#defaultFocusHighlightEnabled} to false.</li>
896 * </ul>
Makoto Onuki864f4bd2016-11-02 11:11:32 -0700897 */
Ian Pedowitz967869d2017-05-04 00:10:04 +0000898 public static final int O = 26;
Jeff Sharkey7beabc22017-07-19 13:57:35 -0600899
900 /**
901 * O MR1.
Dianne Hackborna47d0452017-11-21 15:04:57 -0800902 *
903 * <p>Applications targeting this or a later release will get these
Andrew Solovaya861ff72018-08-06 13:43:30 -0700904 * new changes in behavior. For more information about this release, see
905 * <a href="/about/versions/oreo/android-8.1">Android 8.1 features and
906 * APIs</a>.</p>
Dianne Hackborna47d0452017-11-21 15:04:57 -0800907 * <ul>
908 * <li>Apps exporting and linking to apk shared libraries must explicitly
909 * enumerate all signing certificates in a consistent order.</li>
910 * <li>{@link android.R.attr#screenOrientation} can not be used to request a fixed
911 * orientation if the associated activity is not fullscreen and opaque.</li>
912 * </ul>
Andrew Solovaya861ff72018-08-06 13:43:30 -0700913 *
Jeff Sharkey7beabc22017-07-19 13:57:35 -0600914 */
Michael Wrighteec01ac2017-08-23 13:49:14 -0700915 public static final int O_MR1 = 27;
Makoto Onuki7bd7a622017-08-31 08:35:59 -0700916
917 /**
918 * P.
Dianne Hackborndd027b32018-01-19 17:44:46 -0800919 *
920 * <p>Applications targeting this or a later release will get these
Andrew Solovaya861ff72018-08-06 13:43:30 -0700921 * new changes in behavior. For more information about this release, see the
922 * <a href="/about/versions/pie/">Android 9 Pie overview</a>.</p>
Dianne Hackborndd027b32018-01-19 17:44:46 -0800923 * <ul>
924 * <li>{@link android.app.Service#startForeground Service.startForeground} requires
925 * that apps hold the permission
926 * {@link android.Manifest.permission#FOREGROUND_SERVICE}.</li>
Chet Haasecb848882018-03-21 14:09:44 -0700927 * <li>{@link android.widget.LinearLayout} will always remeasure weighted children,
928 * even if there is no excess space.</li>
Dianne Hackborndd027b32018-01-19 17:44:46 -0800929 * </ul>
Andrew Solovaya861ff72018-08-06 13:43:30 -0700930 *
Makoto Onuki7bd7a622017-08-31 08:35:59 -0700931 */
Wale Ogunwale3da5f3b2018-04-11 15:12:31 -0700932 public static final int P = 28;
Jeff Sharkey5c877632018-05-15 13:34:52 -0600933
934 /**
935 * Q.
936 * <p>
937 * <em>Why? Why, to give you a taste of your future, a preview of things
938 * to come. Con permiso, Capitan. The hall is rented, the orchestra
939 * engaged. It's now time to see if you can dance.</em>
940 */
941 public static final int Q = CUR_DEVELOPMENT;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700942 }
Andres Moralescb3fd692015-01-14 10:07:55 -0800943
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800944 /** The type of build, like "user" or "eng". */
945 public static final String TYPE = getString("ro.build.type");
946
947 /** Comma-separated tags describing the build, like "unsigned,debug". */
948 public static final String TAGS = getString("ro.build.tags");
949
950 /** A string that uniquely identifies this build. Do not attempt to parse this value. */
Jeff Sharkey55687722014-04-09 18:07:19 -0700951 public static final String FINGERPRINT = deriveFingerprint();
952
953 /**
954 * Some devices split the fingerprint components between multiple
955 * partitions, so we might derive the fingerprint at runtime.
956 */
957 private static String deriveFingerprint() {
958 String finger = SystemProperties.get("ro.build.fingerprint");
959 if (TextUtils.isEmpty(finger)) {
960 finger = getString("ro.product.brand") + '/' +
961 getString("ro.product.name") + '/' +
962 getString("ro.product.device") + ':' +
963 getString("ro.build.version.release") + '/' +
964 getString("ro.build.id") + '/' +
965 getString("ro.build.version.incremental") + ':' +
966 getString("ro.build.type") + '/' +
967 getString("ro.build.tags");
968 }
969 return finger;
970 }
971
972 /**
973 * Ensure that raw fingerprint system property is defined. If it was derived
974 * dynamically by {@link #deriveFingerprint()} this is where we push the
975 * derived value into the property service.
976 *
977 * @hide
978 */
979 public static void ensureFingerprintProperty() {
980 if (TextUtils.isEmpty(SystemProperties.get("ro.build.fingerprint"))) {
Jeff Sharkeybdd44912014-04-11 16:30:14 -0700981 try {
982 SystemProperties.set("ro.build.fingerprint", FINGERPRINT);
983 } catch (IllegalArgumentException e) {
984 Slog.e(TAG, "Failed to set fingerprint property", e);
985 }
Jeff Sharkey55687722014-04-09 18:07:19 -0700986 }
987 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800988
Jeff Sharkey2cffc7d2014-11-14 13:57:53 -0800989 /**
Michael Schwartz18511182017-05-15 11:40:40 -0700990 * True if Treble is enabled and required for this device.
991 *
992 * @hide
993 */
994 public static final boolean IS_TREBLE_ENABLED =
995 SystemProperties.getBoolean("ro.treble.enabled", false);
996
997 /**
998 * Verifies the current flash of the device is consistent with what
Andres Moralesfd282ed2015-02-06 15:07:59 -0800999 * was expected at build time.
Michael Schwartz18511182017-05-15 11:40:40 -07001000 *
1001 * Treble devices will verify the Vendor Interface (VINTF). A device
1002 * launched without Treble:
1003 *
Andres Moralesfd282ed2015-02-06 15:07:59 -08001004 * 1) Checks that device fingerprint is defined and that it matches across
1005 * various partitions.
1006 * 2) Verifies radio and bootloader partitions are those expected in the build.
Jeff Sharkey2cffc7d2014-11-14 13:57:53 -08001007 *
1008 * @hide
1009 */
Andres Moralesfd282ed2015-02-06 15:07:59 -08001010 public static boolean isBuildConsistent() {
Xiaohui Chen2102dcb2015-10-02 16:45:55 -07001011 // Don't care on eng builds. Incremental build may trigger false negative.
Jeff Sharkey5eb3eb52016-12-13 08:44:51 -07001012 if (IS_ENG) return true;
Xiaohui Chen2102dcb2015-10-02 16:45:55 -07001013
Michael Schwartz18511182017-05-15 11:40:40 -07001014 if (IS_TREBLE_ENABLED) {
Bowgo Tsaib1de4312017-11-17 17:18:50 +08001015 // If we can run this code, the device should already pass AVB.
1016 // So, we don't need to check AVB here.
1017 int result = VintfObject.verifyWithoutAvb();
Michael Schwartz18511182017-05-15 11:40:40 -07001018
1019 if (result != 0) {
1020 Slog.e(TAG, "Vendor interface is incompatible, error="
1021 + String.valueOf(result));
1022 }
1023
1024 return result == 0;
1025 }
1026
Jeff Sharkey2cffc7d2014-11-14 13:57:53 -08001027 final String system = SystemProperties.get("ro.build.fingerprint");
1028 final String vendor = SystemProperties.get("ro.vendor.build.fingerprint");
Andres Moralescb3fd692015-01-14 10:07:55 -08001029 final String bootimage = SystemProperties.get("ro.bootimage.build.fingerprint");
Andres Moralesfd282ed2015-02-06 15:07:59 -08001030 final String requiredBootloader = SystemProperties.get("ro.build.expect.bootloader");
1031 final String currentBootloader = SystemProperties.get("ro.bootloader");
1032 final String requiredRadio = SystemProperties.get("ro.build.expect.baseband");
1033 final String currentRadio = SystemProperties.get("gsm.version.baseband");
Jeff Sharkey2cffc7d2014-11-14 13:57:53 -08001034
1035 if (TextUtils.isEmpty(system)) {
1036 Slog.e(TAG, "Required ro.build.fingerprint is empty!");
1037 return false;
1038 }
1039
1040 if (!TextUtils.isEmpty(vendor)) {
1041 if (!Objects.equals(system, vendor)) {
1042 Slog.e(TAG, "Mismatched fingerprints; system reported " + system
1043 + " but vendor reported " + vendor);
1044 return false;
1045 }
1046 }
1047
Andres Moralesc97b92e2015-06-01 17:50:43 +00001048 /* TODO: Figure out issue with checks failing
Andres Moralescb3fd692015-01-14 10:07:55 -08001049 if (!TextUtils.isEmpty(bootimage)) {
Andres Morales7de24ce2015-01-23 12:45:54 -08001050 if (!Objects.equals(system, bootimage)) {
1051 Slog.e(TAG, "Mismatched fingerprints; system reported " + system
Andres Moralescb3fd692015-01-14 10:07:55 -08001052 + " but bootimage reported " + bootimage);
1053 return false;
1054 }
1055 }
1056
Andres Moralesfd282ed2015-02-06 15:07:59 -08001057 if (!TextUtils.isEmpty(requiredBootloader)) {
1058 if (!Objects.equals(currentBootloader, requiredBootloader)) {
1059 Slog.e(TAG, "Mismatched bootloader version: build requires " + requiredBootloader
1060 + " but runtime reports " + currentBootloader);
1061 return false;
1062 }
1063 }
1064
1065 if (!TextUtils.isEmpty(requiredRadio)) {
1066 if (!Objects.equals(currentRadio, requiredRadio)) {
1067 Slog.e(TAG, "Mismatched radio version: build requires " + requiredRadio
1068 + " but runtime reports " + currentRadio);
1069 return false;
1070 }
1071 }
Daniel Rosenberg159c2052015-02-20 13:10:26 -08001072 */
Andres Moralesfd282ed2015-02-06 15:07:59 -08001073
Jeff Sharkey2cffc7d2014-11-14 13:57:53 -08001074 return true;
1075 }
1076
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001077 // The following properties only make sense for internal engineering builds.
1078 public static final long TIME = getLong("ro.build.date.utc") * 1000;
1079 public static final String USER = getString("ro.build.user");
1080 public static final String HOST = getString("ro.build.host");
1081
Doug Zongkerad2171a2011-06-14 11:07:24 -07001082 /**
Jeff Brown89101cd92011-10-27 21:24:54 -07001083 * Returns true if we are running a debug build such as "user-debug" or "eng".
1084 * @hide
1085 */
1086 public static final boolean IS_DEBUGGABLE =
1087 SystemProperties.getInt("ro.debuggable", 0) == 1;
1088
Jeff Sharkey5eb3eb52016-12-13 08:44:51 -07001089 /** {@hide} */
Jeff Sharkeycdee83a2017-01-26 15:29:16 -07001090 public static final boolean IS_ENG = "eng".equals(TYPE);
1091 /** {@hide} */
1092 public static final boolean IS_USERDEBUG = "userdebug".equals(TYPE);
1093 /** {@hide} */
1094 public static final boolean IS_USER = "user".equals(TYPE);
Jeff Sharkey5eb3eb52016-12-13 08:44:51 -07001095
Jeff Brown89101cd92011-10-27 21:24:54 -07001096 /**
Xiaohui Chen387c65f2017-01-17 14:29:03 -08001097 * Whether this build is running inside a container.
1098 *
1099 * We should try to avoid checking this flag if possible to minimize
1100 * unnecessarily diverging from non-container Android behavior.
1101 * Checking this flag is acceptable when low-level resources being
1102 * different, e.g. the availability of certain capabilities, access to
1103 * system resources being restricted, and the fact that the host OS might
1104 * handle some features for us.
1105 * For higher-level behavior differences, other checks should be preferred.
1106 * @hide
1107 */
1108 public static final boolean IS_CONTAINER =
1109 SystemProperties.getBoolean("ro.boot.container", false);
1110
1111 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001112 * Specifies whether the permissions needed by a legacy app should be
1113 * reviewed before any of its components can run. A legacy app is one
1114 * with targetSdkVersion < 23, i.e apps using the old permission model.
1115 * If review is not required, permissions are reviewed before the app
1116 * is installed.
1117 *
1118 * @hide
Svet Ganov77df6f32016-08-17 11:46:34 -07001119 * @removed
Svet Ganov9c165d72015-12-01 19:52:26 -08001120 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001121 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001122 public static final boolean PERMISSIONS_REVIEW_REQUIRED =
1123 SystemProperties.getInt("ro.permission_review_required", 0) == 1;
1124
1125 /**
Doug Zongkerad2171a2011-06-14 11:07:24 -07001126 * Returns the version string for the radio firmware. May return
1127 * null (if, for instance, the radio is not currently on).
1128 */
1129 public static String getRadioVersion() {
Seongho Kim73273e02018-11-16 13:44:48 +09001130 String propVal = SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION);
1131 return TextUtils.isEmpty(propVal) ? null : propVal;
Doug Zongkerad2171a2011-06-14 11:07:24 -07001132 }
1133
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001134 private static String getString(String property) {
1135 return SystemProperties.get(property, UNKNOWN);
1136 }
1137
Torne (Richard Coles)ff701a62014-07-30 12:11:15 +01001138 private static String[] getStringList(String property, String separator) {
1139 String value = SystemProperties.get(property);
1140 if (value.isEmpty()) {
1141 return new String[0];
1142 } else {
1143 return value.split(separator);
1144 }
1145 }
1146
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001147 private static long getLong(String property) {
1148 try {
1149 return Long.parseLong(SystemProperties.get(property));
1150 } catch (NumberFormatException e) {
1151 return -1;
1152 }
1153 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001154}