From: Chih-Wei Huang Date: Thu, 1 Oct 2015 17:07:32 +0000 (+0800) Subject: Allow to control native bridge via a property X-Git-Tag: android-x86-6.0-r1~53 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fdevice-generic-common.git;a=commitdiff_plain;h=39745eb0e933d7760008dce12968b4e5cf89acd3 Allow to control native bridge via a property The property is set by the Settings app. --- diff --git a/init.x86.rc b/init.x86.rc index 9001841..93172fe 100644 --- a/init.x86.rc +++ b/init.x86.rc @@ -118,8 +118,9 @@ service iprenew_eth0 /system/bin/dhcpcd -n disabled oneshot -service enable_houdini /system/bin/enable_houdini +service nativebridge /system/bin/enable_nativebridge class main + disabled oneshot service powerbtnd /system/bin/powerbtnd @@ -177,3 +178,9 @@ on property:net.dns1=* on property:debug.logcat=1 class_start debug + +on property:persist.sys.nativebridge=1 + start nativebridge + +on property:persist.sys.nativebridge=0 + stop nativebridge diff --git a/nativebridge/Android.mk b/nativebridge/Android.mk index e24dda5..51fdb43 100644 --- a/nativebridge/Android.mk +++ b/nativebridge/Android.mk @@ -16,7 +16,7 @@ LOCAL_MODULE := libnb 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) diff --git a/nativebridge/src/libnb.cpp b/nativebridge/src/libnb.cpp index 72e334d..8172c92 100644 --- a/nativebridge/src/libnb.cpp +++ b/nativebridge/src/libnb.cpp @@ -15,6 +15,7 @@ #include #include +#include #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); - 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)