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

Commit beec0867 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Use classloader namespace instead of lib paths to load WebView libs.

When loading WebView's native libraries we now have a classloader
pointing to the namespace of thise libraries - so we no longer need to
explicitly reference those libraries by their path names.

Bug: 62860565
Test: Start a WebView-using app. Ensure that libwebviewchromium.so is
loaded into the app process.

Change-Id: I205131f4b5fac7c33374560515b85ddef19a7ce9
parent d9dd77ea
Loading
Loading
Loading
Loading
+5 −8
Original line number Original line Diff line number Diff line
@@ -215,12 +215,10 @@ class WebViewLibraryLoader {
            return WebViewFactory.LIBLOAD_ADDRESS_SPACE_NOT_RESERVED;
            return WebViewFactory.LIBLOAD_ADDRESS_SPACE_NOT_RESERVED;
        }
        }


        String[] args = getWebViewNativeLibraryPaths(packageInfo);
        final String libraryFileName =
        int result = nativeLoadWithRelroFile(args[0] /* path32 */,
                WebViewFactory.getWebViewLibrary(packageInfo.applicationInfo);
                                             args[1] /* path64 */,
        int result = nativeLoadWithRelroFile(libraryFileName, CHROMIUM_WEBVIEW_NATIVE_RELRO_32,
                                             CHROMIUM_WEBVIEW_NATIVE_RELRO_32,
                                             CHROMIUM_WEBVIEW_NATIVE_RELRO_64, clazzLoader);
                                             CHROMIUM_WEBVIEW_NATIVE_RELRO_64,
                                             clazzLoader);
        if (result != WebViewFactory.LIBLOAD_SUCCESS) {
        if (result != WebViewFactory.LIBLOAD_SUCCESS) {
            Log.w(LOGTAG, "failed to load with relro file, proceeding without");
            Log.w(LOGTAG, "failed to load with relro file, proceeding without");
        } else if (DEBUG) {
        } else if (DEBUG) {
@@ -317,7 +315,6 @@ class WebViewLibraryLoader {
    static native boolean nativeReserveAddressSpace(long addressSpaceToReserve);
    static native boolean nativeReserveAddressSpace(long addressSpaceToReserve);
    static native boolean nativeCreateRelroFile(String lib32, String lib64,
    static native boolean nativeCreateRelroFile(String lib32, String lib64,
                                                        String relro32, String relro64);
                                                        String relro32, String relro64);
    static native int nativeLoadWithRelroFile(String lib32, String lib64,
    static native int nativeLoadWithRelroFile(String lib, String relro32, String relro64,
                                                      String relro32, String relro64,
                                                      ClassLoader clazzLoader);
                                                      ClassLoader clazzLoader);
}
}
+5 −7
Original line number Original line Diff line number Diff line
@@ -167,16 +167,14 @@ jboolean CreateRelroFile(JNIEnv* env, jclass, jstring lib32, jstring lib64,
  return ret;
  return ret;
}
}


jint LoadWithRelroFile(JNIEnv* env, jclass, jstring lib32, jstring lib64,
jint LoadWithRelroFile(JNIEnv* env, jclass, jstring lib, jstring relro32,
                       jstring relro32, jstring relro64, jobject clazzLoader) {
                       jstring relro64, jobject clazzLoader) {
#ifdef __LP64__
#ifdef __LP64__
  jstring lib = lib64;
  jstring relro = relro64;
  jstring relro = relro64;
  (void)lib32; (void)relro32;
  (void)relro32;
#else
#else
  jstring lib = lib32;
  jstring relro = relro32;
  jstring relro = relro32;
  (void)lib64; (void)relro64;
  (void)relro64;
#endif
#endif
  jint ret = LIBLOAD_FAILED_JNI_CALL;
  jint ret = LIBLOAD_FAILED_JNI_CALL;
  const char* lib_utf8 = env->GetStringUTFChars(lib, NULL);
  const char* lib_utf8 = env->GetStringUTFChars(lib, NULL);
@@ -201,7 +199,7 @@ const JNINativeMethod kJniMethods[] = {
      "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z",
      "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z",
      reinterpret_cast<void*>(CreateRelroFile) },
      reinterpret_cast<void*>(CreateRelroFile) },
  { "nativeLoadWithRelroFile",
  { "nativeLoadWithRelroFile",
      "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)I",
      "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)I",
      reinterpret_cast<void*>(LoadWithRelroFile) },
      reinterpret_cast<void*>(LoadWithRelroFile) },
};
};