Build.java revision fa9cafa074eb5d98b49b63795cd947877df1f21d
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 private 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 /** Various version strings. */ 57 public static class VERSION { 58 /** 59 * The internal value used by the underlying source control to 60 * represent this build. E.g., a perforce changelist number 61 * or a git hash. 62 */ 63 public static final String INCREMENTAL = getString("ro.build.version.incremental"); 64 65 /** 66 * The user-visible version string. E.g., "1.0" or "3.4b5". 67 */ 68 public static final String RELEASE = getString("ro.build.version.release"); 69 70 /** 71 * The user-visible SDK version of the framework in its raw String 72 * representation; use {@link #SDK_INT} instead. 73 * 74 * @deprecated Use {@link #SDK_INT} to easily get this as an integer. 75 */ 76 @Deprecated 77 public static final String SDK = getString("ro.build.version.sdk"); 78 79 /** 80 * The user-visible SDK version of the framework; its possible 81 * values are defined in {@link Build.VERSION_CODES}. 82 */ 83 public static final int SDK_INT = SystemProperties.getInt( 84 "ro.build.version.sdk", 0); 85 86 /** 87 * The current development codename, or the string "REL" if this is 88 * a release build. 89 */ 90 public static final String CODENAME = getString("ro.build.version.codename"); 91 } 92 93 /** 94 * Enumeration of the currently known SDK version codes. These are the 95 * values that can be found in {@link VERSION#SDK}. Version numbers 96 * increment monotonically with each official platform release. 97 */ 98 public static class VERSION_CODES { 99 /** 100 * Magic version number for a current development build, which has 101 * not yet turned into an official release. 102 */ 103 public static final int CUR_DEVELOPMENT = 10000; 104 105 /** 106 * October 2008: The original, first, version of Android. Yay! 107 */ 108 public static final int BASE = 1; 109 110 /** 111 * February 2009: First Android update, officially called 1.1. 112 */ 113 public static final int BASE_1_1 = 2; 114 115 /** 116 * May 2009: Android 1.5. 117 */ 118 public static final int CUPCAKE = 3; 119 120 /** 121 * September 2009: Android 1.6. 122 * 123 * <p>Applications targeting this or a later release will get these 124 * new changes in behavior:</p> 125 * <ul> 126 * <li> They must explicitly request the 127 * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission to be 128 * able to modify the contents of the SD card. (Apps targeting 129 * earlier versions will always request the permission.) 130 * <li> They must explicitly request the 131 * {@link android.Manifest.permission#READ_PHONE_STATE} permission to be 132 * able to be able to retrieve phone state info. (Apps targeting 133 * earlier versions will always request the permission.) 134 * <li> They are assumed to support different screen densities and 135 * sizes. (Apps targeting earlier versions are assumed to only support 136 * medium density normal size screens unless otherwise indicated). 137 * They can still explicitly specify screen support either way with the 138 * supports-screens manifest tag. 139 * </ul> 140 */ 141 public static final int DONUT = 4; 142 143 /** 144 * November 2009: Android 2.0 145 * 146 * <p>Applications targeting this or a later release will get these 147 * new changes in behavior:</p> 148 * <ul> 149 * <li> The {@link android.app.Service#onStartCommand 150 * Service.onStartCommand} function will return the new 151 * {@link android.app.Service#START_STICKY} behavior instead of the 152 * old compatibility {@link android.app.Service#START_STICKY_COMPATIBILITY}. 153 * <li> The {@link android.app.Activity} class will now execute back 154 * key presses on the key up instead of key down, to be able to detect 155 * canceled presses from virtual keys. 156 * <li> The {@link android.widget.TabWidget} class will use a new color scheme 157 * for tabs. In the new scheme, the foreground tab has a medium gray background 158 * the background tabs have a dark gray background. 159 * </ul> 160 */ 161 public static final int ECLAIR = 5; 162 163 /** 164 * December 2009: Android 2.0.1 165 */ 166 public static final int ECLAIR_0_1 = 6; 167 168 /** 169 * January 2010: Android 2.1 170 */ 171 public static final int ECLAIR_MR1 = 7; 172 } 173 174 /** The type of build, like "user" or "eng". */ 175 public static final String TYPE = getString("ro.build.type"); 176 177 /** Comma-separated tags describing the build, like "unsigned,debug". */ 178 public static final String TAGS = getString("ro.build.tags"); 179 180 /** A string that uniquely identifies this build. Do not attempt to parse this value. */ 181 public static final String FINGERPRINT = getString("ro.build.fingerprint"); 182 183 // The following properties only make sense for internal engineering builds. 184 public static final long TIME = getLong("ro.build.date.utc") * 1000; 185 public static final String USER = getString("ro.build.user"); 186 public static final String HOST = getString("ro.build.host"); 187 188 private static String getString(String property) { 189 return SystemProperties.get(property, UNKNOWN); 190 } 191 192 private static long getLong(String property) { 193 try { 194 return Long.parseLong(SystemProperties.get(property)); 195 } catch (NumberFormatException e) { 196 return -1; 197 } 198 } 199} 200