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

Commit 165121c0 authored by Dimitry Ivanov's avatar Dimitry Ivanov Committed by android-build-merger
Browse files

Merge "Add error_msg argument to CloseNativeLibrary"

am: 6590255d

Change-Id: I1bbe1acf3b2fb3b2ae2ee77cfacf98f750aedbd1
parents efdbf247 6590255d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -99,7 +99,7 @@ bool NativeBridgeError();
bool NativeBridgeNameAcceptable(const char* native_bridge_library_filename);
bool NativeBridgeNameAcceptable(const char* native_bridge_library_filename);


// Decrements the reference count on the dynamic library handler. If the reference count drops
// Decrements the reference count on the dynamic library handler. If the reference count drops
// to zero then the dynamic library is unloaded.
// to zero then the dynamic library is unloaded. Returns 0 on success and non-zero on error.
int NativeBridgeUnloadLibrary(void* handle);
int NativeBridgeUnloadLibrary(void* handle);


// Get last error message of native bridge when fail to load library or search symbol.
// Get last error message of native bridge when fail to load library or search symbol.
+3 −2
Original line number Original line Diff line number Diff line
@@ -47,8 +47,9 @@ void* OpenNativeLibrary(JNIEnv* env,
                        bool* needs_native_bridge,
                        bool* needs_native_bridge,
                        std::string* error_msg);
                        std::string* error_msg);


__attribute__((visibility("default")))
__attribute__((visibility("default"))) bool CloseNativeLibrary(void* handle,
bool CloseNativeLibrary(void* handle, const bool needs_native_bridge);
                                                               const bool needs_native_bridge,
                                                               std::string* error_msg);


#if defined(__ANDROID__)
#if defined(__ANDROID__)
// Look up linker namespace by class_loader. Returns nullptr if
// Look up linker namespace by class_loader. Returns nullptr if
+15 −3
Original line number Original line Diff line number Diff line
@@ -710,9 +710,21 @@ void* OpenNativeLibrary(JNIEnv* env,
#endif
#endif
}
}


bool CloseNativeLibrary(void* handle, const bool needs_native_bridge) {
bool CloseNativeLibrary(void* handle, const bool needs_native_bridge, std::string* error_msg) {
    return needs_native_bridge ? NativeBridgeUnloadLibrary(handle) :
  bool success;
                                 dlclose(handle);
  if (needs_native_bridge) {
    success = (NativeBridgeUnloadLibrary(handle) == 0);
    if (!success) {
      *error_msg = NativeBridgeGetError();
    }
  } else {
    success = (dlclose(handle) == 0);
    if (!success) {
      *error_msg = dlerror();
    }
  }

  return success;
}
}


#if defined(__ANDROID__)
#if defined(__ANDROID__)