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 | |
| 19 | /** |
| 20 | * Information about the current build, extracted from system properties. |
| 21 | */ |
| 22 | public class Build { |
| 23 | /** Value used for when a build property is unknown. */ |
Ficus Kirkpatrick | 71de785 | 2010-01-08 13:10:51 -0800 | [diff] [blame] | 24 | public static final String UNKNOWN = "unknown"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Dianne Hackborn | b181118 | 2009-05-21 15:45:42 -0700 | [diff] [blame] | 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 | |
Ficus Kirkpatrick | fa9cafa | 2010-01-06 17:37:13 -0800 | [diff] [blame] | 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 | |
Dianne Hackborn | d62ad4f | 2009-05-19 19:06:25 -0700 | [diff] [blame] | 47 | /** The manufacturer of the product/hardware. */ |
| 48 | public static final String MANUFACTURER = getString("ro.product.manufacturer"); |
| 49 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Doug Zongker | 74885ef | 2010-02-02 17:39:26 -0800 | [diff] [blame] | 56 | /** The system bootloader version number. */ |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 57 | public static final String BOOTLOADER = getString("ro.bootloader"); |
| 58 | |
Doug Zongker | 74885ef | 2010-02-02 17:39:26 -0800 | [diff] [blame] | 59 | /** The radio firmware version number. */ |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 60 | public static final String RADIO = getString("gsm.version.baseband"); |
| 61 | |
Doug Zongker | 74885ef | 2010-02-02 17:39:26 -0800 | [diff] [blame] | 62 | /** The name of the hardware (from the kernel command line or /proc). */ |
| 63 | public static final String HARDWARE = getString("ro.hardware"); |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 64 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | /** Various version strings. */ |
| 66 | public static class VERSION { |
| 67 | /** |
| 68 | * The internal value used by the underlying source control to |
| 69 | * represent this build. E.g., a perforce changelist number |
| 70 | * or a git hash. |
| 71 | */ |
| 72 | public static final String INCREMENTAL = getString("ro.build.version.incremental"); |
| 73 | |
| 74 | /** |
| 75 | * The user-visible version string. E.g., "1.0" or "3.4b5". |
| 76 | */ |
| 77 | public static final String RELEASE = getString("ro.build.version.release"); |
| 78 | |
| 79 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 80 | * The user-visible SDK version of the framework in its raw String |
| 81 | * representation; use {@link #SDK_INT} instead. |
| 82 | * |
| 83 | * @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] | 84 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 85 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | public static final String SDK = getString("ro.build.version.sdk"); |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * The user-visible SDK version of the framework; its possible |
| 90 | * values are defined in {@link Build.VERSION_CODES}. |
| 91 | */ |
| 92 | public static final int SDK_INT = SystemProperties.getInt( |
| 93 | "ro.build.version.sdk", 0); |
| 94 | |
| 95 | /** |
| 96 | * The current development codename, or the string "REL" if this is |
| 97 | * a release build. |
| 98 | */ |
| 99 | public static final String CODENAME = getString("ro.build.version.codename"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | } |
| 101 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 102 | /** |
| 103 | * Enumeration of the currently known SDK version codes. These are the |
| 104 | * values that can be found in {@link VERSION#SDK}. Version numbers |
| 105 | * increment monotonically with each official platform release. |
| 106 | */ |
| 107 | public static class VERSION_CODES { |
| 108 | /** |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 109 | * Magic version number for a current development build, which has |
| 110 | * not yet turned into an official release. |
| 111 | */ |
| 112 | public static final int CUR_DEVELOPMENT = 10000; |
| 113 | |
| 114 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 115 | * October 2008: The original, first, version of Android. Yay! |
| 116 | */ |
| 117 | public static final int BASE = 1; |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 118 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 119 | /** |
| 120 | * February 2009: First Android update, officially called 1.1. |
| 121 | */ |
| 122 | public static final int BASE_1_1 = 2; |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 123 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 124 | /** |
| 125 | * May 2009: Android 1.5. |
| 126 | */ |
| 127 | public static final int CUPCAKE = 3; |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 128 | |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 129 | /** |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 130 | * September 2009: Android 1.6. |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 131 | * |
| 132 | * <p>Applications targeting this or a later release will get these |
| 133 | * new changes in behavior:</p> |
| 134 | * <ul> |
| 135 | * <li> They must explicitly request the |
San Mehat | 5a3a77d | 2009-06-01 09:25:28 -0700 | [diff] [blame] | 136 | * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 137 | * able to modify the contents of the SD card. (Apps targeting |
| 138 | * earlier versions will always request the permission.) |
Dianne Hackborn | fe77ec8 | 2009-08-12 16:53:56 -0700 | [diff] [blame] | 139 | * <li> They must explicitly request the |
| 140 | * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be |
| 141 | * able to be able to retrieve phone state info. (Apps targeting |
| 142 | * earlier versions will always request the permission.) |
| 143 | * <li> They are assumed to support different screen densities and |
| 144 | * sizes. (Apps targeting earlier versions are assumed to only support |
| 145 | * medium density normal size screens unless otherwise indicated). |
| 146 | * They can still explicitly specify screen support either way with the |
| 147 | * supports-screens manifest tag. |
Dianne Hackborn | a96cbb4 | 2009-05-13 15:06:13 -0700 | [diff] [blame] | 148 | * </ul> |
| 149 | */ |
Dianne Hackborn | fe77ec8 | 2009-08-12 16:53:56 -0700 | [diff] [blame] | 150 | public static final int DONUT = 4; |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 151 | |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 152 | /** |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 153 | * November 2009: Android 2.0 |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 154 | * |
| 155 | * <p>Applications targeting this or a later release will get these |
| 156 | * new changes in behavior:</p> |
| 157 | * <ul> |
| 158 | * <li> The {@link android.app.Service#onStartCommand |
| 159 | * Service.onStartCommand} function will return the new |
| 160 | * {@link android.app.Service#START_STICKY} behavior instead of the |
| 161 | * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}. |
Dianne Hackborn | 8d37426 | 2009-09-14 21:21:52 -0700 | [diff] [blame] | 162 | * <li> The {@link android.app.Activity} class will now execute back |
| 163 | * key presses on the key up instead of key down, to be able to detect |
| 164 | * canceled presses from virtual keys. |
Mike Cleron | 7609764 | 2009-09-25 17:53:56 -0700 | [diff] [blame] | 165 | * <li> The {@link android.widget.TabWidget} class will use a new color scheme |
| 166 | * for tabs. In the new scheme, the foreground tab has a medium gray background |
| 167 | * the background tabs have a dark gray background. |
Dianne Hackborn | f6f9f2d | 2009-08-21 16:26:03 -0700 | [diff] [blame] | 168 | * </ul> |
| 169 | */ |
Jeff Hamilton | 6dc3f4e | 2009-10-10 12:06:19 -0500 | [diff] [blame] | 170 | public static final int ECLAIR = 5; |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 171 | |
| 172 | /** |
Dianne Hackborn | 1778776 | 2009-11-12 16:11:36 -0800 | [diff] [blame] | 173 | * December 2009: Android 2.0.1 |
Dianne Hackborn | 0fa3591 | 2009-10-23 12:32:45 -0700 | [diff] [blame] | 174 | */ |
Dianne Hackborn | 1778776 | 2009-11-12 16:11:36 -0800 | [diff] [blame] | 175 | public static final int ECLAIR_0_1 = 6; |
Dianne Hackborn | 23ef7b4 | 2009-11-18 18:20:39 -0800 | [diff] [blame] | 176 | |
| 177 | /** |
| 178 | * January 2010: Android 2.1 |
| 179 | */ |
| 180 | public static final int ECLAIR_MR1 = 7; |
Adam Powell | 216bccf | 2010-02-01 15:03:17 -0800 | [diff] [blame] | 181 | |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 182 | /** |
| 183 | * June 2010: Android 2.2 |
| 184 | */ |
Adam Powell | 216bccf | 2010-02-01 15:03:17 -0800 | [diff] [blame] | 185 | public static final int FROYO = 8; |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 186 | |
Dianne Hackborn | 3e03cfa | 2010-06-13 12:07:00 -0700 | [diff] [blame] | 187 | /** |
| 188 | * Next version of Android. |
| 189 | * |
| 190 | * <p>Applications targeting this or a later release will get these |
| 191 | * new changes in behavior:</p> |
| 192 | * <ul> |
| 193 | * <li> The status bar is now dark. Targeting this version allows |
| 194 | * the platform to perform performing compatibility on status bar |
| 195 | * graphics to ensure they look okay on a dark background. |
| 196 | * </ul> |
| 197 | */ |
Dianne Hackborn | 14cee9f | 2010-04-23 17:51:26 -0700 | [diff] [blame] | 198 | public static final int GINGERBREAD = CUR_DEVELOPMENT; |
Dianne Hackborn | b1ad597 | 2010-08-02 17:30:33 -0700 | [diff] [blame^] | 199 | |
| 200 | /** |
| 201 | * Next next version of Android. |
| 202 | * |
| 203 | * <p>Applications targeting this or a later release will get these |
| 204 | * new changes in behavior:</p> |
| 205 | * <ul> |
| 206 | * <li> Alerts UI change? |
| 207 | * </ul> |
| 208 | */ |
| 209 | public static final int HONEYCOMB = CUR_DEVELOPMENT; |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame] | 210 | } |
| 211 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 212 | /** The type of build, like "user" or "eng". */ |
| 213 | public static final String TYPE = getString("ro.build.type"); |
| 214 | |
| 215 | /** Comma-separated tags describing the build, like "unsigned,debug". */ |
| 216 | public static final String TAGS = getString("ro.build.tags"); |
| 217 | |
| 218 | /** A string that uniquely identifies this build. Do not attempt to parse this value. */ |
| 219 | public static final String FINGERPRINT = getString("ro.build.fingerprint"); |
| 220 | |
| 221 | // The following properties only make sense for internal engineering builds. |
| 222 | public static final long TIME = getLong("ro.build.date.utc") * 1000; |
| 223 | public static final String USER = getString("ro.build.user"); |
| 224 | public static final String HOST = getString("ro.build.host"); |
| 225 | |
| 226 | private static String getString(String property) { |
| 227 | return SystemProperties.get(property, UNKNOWN); |
| 228 | } |
| 229 | |
| 230 | private static long getLong(String property) { |
| 231 | try { |
| 232 | return Long.parseLong(SystemProperties.get(property)); |
| 233 | } catch (NumberFormatException e) { |
| 234 | return -1; |
| 235 | } |
| 236 | } |
| 237 | } |