From 1851118aa457baa8b489abfd3ef161014ed69d96 Mon Sep 17 00:00:00 2001 From: Michael Schwartz Date: Mon, 15 May 2017 11:40:40 -0700 Subject: [PATCH] Check VintfObject compatibility on boot Bug: 36814984 Test: Build, flash boot sailfish and shared system image. Change-Id: Ibd6694079d9e2641a7b77d774a2df085e9a8545a --- core/java/android/os/Build.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 4bad7ab76be65..a2fb9db8c64bb 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -807,8 +807,20 @@ public class Build { } /** - * Verifies the the current flash of the device is consistent with what + * True if Treble is enabled and required for this device. + * + * @hide + */ + public static final boolean IS_TREBLE_ENABLED = + SystemProperties.getBoolean("ro.treble.enabled", false); + + /** + * Verifies the current flash of the device is consistent with what * was expected at build time. + * + * Treble devices will verify the Vendor Interface (VINTF). A device + * launched without Treble: + * * 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. @@ -819,6 +831,17 @@ public class Build { // Don't care on eng builds. Incremental build may trigger false negative. if (IS_ENG) return true; + if (IS_TREBLE_ENABLED) { + int result = VintfObject.verify(new String[0]); + + if (result != 0) { + Slog.e(TAG, "Vendor interface is incompatible, error=" + + String.valueOf(result)); + } + + return result == 0; + } + 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");