From 882cad2d87fc003ced61ddf9d68f8810ec8c4b3f Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Mon, 1 May 2017 15:12:49 -0700 Subject: 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 (cherry picked from commit af0264bbe9f5e1228eb8fb486fa3d0d8e6e8605e) --- libnativebridge/native_bridge.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'libnativebridge') diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc index 050373ae5..02b4fe7ad 100644 --- a/libnativebridge/native_bridge.cc +++ b/libnativebridge/native_bridge.cc @@ -85,12 +85,14 @@ static NativeBridgeState state = NativeBridgeState::kNotSetup; // Nativebridge implementation. // Used by isCompatibleWith() which is introduced in v2. enum NativeBridgeImplementationVersion { - // first version, not used. - DEFAULT_VERSION = 1, - // The version which signal semantic is introduced. - SIGNAL_VERSION = 2, - // The version which namespace semantic is introduced. - NAMESPACE_VERSION = 3, + // first version, not used. + DEFAULT_VERSION = 1, + // The version which signal semantic is introduced. + 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)) { -- cgit v1.2.3