From 1b5e241b9217c4d8842925a29d1ca4228329538b Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Fri, 8 Nov 2019 15:06:37 +0900 Subject: Use sysprop library for telephony props Bug: 117924132 Bug: 141246285 Test: lunch blueline-userdebug; m checkbuild Change-Id: Idefa10b5bdeaff69496bc66730a7398258f3a38e --- core/java/android/os/Build.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'core/java/android') diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 6a709b56f35a..123ed6f611f5 100755 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -26,17 +26,17 @@ import android.annotation.UnsupportedAppUsage; import android.app.ActivityThread; import android.app.Application; import android.content.Context; +import android.sysprop.TelephonyProperties; import android.text.TextUtils; import android.util.Slog; import android.view.View; -import com.android.internal.telephony.TelephonyProperties; - import dalvik.system.VMRuntime; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * Information about the current build, extracted from system properties. @@ -99,7 +99,8 @@ public class Build { * {@link #getRadioVersion} instead. */ @Deprecated - public static final String RADIO = getString(TelephonyProperties.PROPERTY_BASEBAND_VERSION); + public static final String RADIO = joinListOrElse( + TelephonyProperties.baseband_version(), UNKNOWN); /** The name of the hardware (from the kernel command line or /proc). */ public static final String HARDWARE = getString("ro.hardware"); @@ -1088,7 +1089,8 @@ public class Build { final String requiredBootloader = SystemProperties.get("ro.build.expect.bootloader"); final String currentBootloader = SystemProperties.get("ro.bootloader"); final String requiredRadio = SystemProperties.get("ro.build.expect.baseband"); - final String currentRadio = SystemProperties.get("gsm.version.baseband"); + final String currentRadio = joinListOrElse( + TelephonyProperties.baseband_version(), ""); if (TextUtils.isEmpty(system)) { Slog.e(TAG, "Required ro.build.fingerprint is empty!"); @@ -1262,8 +1264,7 @@ public class Build { * null (if, for instance, the radio is not currently on). */ public static String getRadioVersion() { - String propVal = SystemProperties.get(TelephonyProperties.PROPERTY_BASEBAND_VERSION); - return TextUtils.isEmpty(propVal) ? null : propVal; + return joinListOrElse(TelephonyProperties.baseband_version(), null); } @UnsupportedAppUsage @@ -1288,4 +1289,10 @@ public class Build { return -1; } } + + private static String joinListOrElse(List list, String defaultValue) { + String ret = list.stream().map(elem -> elem == null ? "" : elem.toString()) + .collect(Collectors.joining(",")); + return ret.isEmpty() ? defaultValue : ret; + } } -- cgit v1.2.3