diff options
| author | 2018-02-07 14:16:21 -0800 | |
|---|---|---|
| committer | 2018-02-07 14:30:43 -0800 | |
| commit | 0e5e472b4b207e1edbd9061acf57c56b88073c51 (patch) | |
| tree | 01c569f85e5739eb03d1b65f9c5de0dea5cda9ea | |
| parent | f448371208a53a93657b8120105e5f5fbb9feee8 (diff) | |
VintfObject: add getTargetFcmVersion
Add getTargetFrameworkCompatibilityMatrixVersion that returns
target FCM version in device manifest.
Test: VintfDeviceInfo
Bug: 70993015
Change-Id: Ia6354f85e7fae898444067977fb594febb0112fa
| -rw-r--r-- | core/java/android/os/VintfObject.java | 7 | ||||
| -rw-r--r-- | core/jni/android_os_VintfObject.cpp | 14 |
2 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/os/VintfObject.java b/core/java/android/os/VintfObject.java index 340f3fb8cd25..951cbf52c92e 100644 --- a/core/java/android/os/VintfObject.java +++ b/core/java/android/os/VintfObject.java @@ -80,4 +80,11 @@ public class VintfObject { * ("25.1.3", ["libjpeg.so", "libbase.so"])] */ public static native Map<String, String[]> getVndkSnapshots(); + + /** + * @return target FCM version, a number specified in the device manifest + * indicating the FCM version that the device manifest implements. Null if + * device manifest doesn't specify this number (for legacy devices). + */ + public static native Long getTargetFrameworkCompatibilityMatrixVersion(); } diff --git a/core/jni/android_os_VintfObject.cpp b/core/jni/android_os_VintfObject.cpp index 1eeea517cd78..2fa68b0638ff 100644 --- a/core/jni/android_os_VintfObject.cpp +++ b/core/jni/android_os_VintfObject.cpp @@ -32,10 +32,13 @@ static jclass gString; static jclass gHashMapClazz; static jmethodID gHashMapInit; static jmethodID gHashMapPut; +static jclass gLongClazz; +static jmethodID gLongValueOf; namespace android { using vintf::HalManifest; +using vintf::Level; using vintf::SchemaType; using vintf::VintfObject; using vintf::XmlConverter; @@ -154,6 +157,14 @@ static jobject android_os_VintfObject_getVndkSnapshots(JNIEnv* env, jclass) { return jMap; } +static jobject android_os_VintfObject_getTargetFrameworkCompatibilityMatrixVersion(JNIEnv* env, jclass) { + std::shared_ptr<const HalManifest> manifest = VintfObject::GetDeviceHalManifest(); + if (manifest == nullptr || manifest->level() == Level::UNSPECIFIED) { + return nullptr; + } + return env->CallStaticObjectMethod(gLongClazz, gLongValueOf, static_cast<jlong>(manifest->level())); +} + // ---------------------------------------------------------------------------- static const JNINativeMethod gVintfObjectMethods[] = { @@ -163,6 +174,7 @@ static const JNINativeMethod gVintfObjectMethods[] = { {"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}, }; const char* const kVintfObjectPathName = "android/os/VintfObject"; @@ -175,6 +187,8 @@ int register_android_os_VintfObject(JNIEnv* env) gHashMapInit = GetMethodIDOrDie(env, gHashMapClazz, "<init>", "()V"); gHashMapPut = GetMethodIDOrDie(env, gHashMapClazz, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + gLongClazz = MakeGlobalRefOrDie(env, FindClassOrDie(env, "java/lang/Long")); + gLongValueOf = GetStaticMethodIDOrDie(env, gLongClazz, "valueOf", "(J)Ljava/lang/Long;"); return RegisterMethodsOrDie(env, kVintfObjectPathName, gVintfObjectMethods, NELEM(gVintfObjectMethods)); |