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

Commit 667d55cf authored by Andres Morales's avatar Andres Morales Committed by Android (Google) Code Review
Browse files

Merge "check bootloader and baseband version"

parents e36fe704 fd282ed2
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
@@ -10929,7 +10929,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();
            }