diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 5ac0aa3ffdade..5bdaf6e25e56a 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -5203,10 +5203,6 @@ public final class ActivityThread { } else { Log.e(TAG, "Unable to setupGraphicsSupport due to missing code-cache directory"); } - - // Add the lib dir path to hardware renderer so that vulkan layers - // can be searched for within that directory. - ThreadedRenderer.setLibDir(data.info.getLibDir()); } // Install the Network Security Config Provider. This must happen before the application diff --git a/core/java/android/app/ApplicationLoaders.java b/core/java/android/app/ApplicationLoaders.java index d89e1864f36fd..c86994438096b 100644 --- a/core/java/android/app/ApplicationLoaders.java +++ b/core/java/android/app/ApplicationLoaders.java @@ -65,6 +65,8 @@ class ApplicationLoaders { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); + setupVulkanLayerPath(pathClassloader, librarySearchPath); + mLoaders.put(zip, pathClassloader); return pathClassloader; } @@ -76,6 +78,8 @@ class ApplicationLoaders { } } + private static native void setupVulkanLayerPath(ClassLoader classLoader, String librarySearchPath); + /** * Adds a new path the classpath of the given loader. * @throws IllegalStateException if the provided class loader is not a {@link PathClassLoader}. diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java index 1cd2fb0ee96bf..e650d956915ac 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -251,17 +251,6 @@ public final class ThreadedRenderer { ThreadedRenderer.setupShadersDiskCache(new File(cacheDir, CACHE_PATH_SHADERS).getAbsolutePath()); } - /** - * Sets the library directory to use as a search path for vulkan layers. - * - * @param libDir A directory that contains vulkan layers - * - * @hide - */ - public static void setLibDir(String libDir) { - ThreadedRenderer.setupVulkanLayerPath(libDir); - } - /** * Creates a hardware renderer using OpenGL. * @@ -980,7 +969,6 @@ public final class ThreadedRenderer { } static native void setupShadersDiskCache(String cacheFile); - static native void setupVulkanLayerPath(String layerPath); private static native void nSetAtlas(long nativeProxy, GraphicBuffer buffer, long[] map); private static native void nSetProcessStatsBuffer(long nativeProxy, int fd); diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 7e51265d73dcc..60e888d17fc06 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -34,6 +34,7 @@ LOCAL_SRC_FILES:= \ com_google_android_gles_jni_EGLImpl.cpp \ com_google_android_gles_jni_GLImpl.cpp.arm \ android_app_Activity.cpp \ + android_app_ApplicationLoaders.cpp \ android_app_NativeActivity.cpp \ android_app_admin_SecurityLog.cpp \ android_opengl_EGL14.cpp \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 030102fade167..536c09cd01ad0 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -180,6 +180,7 @@ extern int register_android_backup_BackupHelperDispatcher(JNIEnv *env); extern int register_android_app_backup_FullBackup(JNIEnv *env); extern int register_android_app_Activity(JNIEnv *env); extern int register_android_app_ActivityThread(JNIEnv *env); +extern int register_android_app_ApplicationLoaders(JNIEnv *env); extern int register_android_app_NativeActivity(JNIEnv *env); extern int register_android_media_RemoteDisplay(JNIEnv *env); extern int register_android_util_jar_StrictJarFile(JNIEnv* env); @@ -1388,6 +1389,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_app_backup_FullBackup), REG_JNI(register_android_app_Activity), REG_JNI(register_android_app_ActivityThread), + REG_JNI(register_android_app_ApplicationLoaders), REG_JNI(register_android_app_NativeActivity), REG_JNI(register_android_util_jar_StrictJarFile), REG_JNI(register_android_view_InputChannel), diff --git a/core/jni/android_app_ApplicationLoaders.cpp b/core/jni/android_app_ApplicationLoaders.cpp new file mode 100644 index 0000000000000..24ee9591fc2f9 --- /dev/null +++ b/core/jni/android_app_ApplicationLoaders.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "core_jni_helpers.h" + +static void setupVulkanLayerPath_native(JNIEnv* env, jobject clazz, + jobject classLoader, jstring librarySearchPath) { + ScopedUtfChars layerPathChars(env, librarySearchPath); + vulkan::LoaderData& loader_data = vulkan::LoaderData::GetInstance(); + loader_data.layer_path = layerPathChars.c_str(); + loader_data.app_namespace = android::FindNamespaceByClassLoader(env, classLoader); +} + +static const JNINativeMethod g_methods[] = { + { "setupVulkanLayerPath", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V", + reinterpret_cast(setupVulkanLayerPath_native) }, +}; + +static const char* const kApplicationLoadersName = "android/app/ApplicationLoaders"; + +namespace android +{ + +int register_android_app_ApplicationLoaders(JNIEnv* env) { + return RegisterMethodsOrDie(env, kApplicationLoadersName, g_methods, NELEM(g_methods)); +} + +} // namespace android diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp index 2b8e1fd924175..1cf2611927a01 100644 --- a/core/jni/android_view_ThreadedRenderer.cpp +++ b/core/jni/android_view_ThreadedRenderer.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -50,7 +49,6 @@ #include #include #include -#include namespace android { @@ -716,18 +714,6 @@ static void android_view_ThreadedRenderer_setupShadersDiskCache(JNIEnv* env, job env->ReleaseStringUTFChars(diskCachePath, cacheArray); } -// ---------------------------------------------------------------------------- -// Layers -// ---------------------------------------------------------------------------- - -static void android_view_ThreadedRenderer_setupVulkanLayerPath(JNIEnv* env, jobject clazz, - jstring layerPath) { - - const char* layerArray = env->GetStringUTFChars(layerPath, NULL); - vulkan::LoaderData::GetInstance().layer_path = layerArray; - env->ReleaseStringUTFChars(layerPath, layerArray); -} - // ---------------------------------------------------------------------------- // JNI Glue // ---------------------------------------------------------------------------- @@ -770,8 +756,6 @@ static const JNINativeMethod gMethods[] = { { "nDumpProfileData", "([BLjava/io/FileDescriptor;)V", (void*) android_view_ThreadedRenderer_dumpProfileData }, { "setupShadersDiskCache", "(Ljava/lang/String;)V", (void*) android_view_ThreadedRenderer_setupShadersDiskCache }, - { "setupVulkanLayerPath", "(Ljava/lang/String;)V", - (void*) android_view_ThreadedRenderer_setupVulkanLayerPath }, { "nAddRenderNode", "(JJZ)V", (void*) android_view_ThreadedRenderer_addRenderNode}, { "nRemoveRenderNode", "(JJ)V", (void*) android_view_ThreadedRenderer_removeRenderNode}, { "nDrawRenderNode", "(JJ)V", (void*) android_view_ThreadedRendererd_drawRenderNode},