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

Commit af0264bb authored by Dimitry Ivanov's avatar Dimitry Ivanov
Browse files

Load vendor public libraries to sphal namespace

Load vendor public libraries to sphal namespace
if it exists - preserve old behavior of loading
these libraries to default namespace if sphal
namespace is not present on the device.

Bug: http://b/37410104
Test: cts-tradefed run singleCommand cts --skip-preconditions -m CtsJniTestCases
      on marlin (with enabled sphal configuration) and on angler where ld.config.txt
      is not present.

Change-Id: Iaa3fa437ba2900acc2e5b9c78039fe1553e4c9dd
parent eb9694a2
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -161,6 +161,9 @@ bool NativeBridgeLinkNamespaces(native_bridge_namespace_t* from, native_bridge_n
// Use NativeBridgeLoadLibrary() instead in non-namespace scenario.
void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns);

// Returns vendor namespace if it is enabled for the device and null otherwise
native_bridge_namespace_t* NativeBridgeGetVendorNamespace();

// Native bridge interfaces to runtime.
struct NativeBridgeCallbacks {
  // Version number of the interface.
@@ -348,6 +351,15 @@ struct NativeBridgeCallbacks {
  // Starting with v3, NativeBridge has two scenarios: with/without namespace.
  // Use loadLibrary instead in non-namespace scenario.
  void* (*loadLibraryExt)(const char* libpath, int flag, native_bridge_namespace_t* ns);

  // Get native bridge version of vendor namespace.
  // The vendor namespace is the namespace used to load vendor public libraries.
  // With O release this namespace can be different from the default namespace.
  // For the devices without enable vendor namespaces this function should return null
  //
  // Returns:
  //   vendor namespace or null if it was not set up for the device
  native_bridge_namespace_t* (*getVendorNamespace)();
};

// Runtime interfaces to native bridge.
+1 −0
Original line number Diff line number Diff line
../.clang-format-2
 No newline at end of file
+16 −6
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ enum NativeBridgeImplementationVersion {
  SIGNAL_VERSION = 2,
  // The version which namespace semantic is introduced.
  NAMESPACE_VERSION = 3,
  // The version with vendor namespaces
  VENDOR_NAMESPACE_VERSION = 4,
};

// Whether we had an error at some point.
@@ -621,6 +623,14 @@ bool NativeBridgeLinkNamespaces(native_bridge_namespace_t* from, native_bridge_n
    return false;
}

native_bridge_namespace_t* NativeBridgeGetVendorNamespace() {
  if (!NativeBridgeInitialized() || !isCompatibleWith(VENDOR_NAMESPACE_VERSION)) {
    return nullptr;
  }

  return callbacks->getVendorNamespace();
}

void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns) {
  if (NativeBridgeInitialized()) {
    if (isCompatibleWith(NAMESPACE_VERSION)) {
+1 −0
Original line number Diff line number Diff line
../.clang-format-2
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -124,6 +124,8 @@ extern bool android_link_namespaces(android_namespace_t* from,
 */
extern void android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size);

extern android_namespace_t* android_get_exported_namespace(const char* name);

__END_DECLS

#endif /* __ANDROID_DLEXT_NAMESPACES_H__ */
Loading