Loading libnativebridge/include/nativebridge/native_bridge.h +13 −2 Original line number Original line Diff line number Diff line Loading @@ -164,8 +164,9 @@ bool NativeBridgeLinkNamespaces(struct native_bridge_namespace_t* from, void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, struct native_bridge_namespace_t* ns); struct native_bridge_namespace_t* ns); // Returns vendor namespace if it is enabled for the device and null otherwise // Returns exported namespace by the name. This is a reflection of struct native_bridge_namespace_t* NativeBridgeGetVendorNamespace(); // android_get_exported_namespace function. Introduced in v5. struct native_bridge_namespace_t* NativeBridgeGetExportedNamespace(const char* name); // Native bridge interfaces to runtime. // Native bridge interfaces to runtime. struct NativeBridgeCallbacks { struct NativeBridgeCallbacks { Loading Loading @@ -362,7 +363,17 @@ struct NativeBridgeCallbacks { // // // Returns: // Returns: // vendor namespace or null if it was not set up for the device // vendor namespace or null if it was not set up for the device // // Starting with v5 (Android Q) this function is no longer used. // Use getExportedNamespace() below. struct native_bridge_namespace_t* (*getVendorNamespace)(); struct native_bridge_namespace_t* (*getVendorNamespace)(); // Get native bridge version of exported namespace. Peer of // android_get_exported_namespace(const char*) function. // // Returns: // exported namespace or null if it was not set up for the device struct native_bridge_namespace_t* (*getExportedNamespace)(const char* name); }; }; // Runtime interfaces to native bridge. // Runtime interfaces to native bridge. Loading libnativebridge/libnativebridge.map.txt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ LIBNATIVEBRIDGE_1 { NativeBridgeGetError; NativeBridgeGetError; NativeBridgeIsPathSupported; NativeBridgeIsPathSupported; NativeBridgeCreateNamespace; NativeBridgeCreateNamespace; NativeBridgeGetVendorNamespace; NativeBridgeGetExportedNamespace; NativeBridgeLinkNamespaces; NativeBridgeLinkNamespaces; NativeBridgeLoadLibraryExt; NativeBridgeLoadLibraryExt; NativeBridgeInitAnonymousNamespace; NativeBridgeInitAnonymousNamespace; Loading libnativebridge/native_bridge.cc +15 −3 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,8 @@ enum NativeBridgeImplementationVersion { NAMESPACE_VERSION = 3, NAMESPACE_VERSION = 3, // The version with vendor namespaces // The version with vendor namespaces VENDOR_NAMESPACE_VERSION = 4, VENDOR_NAMESPACE_VERSION = 4, // The version with runtime namespaces RUNTIME_NAMESPACE_VERSION = 5, }; }; // Whether we had an error at some point. // Whether we had an error at some point. Loading Loading @@ -610,14 +612,24 @@ bool NativeBridgeLinkNamespaces(native_bridge_namespace_t* from, native_bridge_n return false; return false; } } native_bridge_namespace_t* NativeBridgeGetVendorNamespace() { native_bridge_namespace_t* NativeBridgeGetExportedNamespace(const char* name) { if (!NativeBridgeInitialized() || !isCompatibleWith(VENDOR_NAMESPACE_VERSION)) { if (!NativeBridgeInitialized()) { return nullptr; return nullptr; } } if (isCompatibleWith(RUNTIME_NAMESPACE_VERSION)) { return callbacks->getExportedNamespace(name); } // sphal is vendor namespace name -> use v4 callback in the case NB callbacks // are not compatible with v5 if (isCompatibleWith(VENDOR_NAMESPACE_VERSION) && name != nullptr && strcmp("sphal", name) == 0) { return callbacks->getVendorNamespace(); return callbacks->getVendorNamespace(); } } return nullptr; } void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns) { void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns) { if (NativeBridgeInitialized()) { if (NativeBridgeInitialized()) { if (isCompatibleWith(NAMESPACE_VERSION)) { if (isCompatibleWith(NAMESPACE_VERSION)) { Loading libnativeloader/native_loader.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -300,7 +300,7 @@ class LibraryNamespaces { return nullptr; return nullptr; } } native_bridge_namespace_t* vendor_ns = NativeBridgeGetVendorNamespace(); native_bridge_namespace_t* vendor_ns = NativeBridgeGetExportedNamespace(kVendorNamespaceName); if (!NativeBridgeLinkNamespaces(ns, nullptr, system_exposed_libraries.c_str())) { if (!NativeBridgeLinkNamespaces(ns, nullptr, system_exposed_libraries.c_str())) { *error_msg = NativeBridgeGetError(); *error_msg = NativeBridgeGetError(); Loading Loading
libnativebridge/include/nativebridge/native_bridge.h +13 −2 Original line number Original line Diff line number Diff line Loading @@ -164,8 +164,9 @@ bool NativeBridgeLinkNamespaces(struct native_bridge_namespace_t* from, void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, struct native_bridge_namespace_t* ns); struct native_bridge_namespace_t* ns); // Returns vendor namespace if it is enabled for the device and null otherwise // Returns exported namespace by the name. This is a reflection of struct native_bridge_namespace_t* NativeBridgeGetVendorNamespace(); // android_get_exported_namespace function. Introduced in v5. struct native_bridge_namespace_t* NativeBridgeGetExportedNamespace(const char* name); // Native bridge interfaces to runtime. // Native bridge interfaces to runtime. struct NativeBridgeCallbacks { struct NativeBridgeCallbacks { Loading Loading @@ -362,7 +363,17 @@ struct NativeBridgeCallbacks { // // // Returns: // Returns: // vendor namespace or null if it was not set up for the device // vendor namespace or null if it was not set up for the device // // Starting with v5 (Android Q) this function is no longer used. // Use getExportedNamespace() below. struct native_bridge_namespace_t* (*getVendorNamespace)(); struct native_bridge_namespace_t* (*getVendorNamespace)(); // Get native bridge version of exported namespace. Peer of // android_get_exported_namespace(const char*) function. // // Returns: // exported namespace or null if it was not set up for the device struct native_bridge_namespace_t* (*getExportedNamespace)(const char* name); }; }; // Runtime interfaces to native bridge. // Runtime interfaces to native bridge. Loading
libnativebridge/libnativebridge.map.txt +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,7 @@ LIBNATIVEBRIDGE_1 { NativeBridgeGetError; NativeBridgeGetError; NativeBridgeIsPathSupported; NativeBridgeIsPathSupported; NativeBridgeCreateNamespace; NativeBridgeCreateNamespace; NativeBridgeGetVendorNamespace; NativeBridgeGetExportedNamespace; NativeBridgeLinkNamespaces; NativeBridgeLinkNamespaces; NativeBridgeLoadLibraryExt; NativeBridgeLoadLibraryExt; NativeBridgeInitAnonymousNamespace; NativeBridgeInitAnonymousNamespace; Loading
libnativebridge/native_bridge.cc +15 −3 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,8 @@ enum NativeBridgeImplementationVersion { NAMESPACE_VERSION = 3, NAMESPACE_VERSION = 3, // The version with vendor namespaces // The version with vendor namespaces VENDOR_NAMESPACE_VERSION = 4, VENDOR_NAMESPACE_VERSION = 4, // The version with runtime namespaces RUNTIME_NAMESPACE_VERSION = 5, }; }; // Whether we had an error at some point. // Whether we had an error at some point. Loading Loading @@ -610,14 +612,24 @@ bool NativeBridgeLinkNamespaces(native_bridge_namespace_t* from, native_bridge_n return false; return false; } } native_bridge_namespace_t* NativeBridgeGetVendorNamespace() { native_bridge_namespace_t* NativeBridgeGetExportedNamespace(const char* name) { if (!NativeBridgeInitialized() || !isCompatibleWith(VENDOR_NAMESPACE_VERSION)) { if (!NativeBridgeInitialized()) { return nullptr; return nullptr; } } if (isCompatibleWith(RUNTIME_NAMESPACE_VERSION)) { return callbacks->getExportedNamespace(name); } // sphal is vendor namespace name -> use v4 callback in the case NB callbacks // are not compatible with v5 if (isCompatibleWith(VENDOR_NAMESPACE_VERSION) && name != nullptr && strcmp("sphal", name) == 0) { return callbacks->getVendorNamespace(); return callbacks->getVendorNamespace(); } } return nullptr; } void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns) { void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns) { if (NativeBridgeInitialized()) { if (NativeBridgeInitialized()) { if (isCompatibleWith(NAMESPACE_VERSION)) { if (isCompatibleWith(NAMESPACE_VERSION)) { Loading
libnativeloader/native_loader.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -300,7 +300,7 @@ class LibraryNamespaces { return nullptr; return nullptr; } } native_bridge_namespace_t* vendor_ns = NativeBridgeGetVendorNamespace(); native_bridge_namespace_t* vendor_ns = NativeBridgeGetExportedNamespace(kVendorNamespaceName); if (!NativeBridgeLinkNamespaces(ns, nullptr, system_exposed_libraries.c_str())) { if (!NativeBridgeLinkNamespaces(ns, nullptr, system_exposed_libraries.c_str())) { *error_msg = NativeBridgeGetError(); *error_msg = NativeBridgeGetError(); Loading