OSDN Git Service

Allow to control native bridge via a property
authorChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 1 Oct 2015 17:07:32 +0000 (01:07 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 5 May 2016 18:17:12 +0000 (02:17 +0800)
The property is set by the Settings app.

init.x86.rc
nativebridge/Android.mk
nativebridge/src/libnb.cpp

index 9001841..93172fe 100644 (file)
@@ -118,8 +118,9 @@ service iprenew_eth0 /system/bin/dhcpcd -n
     disabled
     oneshot
 
     disabled
     oneshot
 
-service enable_houdini /system/bin/enable_houdini
+service nativebridge /system/bin/enable_nativebridge
     class main
     class main
+    disabled
     oneshot
 
 service powerbtnd /system/bin/powerbtnd
     oneshot
 
 service powerbtnd /system/bin/powerbtnd
@@ -177,3 +178,9 @@ on property:net.dns1=*
 
 on property:debug.logcat=1
     class_start debug
 
 on property:debug.logcat=1
     class_start debug
+
+on property:persist.sys.nativebridge=1
+    start nativebridge
+
+on property:persist.sys.nativebridge=0
+    stop nativebridge
index e24dda5..51fdb43 100644 (file)
@@ -16,7 +16,7 @@ LOCAL_MODULE := libnb
 LOCAL_SRC_FILES := src/libnb.cpp
 LOCAL_CFLAGS := -Werror -Wall
 LOCAL_CPPFLAGS := -std=c++11
 LOCAL_SRC_FILES := src/libnb.cpp
 LOCAL_CFLAGS := -Werror -Wall
 LOCAL_CPPFLAGS := -std=c++11
-LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_SHARED_LIBRARIES := libcutils libdl liblog
 LOCAL_MULTILIB := both
 
 include $(BUILD_SHARED_LIBRARY)
 LOCAL_MULTILIB := both
 
 include $(BUILD_SHARED_LIBRARY)
index 72e334d..8172c92 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <dlfcn.h>
 #include <cutils/log.h>
 
 #include <dlfcn.h>
 #include <cutils/log.h>
+#include <cutils/properties.h>
 #include "nativebridge/native_bridge.h"
 
 namespace android {
 #include "nativebridge/native_bridge.h"
 
 namespace android {
@@ -51,8 +52,14 @@ static bool native_bridge2_initialize(const NativeBridgeRuntimeCallbacks *art_cb
                                       const char *isa)
 {
     ALOGV("enter native_bridge2_initialize %s %s", app_code_cache_dir, isa);
                                       const char *isa)
 {
     ALOGV("enter native_bridge2_initialize %s %s", app_code_cache_dir, isa);
-    NativeBridgeCallbacks *cb = get_callbacks();
-    return cb ? cb->initialize(art_cbs, app_code_cache_dir, isa) : false;
+    if (property_get_bool("persist.sys.nativebridge", 0)) {
+        if (NativeBridgeCallbacks *cb = get_callbacks()) {
+            return cb->initialize(art_cbs, app_code_cache_dir, isa);
+        }
+    } else {
+        ALOGW("Native bridge is disabled");
+    }
+    return false;
 }
 
 static void *native_bridge2_loadLibrary(const char *libpath, int flag)
 }
 
 static void *native_bridge2_loadLibrary(const char *libpath, int flag)