From ad2171acf423224d925d1b7cefa7184882e100bf Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Tue, 14 Jun 2011 11:07:24 -0700 Subject: [PATCH] deprecate RADIO constant, add getRadioVersion method On many devices the radio version system property is only available when the radio is on, which is frequently not the case when the static initializers for the Build class are run (eg, if the system has just booted). This means RADIO is forever "unknown" on these devices. Deprecate it and add a method to return the radio version instead. Apps will still have to deal with getting a null back if the radio version is currently unavailable. Change-Id: I63528eae93e1b9d0f7cec5a382724d0391ba1104 --- api/current.txt | 3 ++- core/java/android/os/Build.java | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/api/current.txt b/api/current.txt index f641c96552cfe..26f4b78783fc6 100644 --- a/api/current.txt +++ b/api/current.txt @@ -13588,6 +13588,7 @@ package android.os { public class Build { ctor public Build(); + method public static java.lang.String getRadioVersion(); field public static final java.lang.String BOARD; field public static final java.lang.String BOOTLOADER; field public static final java.lang.String BRAND; @@ -13602,7 +13603,7 @@ package android.os { field public static final java.lang.String MANUFACTURER; field public static final java.lang.String MODEL; field public static final java.lang.String PRODUCT; - field public static final java.lang.String RADIO; + field public static final deprecated java.lang.String RADIO; field public static final java.lang.String SERIAL; field public static final java.lang.String TAGS; field public static final long TIME; diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 8ff5beb035cc4..3ccc81477e4c7 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -16,6 +16,8 @@ package android.os; +import com.android.internal.telephony.TelephonyProperties; + /** * Information about the current build, extracted from system properties. */ @@ -56,8 +58,16 @@ public class Build { /** The system bootloader version number. */ public static final String BOOTLOADER = getString("ro.bootloader"); - /** The radio firmware version number. */ - public static final String RADIO = getString("gsm.version.baseband"); + /** + * The radio firmware version number. + * + * @deprecated The radio firmware version is frequently not + * available when this class is initialized, leading to a blank or + * "unknown" value for this string. Use + * {@link #getRadioVersion} instead. + */ + @Deprecated + public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION); /** The name of the hardware (from the kernel command line or /proc). */ public static final String HARDWARE = getString("ro.hardware"); @@ -266,6 +276,14 @@ public class Build { public static final String USER = getString("ro.build.user"); public static final String HOST = getString("ro.build.host"); + /** + * Returns the version string for the radio firmware. May return + * null (if, for instance, the radio is not currently on). + */ + public static String getRadioVersion() { + return SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION, null); + } + private static String getString(String property) { return SystemProperties.get(property, UNKNOWN); }