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

Commit 747d3da3 authored by Winson's avatar Winson
Browse files

Fix OverlayableInfo native construction

With the removal of the policy field and the regen of the
constructor, the native code is failing.

Fixed and moved it to static initialization, following the same
pattern as the other files, so that it's caught during boot.

Test: manual getOverlayableInfo call at startup boots successfully

Change-Id: I6a04a1b314ad851dd9ecba78e3b52b0564d79df6
parent 4ca4a363
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ using ::android::base::unique_fd;

namespace android {

static struct overlayableinfo_offsets_t {
  jclass classObject;
  jmethodID constructor;
} gOverlayableInfoOffsets;

static jlong NativeLoad(JNIEnv* env, jclass /*clazz*/, jstring java_path, jboolean system,
                        jboolean force_shared_lib, jboolean overlay, jboolean for_loader) {
  ScopedUtfChars path(env, java_path);
@@ -222,12 +227,9 @@ static jobject NativeGetOverlayableInfo(JNIEnv* env, jclass /*clazz*/, jlong ptr
    return 0;
  }

  jclass overlayable_class = env->FindClass("android/content/om/OverlayableInfo");
  jmethodID overlayable_constructor = env->GetMethodID(overlayable_class, "<init>",
                                                       "(Ljava/lang/String;Ljava/lang/String;I)V");
  return env->NewObject(
      overlayable_class,
      overlayable_constructor,
      gOverlayableInfoOffsets.classObject,
      gOverlayableInfoOffsets.constructor,
      overlayable_name,
      actor_string
  );
@@ -267,6 +269,11 @@ static const JNINativeMethod gApkAssetsMethods[] = {
};

int register_android_content_res_ApkAssets(JNIEnv* env) {
  jclass overlayableInfoClass = FindClassOrDie(env, "android/content/om/OverlayableInfo");
  gOverlayableInfoOffsets.classObject = MakeGlobalRefOrDie(env, overlayableInfoClass);
  gOverlayableInfoOffsets.constructor = GetMethodIDOrDie(env, gOverlayableInfoOffsets.classObject,
      "<init>", "(Ljava/lang/String;Ljava/lang/String;)V");

  return RegisterMethodsOrDie(env, "android/content/res/ApkAssets", gApkAssetsMethods,
                              arraysize(gApkAssetsMethods));
}