From fd282ed2f4649cc77127ab15b9167971abb5f379 Mon Sep 17 00:00:00 2001 From: Andres Morales Date: Fri, 6 Feb 2015 15:07:59 -0800 Subject: check bootloader and baseband version Make sure flashed bootloader/radio matches what we expect statically. Change-Id: I71dfcc658695ef5542bc968747345efe0936c350 --- core/java/android/os/Build.java | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'core/java/android/os') diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index e4b594a..eb86e7e 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -650,15 +650,22 @@ public class Build { } /** - * Check that device fingerprint is defined and that it matches across - * various partitions. + * Verifies the the current flash of the device is consistent with what + * was expected at build time. + * 1) Checks that device fingerprint is defined and that it matches across + * various partitions. + * 2) Verifies radio and bootloader partitions are those expected in the build. * * @hide */ - public static boolean isFingerprintConsistent() { + public static boolean isBuildConsistent() { final String system = SystemProperties.get("ro.build.fingerprint"); final String vendor = SystemProperties.get("ro.vendor.build.fingerprint"); final String bootimage = SystemProperties.get("ro.bootimage.build.fingerprint"); + 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"); if (TextUtils.isEmpty(system)) { Slog.e(TAG, "Required ro.build.fingerprint is empty!"); @@ -681,6 +688,22 @@ public class Build { } } + if (!TextUtils.isEmpty(requiredBootloader)) { + if (!Objects.equals(currentBootloader, requiredBootloader)) { + Slog.e(TAG, "Mismatched bootloader version: build requires " + requiredBootloader + + " but runtime reports " + currentBootloader); + return false; + } + } + + if (!TextUtils.isEmpty(requiredRadio)) { + if (!Objects.equals(currentRadio, requiredRadio)) { + Slog.e(TAG, "Mismatched radio version: build requires " + requiredRadio + + " but runtime reports " + currentRadio); + return false; + } + } + return true; } -- cgit v1.1