The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.os; |
| 18 | |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 19 | import android.Manifest; |
| 20 | import android.annotation.RequiresPermission; |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Dianne Hackborn | 337e01a | 2018-02-27 17:16:37 -0800 | [diff] [blame] | 22 | import android.annotation.TestApi; |
Dianne Hackborn | a47d045 | 2017-11-21 15:04:57 -0800 | [diff] [blame] | 23 | import android.app.Application; |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 24 | import android.content.Context; |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 25 | import android.text.TextUtils; |
Jeff Sharkey | bdd4491 | 2014-04-11 16:30:14 -0700 | [diff] [blame] | 26 | import android.util.Slog; |
Dianne Hackborn | a47d045 | 2017-11-21 15:04:57 -0800 | [diff] [blame] | 27 | import android.view.View; |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 28 | |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 29 | import com.android.internal.telephony.TelephonyProperties; |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 30 | |
Narayan Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 31 | import dalvik.system.VMRuntime; |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 32 | |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 33 | import java.util.Objects; |
| 34 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | /** |
| 36 | * Information about the current build, extracted from system properties. |
| 37 | */ |
| 38 | public class Build { |
Jeff Sharkey | bdd4491 | 2014-04-11 16:30:14 -0700 | [diff] [blame] | 39 | private static final String TAG = "Build"; |
| 40 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | /** Value used for when a build property is unknown. */ |
Ficus Kirkpatrick | 71de785 | 2010-01-08 13:10:51 -0800 | [diff] [blame] | 42 | public static final String UNKNOWN = "unknown"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | |
| 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 Kamath | 1adf400 | 2014-07-12 11:46:37 +0100 | [diff] [blame] | 59 | /** |
| 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 Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 65 | public static final String CPU_ABI; |
Dianne Hackborn | b181118 | 2009-05-21 15:45:42 -0700 | [diff] [blame] | 66 | |
Narayan Kamath | 1adf400 | 2014-07-12 11:46:37 +0100 | [diff] [blame] | 67 | /** |
| 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 Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 73 | public static final String CPU_ABI2; |
Ficus Kirkpatrick | fa9cafa | 2010-01-06 17:37:13 -0800 | [diff] [blame] | 74 | |
Dianne Hackborn | d62ad4f | 2009-05-19 19:06:25 -0700 | [diff] [blame] | 75 | /** The manufacturer of the product/hardware. */ |
| 76 | public static final String MANUFACTURER = getString("ro.product.manufacturer"); |
| 77 | |
Dirk Dougherty | 491b40d | 2013-10-29 18:33:29 -0700 | [diff] [blame] | 78 | /** The consumer-visible brand with which the product/hardware will be associated, if any. */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | 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 Zongker | 74885ef | 2010-02-02 17:39:26 -0800 | [diff] [blame] | 84 | /** The system bootloader version number. */ |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 85 | public static final String BOOTLOADER = getString("ro.bootloader"); |
| 86 | |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 87 | /** |
| 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 Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 97 | |
Doug Zongker | 74885ef | 2010-02-02 17:39:26 -0800 | [diff] [blame] | 98 | /** The name of the hardware (from the kernel command line or /proc). */ |
| 99 | public static final String HARDWARE = getString("ro.hardware"); |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 100 | |
Griff Hazen | d3c454d | 2016-03-25 07:30:34 -0700 | [diff] [blame] | 101 | /** |
| 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 Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 107 | /** |
| 108 | * A hardware serial number, if available. Alphanumeric only, case-insensitive. |
Svet Ganov | 3bb5ea2 | 2017-11-15 19:00:09 -0800 | [diff] [blame] | 109 | * For apps targeting SDK higher than {@link Build.VERSION_CODES#O_MR1} this |
Svet Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 110 | * 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 Hufnagle | d6ebb55 | 2017-05-16 16:48:10 -0700 | [diff] [blame] | 121 | * 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 Ganov | 37e4327 | 2016-09-09 16:01:32 -0700 | [diff] [blame] | 129 | */ |
| 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 Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 141 | |
| 142 | /** |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 143 | * 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 Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 147 | */ |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 148 | public static final String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ","); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 149 | |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 150 | /** |
| 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 Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 155 | */ |
Torne (Richard Coles) | da8c037 | 2014-05-14 16:17:26 +0100 | [diff] [blame] | 156 | public static final String[] SUPPORTED_32_BIT_ABIS = |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 157 | getStringList("ro.product.cpu.abilist32", ","); |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 158 | |
| 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 Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 164 | */ |
Torne (Richard Coles) | da8c037 | 2014-05-14 16:17:26 +0100 | [diff] [blame] | 165 | public static final String[] SUPPORTED_64_BIT_ABIS = |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 166 | getStringList("ro.product.cpu.abilist64", ","); |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 167 | |
| 168 | |
Narayan Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 169 | 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 190 | /** 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 Colascione | d1520aa | 2018-04-06 08:12:05 -0700 | [diff] [blame] | 200 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | */ |
| 206 | public static final String RELEASE = getString("ro.build.version.release"); |
| 207 | |
| 208 | /** |
Dianne Hackborn | c3f7449 | 2015-08-12 16:10:58 -0700 | [diff] [blame] | 209 | * 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 Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 220 | * The user-visible SDK version of the framework in its raw String |
| 221 | * representation; use {@link #SDK_INT} instead. |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 222 | * |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 223 | * @deprecated Use {@link #SDK_INT} to easily get this as an integer. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 224 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 225 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 226 | public static final String SDK = getString("ro.build.version.sdk"); |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 227 | |
| 228 | /** |
Jeff Sharkey | 28c660f | 2017-12-12 13:51:32 -0700 | [diff] [blame] | 229 | * 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}. |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 234 | */ |
| 235 | public static final int SDK_INT = SystemProperties.getInt( |
| 236 | "ro.build.version.sdk", 0); |
| 237 | |
| 238 | /** |
Jeff Sharkey | 28c660f | 2017-12-12 13:51:32 -0700 | [diff] [blame] | 239 | * The SDK version of the software that <em>initially</em> shipped on |
| 240 | * this hardware device. It <em>never</em> changes during the lifetime |
| 241 | * of the device, even when {@link #SDK_INT} increases due to an OTA |
| 242 | * update. |
| 243 | * <p> |
| 244 | * Possible values are defined in {@link Build.VERSION_CODES}. |
| 245 | * |
| 246 | * @see #SDK_INT |
Jeff Sharkey | 1da8bb1 | 2018-03-26 12:50:54 -0600 | [diff] [blame] | 247 | * @hide |
Jeff Sharkey | 28c660f | 2017-12-12 13:51:32 -0700 | [diff] [blame] | 248 | */ |
Jeff Sharkey | 1da8bb1 | 2018-03-26 12:50:54 -0600 | [diff] [blame] | 249 | @TestApi |
Jeff Sharkey | 28c660f | 2017-12-12 13:51:32 -0700 | [diff] [blame] | 250 | public static final int FIRST_SDK_INT = SystemProperties |
| 251 | .getInt("ro.product.first_api_level", 0); |
| 252 | |
| 253 | /** |
Adam Powell | e960030 | 2015-05-06 18:13:09 -0700 | [diff] [blame] | 254 | * The developer preview revision of a prerelease SDK. This value will always |
| 255 | * be <code>0</code> on production platform builds/devices. |
| 256 | * |
| 257 | * <p>When this value is nonzero, any new API added since the last |
| 258 | * officially published {@link #SDK_INT API level} is only guaranteed to be present |
| 259 | * on that specific preview revision. For example, an API <code>Activity.fooBar()</code> |
| 260 | * might be present in preview revision 1 but renamed or removed entirely in |
| 261 | * preview revision 2, which may cause an app attempting to call it to crash |
| 262 | * at runtime.</p> |
| 263 | * |
| 264 | * <p>Experimental apps targeting preview APIs should check this value for |
| 265 | * equality (<code>==</code>) with the preview SDK revision they were built for |
| 266 | * before using any prerelease platform APIs. Apps that detect a preview SDK revision |
| 267 | * other than the specific one they expect should fall back to using APIs from |
| 268 | * the previously published API level only to avoid unwanted runtime exceptions. |
| 269 | * </p> |
| 270 | */ |
| 271 | public static final int PREVIEW_SDK_INT = SystemProperties.getInt( |
| 272 | "ro.build.version.preview_sdk", 0); |
| 273 | |
| 274 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 275 | * The current development codename, or the string "REL" if this is |
| 276 | * a release build. |
| 277 | */ |
| 278 | public static final String CODENAME = getString("ro.build.version.codename"); |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 279 | |
Dianne Hackborn | ffcda10 | 2014-04-24 13:06:27 -0700 | [diff] [blame] | 280 | private static final String[] ALL_CODENAMES |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 281 | = getStringList("ro.build.version.all_codenames", ","); |
Dianne Hackborn | ffcda10 | 2014-04-24 13:06:27 -0700 | [diff] [blame] | 282 | |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 283 | /** |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 284 | * @hide |
| 285 | */ |
Dianne Hackborn | ffcda10 | 2014-04-24 13:06:27 -0700 | [diff] [blame] | 286 | public static final String[] ACTIVE_CODENAMES = "REL".equals(ALL_CODENAMES[0]) |
| 287 | ? new String[0] : ALL_CODENAMES; |
| 288 | |
| 289 | /** |
| 290 | * The SDK version to use when accessing resources. |
| 291 | * Use the current SDK version code. For every active development codename |
| 292 | * we are operating under, we bump the assumed resource platform version by 1. |
| 293 | * @hide |
| 294 | */ |
Dianne Hackborn | 337e01a | 2018-02-27 17:16:37 -0800 | [diff] [blame] | 295 | @TestApi |
Dianne Hackborn | ffcda10 | 2014-04-24 13:06:27 -0700 | [diff] [blame] | 296 | public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length; |
Przemyslaw Szczepaniak | 73b6bc8 | 2017-12-05 11:07:30 +0000 | [diff] [blame] | 297 | |
| 298 | /** |
| 299 | * The current lowest supported value of app target SDK. Applications targeting |
Narayan Kamath | 91c361d | 2018-03-26 18:31:33 +0100 | [diff] [blame] | 300 | * lower values may not function on devices running this SDK version. Its possible |
| 301 | * values are defined in {@link Build.VERSION_CODES}. |
| 302 | * |
| 303 | * @hide |
Przemyslaw Szczepaniak | 73b6bc8 | 2017-12-05 11:07:30 +0000 | [diff] [blame] | 304 | */ |
| 305 | public static final int MIN_SUPPORTED_TARGET_SDK_INT = SystemProperties.getInt( |
| 306 | "ro.build.version.min_supported_target_sdk", 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 307 | } |
| 308 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 309 | /** |
| 310 | * Enumeration of the currently known SDK version codes. These are the |
| 311 | * values that can be found in {@link VERSION#SDK}. Version numbers |
| 312 | * increment monotonically with each official platform release. |
| 313 | */ |
| 314 | public static class VERSION_CODES { |
| 315 | /** |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 316 | * Magic version number for a current development build, which has |
| 317 | * not yet turned into an official release. |
| 318 | */ |
Tobias Thierer | 8bacd9b | 2017-02-15 20:38:29 +0000 | [diff] [blame] | 319 | public static final int CUR_DEVELOPMENT = VMRuntime.SDK_VERSION_CUR_DEVELOPMENT; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 320 | |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 321 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 322 | * October 2008: The original, first, version of Android. Yay! |
| 323 | */ |
| 324 | public static final int BASE = 1; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 325 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 326 | /** |
| 327 | * February 2009: First Android update, officially called 1.1. |
| 328 | */ |
| 329 | public static final int BASE_1_1 = 2; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 330 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 331 | /** |
| 332 | * May 2009: Android 1.5. |
| 333 | */ |
| 334 | public static final int CUPCAKE = 3; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 335 | |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 336 | /** |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 337 | * September 2009: Android 1.6. |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 338 | * |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 339 | * <p>Applications targeting this or a later release will get these |
| 340 | * new changes in behavior:</p> |
| 341 | * <ul> |
| 342 | * <li> They must explicitly request the |
San Mehat | 5a3a77d | 2009-06-01 09:25:28 -0700 | [diff] [blame] | 343 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 344 | * able to modify the contents of the SD card. (Apps targeting |
| 345 | * earlier versions will always request the permission.) |
Dianne Hackborn | fe77ec8 | 2009-08-12 16:53:56 -0700 | [diff] [blame] | 346 | * <li> They must explicitly request the |
| 347 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be |
| 348 | * able to be able to retrieve phone state info. (Apps targeting |
| 349 | * earlier versions will always request the permission.) |
| 350 | * <li> They are assumed to support different screen densities and |
| 351 | * sizes. (Apps targeting earlier versions are assumed to only support |
| 352 | * medium density normal size screens unless otherwise indicated). |
| 353 | * They can still explicitly specify screen support either way with the |
| 354 | * supports-screens manifest tag. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 355 | * <li> {@link android.widget.TabHost} will use the new dark tab |
| 356 | * background design. |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 357 | * </ul> |
| 358 | */ |
Dianne Hackborn | fe77ec8 | 2009-08-12 16:53:56 -0700 | [diff] [blame] | 359 | public static final int DONUT = 4; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 360 | |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 361 | /** |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 362 | * November 2009: Android 2.0 |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 363 | * |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 364 | * <p>Applications targeting this or a later release will get these |
| 365 | * new changes in behavior:</p> |
| 366 | * <ul> |
| 367 | * <li> The {@link android.app.Service#onStartCommand |
| 368 | * Service.onStartCommand} function will return the new |
| 369 | * {@link android.app.Service#START_STICKY} behavior instead of the |
| 370 | * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}. |
Dianne Hackborn | 8d37426 | 2009-09-14 21:21:52 -0700 | [diff] [blame] | 371 | * <li> The {@link android.app.Activity} class will now execute back |
| 372 | * key presses on the key up instead of key down, to be able to detect |
| 373 | * canceled presses from virtual keys. |
Mike Cleron | 7609764 | 2009-09-25 17:53:56 -0700 | [diff] [blame] | 374 | * <li> The {@link android.widget.TabWidget} class will use a new color scheme |
| 375 | * for tabs. In the new scheme, the foreground tab has a medium gray background |
| 376 | * the background tabs have a dark gray background. |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 377 | * </ul> |
| 378 | */ |
Jeff Hamilton | 6dc3f4e | 2009-10-10 12:06:19 -0500 | [diff] [blame] | 379 | public static final int ECLAIR = 5; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 380 | |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 381 | /** |
Dianne Hackborn | 1778776 | 2009-11-12 16:11:36 -0800 | [diff] [blame] | 382 | * December 2009: Android 2.0.1 |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 383 | */ |
Dianne Hackborn | 1778776 | 2009-11-12 16:11:36 -0800 | [diff] [blame] | 384 | public static final int ECLAIR_0_1 = 6; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 385 | |
Dianne Hackborn | 23ef7b4 | 2009-11-18 18:20:39 -0800 | [diff] [blame] | 386 | /** |
| 387 | * January 2010: Android 2.1 |
| 388 | */ |
| 389 | public static final int ECLAIR_MR1 = 7; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 390 | |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 391 | /** |
| 392 | * June 2010: Android 2.2 |
| 393 | */ |
Adam Powell | 216bccf | 2010-02-01 15:03:17 -0800 | [diff] [blame] | 394 | public static final int FROYO = 8; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 395 | |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 396 | /** |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 397 | * November 2010: Android 2.3 |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 398 | * |
| 399 | * <p>Applications targeting this or a later release will get these |
| 400 | * new changes in behavior:</p> |
| 401 | * <ul> |
| 402 | * <li> The application's notification icons will be shown on the new |
| 403 | * dark status bar background, so must be visible in this situation. |
| 404 | * </ul> |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 405 | */ |
Dianne Hackborn | 4fa1a22 | 2010-10-18 13:10:49 -0700 | [diff] [blame] | 406 | public static final int GINGERBREAD = 9; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 407 | |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 408 | /** |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 409 | * February 2011: Android 2.3.3. |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 410 | */ |
| 411 | public static final int GINGERBREAD_MR1 = 10; |
Dianne Hackborn | b1ad597 | 2010-08-02 17:30:33 -0700 | [diff] [blame] | 412 | |
| 413 | /** |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 414 | * February 2011: Android 3.0. |
Dianne Hackborn | b1ad597 | 2010-08-02 17:30:33 -0700 | [diff] [blame] | 415 | * |
| 416 | * <p>Applications targeting this or a later release will get these |
| 417 | * new changes in behavior:</p> |
| 418 | * <ul> |
Dianne Hackborn | 3e6d50c | 2010-08-23 18:30:44 -0700 | [diff] [blame] | 419 | * <li> The default theme for applications is now dark holographic: |
| 420 | * {@link android.R.style#Theme_Holo}. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 421 | * <li> On large screen devices that do not have a physical menu |
| 422 | * button, the soft (compatibility) menu is disabled. |
Dianne Hackborn | 0aae2d4 | 2010-12-07 23:51:29 -0800 | [diff] [blame] | 423 | * <li> The activity lifecycle has changed slightly as per |
| 424 | * {@link android.app.Activity}. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 425 | * <li> An application will crash if it does not call through |
| 426 | * to the super implementation of its |
| 427 | * {@link android.app.Activity#onPause Activity.onPause()} method. |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 428 | * <li> When an application requires a permission to access one of |
Dianne Hackborn | 6c2c5fc | 2011-01-18 17:02:33 -0800 | [diff] [blame] | 429 | * its components (activity, receiver, service, provider), this |
| 430 | * permission is no longer enforced when the application wants to |
| 431 | * access its own component. This means it can require a permission |
| 432 | * on a component that it does not itself hold and still access that |
| 433 | * component. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 434 | * <li> {@link android.content.Context#getSharedPreferences |
| 435 | * Context.getSharedPreferences()} will not automatically reload |
| 436 | * the preferences if they have changed on storage, unless |
| 437 | * {@link android.content.Context#MODE_MULTI_PROCESS} is used. |
| 438 | * <li> {@link android.view.ViewGroup#setMotionEventSplittingEnabled} |
| 439 | * will default to true. |
| 440 | * <li> {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH} |
| 441 | * is enabled by default on windows. |
| 442 | * <li> {@link android.widget.PopupWindow#isSplitTouchEnabled() |
| 443 | * PopupWindow.isSplitTouchEnabled()} will return true by default. |
| 444 | * <li> {@link android.widget.GridView} and {@link android.widget.ListView} |
| 445 | * will use {@link android.view.View#setActivated View.setActivated} |
| 446 | * for selected items if they do not implement {@link android.widget.Checkable}. |
| 447 | * <li> {@link android.widget.Scroller} will be constructed with |
| 448 | * "flywheel" behavior enabled by default. |
Dianne Hackborn | b1ad597 | 2010-08-02 17:30:33 -0700 | [diff] [blame] | 449 | * </ul> |
| 450 | */ |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 451 | public static final int HONEYCOMB = 11; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 452 | |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 453 | /** |
Dianne Hackborn | a813873 | 2011-05-12 15:45:21 -0700 | [diff] [blame] | 454 | * May 2011: Android 3.1. |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 455 | */ |
| 456 | public static final int HONEYCOMB_MR1 = 12; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 457 | |
Dianne Hackborn | a813873 | 2011-05-12 15:45:21 -0700 | [diff] [blame] | 458 | /** |
Dianne Hackborn | 426431a | 2011-06-09 11:29:08 -0700 | [diff] [blame] | 459 | * June 2011: Android 3.2. |
Dianne Hackborn | e667635 | 2011-06-01 16:51:20 -0700 | [diff] [blame] | 460 | * |
| 461 | * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve |
| 462 | * screen compatibility mode, etc.</p> |
| 463 | * |
| 464 | * <p>As of this version, applications that don't say whether they |
| 465 | * support XLARGE screens will be assumed to do so only if they target |
| 466 | * {@link #HONEYCOMB} or later; it had been {@link #GINGERBREAD} or |
| 467 | * later. Applications that don't support a screen size at least as |
| 468 | * large as the current screen will provide the user with a UI to |
| 469 | * switch them in to screen size compatibility mode.</p> |
Dianne Hackborn | e289bff | 2011-06-13 19:33:22 -0700 | [diff] [blame] | 470 | * |
| 471 | * <p>This version introduces new screen size resource qualifiers |
| 472 | * based on the screen size in dp: see |
| 473 | * {@link android.content.res.Configuration#screenWidthDp}, |
| 474 | * {@link android.content.res.Configuration#screenHeightDp}, and |
| 475 | * {@link android.content.res.Configuration#smallestScreenWidthDp}. |
| 476 | * Supplying these in <supports-screens> as per |
| 477 | * {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp}, |
| 478 | * {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp}, and |
| 479 | * {@link android.content.pm.ApplicationInfo#largestWidthLimitDp} is |
| 480 | * preferred over the older screen size buckets and for older devices |
| 481 | * the appropriate buckets will be inferred from them.</p> |
| 482 | * |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 483 | * <p>Applications targeting this or a later release will get these |
| 484 | * new changes in behavior:</p> |
| 485 | * <ul> |
| 486 | * <li><p>New {@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT} |
Dianne Hackborn | e289bff | 2011-06-13 19:33:22 -0700 | [diff] [blame] | 487 | * and {@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE} |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 488 | * features were introduced in this release. Applications that target |
Dianne Hackborn | e289bff | 2011-06-13 19:33:22 -0700 | [diff] [blame] | 489 | * previous platform versions are assumed to require both portrait and |
| 490 | * landscape support in the device; when targeting Honeycomb MR1 or |
| 491 | * greater the application is responsible for specifying any specific |
| 492 | * orientation it requires.</p> |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 493 | * <li><p>{@link android.os.AsyncTask} will use the serial executor |
| 494 | * by default when calling {@link android.os.AsyncTask#execute}.</p> |
| 495 | * <li><p>{@link android.content.pm.ActivityInfo#configChanges |
| 496 | * ActivityInfo.configChanges} will have the |
| 497 | * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE} and |
| 498 | * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE} |
| 499 | * bits set; these need to be cleared for older applications because |
| 500 | * some developers have done absolute comparisons against this value |
| 501 | * instead of correctly masking the bits they are interested in. |
| 502 | * </ul> |
Dianne Hackborn | a813873 | 2011-05-12 15:45:21 -0700 | [diff] [blame] | 503 | */ |
Dianne Hackborn | 426431a | 2011-06-09 11:29:08 -0700 | [diff] [blame] | 504 | public static final int HONEYCOMB_MR2 = 13; |
Dianne Hackborn | 3fc982f | 2011-03-30 16:20:26 -0700 | [diff] [blame] | 505 | |
| 506 | /** |
Dianne Hackborn | f35fe23 | 2011-11-01 19:25:20 -0700 | [diff] [blame] | 507 | * October 2011: Android 4.0. |
Dianne Hackborn | 2d6833b | 2011-06-24 16:04:19 -0700 | [diff] [blame] | 508 | * |
| 509 | * <p>Applications targeting this or a later release will get these |
| 510 | * new changes in behavior:</p> |
| 511 | * <ul> |
Dianne Hackborn | 9d0e37e | 2011-09-22 12:58:54 -0700 | [diff] [blame] | 512 | * <li> For devices without a dedicated menu key, the software compatibility |
| 513 | * menu key will not be shown even on phones. By targeting Ice Cream Sandwich |
| 514 | * or later, your UI must always have its own menu UI affordance if needed, |
| 515 | * on both tablets and phones. The ActionBar will take care of this for you. |
Dianne Hackborn | 2d6833b | 2011-06-24 16:04:19 -0700 | [diff] [blame] | 516 | * <li> 2d drawing hardware acceleration is now turned on by default. |
| 517 | * You can use |
| 518 | * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} |
| 519 | * to turn it off if needed, although this is strongly discouraged since |
| 520 | * it will result in poor performance on larger screen devices. |
Adam Powell | 6e90a36 | 2011-08-14 16:48:32 -0700 | [diff] [blame] | 521 | * <li> The default theme for applications is now the "device default" theme: |
| 522 | * {@link android.R.style#Theme_DeviceDefault}. This may be the |
| 523 | * holo dark theme or a different dark theme defined by the specific device. |
| 524 | * The {@link android.R.style#Theme_Holo} family must not be modified |
| 525 | * for a device to be considered compatible. Applications that explicitly |
| 526 | * request a theme from the Holo family will be guaranteed that these themes |
| 527 | * will not change character within the same platform version. Applications |
| 528 | * that wish to blend in with the device should use a theme from the |
| 529 | * {@link android.R.style#Theme_DeviceDefault} family. |
Dianne Hackborn | 9d0e37e | 2011-09-22 12:58:54 -0700 | [diff] [blame] | 530 | * <li> Managed cursors can now throw an exception if you directly close |
| 531 | * the cursor yourself without stopping the management of it; previously failures |
| 532 | * would be silently ignored. |
| 533 | * <li> The fadingEdge attribute on views will be ignored (fading edges is no |
| 534 | * longer a standard part of the UI). A new requiresFadingEdge attribute allows |
| 535 | * applications to still force fading edges on for special cases. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 536 | * <li> {@link android.content.Context#bindService Context.bindService()} |
| 537 | * will not automatically add in {@link android.content.Context#BIND_WAIVE_PRIORITY}. |
| 538 | * <li> App Widgets will have standard padding automatically added around |
| 539 | * them, rather than relying on the padding being baked into the widget itself. |
| 540 | * <li> An exception will be thrown if you try to change the type of a |
| 541 | * window after it has been added to the window manager. Previously this |
| 542 | * would result in random incorrect behavior. |
| 543 | * <li> {@link android.view.animation.AnimationSet} will parse out |
| 544 | * the duration, fillBefore, fillAfter, repeatMode, and startOffset |
| 545 | * XML attributes that are defined. |
| 546 | * <li> {@link android.app.ActionBar#setHomeButtonEnabled |
| 547 | * ActionBar.setHomeButtonEnabled()} is false by default. |
Dianne Hackborn | 2d6833b | 2011-06-24 16:04:19 -0700 | [diff] [blame] | 548 | * </ul> |
Dianne Hackborn | 3fc982f | 2011-03-30 16:20:26 -0700 | [diff] [blame] | 549 | */ |
Dianne Hackborn | 0784cfb | 2011-09-14 13:48:15 -0700 | [diff] [blame] | 550 | public static final int ICE_CREAM_SANDWICH = 14; |
Dianne Hackborn | f35fe23 | 2011-11-01 19:25:20 -0700 | [diff] [blame] | 551 | |
| 552 | /** |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 553 | * December 2011: Android 4.0.3. |
Dianne Hackborn | f35fe23 | 2011-11-01 19:25:20 -0700 | [diff] [blame] | 554 | */ |
| 555 | public static final int ICE_CREAM_SANDWICH_MR1 = 15; |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 556 | |
| 557 | /** |
Dianne Hackborn | 435cdb4 | 2012-07-30 17:36:43 -0700 | [diff] [blame] | 558 | * June 2012: Android 4.1. |
Dianne Hackborn | 6569625 | 2012-03-05 18:49:21 -0800 | [diff] [blame] | 559 | * |
| 560 | * <p>Applications targeting this or a later release will get these |
| 561 | * new changes in behavior:</p> |
| 562 | * <ul> |
Dianne Hackborn | 636fd52 | 2012-06-05 17:38:50 -0700 | [diff] [blame] | 563 | * <li> You must explicitly request the {@link android.Manifest.permission#READ_CALL_LOG} |
| 564 | * and/or {@link android.Manifest.permission#WRITE_CALL_LOG} permissions; |
| 565 | * access to the call log is no longer implicitly provided through |
| 566 | * {@link android.Manifest.permission#READ_CONTACTS} and |
| 567 | * {@link android.Manifest.permission#WRITE_CONTACTS}. |
| 568 | * <li> {@link android.widget.RemoteViews} will throw an exception if |
| 569 | * setting an onClick handler for views being generated by a |
| 570 | * {@link android.widget.RemoteViewsService} for a collection container; |
| 571 | * previously this just resulted in a warning log message. |
| 572 | * <li> New {@link android.app.ActionBar} policy for embedded tabs: |
| 573 | * embedded tabs are now always stacked in the action bar when in portrait |
| 574 | * mode, regardless of the size of the screen. |
| 575 | * <li> {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs(boolean) |
| 576 | * WebSettings.setAllowFileAccessFromFileURLs} and |
| 577 | * {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs(boolean) |
| 578 | * WebSettings.setAllowUniversalAccessFromFileURLs} default to false. |
Dianne Hackborn | 6569625 | 2012-03-05 18:49:21 -0800 | [diff] [blame] | 579 | * <li> Calls to {@link android.content.pm.PackageManager#setComponentEnabledSetting |
| 580 | * PackageManager.setComponentEnabledSetting} will now throw an |
| 581 | * IllegalArgumentException if the given component class name does not |
| 582 | * exist in the application's manifest. |
Dianne Hackborn | 636fd52 | 2012-06-05 17:38:50 -0700 | [diff] [blame] | 583 | * <li> {@link android.nfc.NfcAdapter#setNdefPushMessage |
| 584 | * NfcAdapter.setNdefPushMessage}, |
| 585 | * {@link android.nfc.NfcAdapter#setNdefPushMessageCallback |
| 586 | * NfcAdapter.setNdefPushMessageCallback} and |
| 587 | * {@link android.nfc.NfcAdapter#setOnNdefPushCompleteCallback |
| 588 | * NfcAdapter.setOnNdefPushCompleteCallback} will throw |
| 589 | * IllegalStateException if called after the Activity has been destroyed. |
| 590 | * <li> Accessibility services must require the new |
| 591 | * {@link android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE} permission or |
| 592 | * they will not be available for use. |
| 593 | * <li> {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS |
| 594 | * AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} must be set |
| 595 | * for unimportant views to be included in queries. |
Dianne Hackborn | 6569625 | 2012-03-05 18:49:21 -0800 | [diff] [blame] | 596 | * </ul> |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 597 | */ |
Dianne Hackborn | fa61f0b | 2012-05-09 21:49:38 -0700 | [diff] [blame] | 598 | public static final int JELLY_BEAN = 16; |
Dianne Hackborn | 435cdb4 | 2012-07-30 17:36:43 -0700 | [diff] [blame] | 599 | |
| 600 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 601 | * November 2012: Android 4.2, Moar jelly beans! |
Nick Kralevich | f097b16 | 2012-07-28 12:43:48 -0700 | [diff] [blame] | 602 | * |
| 603 | * <p>Applications targeting this or a later release will get these |
| 604 | * new changes in behavior:</p> |
| 605 | * <ul> |
| 606 | * <li>Content Providers: The default value of {@code android:exported} is now |
| 607 | * {@code false}. See |
Nick Kralevich | 2caec6c | 2012-08-08 11:33:17 -0700 | [diff] [blame] | 608 | * <a href="{@docRoot}guide/topics/manifest/provider-element.html#exported"> |
Nick Kralevich | f097b16 | 2012-07-28 12:43:48 -0700 | [diff] [blame] | 609 | * the android:exported section</a> in the provider documentation for more details.</li> |
Dianne Hackborn | fc49474 | 2012-09-27 16:15:42 -0700 | [diff] [blame] | 610 | * <li>{@link android.view.View#getLayoutDirection() View.getLayoutDirection()} |
| 611 | * can return different values than {@link android.view.View#LAYOUT_DIRECTION_LTR} |
| 612 | * based on the locale etc. |
| 613 | * <li> {@link android.webkit.WebView#addJavascriptInterface(Object, String) |
| 614 | * WebView.addJavascriptInterface} requires explicit annotations on methods |
| 615 | * for them to be accessible from Javascript. |
Nick Kralevich | f097b16 | 2012-07-28 12:43:48 -0700 | [diff] [blame] | 616 | * </ul> |
Dianne Hackborn | 435cdb4 | 2012-07-30 17:36:43 -0700 | [diff] [blame] | 617 | */ |
| 618 | public static final int JELLY_BEAN_MR1 = 17; |
Nick Kralevich | a985c3b | 2013-01-09 16:03:14 -0800 | [diff] [blame] | 619 | |
| 620 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 621 | * July 2013: Android 4.3, the revenge of the beans. |
Nick Kralevich | a985c3b | 2013-01-09 16:03:14 -0800 | [diff] [blame] | 622 | */ |
Dianne Hackborn | d2eeed6 | 2013-04-22 13:04:28 -0700 | [diff] [blame] | 623 | public static final int JELLY_BEAN_MR2 = 18; |
Dianne Hackborn | 5d2bfa1 | 2013-03-05 10:28:34 -0800 | [diff] [blame] | 624 | |
| 625 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 626 | * October 2013: Android 4.4, KitKat, another tasty treat. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 627 | * |
| 628 | * <p>Applications targeting this or a later release will get these |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 629 | * new changes in behavior. For more information about this release, see the |
| 630 | * <a href="/about/versions/kitkat/">Android KitKat overview</a>.</p> |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 631 | * <ul> |
Mark Doliner | d0646dc | 2014-08-27 16:04:02 -0700 | [diff] [blame] | 632 | * <li> The default result of |
| 633 | * {@link android.preference.PreferenceActivity#isValidFragment(String) |
Dianne Hackborn | 6bc3789 | 2013-10-03 11:05:14 -0700 | [diff] [blame] | 634 | * PreferenceActivity.isValueFragment} becomes false instead of true.</li> |
| 635 | * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have |
| 636 | * JS URLs evaluated directly and any result of the evaluation will not replace |
| 637 | * the current page content. Apps targetting KITKAT or later that load a JS URL will |
| 638 | * have the result of that URL replace the content of the current page</li> |
| 639 | * <li> {@link android.app.AlarmManager#set AlarmManager.set} becomes interpreted as |
| 640 | * an inexact value, to give the system more flexibility in scheduling alarms.</li> |
| 641 | * <li> {@link android.content.Context#getSharedPreferences(String, int) |
| 642 | * Context.getSharedPreferences} no longer allows a null name.</li> |
| 643 | * <li> {@link android.widget.RelativeLayout} changes to compute wrapped content |
| 644 | * margins correctly.</li> |
| 645 | * <li> {@link android.app.ActionBar}'s window content overlay is allowed to be |
| 646 | * drawn.</li> |
Jeff Sharkey | 3ec2f60 | 2013-10-29 12:21:23 -0700 | [diff] [blame] | 647 | * <li>The {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 648 | * permission is now always enforced.</li> |
| 649 | * <li>Access to package-specific external storage directories belonging |
| 650 | * to the calling app no longer requires the |
| 651 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} or |
| 652 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 653 | * permissions.</li> |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 654 | * </ul> |
Dianne Hackborn | 5d2bfa1 | 2013-03-05 10:28:34 -0800 | [diff] [blame] | 655 | */ |
Dianne Hackborn | 6bc3789 | 2013-10-03 11:05:14 -0700 | [diff] [blame] | 656 | public static final int KITKAT = 19; |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 657 | |
| 658 | /** |
Dianne Hackborn | e7a3435 | 2015-09-17 14:50:47 -0700 | [diff] [blame] | 659 | * June 2014: Android 4.4W. KitKat for watches, snacks on the run. |
Justin Koh | 78b94de | 2014-05-13 15:48:42 -0700 | [diff] [blame] | 660 | * |
| 661 | * <p>Applications targeting this or a later release will get these |
| 662 | * new changes in behavior:</p> |
| 663 | * <ul> |
| 664 | * <li>{@link android.app.AlertDialog} might not have a default background if the theme does |
| 665 | * not specify one.</li> |
| 666 | * </ul> |
Jeff Brown | 1c3f332 | 2014-04-16 13:15:22 -0700 | [diff] [blame] | 667 | */ |
Justin Koh | 78b94de | 2014-05-13 15:48:42 -0700 | [diff] [blame] | 668 | public static final int KITKAT_WATCH = 20; |
Jeff Brown | 047f3c7 | 2014-04-16 14:18:49 -0700 | [diff] [blame] | 669 | |
| 670 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 671 | * Temporary until we completely switch to {@link #LOLLIPOP}. |
Dianne Hackborn | d3511d4 | 2014-10-16 17:48:30 -0700 | [diff] [blame] | 672 | * @hide |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 673 | */ |
| 674 | public static final int L = 21; |
| 675 | |
| 676 | /** |
Dianne Hackborn | e7a3435 | 2015-09-17 14:50:47 -0700 | [diff] [blame] | 677 | * November 2014: Lollipop. A flat one with beautiful shadows. But still tasty. |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 678 | * |
| 679 | * <p>Applications targeting this or a later release will get these |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 680 | * new changes in behavior. For more information about this release, see the |
| 681 | * <a href="/about/versions/lollipop/">Android Lollipop overview</a>.</p> |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 682 | * <ul> |
| 683 | * <li> {@link android.content.Context#bindService Context.bindService} now |
Michael Wright | 5b5def5 | 2014-04-11 13:37:50 -0700 | [diff] [blame] | 684 | * requires an explicit Intent, and will throw an exception if given an implicit |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 685 | * Intent.</li> |
Dianne Hackborn | d3511d4 | 2014-10-16 17:48:30 -0700 | [diff] [blame] | 686 | * <li> {@link android.app.Notification.Builder Notification.Builder} will |
| 687 | * not have the colors of their various notification elements adjusted to better |
| 688 | * match the new material design look.</li> |
| 689 | * <li> {@link android.os.Message} will validate that a message is not currently |
| 690 | * in use when it is recycled.</li> |
| 691 | * <li> Hardware accelerated drawing in windows will be enabled automatically |
| 692 | * in most places.</li> |
| 693 | * <li> {@link android.widget.Spinner} throws an exception if attaching an |
| 694 | * adapter with more than one item type.</li> |
| 695 | * <li> If the app is a launcher, the launcher will be available to the user |
| 696 | * even when they are using corporate profiles (which requires that the app |
| 697 | * use {@link android.content.pm.LauncherApps} to correctly populate its |
| 698 | * apps UI).</li> |
| 699 | * <li> Calling {@link android.app.Service#stopForeground Service.stopForeground} |
| 700 | * with removeNotification false will modify the still posted notification so that |
| 701 | * it is no longer forced to be ongoing.</li> |
| 702 | * <li> A {@link android.service.dreams.DreamService} must require the |
| 703 | * {@link android.Manifest.permission#BIND_DREAM_SERVICE} permission to be usable.</li> |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 704 | * </ul> |
| 705 | */ |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 706 | public static final int LOLLIPOP = 21; |
Dianne Hackborn | 3b69688 | 2014-10-16 18:14:12 -0700 | [diff] [blame] | 707 | |
| 708 | /** |
Dianne Hackborn | e7a3435 | 2015-09-17 14:50:47 -0700 | [diff] [blame] | 709 | * March 2015: Lollipop with an extra sugar coating on the outside! |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 710 | * For more information about this release, see the |
| 711 | * <a href="/about/versions/android-5.1">Android 5.1 APIs</a>. |
Dianne Hackborn | 3b69688 | 2014-10-16 18:14:12 -0700 | [diff] [blame] | 712 | */ |
| 713 | public static final int LOLLIPOP_MR1 = 22; |
Dianne Hackborn | 8bd95f1 | 2015-01-27 13:18:24 -0800 | [diff] [blame] | 714 | |
| 715 | /** |
Dianne Hackborn | e7a3435 | 2015-09-17 14:50:47 -0700 | [diff] [blame] | 716 | * M is for Marshmallow! |
| 717 | * |
| 718 | * <p>Applications targeting this or a later release will get these |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 719 | * new changes in behavior. For more information about this release, see the |
| 720 | * <a href="/about/versions/marshmallow/">Android 6.0 Marshmallow overview</a>.</p> |
Dianne Hackborn | e7a3435 | 2015-09-17 14:50:47 -0700 | [diff] [blame] | 721 | * <ul> |
| 722 | * <li> Runtime permissions. Dangerous permissions are no longer granted at |
| 723 | * install time, but must be requested by the application at runtime through |
| 724 | * {@link android.app.Activity#requestPermissions}.</li> |
| 725 | * <li> Bluetooth and Wi-Fi scanning now requires holding the location permission.</li> |
| 726 | * <li> {@link android.app.AlarmManager#setTimeZone AlarmManager.setTimeZone} will fail if |
| 727 | * the given timezone is non-Olson.</li> |
| 728 | * <li> Activity transitions will only return shared |
| 729 | * elements mapped in the returned view hierarchy back to the calling activity.</li> |
| 730 | * <li> {@link android.view.View} allows a number of behaviors that may break |
| 731 | * existing apps: Canvas throws an exception if restore() is called too many times, |
| 732 | * widgets may return a hint size when returning UNSPECIFIED measure specs, and it |
| 733 | * will respect the attributes {@link android.R.attr#foreground}, |
| 734 | * {@link android.R.attr#foregroundGravity}, {@link android.R.attr#foregroundTint}, and |
| 735 | * {@link android.R.attr#foregroundTintMode}.</li> |
| 736 | * <li> {@link android.view.MotionEvent#getButtonState MotionEvent.getButtonState} |
| 737 | * will no longer report {@link android.view.MotionEvent#BUTTON_PRIMARY} |
| 738 | * and {@link android.view.MotionEvent#BUTTON_SECONDARY} as synonyms for |
| 739 | * {@link android.view.MotionEvent#BUTTON_STYLUS_PRIMARY} and |
| 740 | * {@link android.view.MotionEvent#BUTTON_STYLUS_SECONDARY}.</li> |
| 741 | * <li> {@link android.widget.ScrollView} now respects the layout param margins |
| 742 | * when measuring.</li> |
| 743 | * </ul> |
Dianne Hackborn | 8bd95f1 | 2015-01-27 13:18:24 -0800 | [diff] [blame] | 744 | */ |
Dianne Hackborn | 0e3de6c | 2015-07-29 15:20:21 -0700 | [diff] [blame] | 745 | public static final int M = 23; |
Wale Ogunwale | 7911310 | 2015-10-05 16:52:53 -0700 | [diff] [blame] | 746 | |
| 747 | /** |
Dianne Hackborn | b34cbed | 2016-08-09 13:18:21 -0700 | [diff] [blame] | 748 | * N is for Nougat. |
| 749 | * |
| 750 | * <p>Applications targeting this or a later release will get these |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 751 | * new changes in behavior. For more information about this release, see |
| 752 | * the <a href="/about/versions/nougat/">Android Nougat overview</a>.</p> |
Dianne Hackborn | b34cbed | 2016-08-09 13:18:21 -0700 | [diff] [blame] | 753 | * <ul> |
| 754 | * <li> {@link android.app.DownloadManager.Request#setAllowedNetworkTypes |
| 755 | * DownloadManager.Request.setAllowedNetworkTypes} |
| 756 | * will disable "allow over metered" when specifying only |
Dianne Hackborn | 5f1649e | 2016-08-09 18:00:31 -0700 | [diff] [blame] | 757 | * {@link android.app.DownloadManager.Request#NETWORK_WIFI}.</li> |
Dianne Hackborn | b34cbed | 2016-08-09 13:18:21 -0700 | [diff] [blame] | 758 | * <li> {@link android.app.DownloadManager} no longer allows access to raw |
Dianne Hackborn | 5f1649e | 2016-08-09 18:00:31 -0700 | [diff] [blame] | 759 | * file paths.</li> |
Dianne Hackborn | b34cbed | 2016-08-09 13:18:21 -0700 | [diff] [blame] | 760 | * <li> {@link android.app.Notification.Builder#setShowWhen |
| 761 | * Notification.Builder.setShowWhen} |
| 762 | * must be called explicitly to have the time shown, and various other changes in |
| 763 | * {@link android.app.Notification.Builder Notification.Builder} to how notifications |
| 764 | * are shown.</li> |
| 765 | * <li>{@link android.content.Context#MODE_WORLD_READABLE} and |
| 766 | * {@link android.content.Context#MODE_WORLD_WRITEABLE} are no longer supported.</li> |
| 767 | * <li>{@link android.os.FileUriExposedException} will be thrown to applications.</li> |
| 768 | * <li>Applications will see global drag and drops as per |
| 769 | * {@link android.view.View#DRAG_FLAG_GLOBAL}.</li> |
| 770 | * <li>{@link android.webkit.WebView#evaluateJavascript WebView.evaluateJavascript} |
| 771 | * will not persist state from an empty WebView.</li> |
| 772 | * <li>{@link android.animation.AnimatorSet} will not ignore calls to end() before |
| 773 | * start().</li> |
| 774 | * <li>{@link android.app.AlarmManager#cancel(android.app.PendingIntent) |
| 775 | * AlarmManager.cancel} will throw a NullPointerException if given a null operation.</li> |
| 776 | * <li>{@link android.app.FragmentManager} will ensure fragments have been created |
| 777 | * before being placed on the back stack.</li> |
| 778 | * <li>{@link android.app.FragmentManager} restores fragments in |
| 779 | * {@link android.app.Fragment#onCreate Fragment.onCreate} rather than after the |
| 780 | * method returns.</li> |
| 781 | * <li>{@link android.R.attr#resizeableActivity} defaults to true.</li> |
| 782 | * <li>{@link android.graphics.drawable.AnimatedVectorDrawable} throws exceptions when |
| 783 | * opening invalid VectorDrawable animations.</li> |
| 784 | * <li>{@link android.view.ViewGroup.MarginLayoutParams} will no longer be dropped |
| 785 | * when converting between some types of layout params (such as |
| 786 | * {@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams} to |
| 787 | * {@link android.widget.RelativeLayout.LayoutParams RelativeLayout.LayoutParams}).</li> |
| 788 | * <li>Your application processes will not be killed when the device density changes.</li> |
Vadim Tryshev | 06b9b60 | 2016-09-23 15:32:33 -0700 | [diff] [blame] | 789 | * <li>Drag and drop. After a view receives the |
| 790 | * {@link android.view.DragEvent#ACTION_DRAG_ENTERED} event, when the drag shadow moves into |
| 791 | * a descendant view that can accept the data, the view receives the |
| 792 | * {@link android.view.DragEvent#ACTION_DRAG_EXITED} event and won’t receive |
| 793 | * {@link android.view.DragEvent#ACTION_DRAG_LOCATION} and |
| 794 | * {@link android.view.DragEvent#ACTION_DROP} events while the drag shadow is within that |
| 795 | * descendant view, even if the descendant view returns <code>false</code> from its handler |
| 796 | * for these events.</li> |
Dianne Hackborn | b34cbed | 2016-08-09 13:18:21 -0700 | [diff] [blame] | 797 | * </ul> |
Wale Ogunwale | 7911310 | 2015-10-05 16:52:53 -0700 | [diff] [blame] | 798 | */ |
Adam Powell | 43ec62a | 2016-05-25 16:36:41 -0700 | [diff] [blame] | 799 | public static final int N = 24; |
Michael Wright | 863ae3e | 2016-06-29 15:47:16 +0100 | [diff] [blame] | 800 | |
| 801 | /** |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 802 | * N MR1: Nougat++. For more information about this release, see |
| 803 | * <a href="/about/versions/nougat/android-7.1">Android 7.1 for |
| 804 | * Developers</a>. |
Michael Wright | 863ae3e | 2016-06-29 15:47:16 +0100 | [diff] [blame] | 805 | */ |
| 806 | public static final int N_MR1 = 25; |
Makoto Onuki | 864f4bd | 2016-11-02 11:11:32 -0700 | [diff] [blame] | 807 | |
| 808 | /** |
| 809 | * O. |
Evan Rosky | 534de29 | 2017-06-23 09:45:38 -0700 | [diff] [blame] | 810 | * |
| 811 | * <p>Applications targeting this or a later release will get these |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 812 | * new changes in behavior. For more information about this release, see |
| 813 | * the <a href="/about/versions/oreo/">Android Oreo overview</a>.</p> |
Evan Rosky | 534de29 | 2017-06-23 09:45:38 -0700 | [diff] [blame] | 814 | * <ul> |
Dianne Hackborn | a47d045 | 2017-11-21 15:04:57 -0800 | [diff] [blame] | 815 | * <li><a href="{@docRoot}about/versions/oreo/background.html">Background execution limits</a> |
| 816 | * are applied to the application.</li> |
| 817 | * <li>The behavior of AccountManager's |
| 818 | * {@link android.accounts.AccountManager#getAccountsByType}, |
| 819 | * {@link android.accounts.AccountManager#getAccountsByTypeAndFeatures}, and |
| 820 | * {@link android.accounts.AccountManager#hasFeatures} has changed as documented there.</li> |
| 821 | * <li>{@link android.app.ActivityManager.RunningAppProcessInfo#IMPORTANCE_PERCEPTIBLE_PRE_26} |
| 822 | * is now returned as |
| 823 | * {@link android.app.ActivityManager.RunningAppProcessInfo#IMPORTANCE_PERCEPTIBLE}.</li> |
| 824 | * <li>The {@link android.app.NotificationManager} now requires the use of notification |
| 825 | * channels.</li> |
| 826 | * <li>Changes to the strict mode that are set in |
| 827 | * {@link Application#onCreate Application.onCreate} will no longer be clobbered after |
| 828 | * that function returns.</li> |
| 829 | * <li>A shared library apk with native code will have that native code included in |
| 830 | * the library path of its clients.</li> |
| 831 | * <li>{@link android.content.Context#getSharedPreferences Context.getSharedPreferences} |
| 832 | * in credential encrypted storage will throw an exception before the user is unlocked.</li> |
| 833 | * <li>Attempting to retrieve a {@link Context#FINGERPRINT_SERVICE} on a device that |
| 834 | * does not support that feature will now throw a runtime exception.</li> |
| 835 | * <li>{@link android.app.Fragment} will stop any active view animations when |
| 836 | * the fragment is stopped.</li> |
| 837 | * <li>Some compatibility code in Resources that attempts to use the default Theme |
| 838 | * the app may be using will be turned off, requiring the app to explicitly request |
| 839 | * resources with the right theme.</li> |
| 840 | * <li>{@link android.content.ContentResolver#notifyChange ContentResolver.notifyChange} and |
| 841 | * {@link android.content.ContentResolver#registerContentObserver |
| 842 | * ContentResolver.registerContentObserver} |
| 843 | * will throw a SecurityException if the caller does not have permission to access |
| 844 | * the provider (or the provider doesn't exit); otherwise the call will be silently |
| 845 | * ignored.</li> |
| 846 | * <li>{@link android.hardware.camera2.CameraDevice#createCaptureRequest |
| 847 | * CameraDevice.createCaptureRequest} will enable |
| 848 | * {@link android.hardware.camera2.CaptureRequest#CONTROL_ENABLE_ZSL} by default for |
| 849 | * still image capture.</li> |
| 850 | * <li>WallpaperManager's {@link android.app.WallpaperManager#getWallpaperFile}, |
| 851 | * {@link android.app.WallpaperManager#getDrawable}, |
| 852 | * {@link android.app.WallpaperManager#getFastDrawable}, |
| 853 | * {@link android.app.WallpaperManager#peekDrawable}, and |
| 854 | * {@link android.app.WallpaperManager#peekFastDrawable} will throw an exception |
| 855 | * if you can not access the wallpaper.</li> |
| 856 | * <li>The behavior of |
| 857 | * {@link android.hardware.usb.UsbDeviceConnection#requestWait UsbDeviceConnection.requestWait} |
| 858 | * is modified as per the documentation there.</li> |
| 859 | * <li>{@link StrictMode.VmPolicy.Builder#detectAll StrictMode.VmPolicy.Builder.detectAll} |
| 860 | * will also enable {@link StrictMode.VmPolicy.Builder#detectContentUriWithoutPermission} |
| 861 | * and {@link StrictMode.VmPolicy.Builder#detectUntaggedSockets}.</li> |
| 862 | * <li>{@link StrictMode.ThreadPolicy.Builder#detectAll StrictMode.ThreadPolicy.Builder.detectAll} |
| 863 | * will also enable {@link StrictMode.ThreadPolicy.Builder#detectUnbufferedIo}.</li> |
| 864 | * <li>{@link android.provider.DocumentsContract}'s various methods will throw failure |
| 865 | * exceptions back to the caller instead of returning null. |
| 866 | * <li>{@link View#hasFocusable View.hasFocusable} now includes auto-focusable views.</li> |
| 867 | * <li>{@link android.view.SurfaceView} will no longer always change the underlying |
| 868 | * Surface object when something about it changes; apps need to look at the current |
| 869 | * state of the object to determine which things they are interested in have changed.</li> |
| 870 | * <li>{@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} must be |
| 871 | * used for overlay windows, other system overlay window types are not allowed.</li> |
| 872 | * <li>{@link android.view.ViewTreeObserver#addOnDrawListener |
| 873 | * ViewTreeObserver.addOnDrawListener} will throw an exception if called from within |
| 874 | * onDraw.</li> |
| 875 | * <li>{@link android.graphics.Canvas#setBitmap Canvas.setBitmap} will no longer preserve |
| 876 | * the current matrix and clip stack of the canvas.</li> |
| 877 | * <li>{@link android.widget.ListPopupWindow#setHeight ListPopupWindow.setHeight} |
| 878 | * will throw an exception if a negative height is supplied.</li> |
| 879 | * <li>{@link android.widget.TextView} will use internationalized input for numbers, |
| 880 | * dates, and times.</li> |
| 881 | * <li>{@link android.widget.Toast} must be used for showing toast windows; the toast |
| 882 | * window type can not be directly used.</li> |
| 883 | * <li>{@link android.net.wifi.WifiManager#getConnectionInfo WifiManager.getConnectionInfo} |
| 884 | * requires that the caller hold the location permission to return BSSID/SSID</li> |
| 885 | * <li>{@link android.net.wifi.p2p.WifiP2pManager#requestPeers WifiP2pManager.requestPeers} |
| 886 | * requires the caller hold the location permission.</li> |
| 887 | * <li>{@link android.R.attr#maxAspectRatio} defaults to 0, meaning there is no restriction |
| 888 | * on the app's maximum aspect ratio (so it can be stretched to fill larger screens).</li> |
Evan Rosky | 534de29 | 2017-06-23 09:45:38 -0700 | [diff] [blame] | 889 | * <li>{@link android.R.attr#focusable} defaults to a new state ({@code auto}) where it will |
| 890 | * inherit the value of {@link android.R.attr#clickable} unless explicitly overridden.</li> |
| 891 | * <li>A default theme-appropriate focus-state highlight will be supplied to all Views |
| 892 | * which don't provide a focus-state drawable themselves. This can be disabled by setting |
| 893 | * {@link android.R.attr#defaultFocusHighlightEnabled} to false.</li> |
| 894 | * </ul> |
Makoto Onuki | 864f4bd | 2016-11-02 11:11:32 -0700 | [diff] [blame] | 895 | */ |
Ian Pedowitz | 967869d | 2017-05-04 00:10:04 +0000 | [diff] [blame] | 896 | public static final int O = 26; |
Jeff Sharkey | 7beabc2 | 2017-07-19 13:57:35 -0600 | [diff] [blame] | 897 | |
| 898 | /** |
| 899 | * O MR1. |
Dianne Hackborn | a47d045 | 2017-11-21 15:04:57 -0800 | [diff] [blame] | 900 | * |
| 901 | * <p>Applications targeting this or a later release will get these |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 902 | * new changes in behavior. For more information about this release, see |
| 903 | * <a href="/about/versions/oreo/android-8.1">Android 8.1 features and |
| 904 | * APIs</a>.</p> |
Dianne Hackborn | a47d045 | 2017-11-21 15:04:57 -0800 | [diff] [blame] | 905 | * <ul> |
| 906 | * <li>Apps exporting and linking to apk shared libraries must explicitly |
| 907 | * enumerate all signing certificates in a consistent order.</li> |
| 908 | * <li>{@link android.R.attr#screenOrientation} can not be used to request a fixed |
| 909 | * orientation if the associated activity is not fullscreen and opaque.</li> |
| 910 | * </ul> |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 911 | * |
Jeff Sharkey | 7beabc2 | 2017-07-19 13:57:35 -0600 | [diff] [blame] | 912 | */ |
Michael Wright | eec01ac | 2017-08-23 13:49:14 -0700 | [diff] [blame] | 913 | public static final int O_MR1 = 27; |
Makoto Onuki | 7bd7a62 | 2017-08-31 08:35:59 -0700 | [diff] [blame] | 914 | |
| 915 | /** |
| 916 | * P. |
Dianne Hackborn | dd027b3 | 2018-01-19 17:44:46 -0800 | [diff] [blame] | 917 | * |
| 918 | * <p>Applications targeting this or a later release will get these |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 919 | * new changes in behavior. For more information about this release, see the |
| 920 | * <a href="/about/versions/pie/">Android 9 Pie overview</a>.</p> |
Dianne Hackborn | dd027b3 | 2018-01-19 17:44:46 -0800 | [diff] [blame] | 921 | * <ul> |
| 922 | * <li>{@link android.app.Service#startForeground Service.startForeground} requires |
| 923 | * that apps hold the permission |
| 924 | * {@link android.Manifest.permission#FOREGROUND_SERVICE}.</li> |
Chet Haase | cb84888 | 2018-03-21 14:09:44 -0700 | [diff] [blame] | 925 | * <li>{@link android.widget.LinearLayout} will always remeasure weighted children, |
| 926 | * even if there is no excess space.</li> |
Dianne Hackborn | dd027b3 | 2018-01-19 17:44:46 -0800 | [diff] [blame] | 927 | * </ul> |
Andrew Solovay | a861ff7 | 2018-08-06 13:43:30 -0700 | [diff] [blame] | 928 | * |
Makoto Onuki | 7bd7a62 | 2017-08-31 08:35:59 -0700 | [diff] [blame] | 929 | */ |
Wale Ogunwale | 3da5f3b | 2018-04-11 15:12:31 -0700 | [diff] [blame] | 930 | public static final int P = 28; |
Jeff Sharkey | 5c87763 | 2018-05-15 13:34:52 -0600 | [diff] [blame] | 931 | |
| 932 | /** |
| 933 | * Q. |
| 934 | * <p> |
| 935 | * <em>Why? Why, to give you a taste of your future, a preview of things |
| 936 | * to come. Con permiso, Capitan. The hall is rented, the orchestra |
| 937 | * engaged. It's now time to see if you can dance.</em> |
| 938 | */ |
| 939 | public static final int Q = CUR_DEVELOPMENT; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 940 | } |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 941 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 942 | /** The type of build, like "user" or "eng". */ |
| 943 | public static final String TYPE = getString("ro.build.type"); |
| 944 | |
| 945 | /** Comma-separated tags describing the build, like "unsigned,debug". */ |
| 946 | public static final String TAGS = getString("ro.build.tags"); |
| 947 | |
| 948 | /** A string that uniquely identifies this build. Do not attempt to parse this value. */ |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 949 | public static final String FINGERPRINT = deriveFingerprint(); |
| 950 | |
| 951 | /** |
| 952 | * Some devices split the fingerprint components between multiple |
| 953 | * partitions, so we might derive the fingerprint at runtime. |
| 954 | */ |
| 955 | private static String deriveFingerprint() { |
| 956 | String finger = SystemProperties.get("ro.build.fingerprint"); |
| 957 | if (TextUtils.isEmpty(finger)) { |
| 958 | finger = getString("ro.product.brand") + '/' + |
| 959 | getString("ro.product.name") + '/' + |
| 960 | getString("ro.product.device") + ':' + |
| 961 | getString("ro.build.version.release") + '/' + |
| 962 | getString("ro.build.id") + '/' + |
| 963 | getString("ro.build.version.incremental") + ':' + |
| 964 | getString("ro.build.type") + '/' + |
| 965 | getString("ro.build.tags"); |
| 966 | } |
| 967 | return finger; |
| 968 | } |
| 969 | |
| 970 | /** |
| 971 | * Ensure that raw fingerprint system property is defined. If it was derived |
| 972 | * dynamically by {@link #deriveFingerprint()} this is where we push the |
| 973 | * derived value into the property service. |
| 974 | * |
| 975 | * @hide |
| 976 | */ |
| 977 | public static void ensureFingerprintProperty() { |
| 978 | if (TextUtils.isEmpty(SystemProperties.get("ro.build.fingerprint"))) { |
Jeff Sharkey | bdd4491 | 2014-04-11 16:30:14 -0700 | [diff] [blame] | 979 | try { |
| 980 | SystemProperties.set("ro.build.fingerprint", FINGERPRINT); |
| 981 | } catch (IllegalArgumentException e) { |
| 982 | Slog.e(TAG, "Failed to set fingerprint property", e); |
| 983 | } |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 984 | } |
| 985 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 986 | |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 987 | /** |
Michael Schwartz | 1851118 | 2017-05-15 11:40:40 -0700 | [diff] [blame] | 988 | * True if Treble is enabled and required for this device. |
| 989 | * |
| 990 | * @hide |
| 991 | */ |
| 992 | public static final boolean IS_TREBLE_ENABLED = |
| 993 | SystemProperties.getBoolean("ro.treble.enabled", false); |
| 994 | |
| 995 | /** |
| 996 | * Verifies the current flash of the device is consistent with what |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 997 | * was expected at build time. |
Michael Schwartz | 1851118 | 2017-05-15 11:40:40 -0700 | [diff] [blame] | 998 | * |
| 999 | * Treble devices will verify the Vendor Interface (VINTF). A device |
| 1000 | * launched without Treble: |
| 1001 | * |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 1002 | * 1) Checks that device fingerprint is defined and that it matches across |
| 1003 | * various partitions. |
| 1004 | * 2) Verifies radio and bootloader partitions are those expected in the build. |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 1005 | * |
| 1006 | * @hide |
| 1007 | */ |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 1008 | public static boolean isBuildConsistent() { |
Xiaohui Chen | 2102dcb | 2015-10-02 16:45:55 -0700 | [diff] [blame] | 1009 | // Don't care on eng builds. Incremental build may trigger false negative. |
Jeff Sharkey | 5eb3eb5 | 2016-12-13 08:44:51 -0700 | [diff] [blame] | 1010 | if (IS_ENG) return true; |
Xiaohui Chen | 2102dcb | 2015-10-02 16:45:55 -0700 | [diff] [blame] | 1011 | |
Michael Schwartz | 1851118 | 2017-05-15 11:40:40 -0700 | [diff] [blame] | 1012 | if (IS_TREBLE_ENABLED) { |
Bowgo Tsai | b1de431 | 2017-11-17 17:18:50 +0800 | [diff] [blame] | 1013 | // If we can run this code, the device should already pass AVB. |
| 1014 | // So, we don't need to check AVB here. |
| 1015 | int result = VintfObject.verifyWithoutAvb(); |
Michael Schwartz | 1851118 | 2017-05-15 11:40:40 -0700 | [diff] [blame] | 1016 | |
| 1017 | if (result != 0) { |
| 1018 | Slog.e(TAG, "Vendor interface is incompatible, error=" |
| 1019 | + String.valueOf(result)); |
| 1020 | } |
| 1021 | |
| 1022 | return result == 0; |
| 1023 | } |
| 1024 | |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 1025 | final String system = SystemProperties.get("ro.build.fingerprint"); |
| 1026 | final String vendor = SystemProperties.get("ro.vendor.build.fingerprint"); |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 1027 | final String bootimage = SystemProperties.get("ro.bootimage.build.fingerprint"); |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 1028 | final String requiredBootloader = SystemProperties.get("ro.build.expect.bootloader"); |
| 1029 | final String currentBootloader = SystemProperties.get("ro.bootloader"); |
| 1030 | final String requiredRadio = SystemProperties.get("ro.build.expect.baseband"); |
| 1031 | final String currentRadio = SystemProperties.get("gsm.version.baseband"); |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 1032 | |
| 1033 | if (TextUtils.isEmpty(system)) { |
| 1034 | Slog.e(TAG, "Required ro.build.fingerprint is empty!"); |
| 1035 | return false; |
| 1036 | } |
| 1037 | |
| 1038 | if (!TextUtils.isEmpty(vendor)) { |
| 1039 | if (!Objects.equals(system, vendor)) { |
| 1040 | Slog.e(TAG, "Mismatched fingerprints; system reported " + system |
| 1041 | + " but vendor reported " + vendor); |
| 1042 | return false; |
| 1043 | } |
| 1044 | } |
| 1045 | |
Andres Morales | c97b92e | 2015-06-01 17:50:43 +0000 | [diff] [blame] | 1046 | /* TODO: Figure out issue with checks failing |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 1047 | if (!TextUtils.isEmpty(bootimage)) { |
Andres Morales | 7de24ce | 2015-01-23 12:45:54 -0800 | [diff] [blame] | 1048 | if (!Objects.equals(system, bootimage)) { |
| 1049 | Slog.e(TAG, "Mismatched fingerprints; system reported " + system |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 1050 | + " but bootimage reported " + bootimage); |
| 1051 | return false; |
| 1052 | } |
| 1053 | } |
| 1054 | |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 1055 | if (!TextUtils.isEmpty(requiredBootloader)) { |
| 1056 | if (!Objects.equals(currentBootloader, requiredBootloader)) { |
| 1057 | Slog.e(TAG, "Mismatched bootloader version: build requires " + requiredBootloader |
| 1058 | + " but runtime reports " + currentBootloader); |
| 1059 | return false; |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | if (!TextUtils.isEmpty(requiredRadio)) { |
| 1064 | if (!Objects.equals(currentRadio, requiredRadio)) { |
| 1065 | Slog.e(TAG, "Mismatched radio version: build requires " + requiredRadio |
| 1066 | + " but runtime reports " + currentRadio); |
| 1067 | return false; |
| 1068 | } |
| 1069 | } |
Daniel Rosenberg | 159c205 | 2015-02-20 13:10:26 -0800 | [diff] [blame] | 1070 | */ |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 1071 | |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 1072 | return true; |
| 1073 | } |
| 1074 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1075 | // The following properties only make sense for internal engineering builds. |
| 1076 | public static final long TIME = getLong("ro.build.date.utc") * 1000; |
| 1077 | public static final String USER = getString("ro.build.user"); |
| 1078 | public static final String HOST = getString("ro.build.host"); |
| 1079 | |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 1080 | /** |
Jeff Brown | 89101cd9 | 2011-10-27 21:24:54 -0700 | [diff] [blame] | 1081 | * Returns true if we are running a debug build such as "user-debug" or "eng". |
| 1082 | * @hide |
| 1083 | */ |
| 1084 | public static final boolean IS_DEBUGGABLE = |
| 1085 | SystemProperties.getInt("ro.debuggable", 0) == 1; |
| 1086 | |
Jeff Sharkey | 5eb3eb5 | 2016-12-13 08:44:51 -0700 | [diff] [blame] | 1087 | /** {@hide} */ |
Jeff Sharkey | cdee83a | 2017-01-26 15:29:16 -0700 | [diff] [blame] | 1088 | public static final boolean IS_ENG = "eng".equals(TYPE); |
| 1089 | /** {@hide} */ |
| 1090 | public static final boolean IS_USERDEBUG = "userdebug".equals(TYPE); |
| 1091 | /** {@hide} */ |
| 1092 | public static final boolean IS_USER = "user".equals(TYPE); |
Jeff Sharkey | 5eb3eb5 | 2016-12-13 08:44:51 -0700 | [diff] [blame] | 1093 | |
Jeff Brown | 89101cd9 | 2011-10-27 21:24:54 -0700 | [diff] [blame] | 1094 | /** |
Xiaohui Chen | 387c65f | 2017-01-17 14:29:03 -0800 | [diff] [blame] | 1095 | * Whether this build is running inside a container. |
| 1096 | * |
| 1097 | * We should try to avoid checking this flag if possible to minimize |
| 1098 | * unnecessarily diverging from non-container Android behavior. |
| 1099 | * Checking this flag is acceptable when low-level resources being |
| 1100 | * different, e.g. the availability of certain capabilities, access to |
| 1101 | * system resources being restricted, and the fact that the host OS might |
| 1102 | * handle some features for us. |
| 1103 | * For higher-level behavior differences, other checks should be preferred. |
| 1104 | * @hide |
| 1105 | */ |
| 1106 | public static final boolean IS_CONTAINER = |
| 1107 | SystemProperties.getBoolean("ro.boot.container", false); |
| 1108 | |
| 1109 | /** |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1110 | * Specifies whether the permissions needed by a legacy app should be |
| 1111 | * reviewed before any of its components can run. A legacy app is one |
| 1112 | * with targetSdkVersion < 23, i.e apps using the old permission model. |
| 1113 | * If review is not required, permissions are reviewed before the app |
| 1114 | * is installed. |
| 1115 | * |
| 1116 | * @hide |
Svet Ganov | 77df6f3 | 2016-08-17 11:46:34 -0700 | [diff] [blame] | 1117 | * @removed |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1118 | */ |
Svet Ganov | ae0e03a | 2016-02-25 18:22:10 -0800 | [diff] [blame] | 1119 | @SystemApi |
Svet Ganov | 9c165d7 | 2015-12-01 19:52:26 -0800 | [diff] [blame] | 1120 | public static final boolean PERMISSIONS_REVIEW_REQUIRED = |
| 1121 | SystemProperties.getInt("ro.permission_review_required", 0) == 1; |
| 1122 | |
| 1123 | /** |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 1124 | * Returns the version string for the radio firmware. May return |
| 1125 | * null (if, for instance, the radio is not currently on). |
| 1126 | */ |
| 1127 | public static String getRadioVersion() { |
Seongho Kim | 73273e0 | 2018-11-16 13:44:48 +0900 | [diff] [blame] | 1128 | String propVal = SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION); |
| 1129 | return TextUtils.isEmpty(propVal) ? null : propVal; |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1132 | private static String getString(String property) { |
| 1133 | return SystemProperties.get(property, UNKNOWN); |
| 1134 | } |
| 1135 | |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 1136 | private static String[] getStringList(String property, String separator) { |
| 1137 | String value = SystemProperties.get(property); |
| 1138 | if (value.isEmpty()) { |
| 1139 | return new String[0]; |
| 1140 | } else { |
| 1141 | return value.split(separator); |
| 1142 | } |
| 1143 | } |
| 1144 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1145 | private static long getLong(String property) { |
| 1146 | try { |
| 1147 | return Long.parseLong(SystemProperties.get(property)); |
| 1148 | } catch (NumberFormatException e) { |
| 1149 | return -1; |
| 1150 | } |
| 1151 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1152 | } |