Merge "nativeloader: Add Reset capabilities" into nyc-dev
diff --git a/libnativeloader/include/nativeloader/native_loader.h b/libnativeloader/include/nativeloader/native_loader.h
index 1bd3b8f..d606a76 100644
--- a/libnativeloader/include/nativeloader/native_loader.h
+++ b/libnativeloader/include/nativeloader/native_loader.h
@@ -50,6 +50,9 @@
android_namespace_t* FindNamespaceByClassLoader(JNIEnv* env, jobject class_loader);
#endif
+__attribute__((visibility("default")))
+void ResetNativeLoader();
+
}; // namespace android
#endif // NATIVE_BRIDGE_H_
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 665b5b5..baad197 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -131,6 +131,10 @@
public_libraries_ = base::Join(sonames, ':');
}
+ void Reset() {
+ namespaces_.clear();
+ }
+
private:
bool ReadConfig(const std::string& configFile, std::vector<std::string>* sonames) {
// Read list of public native libraries from the config file.
@@ -185,6 +189,12 @@
#endif
}
+void ResetNativeLoader() {
+#if defined(__ANDROID__)
+ std::lock_guard<std::mutex> guard(g_namespaces_mutex);
+ g_namespaces->Reset();
+#endif
+}
jstring CreateClassLoaderNamespace(JNIEnv* env,
int32_t target_sdk_version,