Merge "Add an api for platform sepolicy version to vintf"
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
@@ -145,12 +169,17 @@ 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},
|
||||
{"getVndkSnapshots", "()Ljava/util/Map;", (void*)android_os_VintfObject_getVndkSnapshots},
|
||||
{"getTargetFrameworkCompatibilityMatrixVersion", "()Ljava/lang/Long;", (void*)android_os_VintfObject_getTargetFrameworkCompatibilityMatrixVersion},
|
||||
{"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},
|
||||
{"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},
|
||||
};
|
||||
|
||||
const char* const kVintfObjectPathName = "android/os/VintfObject";
|
||||
|
||||
Reference in New Issue
Block a user