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 19 import android.text.TextUtils; 20 import android.util.Slog; 21 22 import com.android.internal.telephony.TelephonyProperties; 23 24 import dalvik.system.VMRuntime; 25 26 import java.util.Objects; 27 28 /** 29 * Information about the current build, extracted from system properties. 30 */ 31 public class Build { 32 private static final String TAG = "Build"; 33 34 /** Value used for when a build property is unknown. */ 35 public static final String UNKNOWN = "unknown"; 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 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 58 public static final String CPU_ABI; 59 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 66 public static final String CPU_ABI2; 67 68 /** The manufacturer of the product/hardware. */ 69 public static final String MANUFACTURER = getString("ro.product.manufacturer"); 70 71 /** The consumer-visible brand with which the product/hardware will be associated, if any. */ 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 77 /** The system bootloader version number. */ 78 public static final String BOOTLOADER = getString("ro.bootloader"); 79 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); 90 91 /** The name of the hardware (from the kernel command line or /proc). */ 92 public static final String HARDWARE = getString("ro.hardware"); 93 94 /** A hardware serial number, if available. Alphanumeric only, case-insensitive. */ 95 public static final String SERIAL = getString("ro.serialno"); 96 97 /** 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}. 102 */ 103 public static final String[] SUPPORTED_ABIS = getStringList("ro.product.cpu.abilist", ","); 104 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}. 110 */ 111 public static final String[] SUPPORTED_32_BIT_ABIS = 112 getStringList("ro.product.cpu.abilist32", ","); 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}. 119 */ 120 public static final String[] SUPPORTED_64_BIT_ABIS = 121 getStringList("ro.product.cpu.abilist64", ","); 122 123 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 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 /** 160 * The base OS build the product is based on. 161 * For Pre-API 23 - use support libs to access. 162 * @hide 163 */ 164 public static final String BASE_OS = SystemProperties.get("ro.build.version.base_os", ""); 165 166 /** 167 * The user-visible security patch level. 168 * For Pre-API 23 - use support libs to access. 169 * @hide 170 */ 171 public static final String SECURITY_PATCH = SystemProperties.get( 172 "ro.build.version.security_patch", ""); 173 174 /** 175 * The user-visible SDK version of the framework in its raw String 176 * representation; use {@link #SDK_INT} instead. 177 * 178 * @deprecated Use {@link #SDK_INT} to easily get this as an integer. 179 */ 180 @Deprecated 181 public static final String SDK = getString("ro.build.version.sdk"); 182 183 /** 184 * The user-visible SDK version of the framework; its possible 185 * values are defined in {@link Build.VERSION_CODES}. 186 */ 187 public static final int SDK_INT = SystemProperties.getInt( 188 "ro.build.version.sdk", 0); 189 190 /** 191 * The current development codename, or the string "REL" if this is 192 * a release build. 193 */ 194 public static final String CODENAME = getString("ro.build.version.codename"); 195 196 private static final String[] ALL_CODENAMES 197 = getStringList("ro.build.version.all_codenames", ","); 198 199 /** 200 * @hide 201 */ 202 public static final String[] ACTIVE_CODENAMES = "REL".equals(ALL_CODENAMES[0]) 203 ? new String[0] : ALL_CODENAMES; 204 205 /** 206 * The SDK version to use when accessing resources. 207 * Use the current SDK version code. For every active development codename 208 * we are operating under, we bump the assumed resource platform version by 1. 209 * @hide 210 */ 211 public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length; 212 } 213 214 /** 215 * Enumeration of the currently known SDK version codes. These are the 216 * values that can be found in {@link VERSION#SDK}. Version numbers 217 * increment monotonically with each official platform release. 218 */ 219 public static class VERSION_CODES { 220 /** 221 * Magic version number for a current development build, which has 222 * not yet turned into an official release. 223 */ 224 public static final int CUR_DEVELOPMENT = 10000; 225 226 /** 227 * October 2008: The original, first, version of Android. Yay! 228 */ 229 public static final int BASE = 1; 230 231 /** 232 * February 2009: First Android update, officially called 1.1. 233 */ 234 public static final int BASE_1_1 = 2; 235 236 /** 237 * May 2009: Android 1.5. 238 */ 239 public static final int CUPCAKE = 3; 240 241 /** 242 * September 2009: Android 1.6. 243 * 244 * <p>Applications targeting this or a later release will get these 245 * new changes in behavior:</p> 246 * <ul> 247 * <li> They must explicitly request the 248 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be 249 * able to modify the contents of the SD card. (Apps targeting 250 * earlier versions will always request the permission.) 251 * <li> They must explicitly request the 252 * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be 253 * able to be able to retrieve phone state info. (Apps targeting 254 * earlier versions will always request the permission.) 255 * <li> They are assumed to support different screen densities and 256 * sizes. (Apps targeting earlier versions are assumed to only support 257 * medium density normal size screens unless otherwise indicated). 258 * They can still explicitly specify screen support either way with the 259 * supports-screens manifest tag. 260 * <li> {@link android.widget.TabHost} will use the new dark tab 261 * background design. 262 * </ul> 263 */ 264 public static final int DONUT = 4; 265 266 /** 267 * November 2009: Android 2.0 268 * 269 * <p>Applications targeting this or a later release will get these 270 * new changes in behavior:</p> 271 * <ul> 272 * <li> The {@link android.app.Service#onStartCommand 273 * Service.onStartCommand} function will return the new 274 * {@link android.app.Service#START_STICKY} behavior instead of the 275 * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}. 276 * <li> The {@link android.app.Activity} class will now execute back 277 * key presses on the key up instead of key down, to be able to detect 278 * canceled presses from virtual keys. 279 * <li> The {@link android.widget.TabWidget} class will use a new color scheme 280 * for tabs. In the new scheme, the foreground tab has a medium gray background 281 * the background tabs have a dark gray background. 282 * </ul> 283 */ 284 public static final int ECLAIR = 5; 285 286 /** 287 * December 2009: Android 2.0.1 288 */ 289 public static final int ECLAIR_0_1 = 6; 290 291 /** 292 * January 2010: Android 2.1 293 */ 294 public static final int ECLAIR_MR1 = 7; 295 296 /** 297 * June 2010: Android 2.2 298 */ 299 public static final int FROYO = 8; 300 301 /** 302 * November 2010: Android 2.3 303 * 304 * <p>Applications targeting this or a later release will get these 305 * new changes in behavior:</p> 306 * <ul> 307 * <li> The application's notification icons will be shown on the new 308 * dark status bar background, so must be visible in this situation. 309 * </ul> 310 */ 311 public static final int GINGERBREAD = 9; 312 313 /** 314 * February 2011: Android 2.3.3. 315 */ 316 public static final int GINGERBREAD_MR1 = 10; 317 318 /** 319 * February 2011: Android 3.0. 320 * 321 * <p>Applications targeting this or a later release will get these 322 * new changes in behavior:</p> 323 * <ul> 324 * <li> The default theme for applications is now dark holographic: 325 * {@link android.R.style#Theme_Holo}. 326 * <li> On large screen devices that do not have a physical menu 327 * button, the soft (compatibility) menu is disabled. 328 * <li> The activity lifecycle has changed slightly as per 329 * {@link android.app.Activity}. 330 * <li> An application will crash if it does not call through 331 * to the super implementation of its 332 * {@link android.app.Activity#onPause Activity.onPause()} method. 333 * <li> When an application requires a permission to access one of 334 * its components (activity, receiver, service, provider), this 335 * permission is no longer enforced when the application wants to 336 * access its own component. This means it can require a permission 337 * on a component that it does not itself hold and still access that 338 * component. 339 * <li> {@link android.content.Context#getSharedPreferences 340 * Context.getSharedPreferences()} will not automatically reload 341 * the preferences if they have changed on storage, unless 342 * {@link android.content.Context#MODE_MULTI_PROCESS} is used. 343 * <li> {@link android.view.ViewGroup#setMotionEventSplittingEnabled} 344 * will default to true. 345 * <li> {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH} 346 * is enabled by default on windows. 347 * <li> {@link android.widget.PopupWindow#isSplitTouchEnabled() 348 * PopupWindow.isSplitTouchEnabled()} will return true by default. 349 * <li> {@link android.widget.GridView} and {@link android.widget.ListView} 350 * will use {@link android.view.View#setActivated View.setActivated} 351 * for selected items if they do not implement {@link android.widget.Checkable}. 352 * <li> {@link android.widget.Scroller} will be constructed with 353 * "flywheel" behavior enabled by default. 354 * </ul> 355 */ 356 public static final int HONEYCOMB = 11; 357 358 /** 359 * May 2011: Android 3.1. 360 */ 361 public static final int HONEYCOMB_MR1 = 12; 362 363 /** 364 * June 2011: Android 3.2. 365 * 366 * <p>Update to Honeycomb MR1 to support 7 inch tablets, improve 367 * screen compatibility mode, etc.</p> 368 * 369 * <p>As of this version, applications that don't say whether they 370 * support XLARGE screens will be assumed to do so only if they target 371 * {@link #HONEYCOMB} or later; it had been {@link #GINGERBREAD} or 372 * later. Applications that don't support a screen size at least as 373 * large as the current screen will provide the user with a UI to 374 * switch them in to screen size compatibility mode.</p> 375 * 376 * <p>This version introduces new screen size resource qualifiers 377 * based on the screen size in dp: see 378 * {@link android.content.res.Configuration#screenWidthDp}, 379 * {@link android.content.res.Configuration#screenHeightDp}, and 380 * {@link android.content.res.Configuration#smallestScreenWidthDp}. 381 * Supplying these in <supports-screens> as per 382 * {@link android.content.pm.ApplicationInfo#requiresSmallestWidthDp}, 383 * {@link android.content.pm.ApplicationInfo#compatibleWidthLimitDp}, and 384 * {@link android.content.pm.ApplicationInfo#largestWidthLimitDp} is 385 * preferred over the older screen size buckets and for older devices 386 * the appropriate buckets will be inferred from them.</p> 387 * 388 * <p>Applications targeting this or a later release will get these 389 * new changes in behavior:</p> 390 * <ul> 391 * <li><p>New {@link android.content.pm.PackageManager#FEATURE_SCREEN_PORTRAIT} 392 * and {@link android.content.pm.PackageManager#FEATURE_SCREEN_LANDSCAPE} 393 * features were introduced in this release. Applications that target 394 * previous platform versions are assumed to require both portrait and 395 * landscape support in the device; when targeting Honeycomb MR1 or 396 * greater the application is responsible for specifying any specific 397 * orientation it requires.</p> 398 * <li><p>{@link android.os.AsyncTask} will use the serial executor 399 * by default when calling {@link android.os.AsyncTask#execute}.</p> 400 * <li><p>{@link android.content.pm.ActivityInfo#configChanges 401 * ActivityInfo.configChanges} will have the 402 * {@link android.content.pm.ActivityInfo#CONFIG_SCREEN_SIZE} and 403 * {@link android.content.pm.ActivityInfo#CONFIG_SMALLEST_SCREEN_SIZE} 404 * bits set; these need to be cleared for older applications because 405 * some developers have done absolute comparisons against this value 406 * instead of correctly masking the bits they are interested in. 407 * </ul> 408 */ 409 public static final int HONEYCOMB_MR2 = 13; 410 411 /** 412 * October 2011: Android 4.0. 413 * 414 * <p>Applications targeting this or a later release will get these 415 * new changes in behavior:</p> 416 * <ul> 417 * <li> For devices without a dedicated menu key, the software compatibility 418 * menu key will not be shown even on phones. By targeting Ice Cream Sandwich 419 * or later, your UI must always have its own menu UI affordance if needed, 420 * on both tablets and phones. The ActionBar will take care of this for you. 421 * <li> 2d drawing hardware acceleration is now turned on by default. 422 * You can use 423 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 424 * to turn it off if needed, although this is strongly discouraged since 425 * it will result in poor performance on larger screen devices. 426 * <li> The default theme for applications is now the "device default" theme: 427 * {@link android.R.style#Theme_DeviceDefault}. This may be the 428 * holo dark theme or a different dark theme defined by the specific device. 429 * The {@link android.R.style#Theme_Holo} family must not be modified 430 * for a device to be considered compatible. Applications that explicitly 431 * request a theme from the Holo family will be guaranteed that these themes 432 * will not change character within the same platform version. Applications 433 * that wish to blend in with the device should use a theme from the 434 * {@link android.R.style#Theme_DeviceDefault} family. 435 * <li> Managed cursors can now throw an exception if you directly close 436 * the cursor yourself without stopping the management of it; previously failures 437 * would be silently ignored. 438 * <li> The fadingEdge attribute on views will be ignored (fading edges is no 439 * longer a standard part of the UI). A new requiresFadingEdge attribute allows 440 * applications to still force fading edges on for special cases. 441 * <li> {@link android.content.Context#bindService Context.bindService()} 442 * will not automatically add in {@link android.content.Context#BIND_WAIVE_PRIORITY}. 443 * <li> App Widgets will have standard padding automatically added around 444 * them, rather than relying on the padding being baked into the widget itself. 445 * <li> An exception will be thrown if you try to change the type of a 446 * window after it has been added to the window manager. Previously this 447 * would result in random incorrect behavior. 448 * <li> {@link android.view.animation.AnimationSet} will parse out 449 * the duration, fillBefore, fillAfter, repeatMode, and startOffset 450 * XML attributes that are defined. 451 * <li> {@link android.app.ActionBar#setHomeButtonEnabled 452 * ActionBar.setHomeButtonEnabled()} is false by default. 453 * </ul> 454 */ 455 public static final int ICE_CREAM_SANDWICH = 14; 456 457 /** 458 * December 2011: Android 4.0.3. 459 */ 460 public static final int ICE_CREAM_SANDWICH_MR1 = 15; 461 462 /** 463 * June 2012: Android 4.1. 464 * 465 * <p>Applications targeting this or a later release will get these 466 * new changes in behavior:</p> 467 * <ul> 468 * <li> You must explicitly request the {@link android.Manifest.permission#READ_CALL_LOG} 469 * and/or {@link android.Manifest.permission#WRITE_CALL_LOG} permissions; 470 * access to the call log is no longer implicitly provided through 471 * {@link android.Manifest.permission#READ_CONTACTS} and 472 * {@link android.Manifest.permission#WRITE_CONTACTS}. 473 * <li> {@link android.widget.RemoteViews} will throw an exception if 474 * setting an onClick handler for views being generated by a 475 * {@link android.widget.RemoteViewsService} for a collection container; 476 * previously this just resulted in a warning log message. 477 * <li> New {@link android.app.ActionBar} policy for embedded tabs: 478 * embedded tabs are now always stacked in the action bar when in portrait 479 * mode, regardless of the size of the screen. 480 * <li> {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs(boolean) 481 * WebSettings.setAllowFileAccessFromFileURLs} and 482 * {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs(boolean) 483 * WebSettings.setAllowUniversalAccessFromFileURLs} default to false. 484 * <li> Calls to {@link android.content.pm.PackageManager#setComponentEnabledSetting 485 * PackageManager.setComponentEnabledSetting} will now throw an 486 * IllegalArgumentException if the given component class name does not 487 * exist in the application's manifest. 488 * <li> {@link android.nfc.NfcAdapter#setNdefPushMessage 489 * NfcAdapter.setNdefPushMessage}, 490 * {@link android.nfc.NfcAdapter#setNdefPushMessageCallback 491 * NfcAdapter.setNdefPushMessageCallback} and 492 * {@link android.nfc.NfcAdapter#setOnNdefPushCompleteCallback 493 * NfcAdapter.setOnNdefPushCompleteCallback} will throw 494 * IllegalStateException if called after the Activity has been destroyed. 495 * <li> Accessibility services must require the new 496 * {@link android.Manifest.permission#BIND_ACCESSIBILITY_SERVICE} permission or 497 * they will not be available for use. 498 * <li> {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS 499 * AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS} must be set 500 * for unimportant views to be included in queries. 501 * </ul> 502 */ 503 public static final int JELLY_BEAN = 16; 504 505 /** 506 * November 2012: Android 4.2, Moar jelly beans! 507 * 508 * <p>Applications targeting this or a later release will get these 509 * new changes in behavior:</p> 510 * <ul> 511 * <li>Content Providers: The default value of {@code android:exported} is now 512 * {@code false}. See 513 * <a href="{@docRoot}guide/topics/manifest/provider-element.html#exported"> 514 * the android:exported section</a> in the provider documentation for more details.</li> 515 * <li>{@link android.view.View#getLayoutDirection() View.getLayoutDirection()} 516 * can return different values than {@link android.view.View#LAYOUT_DIRECTION_LTR} 517 * based on the locale etc. 518 * <li> {@link android.webkit.WebView#addJavascriptInterface(Object, String) 519 * WebView.addJavascriptInterface} requires explicit annotations on methods 520 * for them to be accessible from Javascript. 521 * </ul> 522 */ 523 public static final int JELLY_BEAN_MR1 = 17; 524 525 /** 526 * July 2013: Android 4.3, the revenge of the beans. 527 */ 528 public static final int JELLY_BEAN_MR2 = 18; 529 530 /** 531 * October 2013: Android 4.4, KitKat, another tasty treat. 532 * 533 * <p>Applications targeting this or a later release will get these 534 * new changes in behavior:</p> 535 * <ul> 536 * <li> The default result of {android.preference.PreferenceActivity#isValidFragment 537 * PreferenceActivity.isValueFragment} becomes false instead of true.</li> 538 * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have 539 * JS URLs evaluated directly and any result of the evaluation will not replace 540 * the current page content. Apps targetting KITKAT or later that load a JS URL will 541 * have the result of that URL replace the content of the current page</li> 542 * <li> {@link android.app.AlarmManager#set AlarmManager.set} becomes interpreted as 543 * an inexact value, to give the system more flexibility in scheduling alarms.</li> 544 * <li> {@link android.content.Context#getSharedPreferences(String, int) 545 * Context.getSharedPreferences} no longer allows a null name.</li> 546 * <li> {@link android.widget.RelativeLayout} changes to compute wrapped content 547 * margins correctly.</li> 548 * <li> {@link android.app.ActionBar}'s window content overlay is allowed to be 549 * drawn.</li> 550 * <li>The {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} 551 * permission is now always enforced.</li> 552 * <li>Access to package-specific external storage directories belonging 553 * to the calling app no longer requires the 554 * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} or 555 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} 556 * permissions.</li> 557 * </ul> 558 */ 559 public static final int KITKAT = 19; 560 561 /** 562 * Android 4.4W: KitKat for watches, snacks on the run. 563 * 564 * <p>Applications targeting this or a later release will get these 565 * new changes in behavior:</p> 566 * <ul> 567 * <li>{@link android.app.AlertDialog} might not have a default background if the theme does 568 * not specify one.</li> 569 * </ul> 570 */ 571 public static final int KITKAT_WATCH = 20; 572 573 /** 574 * Temporary until we completely switch to {@link #LOLLIPOP}. 575 * @hide 576 */ 577 public static final int L = 21; 578 579 /** 580 * Lollipop. A flat one with beautiful shadows. But still tasty. 581 * 582 * <p>Applications targeting this or a later release will get these 583 * new changes in behavior:</p> 584 * <ul> 585 * <li> {@link android.content.Context#bindService Context.bindService} now 586 * requires an explicit Intent, and will throw an exception if given an implicit 587 * Intent.</li> 588 * <li> {@link android.app.Notification.Builder Notification.Builder} will 589 * not have the colors of their various notification elements adjusted to better 590 * match the new material design look.</li> 591 * <li> {@link android.os.Message} will validate that a message is not currently 592 * in use when it is recycled.</li> 593 * <li> Hardware accelerated drawing in windows will be enabled automatically 594 * in most places.</li> 595 * <li> {@link android.widget.Spinner} throws an exception if attaching an 596 * adapter with more than one item type.</li> 597 * <li> If the app is a launcher, the launcher will be available to the user 598 * even when they are using corporate profiles (which requires that the app 599 * use {@link android.content.pm.LauncherApps} to correctly populate its 600 * apps UI).</li> 601 * <li> Calling {@link android.app.Service#stopForeground Service.stopForeground} 602 * with removeNotification false will modify the still posted notification so that 603 * it is no longer forced to be ongoing.</li> 604 * <li> A {@link android.service.dreams.DreamService} must require the 605 * {@link android.Manifest.permission#BIND_DREAM_SERVICE} permission to be usable.</li> 606 * </ul> 607 */ 608 public static final int LOLLIPOP = 21; 609 610 /** 611 * Lollipop with an extra sugar coating on the outside! 612 */ 613 public static final int LOLLIPOP_MR1 = 22; 614 } 615 616 /** The type of build, like "user" or "eng". */ 617 public static final String TYPE = getString("ro.build.type"); 618 619 /** Comma-separated tags describing the build, like "unsigned,debug". */ 620 public static final String TAGS = getString("ro.build.tags"); 621 622 /** A string that uniquely identifies this build. Do not attempt to parse this value. */ 623 public static final String FINGERPRINT = deriveFingerprint(); 624 625 /** 626 * Some devices split the fingerprint components between multiple 627 * partitions, so we might derive the fingerprint at runtime. 628 */ deriveFingerprint()629 private static String deriveFingerprint() { 630 String finger = SystemProperties.get("ro.build.fingerprint"); 631 if (TextUtils.isEmpty(finger)) { 632 finger = getString("ro.product.brand") + '/' + 633 getString("ro.product.name") + '/' + 634 getString("ro.product.device") + ':' + 635 getString("ro.build.version.release") + '/' + 636 getString("ro.build.id") + '/' + 637 getString("ro.build.version.incremental") + ':' + 638 getString("ro.build.type") + '/' + 639 getString("ro.build.tags"); 640 } 641 return finger; 642 } 643 644 /** 645 * Ensure that raw fingerprint system property is defined. If it was derived 646 * dynamically by {@link #deriveFingerprint()} this is where we push the 647 * derived value into the property service. 648 * 649 * @hide 650 */ ensureFingerprintProperty()651 public static void ensureFingerprintProperty() { 652 if (TextUtils.isEmpty(SystemProperties.get("ro.build.fingerprint"))) { 653 try { 654 SystemProperties.set("ro.build.fingerprint", FINGERPRINT); 655 } catch (IllegalArgumentException e) { 656 Slog.e(TAG, "Failed to set fingerprint property", e); 657 } 658 } 659 } 660 661 /** 662 * Check that device fingerprint is defined and that it matches across 663 * various partitions. 664 * 665 * @hide 666 */ isFingerprintConsistent()667 public static boolean isFingerprintConsistent() { 668 final String system = SystemProperties.get("ro.build.fingerprint"); 669 final String vendor = SystemProperties.get("ro.vendor.build.fingerprint"); 670 671 if (TextUtils.isEmpty(system)) { 672 Slog.e(TAG, "Required ro.build.fingerprint is empty!"); 673 return false; 674 } 675 676 if (!TextUtils.isEmpty(vendor)) { 677 if (!Objects.equals(system, vendor)) { 678 Slog.e(TAG, "Mismatched fingerprints; system reported " + system 679 + " but vendor reported " + vendor); 680 return false; 681 } 682 } 683 684 return true; 685 } 686 687 // The following properties only make sense for internal engineering builds. 688 public static final long TIME = getLong("ro.build.date.utc") * 1000; 689 public static final String USER = getString("ro.build.user"); 690 public static final String HOST = getString("ro.build.host"); 691 692 /** 693 * Returns true if we are running a debug build such as "user-debug" or "eng". 694 * @hide 695 */ 696 public static final boolean IS_DEBUGGABLE = 697 SystemProperties.getInt("ro.debuggable", 0) == 1; 698 699 /** 700 * Returns the version string for the radio firmware. May return 701 * null (if, for instance, the radio is not currently on). 702 */ getRadioVersion()703 public static String getRadioVersion() { 704 return SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION, null); 705 } 706 getString(String property)707 private static String getString(String property) { 708 return SystemProperties.get(property, UNKNOWN); 709 } 710 getStringList(String property, String separator)711 private static String[] getStringList(String property, String separator) { 712 String value = SystemProperties.get(property); 713 if (value.isEmpty()) { 714 return new String[0]; 715 } else { 716 return value.split(separator); 717 } 718 } 719 getLong(String property)720 private static long getLong(String property) { 721 try { 722 return Long.parseLong(SystemProperties.get(property)); 723 } catch (NumberFormatException e) { 724 return -1; 725 } 726 } 727 } 728