Build.java revision 3fc982f41fda1f254bfbc35490d81cd82a0ed90a
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 19/** 20 * Information about the current build, extracted from system properties. 21 */ 22public class Build { 23 /** Value used for when a build property is unknown. */ 24 public static final String UNKNOWN = "unknown"; 25 26 /** Either a changelist number, or a label like "M4-rc20". */ 27 public static final String ID = getString("ro.build.id"); 28 29 /** A build ID string meant for displaying to the user */ 30 public static final String DISPLAY = getString("ro.build.display.id"); 31 32 /** The name of the overall product. */ 33 public static final String PRODUCT = getString("ro.product.name"); 34 35 /** The name of the industrial design. */ 36 public static final String DEVICE = getString("ro.product.device"); 37 38 /** The name of the underlying board, like "goldfish". */ 39 public static final String BOARD = getString("ro.product.board"); 40 41 /** The name of the instruction set (CPU type + ABI convention) of native code. */ 42 public static final String CPU_ABI = getString("ro.product.cpu.abi"); 43 44 /** The name of the second instruction set (CPU type + ABI convention) of native code. */ 45 public static final String CPU_ABI2 = getString("ro.product.cpu.abi2"); 46 47 /** The manufacturer of the product/hardware. */ 48 public static final String MANUFACTURER = getString("ro.product.manufacturer"); 49 50 /** The brand (e.g., carrier) the software is customized for, if any. */ 51 public static final String BRAND = getString("ro.product.brand"); 52 53 /** The end-user-visible name for the end product. */ 54 public static final String MODEL = getString("ro.product.model"); 55 56 /** The system bootloader version number. */ 57 public static final String BOOTLOADER = getString("ro.bootloader"); 58 59 /** The radio firmware version number. */ 60 public static final String RADIO = getString("gsm.version.baseband"); 61 62 /** The name of the hardware (from the kernel command line or /proc). */ 63 public static final String HARDWARE = getString("ro.hardware"); 64 65 /** A hardware serial number, if available. Alphanumeric only, case-insensitive. */ 66 public static final String SERIAL = getString("ro.serialno"); 67 68 /** Various version strings. */ 69 public static class VERSION { 70 /** 71 * The internal value used by the underlying source control to 72 * represent this build. E.g., a perforce changelist number 73 * or a git hash. 74 */ 75 public static final String INCREMENTAL = getString("ro.build.version.incremental"); 76 77 /** 78 * The user-visible version string. E.g., "1.0" or "3.4b5". 79 */ 80 public static final String RELEASE = getString("ro.build.version.release"); 81 82 /** 83 * The user-visible SDK version of the framework in its raw String 84 * representation; use {@link #SDK_INT} instead. 85 * 86 * @deprecated Use {@link #SDK_INT} to easily get this as an integer. 87 */ 88 @Deprecated 89 public static final String SDK = getString("ro.build.version.sdk"); 90 91 /** 92 * The user-visible SDK version of the framework; its possible 93 * values are defined in {@link Build.VERSION_CODES}. 94 */ 95 public static final int SDK_INT = SystemProperties.getInt( 96 "ro.build.version.sdk", 0); 97 98 /** 99 * The current development codename, or the string "REL" if this is 100 * a release build. 101 */ 102 public static final String CODENAME = getString("ro.build.version.codename"); 103 104 /** 105 * The SDK version to use when accessing resources. 106 * Use the current SDK version code. If we are a development build, 107 * also allow the previous SDK version + 1. 108 * @hide 109 */ 110 public static final int RESOURCES_SDK_INT = SDK_INT 111 + ("REL".equals(CODENAME) ? 0 : 1); 112 } 113 114 /** 115 * Enumeration of the currently known SDK version codes. These are the 116 * values that can be found in {@link VERSION#SDK}. Version numbers 117 * increment monotonically with each official platform release. 118 */ 119 public static class VERSION_CODES { 120 /** 121 * Magic version number for a current development build, which has 122 * not yet turned into an official release. 123 */ 124 public static final int CUR_DEVELOPMENT = 10000; 125 126 /** 127 * October 2008: The original, first, version of Android. Yay! 128 */ 129 public static final int BASE = 1; 130 131 /** 132 * February 2009: First Android update, officially called 1.1. 133 */ 134 public static final int BASE_1_1 = 2; 135 136 /** 137 * May 2009: Android 1.5. 138 */ 139 public static final int CUPCAKE = 3; 140 141 /** 142 * September 2009: Android 1.6. 143 * 144 * <p>Applications targeting this or a later release will get these 145 * new changes in behavior:</p> 146 * <ul> 147 * <li> They must explicitly request the 148 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be 149 * able to modify the contents of the SD card. (Apps targeting 150 * earlier versions will always request the permission.) 151 * <li> They must explicitly request the 152 * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be 153 * able to be able to retrieve phone state info. (Apps targeting 154 * earlier versions will always request the permission.) 155 * <li> They are assumed to support different screen densities and 156 * sizes. (Apps targeting earlier versions are assumed to only support 157 * medium density normal size screens unless otherwise indicated). 158 * They can still explicitly specify screen support either way with the 159 * supports-screens manifest tag. 160 * </ul> 161 */ 162 public static final int DONUT = 4; 163 164 /** 165 * November 2009: Android 2.0 166 * 167 * <p>Applications targeting this or a later release will get these 168 * new changes in behavior:</p> 169 * <ul> 170 * <li> The {@link android.app.Service#onStartCommand 171 * Service.onStartCommand} function will return the new 172 * {@link android.app.Service#START_STICKY} behavior instead of the 173 * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}. 174 * <li> The {@link android.app.Activity} class will now execute back 175 * key presses on the key up instead of key down, to be able to detect 176 * canceled presses from virtual keys. 177 * <li> The {@link android.widget.TabWidget} class will use a new color scheme 178 * for tabs. In the new scheme, the foreground tab has a medium gray background 179 * the background tabs have a dark gray background. 180 * </ul> 181 */ 182 public static final int ECLAIR = 5; 183 184 /** 185 * December 2009: Android 2.0.1 186 */ 187 public static final int ECLAIR_0_1 = 6; 188 189 /** 190 * January 2010: Android 2.1 191 */ 192 public static final int ECLAIR_MR1 = 7; 193 194 /** 195 * June 2010: Android 2.2 196 */ 197 public static final int FROYO = 8; 198 199 /** 200 * November 2010: Android 2.3 201 */ 202 public static final int GINGERBREAD = 9; 203 204 /** 205 * February 2011: Android 2.3.3. 206 */ 207 public static final int GINGERBREAD_MR1 = 10; 208 209 /** 210 * February 2011: Android 3.0. 211 * 212 * <p>Applications targeting this or a later release will get these 213 * new changes in behavior:</p> 214 * <ul> 215 * <li> The default theme for applications is now dark holographic: 216 * {@link android.R.style#Theme_Holo}. 217 * <li> The activity lifecycle has changed slightly as per 218 * {@link android.app.Activity}. 219 * <li> When an application requires a permission to access one of 220 * its components (activity, receiver, service, provider), this 221 * permission is no longer enforced when the application wants to 222 * access its own component. This means it can require a permission 223 * on a component that it does not itself hold and still access that 224 * component. 225 * </ul> 226 */ 227 public static final int HONEYCOMB = 11; 228 229 /** 230 * Newest version of Android, version 3.1. 231 */ 232 public static final int HONEYCOMB_MR1 = 12; 233 234 /** 235 * Current version under development. 236 */ 237 public static final int ICE_CREAM_SANDWICH = CUR_DEVELOPMENT; 238 } 239 240 /** The type of build, like "user" or "eng". */ 241 public static final String TYPE = getString("ro.build.type"); 242 243 /** Comma-separated tags describing the build, like "unsigned,debug". */ 244 public static final String TAGS = getString("ro.build.tags"); 245 246 /** A string that uniquely identifies this build. Do not attempt to parse this value. */ 247 public static final String FINGERPRINT = getString("ro.build.fingerprint"); 248 249 // The following properties only make sense for internal engineering builds. 250 public static final long TIME = getLong("ro.build.date.utc") * 1000; 251 public static final String USER = getString("ro.build.user"); 252 public static final String HOST = getString("ro.build.host"); 253 254 private static String getString(String property) { 255 return SystemProperties.get(property, UNKNOWN); 256 } 257 258 private static long getLong(String property) { 259 try { 260 return Long.parseLong(SystemProperties.get(property)); 261 } catch (NumberFormatException e) { 262 return -1; 263 } 264 } 265} 266