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 | |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 19 | import android.text.TextUtils; |
Jeff Sharkey | bdd4491 | 2014-04-11 16:30:14 -0700 | [diff] [blame] | 20 | import android.util.Slog; |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 21 | |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 22 | import com.android.internal.telephony.TelephonyProperties; |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 23 | |
Narayan Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 24 | import dalvik.system.VMRuntime; |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 25 | |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 26 | import java.util.Objects; |
| 27 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | /** |
| 29 | * Information about the current build, extracted from system properties. |
| 30 | */ |
| 31 | public class Build { |
Jeff Sharkey | bdd4491 | 2014-04-11 16:30:14 -0700 | [diff] [blame] | 32 | private static final String TAG = "Build"; |
| 33 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | /** Value used for when a build property is unknown. */ |
Ficus Kirkpatrick | 71de785 | 2010-01-08 13:10:51 -0800 | [diff] [blame] | 35 | public static final String UNKNOWN = "unknown"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
| 37 | /** Either a changelist number, or a label like "M4-rc20". */ |
| 38 | public static final String ID = getString("ro.build.id"); |
| 39 | |
| 40 | /** A build ID string meant for displaying to the user */ |
| 41 | public static final String DISPLAY = getString("ro.build.display.id"); |
| 42 | |
| 43 | /** The name of the overall product. */ |
| 44 | public static final String PRODUCT = getString("ro.product.name"); |
| 45 | |
| 46 | /** The name of the industrial design. */ |
| 47 | public static final String DEVICE = getString("ro.product.device"); |
| 48 | |
| 49 | /** The name of the underlying board, like "goldfish". */ |
| 50 | public static final String BOARD = getString("ro.product.board"); |
| 51 | |
Narayan Kamath | 1adf400 | 2014-07-12 11:46:37 +0100 | [diff] [blame] | 52 | /** |
| 53 | * The name of the instruction set (CPU type + ABI convention) of native code. |
| 54 | * |
| 55 | * @deprecated Use {@link #SUPPORTED_ABIS} instead. |
| 56 | */ |
| 57 | @Deprecated |
Narayan Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 58 | public static final String CPU_ABI; |
Dianne Hackborn | b181118 | 2009-05-21 15:45:42 -0700 | [diff] [blame] | 59 | |
Narayan Kamath | 1adf400 | 2014-07-12 11:46:37 +0100 | [diff] [blame] | 60 | /** |
| 61 | * The name of the second instruction set (CPU type + ABI convention) of native code. |
| 62 | * |
| 63 | * @deprecated Use {@link #SUPPORTED_ABIS} instead. |
| 64 | */ |
| 65 | @Deprecated |
Narayan Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 66 | public static final String CPU_ABI2; |
Ficus Kirkpatrick | fa9cafa | 2010-01-06 17:37:13 -0800 | [diff] [blame] | 67 | |
Dianne Hackborn | d62ad4f | 2009-05-19 19:06:25 -0700 | [diff] [blame] | 68 | /** The manufacturer of the product/hardware. */ |
| 69 | public static final String MANUFACTURER = getString("ro.product.manufacturer"); |
| 70 | |
Dirk Dougherty | 491b40d | 2013-10-29 18:33:29 -0700 | [diff] [blame] | 71 | /** 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] | 72 | public static final String BRAND = getString("ro.product.brand"); |
| 73 | |
| 74 | /** The end-user-visible name for the end product. */ |
| 75 | public static final String MODEL = getString("ro.product.model"); |
| 76 | |
Doug Zongker | 74885ef | 2010-02-02 17:39:26 -0800 | [diff] [blame] | 77 | /** The system bootloader version number. */ |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 78 | public static final String BOOTLOADER = getString("ro.bootloader"); |
| 79 | |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 80 | /** |
| 81 | * The radio firmware version number. |
| 82 | * |
| 83 | * @deprecated The radio firmware version is frequently not |
| 84 | * available when this class is initialized, leading to a blank or |
| 85 | * "unknown" value for this string. Use |
| 86 | * {@link #getRadioVersion} instead. |
| 87 | */ |
| 88 | @Deprecated |
| 89 | public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION); |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 90 | |
Doug Zongker | 74885ef | 2010-02-02 17:39:26 -0800 | [diff] [blame] | 91 | /** The name of the hardware (from the kernel command line or /proc). */ |
| 92 | public static final String HARDWARE = getString("ro.hardware"); |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 93 | |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 94 | /** A hardware serial number, if available. Alphanumeric only, case-insensitive. */ |
Doug Zongker | 7d2e3df | 2010-08-11 16:58:04 -0700 | [diff] [blame] | 95 | public static final String SERIAL = getString("ro.serialno"); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 96 | |
| 97 | /** |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 98 | * An ordered list of ABIs supported by this device. The most preferred ABI is the first |
| 99 | * element in the list. |
| 100 | * |
| 101 | * See {@link #SUPPORTED_32_BIT_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}. |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 102 | */ |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 103 | public static final String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ","); |
Ramin Zaghi | 1378aba | 2014-02-28 15:03:19 +0000 | [diff] [blame] | 104 | |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 105 | /** |
| 106 | * An ordered list of <b>32 bit</b> ABIs supported by this device. The most preferred ABI |
| 107 | * is the first element in the list. |
| 108 | * |
| 109 | * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_64_BIT_ABIS}. |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 110 | */ |
Torne (Richard Coles) | da8c037 | 2014-05-14 16:17:26 +0100 | [diff] [blame] | 111 | public static final String[] SUPPORTED_32_BIT_ABIS = |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 112 | getStringList("ro.product.cpu.abilist32", ","); |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * An ordered list of <b>64 bit</b> ABIs supported by this device. The most preferred ABI |
| 116 | * is the first element in the list. |
| 117 | * |
| 118 | * See {@link #SUPPORTED_ABIS} and {@link #SUPPORTED_32_BIT_ABIS}. |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 119 | */ |
Torne (Richard Coles) | da8c037 | 2014-05-14 16:17:26 +0100 | [diff] [blame] | 120 | public static final String[] SUPPORTED_64_BIT_ABIS = |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 121 | getStringList("ro.product.cpu.abilist64", ","); |
Narayan Kamath | 0f206a1 | 2014-04-12 11:41:13 +0100 | [diff] [blame] | 122 | |
| 123 | |
Narayan Kamath | eff258c | 2014-09-30 13:20:57 +0100 | [diff] [blame] | 124 | static { |
| 125 | /* |
| 126 | * Adjusts CPU_ABI and CPU_ABI2 depending on whether or not a given process is 64 bit. |
| 127 | * 32 bit processes will always see 32 bit ABIs in these fields for backward |
| 128 | * compatibility. |
| 129 | */ |
| 130 | final String[] abiList; |
| 131 | if (VMRuntime.getRuntime().is64Bit()) { |
| 132 | abiList = SUPPORTED_64_BIT_ABIS; |
| 133 | } else { |
| 134 | abiList = SUPPORTED_32_BIT_ABIS; |
| 135 | } |
| 136 | |
| 137 | CPU_ABI = abiList[0]; |
| 138 | if (abiList.length > 1) { |
| 139 | CPU_ABI2 = abiList[1]; |
| 140 | } else { |
| 141 | CPU_ABI2 = ""; |
| 142 | } |
| 143 | } |
| 144 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 145 | /** Various version strings. */ |
| 146 | public static class VERSION { |
| 147 | /** |
| 148 | * The internal value used by the underlying source control to |
| 149 | * represent this build. E.g., a perforce changelist number |
| 150 | * or a git hash. |
| 151 | */ |
| 152 | public static final String INCREMENTAL = getString("ro.build.version.incremental"); |
| 153 | |
| 154 | /** |
| 155 | * The user-visible version string. E.g., "1.0" or "3.4b5". |
| 156 | */ |
| 157 | public static final String RELEASE = getString("ro.build.version.release"); |
| 158 | |
| 159 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 160 | * The user-visible SDK version of the framework in its raw String |
| 161 | * representation; use {@link #SDK_INT} instead. |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 162 | * |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 163 | * @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] | 164 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 165 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | public static final String SDK = getString("ro.build.version.sdk"); |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 167 | |
| 168 | /** |
| 169 | * The user-visible SDK version of the framework; its possible |
| 170 | * values are defined in {@link Build.VERSION_CODES}. |
| 171 | */ |
| 172 | public static final int SDK_INT = SystemProperties.getInt( |
| 173 | "ro.build.version.sdk", 0); |
| 174 | |
| 175 | /** |
| 176 | * The current development codename, or the string "REL" if this is |
| 177 | * a release build. |
| 178 | */ |
| 179 | public static final String CODENAME = getString("ro.build.version.codename"); |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 180 | |
Dianne Hackborn | ffcda10 | 2014-04-24 13:06:27 -0700 | [diff] [blame] | 181 | private static final String[] ALL_CODENAMES |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 182 | = getStringList("ro.build.version.all_codenames", ","); |
Dianne Hackborn | ffcda10 | 2014-04-24 13:06:27 -0700 | [diff] [blame] | 183 | |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 184 | /** |
Dianne Hackborn | 3b81bc1 | 2011-01-15 11:50:52 -0800 | [diff] [blame] | 185 | * @hide |
| 186 | */ |
Dianne Hackborn | ffcda10 | 2014-04-24 13:06:27 -0700 | [diff] [blame] | 187 | public static final String[] ACTIVE_CODENAMES = "REL".equals(ALL_CODENAMES[0]) |
| 188 | ? new String[0] : ALL_CODENAMES; |
| 189 | |
| 190 | /** |
| 191 | * The SDK version to use when accessing resources. |
| 192 | * Use the current SDK version code. For every active development codename |
| 193 | * we are operating under, we bump the assumed resource platform version by 1. |
| 194 | * @hide |
| 195 | */ |
| 196 | public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 197 | } |
| 198 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 199 | /** |
| 200 | * Enumeration of the currently known SDK version codes. These are the |
| 201 | * values that can be found in {@link VERSION#SDK}. Version numbers |
| 202 | * increment monotonically with each official platform release. |
| 203 | */ |
| 204 | public static class VERSION_CODES { |
| 205 | /** |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 206 | * Magic version number for a current development build, which has |
| 207 | * not yet turned into an official release. |
| 208 | */ |
| 209 | public static final int CUR_DEVELOPMENT = 10000; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 210 | |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 211 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 212 | * October 2008: The original, first, version of Android. Yay! |
| 213 | */ |
| 214 | public static final int BASE = 1; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 215 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 216 | /** |
| 217 | * February 2009: First Android update, officially called 1.1. |
| 218 | */ |
| 219 | public static final int BASE_1_1 = 2; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 220 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 221 | /** |
| 222 | * May 2009: Android 1.5. |
| 223 | */ |
| 224 | public static final int CUPCAKE = 3; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 225 | |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 226 | /** |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 227 | * September 2009: Android 1.6. |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 228 | * |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 229 | * <p>Applications targeting this or a later release will get these |
| 230 | * new changes in behavior:</p> |
| 231 | * <ul> |
| 232 | * <li> They must explicitly request the |
San Mehat | 5a3a77d | 2009-06-01 09:25:28 -0700 | [diff] [blame] | 233 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 234 | * able to modify the contents of the SD card. (Apps targeting |
| 235 | * earlier versions will always request the permission.) |
Dianne Hackborn | fe77ec8 | 2009-08-12 16:53:56 -0700 | [diff] [blame] | 236 | * <li> They must explicitly request the |
| 237 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be |
| 238 | * able to be able to retrieve phone state info. (Apps targeting |
| 239 | * earlier versions will always request the permission.) |
| 240 | * <li> They are assumed to support different screen densities and |
| 241 | * sizes. (Apps targeting earlier versions are assumed to only support |
| 242 | * medium density normal size screens unless otherwise indicated). |
| 243 | * They can still explicitly specify screen support either way with the |
| 244 | * supports-screens manifest tag. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 245 | * <li> {@link android.widget.TabHost} will use the new dark tab |
| 246 | * background design. |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 247 | * </ul> |
| 248 | */ |
Dianne Hackborn | fe77ec8 | 2009-08-12 16:53:56 -0700 | [diff] [blame] | 249 | public static final int DONUT = 4; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 250 | |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 251 | /** |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 252 | * November 2009: Android 2.0 |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 253 | * |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 254 | * <p>Applications targeting this or a later release will get these |
| 255 | * new changes in behavior:</p> |
| 256 | * <ul> |
| 257 | * <li> The {@link android.app.Service#onStartCommand |
| 258 | * Service.onStartCommand} function will return the new |
| 259 | * {@link android.app.Service#START_STICKY} behavior instead of the |
| 260 | * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}. |
Dianne Hackborn | 8d37426 | 2009-09-14 21:21:52 -0700 | [diff] [blame] | 261 | * <li> The {@link android.app.Activity} class will now execute back |
| 262 | * key presses on the key up instead of key down, to be able to detect |
| 263 | * canceled presses from virtual keys. |
Mike Cleron | 7609764 | 2009-09-25 17:53:56 -0700 | [diff] [blame] | 264 | * <li> The {@link android.widget.TabWidget} class will use a new color scheme |
| 265 | * for tabs. In the new scheme, the foreground tab has a medium gray background |
| 266 | * the background tabs have a dark gray background. |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 267 | * </ul> |
| 268 | */ |
Jeff Hamilton | 6dc3f4e | 2009-10-10 12:06:19 -0500 | [diff] [blame] | 269 | public static final int ECLAIR = 5; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 270 | |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 271 | /** |
Dianne Hackborn | 1778776 | 2009-11-12 16:11:36 -0800 | [diff] [blame] | 272 | * December 2009: Android 2.0.1 |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 273 | */ |
Dianne Hackborn | 1778776 | 2009-11-12 16:11:36 -0800 | [diff] [blame] | 274 | public static final int ECLAIR_0_1 = 6; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 275 | |
Dianne Hackborn | 23ef7b4 | 2009-11-18 18:20:39 -0800 | [diff] [blame] | 276 | /** |
| 277 | * January 2010: Android 2.1 |
| 278 | */ |
| 279 | public static final int ECLAIR_MR1 = 7; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 280 | |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 281 | /** |
| 282 | * June 2010: Android 2.2 |
| 283 | */ |
Adam Powell | 216bccf | 2010-02-01 15:03:17 -0800 | [diff] [blame] | 284 | public static final int FROYO = 8; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 285 | |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 286 | /** |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 287 | * November 2010: Android 2.3 |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 288 | * |
| 289 | * <p>Applications targeting this or a later release will get these |
| 290 | * new changes in behavior:</p> |
| 291 | * <ul> |
| 292 | * <li> The application's notification icons will be shown on the new |
| 293 | * dark status bar background, so must be visible in this situation. |
| 294 | * </ul> |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 295 | */ |
Dianne Hackborn | 4fa1a22 | 2010-10-18 13:10:49 -0700 | [diff] [blame] | 296 | public static final int GINGERBREAD = 9; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 297 | |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 298 | /** |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 299 | * February 2011: Android 2.3.3. |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 300 | */ |
| 301 | public static final int GINGERBREAD_MR1 = 10; |
Dianne Hackborn | b1ad597 | 2010-08-02 17:30:33 -0700 | [diff] [blame] | 302 | |
| 303 | /** |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 304 | * February 2011: Android 3.0. |
Dianne Hackborn | b1ad597 | 2010-08-02 17:30:33 -0700 | [diff] [blame] | 305 | * |
| 306 | * <p>Applications targeting this or a later release will get these |
| 307 | * new changes in behavior:</p> |
| 308 | * <ul> |
Dianne Hackborn | 3e6d50c | 2010-08-23 18:30:44 -0700 | [diff] [blame] | 309 | * <li> The default theme for applications is now dark holographic: |
| 310 | * {@link android.R.style#Theme_Holo}. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 311 | * <li> On large screen devices that do not have a physical menu |
| 312 | * button, the soft (compatibility) menu is disabled. |
Dianne Hackborn | 0aae2d4 | 2010-12-07 23:51:29 -0800 | [diff] [blame] | 313 | * <li> The activity lifecycle has changed slightly as per |
| 314 | * {@link android.app.Activity}. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 315 | * <li> An application will crash if it does not call through |
| 316 | * to the super implementation of its |
| 317 | * {@link android.app.Activity#onPause Activity.onPause()} method. |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 318 | * <li> When an application requires a permission to access one of |
Dianne Hackborn | 6c2c5fc | 2011-01-18 17:02:33 -0800 | [diff] [blame] | 319 | * its components (activity, receiver, service, provider), this |
| 320 | * permission is no longer enforced when the application wants to |
| 321 | * access its own component. This means it can require a permission |
| 322 | * on a component that it does not itself hold and still access that |
| 323 | * component. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 324 | * <li> {@link android.content.Context#getSharedPreferences |
| 325 | * Context.getSharedPreferences()} will not automatically reload |
| 326 | * the preferences if they have changed on storage, unless |
| 327 | * {@link android.content.Context#MODE_MULTI_PROCESS} is used. |
| 328 | * <li> {@link android.view.ViewGroup#setMotionEventSplittingEnabled} |
| 329 | * will default to true. |
| 330 | * <li> {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH} |
| 331 | * is enabled by default on windows. |
| 332 | * <li> {@link android.widget.PopupWindow#isSplitTouchEnabled() |
| 333 | * PopupWindow.isSplitTouchEnabled()} will return true by default. |
| 334 | * <li> {@link android.widget.GridView} and {@link android.widget.ListView} |
| 335 | * will use {@link android.view.View#setActivated View.setActivated} |
| 336 | * for selected items if they do not implement {@link android.widget.Checkable}. |
| 337 | * <li> {@link android.widget.Scroller} will be constructed with |
| 338 | * "flywheel" behavior enabled by default. |
Dianne Hackborn | b1ad597 | 2010-08-02 17:30:33 -0700 | [diff] [blame] | 339 | * </ul> |
| 340 | */ |
Dianne Hackborn | 9d97b63 | 2011-01-23 14:56:39 -0800 | [diff] [blame] | 341 | public static final int HONEYCOMB = 11; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 342 | |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 343 | /** |
Dianne Hackborn | a813873 | 2011-05-12 15:45:21 -0700 | [diff] [blame] | 344 | * May 2011: Android 3.1. |
Dianne Hackborn | edf1fc6 | 2011-03-17 18:34:48 -0700 | [diff] [blame] | 345 | */ |
| 346 | public static final int HONEYCOMB_MR1 = 12; |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 347 | |
Dianne Hackborn | a813873 | 2011-05-12 15:45:21 -0700 | [diff] [blame] | 348 | /** |
Dianne Hackborn | 426431a | 2011-06-09 11:29:08 -0700 | [diff] [blame] | 349 | * June 2011: Android 3.2. |
Dianne Hackborn | e667635 | 2011-06-01 16:51:20 -0700 | [diff] [blame] | 350 | * |
| 351 | * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve |
| 352 | * screen compatibility mode, etc.</p> |
| 353 | * |
| 354 | * <p>As of this version, applications that don't say whether they |
| 355 | * support XLARGE screens will be assumed to do so only if they target |
| 356 | * {@link #HONEYCOMB} or later; it had been {@link #GINGERBREAD} or |
| 357 | * later. Applications that don't support a screen size at least as |
| 358 | * large as the current screen will provide the user with a UI to |
| 359 | * switch them in to screen size compatibility mode.</p> |
Dianne Hackborn | e289bff | 2011-06-13 19:33:22 -0700 | [diff] [blame] | 360 | * |
| 361 | * <p>This version introduces new screen size resource qualifiers |
| 362 | * based on the screen size in dp: see |
| 363 | * {@link android.content.res.Configuration#screenWidthDp}, |
| 364 | * {@link android.content.res.Configuration#screenHeightDp}, and |
| 365 | * {@link android.content.res.Configuration#smallestScreenWidthDp}. |
| 366 | * Supplying these in <supports-screens> as per |
| 367 | * {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp}, |
| 368 | * {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp}, and |
| 369 | * {@link android.content.pm.ApplicationInfo#largestWidthLimitDp} is |
| 370 | * preferred over the older screen size buckets and for older devices |
| 371 | * the appropriate buckets will be inferred from them.</p> |
| 372 | * |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 373 | * <p>Applications targeting this or a later release will get these |
| 374 | * new changes in behavior:</p> |
| 375 | * <ul> |
| 376 | * <li><p>New {@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT} |
Dianne Hackborn | e289bff | 2011-06-13 19:33:22 -0700 | [diff] [blame] | 377 | * and {@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE} |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 378 | * features were introduced in this release. Applications that target |
Dianne Hackborn | e289bff | 2011-06-13 19:33:22 -0700 | [diff] [blame] | 379 | * previous platform versions are assumed to require both portrait and |
| 380 | * landscape support in the device; when targeting Honeycomb MR1 or |
| 381 | * greater the application is responsible for specifying any specific |
| 382 | * orientation it requires.</p> |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 383 | * <li><p>{@link android.os.AsyncTask} will use the serial executor |
| 384 | * by default when calling {@link android.os.AsyncTask#execute}.</p> |
| 385 | * <li><p>{@link android.content.pm.ActivityInfo#configChanges |
| 386 | * ActivityInfo.configChanges} will have the |
| 387 | * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE} and |
| 388 | * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE} |
| 389 | * bits set; these need to be cleared for older applications because |
| 390 | * some developers have done absolute comparisons against this value |
| 391 | * instead of correctly masking the bits they are interested in. |
| 392 | * </ul> |
Dianne Hackborn | a813873 | 2011-05-12 15:45:21 -0700 | [diff] [blame] | 393 | */ |
Dianne Hackborn | 426431a | 2011-06-09 11:29:08 -0700 | [diff] [blame] | 394 | public static final int HONEYCOMB_MR2 = 13; |
Dianne Hackborn | 3fc982f | 2011-03-30 16:20:26 -0700 | [diff] [blame] | 395 | |
| 396 | /** |
Dianne Hackborn | f35fe23 | 2011-11-01 19:25:20 -0700 | [diff] [blame] | 397 | * October 2011: Android 4.0. |
Dianne Hackborn | 2d6833b | 2011-06-24 16:04:19 -0700 | [diff] [blame] | 398 | * |
| 399 | * <p>Applications targeting this or a later release will get these |
| 400 | * new changes in behavior:</p> |
| 401 | * <ul> |
Dianne Hackborn | 9d0e37e | 2011-09-22 12:58:54 -0700 | [diff] [blame] | 402 | * <li> For devices without a dedicated menu key, the software compatibility |
| 403 | * menu key will not be shown even on phones. By targeting Ice Cream Sandwich |
| 404 | * or later, your UI must always have its own menu UI affordance if needed, |
| 405 | * 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] | 406 | * <li> 2d drawing hardware acceleration is now turned on by default. |
| 407 | * You can use |
| 408 | * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} |
| 409 | * to turn it off if needed, although this is strongly discouraged since |
| 410 | * it will result in poor performance on larger screen devices. |
Adam Powell | 6e90a36 | 2011-08-14 16:48:32 -0700 | [diff] [blame] | 411 | * <li> The default theme for applications is now the "device default" theme: |
| 412 | * {@link android.R.style#Theme_DeviceDefault}. This may be the |
| 413 | * holo dark theme or a different dark theme defined by the specific device. |
| 414 | * The {@link android.R.style#Theme_Holo} family must not be modified |
| 415 | * for a device to be considered compatible. Applications that explicitly |
| 416 | * request a theme from the Holo family will be guaranteed that these themes |
| 417 | * will not change character within the same platform version. Applications |
| 418 | * that wish to blend in with the device should use a theme from the |
| 419 | * {@link android.R.style#Theme_DeviceDefault} family. |
Dianne Hackborn | 9d0e37e | 2011-09-22 12:58:54 -0700 | [diff] [blame] | 420 | * <li> Managed cursors can now throw an exception if you directly close |
| 421 | * the cursor yourself without stopping the management of it; previously failures |
| 422 | * would be silently ignored. |
| 423 | * <li> The fadingEdge attribute on views will be ignored (fading edges is no |
| 424 | * longer a standard part of the UI). A new requiresFadingEdge attribute allows |
| 425 | * applications to still force fading edges on for special cases. |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 426 | * <li> {@link android.content.Context#bindService Context.bindService()} |
| 427 | * will not automatically add in {@link android.content.Context#BIND_WAIVE_PRIORITY}. |
| 428 | * <li> App Widgets will have standard padding automatically added around |
| 429 | * them, rather than relying on the padding being baked into the widget itself. |
| 430 | * <li> An exception will be thrown if you try to change the type of a |
| 431 | * window after it has been added to the window manager. Previously this |
| 432 | * would result in random incorrect behavior. |
| 433 | * <li> {@link android.view.animation.AnimationSet} will parse out |
| 434 | * the duration, fillBefore, fillAfter, repeatMode, and startOffset |
| 435 | * XML attributes that are defined. |
| 436 | * <li> {@link android.app.ActionBar#setHomeButtonEnabled |
| 437 | * ActionBar.setHomeButtonEnabled()} is false by default. |
Dianne Hackborn | 2d6833b | 2011-06-24 16:04:19 -0700 | [diff] [blame] | 438 | * </ul> |
Dianne Hackborn | 3fc982f | 2011-03-30 16:20:26 -0700 | [diff] [blame] | 439 | */ |
Dianne Hackborn | 0784cfb | 2011-09-14 13:48:15 -0700 | [diff] [blame] | 440 | public static final int ICE_CREAM_SANDWICH = 14; |
Dianne Hackborn | f35fe23 | 2011-11-01 19:25:20 -0700 | [diff] [blame] | 441 | |
| 442 | /** |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 443 | * December 2011: Android 4.0.3. |
Dianne Hackborn | f35fe23 | 2011-11-01 19:25:20 -0700 | [diff] [blame] | 444 | */ |
| 445 | public static final int ICE_CREAM_SANDWICH_MR1 = 15; |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 446 | |
| 447 | /** |
Dianne Hackborn | 435cdb4 | 2012-07-30 17:36:43 -0700 | [diff] [blame] | 448 | * June 2012: Android 4.1. |
Dianne Hackborn | 6569625 | 2012-03-05 18:49:21 -0800 | [diff] [blame] | 449 | * |
| 450 | * <p>Applications targeting this or a later release will get these |
| 451 | * new changes in behavior:</p> |
| 452 | * <ul> |
Dianne Hackborn | 636fd52 | 2012-06-05 17:38:50 -0700 | [diff] [blame] | 453 | * <li> You must explicitly request the {@link android.Manifest.permission#READ_CALL_LOG} |
| 454 | * and/or {@link android.Manifest.permission#WRITE_CALL_LOG} permissions; |
| 455 | * access to the call log is no longer implicitly provided through |
| 456 | * {@link android.Manifest.permission#READ_CONTACTS} and |
| 457 | * {@link android.Manifest.permission#WRITE_CONTACTS}. |
| 458 | * <li> {@link android.widget.RemoteViews} will throw an exception if |
| 459 | * setting an onClick handler for views being generated by a |
| 460 | * {@link android.widget.RemoteViewsService} for a collection container; |
| 461 | * previously this just resulted in a warning log message. |
| 462 | * <li> New {@link android.app.ActionBar} policy for embedded tabs: |
| 463 | * embedded tabs are now always stacked in the action bar when in portrait |
| 464 | * mode, regardless of the size of the screen. |
| 465 | * <li> {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs(boolean) |
| 466 | * WebSettings.setAllowFileAccessFromFileURLs} and |
| 467 | * {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs(boolean) |
| 468 | * WebSettings.setAllowUniversalAccessFromFileURLs} default to false. |
Dianne Hackborn | 6569625 | 2012-03-05 18:49:21 -0800 | [diff] [blame] | 469 | * <li> Calls to {@link android.content.pm.PackageManager#setComponentEnabledSetting |
| 470 | * PackageManager.setComponentEnabledSetting} will now throw an |
| 471 | * IllegalArgumentException if the given component class name does not |
| 472 | * exist in the application's manifest. |
Dianne Hackborn | 636fd52 | 2012-06-05 17:38:50 -0700 | [diff] [blame] | 473 | * <li> {@link android.nfc.NfcAdapter#setNdefPushMessage |
| 474 | * NfcAdapter.setNdefPushMessage}, |
| 475 | * {@link android.nfc.NfcAdapter#setNdefPushMessageCallback |
| 476 | * NfcAdapter.setNdefPushMessageCallback} and |
| 477 | * {@link android.nfc.NfcAdapter#setOnNdefPushCompleteCallback |
| 478 | * NfcAdapter.setOnNdefPushCompleteCallback} will throw |
| 479 | * IllegalStateException if called after the Activity has been destroyed. |
| 480 | * <li> Accessibility services must require the new |
| 481 | * {@link android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE} permission or |
| 482 | * they will not be available for use. |
| 483 | * <li> {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS |
| 484 | * AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} must be set |
| 485 | * for unimportant views to be included in queries. |
Dianne Hackborn | 6569625 | 2012-03-05 18:49:21 -0800 | [diff] [blame] | 486 | * </ul> |
Dianne Hackborn | 81e9276 | 2011-10-09 16:00:21 -0700 | [diff] [blame] | 487 | */ |
Dianne Hackborn | fa61f0b | 2012-05-09 21:49:38 -0700 | [diff] [blame] | 488 | public static final int JELLY_BEAN = 16; |
Dianne Hackborn | 435cdb4 | 2012-07-30 17:36:43 -0700 | [diff] [blame] | 489 | |
| 490 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 491 | * November 2012: Android 4.2, Moar jelly beans! |
Nick Kralevich | f097b16 | 2012-07-28 12:43:48 -0700 | [diff] [blame] | 492 | * |
| 493 | * <p>Applications targeting this or a later release will get these |
| 494 | * new changes in behavior:</p> |
| 495 | * <ul> |
| 496 | * <li>Content Providers: The default value of {@code android:exported} is now |
| 497 | * {@code false}. See |
Nick Kralevich | 2caec6c | 2012-08-08 11:33:17 -0700 | [diff] [blame] | 498 | * <a href="{@docRoot}guide/topics/manifest/provider-element.html#exported"> |
Nick Kralevich | f097b16 | 2012-07-28 12:43:48 -0700 | [diff] [blame] | 499 | * 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] | 500 | * <li>{@link android.view.View#getLayoutDirection() View.getLayoutDirection()} |
| 501 | * can return different values than {@link android.view.View#LAYOUT_DIRECTION_LTR} |
| 502 | * based on the locale etc. |
| 503 | * <li> {@link android.webkit.WebView#addJavascriptInterface(Object, String) |
| 504 | * WebView.addJavascriptInterface} requires explicit annotations on methods |
| 505 | * for them to be accessible from Javascript. |
Nick Kralevich | f097b16 | 2012-07-28 12:43:48 -0700 | [diff] [blame] | 506 | * </ul> |
Dianne Hackborn | 435cdb4 | 2012-07-30 17:36:43 -0700 | [diff] [blame] | 507 | */ |
| 508 | public static final int JELLY_BEAN_MR1 = 17; |
Nick Kralevich | a985c3b | 2013-01-09 16:03:14 -0800 | [diff] [blame] | 509 | |
| 510 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 511 | * July 2013: Android 4.3, the revenge of the beans. |
Nick Kralevich | a985c3b | 2013-01-09 16:03:14 -0800 | [diff] [blame] | 512 | */ |
Dianne Hackborn | d2eeed6 | 2013-04-22 13:04:28 -0700 | [diff] [blame] | 513 | public static final int JELLY_BEAN_MR2 = 18; |
Dianne Hackborn | 5d2bfa1 | 2013-03-05 10:28:34 -0800 | [diff] [blame] | 514 | |
| 515 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 516 | * October 2013: Android 4.4, KitKat, another tasty treat. |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 517 | * |
| 518 | * <p>Applications targeting this or a later release will get these |
| 519 | * new changes in behavior:</p> |
| 520 | * <ul> |
Mark Doliner | d0646dc | 2014-08-27 16:04:02 -0700 | [diff] [blame] | 521 | * <li> The default result of |
| 522 | * {@link android.preference.PreferenceActivity#isValidFragment(String) |
Dianne Hackborn | 6bc3789 | 2013-10-03 11:05:14 -0700 | [diff] [blame] | 523 | * PreferenceActivity.isValueFragment} becomes false instead of true.</li> |
| 524 | * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have |
| 525 | * JS URLs evaluated directly and any result of the evaluation will not replace |
| 526 | * the current page content. Apps targetting KITKAT or later that load a JS URL will |
| 527 | * have the result of that URL replace the content of the current page</li> |
| 528 | * <li> {@link android.app.AlarmManager#set AlarmManager.set} becomes interpreted as |
| 529 | * an inexact value, to give the system more flexibility in scheduling alarms.</li> |
| 530 | * <li> {@link android.content.Context#getSharedPreferences(String, int) |
| 531 | * Context.getSharedPreferences} no longer allows a null name.</li> |
| 532 | * <li> {@link android.widget.RelativeLayout} changes to compute wrapped content |
| 533 | * margins correctly.</li> |
| 534 | * <li> {@link android.app.ActionBar}'s window content overlay is allowed to be |
| 535 | * drawn.</li> |
Jeff Sharkey | 3ec2f60 | 2013-10-29 12:21:23 -0700 | [diff] [blame] | 536 | * <li>The {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} |
| 537 | * permission is now always enforced.</li> |
| 538 | * <li>Access to package-specific external storage directories belonging |
| 539 | * to the calling app no longer requires the |
| 540 | * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} or |
| 541 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} |
| 542 | * permissions.</li> |
Dianne Hackborn | 221ea89 | 2013-08-04 16:50:16 -0700 | [diff] [blame] | 543 | * </ul> |
Dianne Hackborn | 5d2bfa1 | 2013-03-05 10:28:34 -0800 | [diff] [blame] | 544 | */ |
Dianne Hackborn | 6bc3789 | 2013-10-03 11:05:14 -0700 | [diff] [blame] | 545 | public static final int KITKAT = 19; |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 546 | |
| 547 | /** |
Justin Koh | 78b94de | 2014-05-13 15:48:42 -0700 | [diff] [blame] | 548 | * Android 4.4W: KitKat for watches, snacks on the run. |
| 549 | * |
| 550 | * <p>Applications targeting this or a later release will get these |
| 551 | * new changes in behavior:</p> |
| 552 | * <ul> |
| 553 | * <li>{@link android.app.AlertDialog} might not have a default background if the theme does |
| 554 | * not specify one.</li> |
| 555 | * </ul> |
Jeff Brown | 1c3f332 | 2014-04-16 13:15:22 -0700 | [diff] [blame] | 556 | */ |
Justin Koh | 78b94de | 2014-05-13 15:48:42 -0700 | [diff] [blame] | 557 | public static final int KITKAT_WATCH = 20; |
Jeff Brown | 047f3c7 | 2014-04-16 14:18:49 -0700 | [diff] [blame] | 558 | |
| 559 | /** |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 560 | * Temporary until we completely switch to {@link #LOLLIPOP}. |
Dianne Hackborn | d3511d4 | 2014-10-16 17:48:30 -0700 | [diff] [blame] | 561 | * @hide |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 562 | */ |
| 563 | public static final int L = 21; |
| 564 | |
| 565 | /** |
| 566 | * Lollipop. A flat one with beautiful shadows. But still tasty. |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 567 | * |
| 568 | * <p>Applications targeting this or a later release will get these |
| 569 | * new changes in behavior:</p> |
| 570 | * <ul> |
| 571 | * <li> {@link android.content.Context#bindService Context.bindService} now |
Michael Wright | 5b5def5 | 2014-04-11 13:37:50 -0700 | [diff] [blame] | 572 | * 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] | 573 | * Intent.</li> |
Dianne Hackborn | d3511d4 | 2014-10-16 17:48:30 -0700 | [diff] [blame] | 574 | * <li> {@link android.app.Notification.Builder Notification.Builder} will |
| 575 | * not have the colors of their various notification elements adjusted to better |
| 576 | * match the new material design look.</li> |
| 577 | * <li> {@link android.os.Message} will validate that a message is not currently |
| 578 | * in use when it is recycled.</li> |
| 579 | * <li> Hardware accelerated drawing in windows will be enabled automatically |
| 580 | * in most places.</li> |
| 581 | * <li> {@link android.widget.Spinner} throws an exception if attaching an |
| 582 | * adapter with more than one item type.</li> |
| 583 | * <li> If the app is a launcher, the launcher will be available to the user |
| 584 | * even when they are using corporate profiles (which requires that the app |
| 585 | * use {@link android.content.pm.LauncherApps} to correctly populate its |
| 586 | * apps UI).</li> |
| 587 | * <li> Calling {@link android.app.Service#stopForeground Service.stopForeground} |
| 588 | * with removeNotification false will modify the still posted notification so that |
| 589 | * it is no longer forced to be ongoing.</li> |
| 590 | * <li> A {@link android.service.dreams.DreamService} must require the |
| 591 | * {@link android.Manifest.permission#BIND_DREAM_SERVICE} permission to be usable.</li> |
Dianne Hackborn | 10ad982 | 2014-03-17 11:28:36 -0700 | [diff] [blame] | 592 | * </ul> |
| 593 | */ |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 594 | public static final int LOLLIPOP = 21; |
Dianne Hackborn | 3b69688 | 2014-10-16 18:14:12 -0700 | [diff] [blame] | 595 | |
| 596 | /** |
| 597 | * Lollipop with an extra sugar coating on the outside! |
| 598 | */ |
| 599 | public static final int LOLLIPOP_MR1 = 22; |
Dianne Hackborn | 8bd95f1 | 2015-01-27 13:18:24 -0800 | [diff] [blame] | 600 | |
| 601 | /** |
| 602 | * M comes after L. |
| 603 | */ |
| 604 | public static final int MNC = CUR_DEVELOPMENT; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 605 | } |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 606 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 607 | /** The type of build, like "user" or "eng". */ |
| 608 | public static final String TYPE = getString("ro.build.type"); |
| 609 | |
| 610 | /** Comma-separated tags describing the build, like "unsigned,debug". */ |
| 611 | public static final String TAGS = getString("ro.build.tags"); |
| 612 | |
| 613 | /** 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] | 614 | public static final String FINGERPRINT = deriveFingerprint(); |
| 615 | |
| 616 | /** |
| 617 | * Some devices split the fingerprint components between multiple |
| 618 | * partitions, so we might derive the fingerprint at runtime. |
| 619 | */ |
| 620 | private static String deriveFingerprint() { |
| 621 | String finger = SystemProperties.get("ro.build.fingerprint"); |
| 622 | if (TextUtils.isEmpty(finger)) { |
| 623 | finger = getString("ro.product.brand") + '/' + |
| 624 | getString("ro.product.name") + '/' + |
| 625 | getString("ro.product.device") + ':' + |
| 626 | getString("ro.build.version.release") + '/' + |
| 627 | getString("ro.build.id") + '/' + |
| 628 | getString("ro.build.version.incremental") + ':' + |
| 629 | getString("ro.build.type") + '/' + |
| 630 | getString("ro.build.tags"); |
| 631 | } |
| 632 | return finger; |
| 633 | } |
| 634 | |
| 635 | /** |
| 636 | * Ensure that raw fingerprint system property is defined. If it was derived |
| 637 | * dynamically by {@link #deriveFingerprint()} this is where we push the |
| 638 | * derived value into the property service. |
| 639 | * |
| 640 | * @hide |
| 641 | */ |
| 642 | public static void ensureFingerprintProperty() { |
| 643 | if (TextUtils.isEmpty(SystemProperties.get("ro.build.fingerprint"))) { |
Jeff Sharkey | bdd4491 | 2014-04-11 16:30:14 -0700 | [diff] [blame] | 644 | try { |
| 645 | SystemProperties.set("ro.build.fingerprint", FINGERPRINT); |
| 646 | } catch (IllegalArgumentException e) { |
| 647 | Slog.e(TAG, "Failed to set fingerprint property", e); |
| 648 | } |
Jeff Sharkey | 5568772 | 2014-04-09 18:07:19 -0700 | [diff] [blame] | 649 | } |
| 650 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 651 | |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 652 | /** |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 653 | * Verifies the the current flash of the device is consistent with what |
| 654 | * was expected at build time. |
| 655 | * 1) Checks that device fingerprint is defined and that it matches across |
| 656 | * various partitions. |
| 657 | * 2) Verifies radio and bootloader partitions are those expected in the build. |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 658 | * |
| 659 | * @hide |
| 660 | */ |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 661 | public static boolean isBuildConsistent() { |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 662 | final String system = SystemProperties.get("ro.build.fingerprint"); |
| 663 | final String vendor = SystemProperties.get("ro.vendor.build.fingerprint"); |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 664 | final String bootimage = SystemProperties.get("ro.bootimage.build.fingerprint"); |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 665 | final String requiredBootloader = SystemProperties.get("ro.build.expect.bootloader"); |
| 666 | final String currentBootloader = SystemProperties.get("ro.bootloader"); |
| 667 | final String requiredRadio = SystemProperties.get("ro.build.expect.baseband"); |
| 668 | final String currentRadio = SystemProperties.get("gsm.version.baseband"); |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 669 | |
| 670 | if (TextUtils.isEmpty(system)) { |
| 671 | Slog.e(TAG, "Required ro.build.fingerprint is empty!"); |
| 672 | return false; |
| 673 | } |
| 674 | |
| 675 | if (!TextUtils.isEmpty(vendor)) { |
| 676 | if (!Objects.equals(system, vendor)) { |
| 677 | Slog.e(TAG, "Mismatched fingerprints; system reported " + system |
| 678 | + " but vendor reported " + vendor); |
| 679 | return false; |
| 680 | } |
| 681 | } |
| 682 | |
Daniel Rosenberg | 159c205 | 2015-02-20 13:10:26 -0800 | [diff] [blame^] | 683 | /* TODO: Figure out issue with checks failing |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 684 | if (!TextUtils.isEmpty(bootimage)) { |
Andres Morales | 7de24ce | 2015-01-23 12:45:54 -0800 | [diff] [blame] | 685 | if (!Objects.equals(system, bootimage)) { |
| 686 | Slog.e(TAG, "Mismatched fingerprints; system reported " + system |
Andres Morales | cb3fd69 | 2015-01-14 10:07:55 -0800 | [diff] [blame] | 687 | + " but bootimage reported " + bootimage); |
| 688 | return false; |
| 689 | } |
| 690 | } |
| 691 | |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 692 | if (!TextUtils.isEmpty(requiredBootloader)) { |
| 693 | if (!Objects.equals(currentBootloader, requiredBootloader)) { |
| 694 | Slog.e(TAG, "Mismatched bootloader version: build requires " + requiredBootloader |
| 695 | + " but runtime reports " + currentBootloader); |
| 696 | return false; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | if (!TextUtils.isEmpty(requiredRadio)) { |
| 701 | if (!Objects.equals(currentRadio, requiredRadio)) { |
| 702 | Slog.e(TAG, "Mismatched radio version: build requires " + requiredRadio |
| 703 | + " but runtime reports " + currentRadio); |
| 704 | return false; |
| 705 | } |
| 706 | } |
Daniel Rosenberg | 159c205 | 2015-02-20 13:10:26 -0800 | [diff] [blame^] | 707 | */ |
Andres Morales | fd282ed | 2015-02-06 15:07:59 -0800 | [diff] [blame] | 708 | |
Jeff Sharkey | 2cffc7d | 2014-11-14 13:57:53 -0800 | [diff] [blame] | 709 | return true; |
| 710 | } |
| 711 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 712 | // The following properties only make sense for internal engineering builds. |
| 713 | public static final long TIME = getLong("ro.build.date.utc") * 1000; |
| 714 | public static final String USER = getString("ro.build.user"); |
| 715 | public static final String HOST = getString("ro.build.host"); |
| 716 | |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 717 | /** |
Jeff Brown | 89101cd9 | 2011-10-27 21:24:54 -0700 | [diff] [blame] | 718 | * Returns true if we are running a debug build such as "user-debug" or "eng". |
| 719 | * @hide |
| 720 | */ |
| 721 | public static final boolean IS_DEBUGGABLE = |
| 722 | SystemProperties.getInt("ro.debuggable", 0) == 1; |
| 723 | |
| 724 | /** |
Doug Zongker | ad2171a | 2011-06-14 11:07:24 -0700 | [diff] [blame] | 725 | * Returns the version string for the radio firmware. May return |
| 726 | * null (if, for instance, the radio is not currently on). |
| 727 | */ |
| 728 | public static String getRadioVersion() { |
| 729 | return SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION, null); |
| 730 | } |
| 731 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | private static String getString(String property) { |
| 733 | return SystemProperties.get(property, UNKNOWN); |
| 734 | } |
| 735 | |
Torne (Richard Coles) | ff701a6 | 2014-07-30 12:11:15 +0100 | [diff] [blame] | 736 | private static String[] getStringList(String property, String separator) { |
| 737 | String value = SystemProperties.get(property); |
| 738 | if (value.isEmpty()) { |
| 739 | return new String[0]; |
| 740 | } else { |
| 741 | return value.split(separator); |
| 742 | } |
| 743 | } |
| 744 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 745 | private static long getLong(String property) { |
| 746 | try { |
| 747 | return Long.parseLong(SystemProperties.get(property)); |
| 748 | } catch (NumberFormatException e) { |
| 749 | return -1; |
| 750 | } |
| 751 | } |
| 752 | } |