diff options
| author | 2014-08-08 19:03:28 +0000 | |
|---|---|---|
| committer | 2014-08-06 23:49:29 +0000 | |
| commit | 2c798f45128d5253a6206a6a17a7c5db2e4e3014 (patch) | |
| tree | 148d8c22f65bc6136fec35247c397ac61f9526c8 | |
| parent | 76c95026eafdd1e2766122002323f7794afd7554 (diff) | |
| parent | 421b6466977d4b1ccd453f23b7b492f219099702 (diff) | |
Merge "Get the native bridge library from the framework."
| -rw-r--r-- | runtime/native_bridge.cc | 58 | ||||
| -rw-r--r-- | runtime/parsed_options.cc | 2 |
2 files changed, 12 insertions, 48 deletions
diff --git a/runtime/native_bridge.cc b/runtime/native_bridge.cc index 18532e2e33..d0b516bf35 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 @@ static uint32_t GetNativeMethods(JNIEnv* env, jclass clazz, JNINativeMethod* met 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(). -} -bool NativeBridgeInitialize() { - if (!kNativeBridgeEnabled) { - return false; + if (native_bridge_library_string.empty()) { + initialized = true; + available = 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 @@ bool NativeBridgeInitialize() { 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 12f9f33f5f..cf98e6e1d0 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -599,7 +599,7 @@ bool ParsedOptions::Parse(const RuntimeOptions& options, bool ignore_unrecognize 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; } |