Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd282ed2 authored by Andres Morales's avatar Andres Morales
Browse files

check bootloader and baseband version

Make sure flashed bootloader/radio matches what we
expect statically.

Change-Id: I71dfcc658695ef5542bc968747345efe0936c350
parent 26bf3ea5
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -650,15 +650,22 @@ public class Build {
    }

    /**
     * Check that device fingerprint is defined and that it matches across
     * 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;
    }

+61 −61
Original line number Diff line number Diff line
@@ -10925,7 +10925,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            } catch (RemoteException e) {
            }
            if (!Build.isFingerprintConsistent()) {
            if (!Build.isBuildConsistent()) {
                Slog.e(TAG, "Build fingerprint is not consistent, warning user");
                mHandler.obtainMessage(SHOW_FINGERPRINT_ERROR_MSG).sendToTarget();
            }