Build.java revision 3ee9dc58e5e1e39fac184b98cac0c7c46af72dd9
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 17package android.os; 18 19import com.android.internal.telephony.TelephonyProperties; 20 21/** 22 * Information about the current build, extracted from system properties. 23 */ 24public class Build { 25 /** Value used for when a build property is unknown. */ 26 public static final String UNKNOWN = "unknown"; 27 28 /** Either a changelist number, or a label like "M4-rc20". */ 29 public static final String ID = getString("ro.build.id"); 30 31 /** A build ID string meant for displaying to the user */ 32 public static final String DISPLAY = getString("ro.build.display.id"); 33 34 /** The name of the overall product. */ 35 public static final String PRODUCT = getString("ro.product.name"); 36 37 /** The name of the industrial design. */ 38 public static final String DEVICE = getString("ro.product.device"); 39 40 /** The name of the underlying board, like "goldfish". */ 41 public static final String BOARD = getString("ro.product.board"); 42 43 /** The name of the instruction set (CPU type + ABI convention) of native code. */ 44 public static final String CPU_ABI = getString("ro.product.cpu.abi"); 45 46 /** The name of the second instruction set (CPU type + ABI convention) of native code. */ 47 public static final String CPU_ABI2 = getString("ro.product.cpu.abi2"); 48 49 /** The manufacturer of the product/hardware. */ 50 public static final String MANUFACTURER = getString("ro.product.manufacturer"); 51 52 /** The consumer-visible brand with which the product/hardware will be associated, if any. */ 53 public static final String BRAND = getString("ro.product.brand"); 54 55 /** The end-user-visible name for the end product. */ 56 public static final String MODEL = getString("ro.product.model"); 57 58 /** The system bootloader version number. */ 59 public static final String BOOTLOADER = getString("ro.bootloader"); 60 61 /** 62 * The radio firmware version number. 63 * 64 * @deprecated The radio firmware version is frequently not 65 * available when this class is initialized, leading to a blank or 66 * "unknown" value for this string. Use 67 * {@link #getRadioVersion} instead. 68 */ 69 @Deprecated 70 public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION); 71 72 /** The name of the hardware (from the kernel command line or /proc). */ 73 public static final String HARDWARE = getString("ro.hardware"); 74 75 /** A hardware serial number, if available. Alphanumeric only, case-insensitive. */ 76 public static final String SERIAL = getString("ro.serialno"); 77 78 /** 79 * A list of ABIs (in priority) order supported by this device. 80 * 81 * @hide 82 */ 83 public static final String[] SUPPORTED_ABIS = getString("ro.product.cpu.abilist").split(","); 84 85 /** Various version strings. */ 86 public static class VERSION { 87 /** 88 * The internal value used by the underlying source control to 89 * represent this build. E.g., a perforce changelist number 90 * or a git hash. 91 */ 92 public static final String INCREMENTAL = getString("ro.build.version.incremental"); 93 94 /** 95 * The user-visible version string. E.g., "1.0" or "3.4b5". 96 */ 97 public static final String RELEASE = getString("ro.build.version.release"); 98 99 /** 100 * The user-visible SDK version of the framework in its raw String 101 * representation; use {@link #SDK_INT} instead. 102 * 103 * @deprecated Use {@link #SDK_INT} to easily get this as an integer. 104 */ 105 @Deprecated 106 public static final String SDK = getString("ro.build.version.sdk"); 107 108 /** 109 * The user-visible SDK version of the framework; its possible 110 * values are defined in {@link Build.VERSION_CODES}. 111 */ 112 public static final int SDK_INT = SystemProperties.getInt( 113 "ro.build.version.sdk", 0); 114 115 /** 116 * The current development codename, or the string "REL" if this is 117 * a release build. 118 */ 119 public static final String CODENAME = getString("ro.build.version.codename"); 120 121 /** 122 * The SDK version to use when accessing resources. 123 * Use the current SDK version code. If we are a development build, 124 * also allow the previous SDK version + 1. 125 * @hide 126 */ 127 public static final int RESOURCES_SDK_INT = SDK_INT 128 + ("REL".equals(CODENAME) ? 0 : 1); 129 } 130 131 /** 132 * Enumeration of the currently known SDK version codes. These are the 133 * values that can be found in {@link VERSION#SDK}. Version numbers 134 * increment monotonically with each official platform release. 135 */ 136 public static class VERSION_CODES { 137 /** 138 * Magic version number for a current development build, which has 139 * not yet turned into an official release. 140 */ 141 public static final int CUR_DEVELOPMENT = 10000; 142 143 /** 144 * October 2008: The original, first, version of Android. Yay! 145 */ 146 public static final int BASE = 1; 147 148 /** 149 * February 2009: First Android update, officially called 1.1. 150 */ 151 public static final int BASE_1_1 = 2; 152 153 /** 154 * May 2009: Android 1.5. 155 */ 156 public static final int CUPCAKE = 3; 157 158 /** 159 * September 2009: Android 1.6. 160 * 161 * <p>Applications targeting this or a later release will get these 162 * new changes in behavior:</p> 163 * <ul> 164 * <li> They must explicitly request the 165 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be 166 * able to modify the contents of the SD card. (Apps targeting 167 * earlier versions will always request the permission.) 168 * <li> They must explicitly request the 169 * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be 170 * able to be able to retrieve phone state info. (Apps targeting 171 * earlier versions will always request the permission.) 172 * <li> They are assumed to support different screen densities and 173 * sizes. (Apps targeting earlier versions are assumed to only support 174 * medium density normal size screens unless otherwise indicated). 175 * They can still explicitly specify screen support either way with the 176 * supports-screens manifest tag. 177 * <li> {@link android.widget.TabHost} will use the new dark tab 178 * background design. 179 * </ul> 180 */ 181 public static final int DONUT = 4; 182 183 /** 184 * November 2009: Android 2.0 185 * 186 * <p>Applications targeting this or a later release will get these 187 * new changes in behavior:</p> 188 * <ul> 189 * <li> The {@link android.app.Service#onStartCommand 190 * Service.onStartCommand} function will return the new 191 * {@link android.app.Service#START_STICKY} behavior instead of the 192 * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}. 193 * <li> The {@link android.app.Activity} class will now execute back 194 * key presses on the key up instead of key down, to be able to detect 195 * canceled presses from virtual keys. 196 * <li> The {@link android.widget.TabWidget} class will use a new color scheme 197 * for tabs. In the new scheme, the foreground tab has a medium gray background 198 * the background tabs have a dark gray background. 199 * </ul> 200 */ 201 public static final int ECLAIR = 5; 202 203 /** 204 * December 2009: Android 2.0.1 205 */ 206 public static final int ECLAIR_0_1 = 6; 207 208 /** 209 * January 2010: Android 2.1 210 */ 211 public static final int ECLAIR_MR1 = 7; 212 213 /** 214 * June 2010: Android 2.2 215 */ 216 public static final int FROYO = 8; 217 218 /** 219 * November 2010: Android 2.3 220 * 221 * <p>Applications targeting this or a later release will get these 222 * new changes in behavior:</p> 223 * <ul> 224 * <li> The application's notification icons will be shown on the new 225 * dark status bar background, so must be visible in this situation. 226 * </ul> 227 */ 228 public static final int GINGERBREAD = 9; 229 230 /** 231 * February 2011: Android 2.3.3. 232 */ 233 public static final int GINGERBREAD_MR1 = 10; 234 235 /** 236 * February 2011: Android 3.0. 237 * 238 * <p>Applications targeting this or a later release will get these 239 * new changes in behavior:</p> 240 * <ul> 241 * <li> The default theme for applications is now dark holographic: 242 * {@link android.R.style#Theme_Holo}. 243 * <li> On large screen devices that do not have a physical menu 244 * button, the soft (compatibility) menu is disabled. 245 * <li> The activity lifecycle has changed slightly as per 246 * {@link android.app.Activity}. 247 * <li> An application will crash if it does not call through 248 * to the super implementation of its 249 * {@link android.app.Activity#onPause Activity.onPause()} method. 250 * <li> When an application requires a permission to access one of 251 * its components (activity, receiver, service, provider), this 252 * permission is no longer enforced when the application wants to 253 * access its own component. This means it can require a permission 254 * on a component that it does not itself hold and still access that 255 * component. 256 * <li> {@link android.content.Context#getSharedPreferences 257 * Context.getSharedPreferences()} will not automatically reload 258 * the preferences if they have changed on storage, unless 259 * {@link android.content.Context#MODE_MULTI_PROCESS} is used. 260 * <li> {@link android.view.ViewGroup#setMotionEventSplittingEnabled} 261 * will default to true. 262 * <li> {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH} 263 * is enabled by default on windows. 264 * <li> {@link android.widget.PopupWindow#isSplitTouchEnabled() 265 * PopupWindow.isSplitTouchEnabled()} will return true by default. 266 * <li> {@link android.widget.GridView} and {@link android.widget.ListView} 267 * will use {@link android.view.View#setActivated View.setActivated} 268 * for selected items if they do not implement {@link android.widget.Checkable}. 269 * <li> {@link android.widget.Scroller} will be constructed with 270 * "flywheel" behavior enabled by default. 271 * </ul> 272 */ 273 public static final int HONEYCOMB = 11; 274 275 /** 276 * May 2011: Android 3.1. 277 */ 278 public static final int HONEYCOMB_MR1 = 12; 279 280 /** 281 * June 2011: Android 3.2. 282 * 283 * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve 284 * screen compatibility mode, etc.</p> 285 * 286 * <p>As of this version, applications that don't say whether they 287 * support XLARGE screens will be assumed to do so only if they target 288 * {@link #HONEYCOMB} or later; it had been {@link #GINGERBREAD} or 289 * later. Applications that don't support a screen size at least as 290 * large as the current screen will provide the user with a UI to 291 * switch them in to screen size compatibility mode.</p> 292 * 293 * <p>This version introduces new screen size resource qualifiers 294 * based on the screen size in dp: see 295 * {@link android.content.res.Configuration#screenWidthDp}, 296 * {@link android.content.res.Configuration#screenHeightDp}, and 297 * {@link android.content.res.Configuration#smallestScreenWidthDp}. 298 * Supplying these in <supports-screens> as per 299 * {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp}, 300 * {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp}, and 301 * {@link android.content.pm.ApplicationInfo#largestWidthLimitDp} is 302 * preferred over the older screen size buckets and for older devices 303 * the appropriate buckets will be inferred from them.</p> 304 * 305 * <p>Applications targeting this or a later release will get these 306 * new changes in behavior:</p> 307 * <ul> 308 * <li><p>New {@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT} 309 * and {@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE} 310 * features were introduced in this release. Applications that target 311 * previous platform versions are assumed to require both portrait and 312 * landscape support in the device; when targeting Honeycomb MR1 or 313 * greater the application is responsible for specifying any specific 314 * orientation it requires.</p> 315 * <li><p>{@link android.os.AsyncTask} will use the serial executor 316 * by default when calling {@link android.os.AsyncTask#execute}.</p> 317 * <li><p>{@link android.content.pm.ActivityInfo#configChanges 318 * ActivityInfo.configChanges} will have the 319 * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE} and 320 * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE} 321 * bits set; these need to be cleared for older applications because 322 * some developers have done absolute comparisons against this value 323 * instead of correctly masking the bits they are interested in. 324 * </ul> 325 */ 326 public static final int HONEYCOMB_MR2 = 13; 327 328 /** 329 * October 2011: Android 4.0. 330 * 331 * <p>Applications targeting this or a later release will get these 332 * new changes in behavior:</p> 333 * <ul> 334 * <li> For devices without a dedicated menu key, the software compatibility 335 * menu key will not be shown even on phones. By targeting Ice Cream Sandwich 336 * or later, your UI must always have its own menu UI affordance if needed, 337 * on both tablets and phones. The ActionBar will take care of this for you. 338 * <li> 2d drawing hardware acceleration is now turned on by default. 339 * You can use 340 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 341 * to turn it off if needed, although this is strongly discouraged since 342 * it will result in poor performance on larger screen devices. 343 * <li> The default theme for applications is now the "device default" theme: 344 * {@link android.R.style#Theme_DeviceDefault}. This may be the 345 * holo dark theme or a different dark theme defined by the specific device. 346 * The {@link android.R.style#Theme_Holo} family must not be modified 347 * for a device to be considered compatible. Applications that explicitly 348 * request a theme from the Holo family will be guaranteed that these themes 349 * will not change character within the same platform version. Applications 350 * that wish to blend in with the device should use a theme from the 351 * {@link android.R.style#Theme_DeviceDefault} family. 352 * <li> Managed cursors can now throw an exception if you directly close 353 * the cursor yourself without stopping the management of it; previously failures 354 * would be silently ignored. 355 * <li> The fadingEdge attribute on views will be ignored (fading edges is no 356 * longer a standard part of the UI). A new requiresFadingEdge attribute allows 357 * applications to still force fading edges on for special cases. 358 * <li> {@link android.content.Context#bindService Context.bindService()} 359 * will not automatically add in {@link android.content.Context#BIND_WAIVE_PRIORITY}. 360 * <li> App Widgets will have standard padding automatically added around 361 * them, rather than relying on the padding being baked into the widget itself. 362 * <li> An exception will be thrown if you try to change the type of a 363 * window after it has been added to the window manager. Previously this 364 * would result in random incorrect behavior. 365 * <li> {@link android.view.animation.AnimationSet} will parse out 366 * the duration, fillBefore, fillAfter, repeatMode, and startOffset 367 * XML attributes that are defined. 368 * <li> {@link android.app.ActionBar#setHomeButtonEnabled 369 * ActionBar.setHomeButtonEnabled()} is false by default. 370 * </ul> 371 */ 372 public static final int ICE_CREAM_SANDWICH = 14; 373 374 /** 375 * December 2011: Android 4.0.3. 376 */ 377 public static final int ICE_CREAM_SANDWICH_MR1 = 15; 378 379 /** 380 * June 2012: Android 4.1. 381 * 382 * <p>Applications targeting this or a later release will get these 383 * new changes in behavior:</p> 384 * <ul> 385 * <li> You must explicitly request the {@link android.Manifest.permission#READ_CALL_LOG} 386 * and/or {@link android.Manifest.permission#WRITE_CALL_LOG} permissions; 387 * access to the call log is no longer implicitly provided through 388 * {@link android.Manifest.permission#READ_CONTACTS} and 389 * {@link android.Manifest.permission#WRITE_CONTACTS}. 390 * <li> {@link android.widget.RemoteViews} will throw an exception if 391 * setting an onClick handler for views being generated by a 392 * {@link android.widget.RemoteViewsService} for a collection container; 393 * previously this just resulted in a warning log message. 394 * <li> New {@link android.app.ActionBar} policy for embedded tabs: 395 * embedded tabs are now always stacked in the action bar when in portrait 396 * mode, regardless of the size of the screen. 397 * <li> {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs(boolean) 398 * WebSettings.setAllowFileAccessFromFileURLs} and 399 * {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs(boolean) 400 * WebSettings.setAllowUniversalAccessFromFileURLs} default to false. 401 * <li> Calls to {@link android.content.pm.PackageManager#setComponentEnabledSetting 402 * PackageManager.setComponentEnabledSetting} will now throw an 403 * IllegalArgumentException if the given component class name does not 404 * exist in the application's manifest. 405 * <li> {@link android.nfc.NfcAdapter#setNdefPushMessage 406 * NfcAdapter.setNdefPushMessage}, 407 * {@link android.nfc.NfcAdapter#setNdefPushMessageCallback 408 * NfcAdapter.setNdefPushMessageCallback} and 409 * {@link android.nfc.NfcAdapter#setOnNdefPushCompleteCallback 410 * NfcAdapter.setOnNdefPushCompleteCallback} will throw 411 * IllegalStateException if called after the Activity has been destroyed. 412 * <li> Accessibility services must require the new 413 * {@link android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE} permission or 414 * they will not be available for use. 415 * <li> {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS 416 * AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} must be set 417 * for unimportant views to be included in queries. 418 * </ul> 419 */ 420 public static final int JELLY_BEAN = 16; 421 422 /** 423 * Android 4.2: Moar jelly beans! 424 * 425 * <p>Applications targeting this or a later release will get these 426 * new changes in behavior:</p> 427 * <ul> 428 * <li>Content Providers: The default value of {@code android:exported} is now 429 * {@code false}. See 430 * <a href="{@docRoot}guide/topics/manifest/provider-element.html#exported"> 431 * the android:exported section</a> in the provider documentation for more details.</li> 432 * <li>{@link android.view.View#getLayoutDirection() View.getLayoutDirection()} 433 * can return different values than {@link android.view.View#LAYOUT_DIRECTION_LTR} 434 * based on the locale etc. 435 * <li> {@link android.webkit.WebView#addJavascriptInterface(Object, String) 436 * WebView.addJavascriptInterface} requires explicit annotations on methods 437 * for them to be accessible from Javascript. 438 * </ul> 439 */ 440 public static final int JELLY_BEAN_MR1 = 17; 441 442 /** 443 * Android 4.3: Jelly Bean MR2, the revenge of the beans. 444 */ 445 public static final int JELLY_BEAN_MR2 = 18; 446 447 /** 448 * Android 4.4: KitKat, another tasty treat. 449 * 450 * <p>Applications targeting this or a later release will get these 451 * new changes in behavior:</p> 452 * <ul> 453 * <li> The default result of {android.preference.PreferenceActivity#isValidFragment 454 * PreferenceActivity.isValueFragment} becomes false instead of true.</li> 455 * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have 456 * JS URLs evaluated directly and any result of the evaluation will not replace 457 * the current page content. Apps targetting KITKAT or later that load a JS URL will 458 * have the result of that URL replace the content of the current page</li> 459 * <li> {@link android.app.AlarmManager#set AlarmManager.set} becomes interpreted as 460 * an inexact value, to give the system more flexibility in scheduling alarms.</li> 461 * <li> {@link android.content.Context#getSharedPreferences(String, int) 462 * Context.getSharedPreferences} no longer allows a null name.</li> 463 * <li> {@link android.widget.RelativeLayout} changes to compute wrapped content 464 * margins correctly.</li> 465 * <li> {@link android.app.ActionBar}'s window content overlay is allowed to be 466 * drawn.</li> 467 * <li>The {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} 468 * permission is now always enforced.</li> 469 * <li>Access to package-specific external storage directories belonging 470 * to the calling app no longer requires the 471 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} or 472 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} 473 * permissions.</li> 474 * </ul> 475 */ 476 public static final int KITKAT = 19; 477 478 /** 479 * Android 4.5: KitKat for watches, snacks on the run. 480 */ 481 public static final int KITKAT_WATCH = CUR_DEVELOPMENT; // STOPSHIP: update API level 482 } 483 484 /** The type of build, like "user" or "eng". */ 485 public static final String TYPE = getString("ro.build.type"); 486 487 /** Comma-separated tags describing the build, like "unsigned,debug". */ 488 public static final String TAGS = getString("ro.build.tags"); 489 490 /** A string that uniquely identifies this build. Do not attempt to parse this value. */ 491 public static final String FINGERPRINT = getString("ro.build.fingerprint"); 492 493 // The following properties only make sense for internal engineering builds. 494 public static final long TIME = getLong("ro.build.date.utc") * 1000; 495 public static final String USER = getString("ro.build.user"); 496 public static final String HOST = getString("ro.build.host"); 497 498 /** 499 * Returns true if we are running a debug build such as "user-debug" or "eng". 500 * @hide 501 */ 502 public static final boolean IS_DEBUGGABLE = 503 SystemProperties.getInt("ro.debuggable", 0) == 1; 504 505 /** 506 * Returns the version string for the radio firmware. May return 507 * null (if, for instance, the radio is not currently on). 508 */ 509 public static String getRadioVersion() { 510 return SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION, null); 511 } 512 513 private static String getString(String property) { 514 return SystemProperties.get(property, UNKNOWN); 515 } 516 517 private static long getLong(String property) { 518 try { 519 return Long.parseLong(SystemProperties.get(property)); 520 } catch (NumberFormatException e) { 521 return -1; 522 } 523 } 524} 525