diff options
author | Paul Jensen <pauljensen@google.com> | 2014-05-20 11:25:35 -0400 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2014-05-29 18:53:57 +0000 |
commit | 2d6f265d00db883616989788595ead4f3af902a0 (patch) | |
tree | 3f3d6b192f80d768ce4ca4453565fa584b1aef05 /core/jni | |
parent | c7b1b7aeec62677bad38d571e561653763392bf0 (diff) | |
download | frameworks_base-2d6f265d00db883616989788595ead4f3af902a0.zip frameworks_base-2d6f265d00db883616989788595ead4f3af902a0.tar.gz frameworks_base-2d6f265d00db883616989788595ead4f3af902a0.tar.bz2 |
Implement bind-to-network functionality of android.net.Network.
This is implemented by calling through to netd_client.
Included are functions to bind-to-network-for-process strictly for DNS to
facilitate startUsingNetworkFeature() reimplementation.
bug: 13885501
Change-Id: Ib22c7d02ea81d251bdfeeb0f64a47ce32eefcb1b
(cherry picked from commit dbf76f898f1f57eb74722358087c926d2f529bda)
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/Android.mk | 3 | ||||
-rw-r--r-- | core/jni/android_net_NetUtils.cpp | 38 |
2 files changed, 41 insertions, 0 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index a159715..f446c3a 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -173,8 +173,10 @@ LOCAL_C_INCLUDES += \ $(call include-path-for, bluedroid) \ $(call include-path-for, libhardware)/hardware \ $(call include-path-for, libhardware_legacy)/hardware_legacy \ + $(TOP)/bionic/libc/dns/include \ $(TOP)/frameworks/av/include \ $(TOP)/system/media/camera/include \ + $(TOP)/system/netd/include \ external/pdfium/core/include/fpdfapi \ external/pdfium/core/include/fpdfdoc \ external/pdfium/fpdfsdk/include \ @@ -233,6 +235,7 @@ LOCAL_SHARED_LIBRARIES := \ libaudioutils \ libpdfium \ libimg_utils \ + libnetd_client \ ifeq ($(USE_OPENGL_RENDERER),true) LOCAL_SHARED_LIBRARIES += libhwui diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp index 6d23c32..bc5e1b3 100644 --- a/core/jni/android_net_NetUtils.cpp +++ b/core/jni/android_net_NetUtils.cpp @@ -18,6 +18,8 @@ #include "jni.h" #include "JNIHelp.h" +#include "NetdClient.h" +#include "resolv_netid.h" #include <utils/misc.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> @@ -250,6 +252,36 @@ static void android_net_utils_markSocket(JNIEnv *env, jobject thiz, jint socket, } } +static void android_net_utils_bindProcessToNetwork(JNIEnv *env, jobject thiz, jint netId) +{ + setNetworkForProcess(netId); +} + +static void android_net_utils_unbindProcessToNetwork(JNIEnv *env, jobject thiz) +{ + setNetworkForProcess(NETID_UNSET); +} + +static jint android_net_utils_getNetworkBoundToProcess(JNIEnv *env, jobject thiz) +{ + return getNetworkForProcess(); +} + +static void android_net_utils_bindProcessToNetworkForHostResolution(JNIEnv *env, jobject thiz, jint netId) +{ + setNetworkForResolv(netId); +} + +static void android_net_utils_unbindProcessToNetworkForHostResolution(JNIEnv *env, jobject thiz) +{ + setNetworkForResolv(NETID_UNSET); +} + +static void android_net_utils_bindSocketToNetwork(JNIEnv *env, jobject thiz, jint socket, jint netId) +{ + setNetworkForSocket(netId, socket); +} + // ---------------------------------------------------------------------------- /* @@ -267,6 +299,12 @@ static JNINativeMethod gNetworkUtilMethods[] = { { "releaseDhcpLease", "(Ljava/lang/String;)Z", (void *)android_net_utils_releaseDhcpLease }, { "getDhcpError", "()Ljava/lang/String;", (void*) android_net_utils_getDhcpError }, { "markSocket", "(II)V", (void*) android_net_utils_markSocket }, + { "bindProcessToNetwork", "(I)V", (void*) android_net_utils_bindProcessToNetwork }, + { "getNetworkBoundToProcess", "()I", (void*) android_net_utils_getNetworkBoundToProcess }, + { "unbindProcessToNetwork", "()V", (void*) android_net_utils_unbindProcessToNetwork }, + { "bindProcessToNetworkForHostResolution", "(I)V", (void*) android_net_utils_bindProcessToNetworkForHostResolution }, + { "unbindProcessToNetworkForHostResolution", "()V", (void*) android_net_utils_unbindProcessToNetworkForHostResolution }, + { "bindSocketToNetwork", "(II)V", (void*) android_net_utils_bindSocketToNetwork }, }; int register_android_net_NetworkUtils(JNIEnv* env) |