Get the native bridge library from the framework.

Framework now passes the name of the native bridge to the runtime so
there's no need to do the reading in libart.

Bug: 16843953
Change-Id: I59b5c3050c6e1a37a627a8c98d7085e91487c32c
diff --git a/runtime/native_bridge.cc b/runtime/native_bridge.cc
index 18532e2..d0b516b 100644
--- a/runtime/native_bridge.cc
+++ b/runtime/native_bridge.cc
@@ -34,22 +34,6 @@
 
 namespace art {
 
-// Is native-bridge support enabled?
-static constexpr bool kNativeBridgeEnabled = true;
-
-// Default library name for native-bridge.
-static constexpr const char* kDefaultNativeBridge = "libnativebridge.so";
-
-#ifdef HAVE_ANDROID_OS
-// TODO: This will be removed once we have native-bridge command-line arguments.
-
-// Property that defines the library name of native-bridge.
-static constexpr const char* kPropNativeBridge = "persist.native.bridge";
-
-// Property that enables native-bridge.
-static constexpr const char* kPropEnableNativeBridge = "persist.enable.native.bridge";
-#endif
-
 // The symbol name exposed by native-bridge with the type of NativeBridgeCallbacks.
 static constexpr const char* kNativeBridgeInterfaceSymbol = "NativeBridgeItf";
 
@@ -208,22 +192,25 @@
   return count;
 }
 
-NativeBridgeArtCallbacks NativeBridgeArtItf = {
+static NativeBridgeArtCallbacks NativeBridgeArtItf = {
   GetMethodShorty,
   GetNativeMethodCount,
   GetNativeMethods
 };
 
 void SetNativeBridgeLibraryString(const std::string& nb_library_string) {
+  // This is called when the runtime starts and nothing is working concurrently
+  // so we don't need a lock here.
+
   native_bridge_library_string = nb_library_string;
-  // TODO: when given an empty string, set initialized_ to true and available_ to false. This
-  //       change is dependent on the property removal in Initialize().
+
+  if (native_bridge_library_string.empty()) {
+    initialized = true;
+    available = false;
+  }
 }
 
-bool NativeBridgeInitialize() {
-  if (!kNativeBridgeEnabled) {
-    return false;
-  }
+static bool NativeBridgeInitialize() {
   // TODO: Missing annotalysis static lock ordering of DEFAULT_MUTEX_ACQUIRED, place lock into
   // global order or remove.
   static Mutex lock("native bridge lock");
@@ -236,30 +223,7 @@
 
   available = false;
 
-  const char* libnb_path;
-
-  if (!native_bridge_library_string.empty()) {
-    libnb_path = native_bridge_library_string.c_str();
-  } else {
-    // TODO: Remove this once the frameworks side is completely implemented.
-
-    libnb_path = kDefaultNativeBridge;
-#ifdef HAVE_ANDROID_OS
-    char prop_buf[PROP_VALUE_MAX];
-    property_get(kPropEnableNativeBridge, prop_buf, "false");
-    if (strcmp(prop_buf, "true") != 0) {
-      initialized = true;
-      return false;
-    }
-
-    // If prop persist.native.bridge set, overwrite the default name.
-    int name_len = property_get(kPropNativeBridge, prop_buf, kDefaultNativeBridge);
-    if (name_len > 0)
-      libnb_path = prop_buf;
-#endif
-  }
-
-  void* handle = dlopen(libnb_path, RTLD_LAZY);
+  void* handle = dlopen(native_bridge_library_string.c_str(), RTLD_LAZY);
   if (handle != nullptr) {
     callbacks = reinterpret_cast<NativeBridgeCallbacks*>(dlsym(handle,
                                                                kNativeBridgeInterfaceSymbol));
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 12f9f33..cf98e6e 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -599,7 +599,7 @@
         Usage("Unknown -Xverify option %s\n", verify_mode.c_str());
         return false;
       }
-    } else if (StartsWith(option, "-XX:NativeBridge=")) {
+    } else if (StartsWith(option, "-XX:NativeBridgeLibrary=")) {
       if (!ParseStringAfterChar(option, '=', &native_bridge_library_string_)) {
         return false;
       }