NativeBridge: Tighten security on libnativebridge

Do not allow arbitrary paths for the native bridge - only allow
simple names.

Do not allow re-setup of the native bridge.

Bug: 16404669

(cherry picked from commit cd2ef4c1af69727231b84ebc82864c170ff0e8ad)

Change-Id: Ie22de356d2307fe2758f9094a85d44e61a4098a1
diff --git a/include/nativebridge/native_bridge.h b/include/nativebridge/native_bridge.h
index 2415e6b..c588bbc 100644
--- a/include/nativebridge/native_bridge.h
+++ b/include/nativebridge/native_bridge.h
@@ -29,6 +29,10 @@
 void SetupNativeBridge(const char* native_bridge_library_filename,
                        const NativeBridgeRuntimeCallbacks* runtime_callbacks);
 
+// Check whether a native bridge is available (initialized). Requires a prior call to
+// SetupNativeBridge to make sense.
+bool NativeBridgeAvailable();
+
 // Load a shared library that is supported by the native bridge.
 void* NativeBridgeLoadLibrary(const char* libpath, int flag);
 
@@ -38,6 +42,17 @@
 // True if native library is valid and is for an ABI that is supported by native bridge.
 bool NativeBridgeIsSupported(const char* libpath);
 
+// Returns whether we have seen a native bridge error. This could happen because the library
+// was not found, rejected, could not be initialized and so on.
+//
+// This functionality is mainly for testing.
+bool NativeBridgeError();
+
+// Returns whether a given string is acceptable as a native bridge library filename.
+//
+// This functionality is exposed mainly for testing.
+bool NativeBridgeNameAcceptable(const char* native_bridge_library_filename);
+
 // Native bridge interfaces to runtime.
 struct NativeBridgeCallbacks {
   // Initialize native bridge. Native bridge's internal implementation must ensure MT safety and