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

Commit 77b8f585 authored by Inseob Kim's avatar Inseob Kim Committed by Automerger Merge Worker
Browse files

Merge "Add an api for platform sepolicy version to vintf" am: 3ea60e26 am: 5c509290

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1689587

Change-Id: I88e2475ed84a11cb88995dc1cc33c9398a217507
parents 4052d42e 5c509290
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1191,6 +1191,7 @@ package android.os {

  public class VintfObject {
    method public static String[] getHalNamesAndVersions();
    method @NonNull public static String getPlatformSepolicyVersion();
    method public static String getSepolicyVersion();
    method public static Long getTargetFrameworkCompatibilityMatrixVersion();
    method public static java.util.Map<java.lang.String,java.lang.String[]> getVndkSnapshots();
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.os;

import android.annotation.NonNull;
import android.annotation.TestApi;
import android.util.Slog;

@@ -111,6 +112,15 @@ public class VintfObject {
    @TestApi
    public static native String getSepolicyVersion();

    /**
     * @return the PLATFORM_SEPOLICY_VERSION build flag available in framework
     * compatibility matrix.
     *
     * @hide
     */
    @TestApi
    public static native @NonNull String getPlatformSepolicyVersion();

    /**
     * @return a list of VNDK snapshots supported by the framework, as
     * specified in framework manifest. For example,
+35 −6
Original line number Diff line number Diff line
@@ -37,11 +37,13 @@ static jmethodID gLongValueOf;

namespace android {

using vintf::CompatibilityMatrix;
using vintf::HalManifest;
using vintf::Level;
using vintf::SchemaType;
using vintf::to_string;
using vintf::toXml;
using vintf::Version;
using vintf::VintfObject;
using vintf::Vndk;

@@ -119,6 +121,28 @@ static jstring android_os_VintfObject_getSepolicyVersion(JNIEnv* env, jclass) {
    return env->NewStringUTF(cString.c_str());
}

static jstring android_os_VintfObject_getPlatformSepolicyVersion(JNIEnv* env, jclass) {
    std::shared_ptr<const CompatibilityMatrix> matrix =
            VintfObject::GetFrameworkCompatibilityMatrix();
    if (matrix == nullptr || matrix->type() != SchemaType::FRAMEWORK) {
        jniThrowRuntimeException(env, "Cannot get framework compatibility matrix");
        return nullptr;
    }

    auto versions = matrix->getSepolicyVersions();
    if (versions.empty()) {
        jniThrowRuntimeException(env,
                                 "sepolicy_version in framework compatibility matrix is empty");
        return nullptr;
    }

    Version latest;
    for (const auto& range : versions) {
        latest = std::max(latest, range.maxVer());
    }
    return env->NewStringUTF(to_string(latest).c_str());
}

static jobject android_os_VintfObject_getVndkSnapshots(JNIEnv* env, jclass) {
    std::shared_ptr<const HalManifest> manifest = VintfObject::GetFrameworkHalManifest();
    if (manifest == nullptr || manifest->type() != SchemaType::FRAMEWORK) {
@@ -147,10 +171,15 @@ static jobject android_os_VintfObject_getTargetFrameworkCompatibilityMatrixVersi
static const JNINativeMethod gVintfObjectMethods[] = {
        {"report", "()[Ljava/lang/String;", (void*)android_os_VintfObject_report},
        {"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},
        {"getHalNamesAndVersions", "()[Ljava/lang/String;",
         (void*)android_os_VintfObject_getHalNamesAndVersions},
        {"getSepolicyVersion", "()Ljava/lang/String;",
         (void*)android_os_VintfObject_getSepolicyVersion},
        {"getPlatformSepolicyVersion", "()Ljava/lang/String;",
         (void*)android_os_VintfObject_getPlatformSepolicyVersion},
        {"getVndkSnapshots", "()Ljava/util/Map;", (void*)android_os_VintfObject_getVndkSnapshots},
    {"getTargetFrameworkCompatibilityMatrixVersion", "()Ljava/lang/Long;", (void*)android_os_VintfObject_getTargetFrameworkCompatibilityMatrixVersion},
        {"getTargetFrameworkCompatibilityMatrixVersion", "()Ljava/lang/Long;",
         (void*)android_os_VintfObject_getTargetFrameworkCompatibilityMatrixVersion},
};

const char* const kVintfObjectPathName = "android/os/VintfObject";