From 12ebf362b45d906fca55017c9d06bd6a676f6629 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Wed, 18 Dec 2019 12:52:55 -0800 Subject: [PATCH] Delete VINTF compatibility checks during OTA. Such checks uses old libvintf to parse new VINTF metadata, which is not supported. The check is now moved to OTA package build time, so there is no need to check it on the device. Test: builds Bug: 139300422 Change-Id: Ifaec06b5298f698958e5727316bf661d1960d0aa --- core/java/android/os/VintfObject.java | 30 ++++++++++++++++++++++++--- core/jni/android_os_VintfObject.cpp | 22 +------------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/core/java/android/os/VintfObject.java b/core/java/android/os/VintfObject.java index 1c78b081120a2..7af8f71aa4aa1 100644 --- a/core/java/android/os/VintfObject.java +++ b/core/java/android/os/VintfObject.java @@ -17,6 +17,7 @@ package android.os; import android.annotation.TestApi; +import android.util.Slog; import java.util.Map; @@ -28,6 +29,8 @@ import java.util.Map; @TestApi public class VintfObject { + private static final String LOG_TAG = "VintfObject"; + /** * Slurps all device information (both manifests and both matrices) * and report them. @@ -46,12 +49,33 @@ public class VintfObject { * @param packageInfo a list of serialized form of HalManifest's / * CompatibilityMatri'ces (XML). * @return = 0 if success (compatible) - * > 0 if incompatible - * < 0 if any error (mount partition fails, illformed XML, etc.) + * > 0 if incompatible + * < 0 if any error (mount partition fails, illformed XML, etc.) + * + * @deprecated Checking compatibility against an OTA package is no longer + * supported because the format of VINTF metadata in the OTA package may not + * be recognized by the current system. + * + *

+ *

* * @hide */ - public static native int verify(String[] packageInfo); + @Deprecated + public static int verify(String[] packageInfo) { + if (packageInfo != null && packageInfo.length > 0) { + Slog.w(LOG_TAG, "VintfObject.verify() with non-empty packageInfo is deprecated. " + + "Skipping compatibility checks for update package."); + return 0; + } + Slog.w(LOG_TAG, "VintfObject.verify() is deprecated. Call verifyWithoutAvb() instead."); + return verifyWithoutAvb(); + } /** * Verify Vintf compatibility on the device without checking AVB diff --git a/core/jni/android_os_VintfObject.cpp b/core/jni/android_os_VintfObject.cpp index ee11b6162db01..25ffbabd6199a 100644 --- a/core/jni/android_os_VintfObject.cpp +++ b/core/jni/android_os_VintfObject.cpp @@ -96,28 +96,9 @@ static jobjectArray android_os_VintfObject_report(JNIEnv* env, jclass) return toJavaStringArray(env, cStrings); } -static jint android_os_VintfObject_verify(JNIEnv* env, jclass, jobjectArray packageInfo) { - std::vector cPackageInfo; - if (packageInfo) { - size_t count = env->GetArrayLength(packageInfo); - cPackageInfo.resize(count); - for (size_t i = 0; i < count; ++i) { - jstring element = (jstring)env->GetObjectArrayElement(packageInfo, i); - const char *cString = env->GetStringUTFChars(element, NULL /* isCopy */); - cPackageInfo[i] = cString; - env->ReleaseStringUTFChars(element, cString); - } - } - std::string error; - int32_t status = VintfObject::CheckCompatibility(cPackageInfo, &error); - if (status) - LOG(WARNING) << "VintfObject.verify() returns " << status << ": " << error; - return status; -} - static jint android_os_VintfObject_verifyWithoutAvb(JNIEnv* env, jclass) { std::string error; - int32_t status = VintfObject::CheckCompatibility({}, &error, + int32_t status = VintfObject::GetInstance()->checkCompatibility(&error, ::android::vintf::CheckFlags::DISABLE_AVB_CHECK); if (status) LOG(WARNING) << "VintfObject.verifyWithoutAvb() returns " << status << ": " << error; @@ -170,7 +151,6 @@ static jobject android_os_VintfObject_getTargetFrameworkCompatibilityMatrixVersi static const JNINativeMethod gVintfObjectMethods[] = { {"report", "()[Ljava/lang/String;", (void*)android_os_VintfObject_report}, - {"verify", "([Ljava/lang/String;)I", (void*)android_os_VintfObject_verify}, {"verifyWithoutAvb", "()I", (void*)android_os_VintfObject_verifyWithoutAvb}, {"getHalNamesAndVersions", "()[Ljava/lang/String;", (void*)android_os_VintfObject_getHalNamesAndVersions}, {"getSepolicyVersion", "()Ljava/lang/String;", (void*)android_os_VintfObject_getSepolicyVersion},