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. */ |
| 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 brand (e.g., carrier) the software is customized for, if any. */ |
| 42 | public static final String BRAND = getString("ro.product.brand"); |
| 43 | |
| 44 | /** The end-user-visible name for the end product. */ |
| 45 | public static final String MODEL = getString("ro.product.model"); |
| 46 | |
| 47 | /** Various version strings. */ |
| 48 | public static class VERSION { |
| 49 | /** |
| 50 | * The internal value used by the underlying source control to |
| 51 | * represent this build. E.g., a perforce changelist number |
| 52 | * or a git hash. |
| 53 | */ |
| 54 | public static final String INCREMENTAL = getString("ro.build.version.incremental"); |
| 55 | |
| 56 | /** |
| 57 | * The user-visible version string. E.g., "1.0" or "3.4b5". |
| 58 | */ |
| 59 | public static final String RELEASE = getString("ro.build.version.release"); |
| 60 | |
| 61 | /** |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame^] | 62 | * The user-visible SDK version of the framework in its raw String |
| 63 | * representation; use {@link #SDK_INT} instead. |
| 64 | * |
| 65 | * @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] | 66 | */ |
| 67 | public static final String SDK = getString("ro.build.version.sdk"); |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame^] | 68 | |
| 69 | /** |
| 70 | * The user-visible SDK version of the framework; its possible |
| 71 | * values are defined in {@link Build.VERSION_CODES}. |
| 72 | */ |
| 73 | public static final int SDK_INT = SystemProperties.getInt( |
| 74 | "ro.build.version.sdk", 0); |
| 75 | |
| 76 | /** |
| 77 | * The current development codename, or the string "REL" if this is |
| 78 | * a release build. |
| 79 | */ |
| 80 | 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] | 81 | } |
| 82 | |
Dianne Hackborn | 851a541 | 2009-05-08 12:06:44 -0700 | [diff] [blame^] | 83 | /** |
| 84 | * Enumeration of the currently known SDK version codes. These are the |
| 85 | * values that can be found in {@link VERSION#SDK}. Version numbers |
| 86 | * increment monotonically with each official platform release. |
| 87 | */ |
| 88 | public static class VERSION_CODES { |
| 89 | /** |
| 90 | * October 2008: The original, first, version of Android. Yay! |
| 91 | */ |
| 92 | public static final int BASE = 1; |
| 93 | /** |
| 94 | * February 2009: First Android update, officially called 1.1. |
| 95 | */ |
| 96 | public static final int BASE_1_1 = 2; |
| 97 | /** |
| 98 | * May 2009: Android 1.5. |
| 99 | */ |
| 100 | public static final int CUPCAKE = 3; |
| 101 | } |
| 102 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | /** The type of build, like "user" or "eng". */ |
| 104 | public static final String TYPE = getString("ro.build.type"); |
| 105 | |
| 106 | /** Comma-separated tags describing the build, like "unsigned,debug". */ |
| 107 | public static final String TAGS = getString("ro.build.tags"); |
| 108 | |
| 109 | /** A string that uniquely identifies this build. Do not attempt to parse this value. */ |
| 110 | public static final String FINGERPRINT = getString("ro.build.fingerprint"); |
| 111 | |
| 112 | // The following properties only make sense for internal engineering builds. |
| 113 | public static final long TIME = getLong("ro.build.date.utc") * 1000; |
| 114 | public static final String USER = getString("ro.build.user"); |
| 115 | public static final String HOST = getString("ro.build.host"); |
| 116 | |
| 117 | private static String getString(String property) { |
| 118 | return SystemProperties.get(property, UNKNOWN); |
| 119 | } |
| 120 | |
| 121 | private static long getLong(String property) { |
| 122 | try { |
| 123 | return Long.parseLong(SystemProperties.get(property)); |
| 124 | } catch (NumberFormatException e) { |
| 125 | return -1; |
| 126 | } |
| 127 | } |
| 128 | } |