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