summaryrefslogtreecommitdiffstats
path: root/jni
diff options
context:
space:
mode:
authorSrinu Jella <sjella@codeaurora.org>2013-10-21 11:12:24 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:25:39 -0600
commit3a94fa0de7e0cace5b8ded0a8a439ec4479fa7dd (patch)
treec40125e7aa02ea1c652e94669137f9571cee8165 /jni
parent5e7a10563cd2f7f5a92a2343d91ec88641577dc3 (diff)
downloadandroid_packages_apps_Bluetooth-3a94fa0de7e0cace5b8ded0a8a439ec4479fa7dd.tar.gz
android_packages_apps_Bluetooth-3a94fa0de7e0cace5b8ded0a8a439ec4479fa7dd.tar.bz2
android_packages_apps_Bluetooth-3a94fa0de7e0cace5b8ded0a8a439ec4479fa7dd.zip
Socket: Add Get/Set socket option to the Blueooth Socket (4/4)
Add Get/Set socket option for the Bluetooth socket.These APIs will be called from the frameworks CRs-Fixed: 557180 Change-Id: I5ceef23d49e382089f479e8d618eec1dbc6ed5fb
Diffstat (limited to 'jni')
-rwxr-xr-xjni/com_android_bluetooth_btservice_AdapterService.cpp66
1 files changed, 65 insertions, 1 deletions
diff --git a/jni/com_android_bluetooth_btservice_AdapterService.cpp b/jni/com_android_bluetooth_btservice_AdapterService.cpp
index 3d7b1eeff..931c73e94 100755
--- a/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -1023,6 +1023,67 @@ static jboolean setDevicePropertyNative(JNIEnv *env, jobject obj, jbyteArray add
return result;
}
+static int getSocketOptNative(JNIEnv *env, jobject obj, jint type, jint channel, jint optionName,
+ jbyteArray optionVal) {
+ ALOGV("%s:",__FUNCTION__);
+
+ jbyte *option_val = NULL;
+ int option_len;
+ bt_status_t status;
+
+ if (!sBluetoothSocketInterface) return -1;
+
+ option_val = env->GetByteArrayElements(optionVal, NULL);
+ if (option_val == NULL) {
+ ALOGE("getSocketOptNative :jniThrowIOException ");
+ jniThrowIOException(env, EINVAL);
+ return -1;
+ }
+
+ if ( (status = sBluetoothSocketInterface->get_sock_opt((btsock_type_t)type, channel,
+ (btsock_option_type_t) optionName, (void *) option_val, &option_len)) !=
+ BT_STATUS_SUCCESS) {
+ ALOGE("get_sock_opt failed: %d", status);
+ goto Fail;
+ }
+ env->ReleaseByteArrayElements(optionVal, option_val, 0);
+
+ return option_len;
+Fail:
+ env->ReleaseByteArrayElements(optionVal, option_val, 0);
+ return -1;
+}
+
+static int setSocketOptNative(JNIEnv *env, jobject obj, jint type, jint channel, jint optionName,
+ jbyteArray optionVal, jint optionLen) {
+ ALOGV("%s:",__FUNCTION__);
+
+ jbyte *option_val = NULL;
+ bt_status_t status;
+
+ if (!sBluetoothSocketInterface) return -1;
+
+ option_val = env->GetByteArrayElements(optionVal, NULL);
+ if (option_val == NULL) {
+ ALOGE("setSocketOptNative:jniThrowIOException ");
+ jniThrowIOException(env, EINVAL);
+ return -1;
+ }
+
+ if ( (status = sBluetoothSocketInterface->set_sock_opt((btsock_type_t)type, channel,
+ (btsock_option_type_t) optionName, (void *) option_val, optionLen)) !=
+ BT_STATUS_SUCCESS) {
+ ALOGE("set_sock_opt failed: %d", status);
+ goto Fail;
+ }
+ env->ReleaseByteArrayElements(optionVal, option_val, 0);
+
+ return 0;
+Fail:
+ env->ReleaseByteArrayElements(optionVal, option_val, 0);
+ return -1;
+}
+
static jboolean getRemoteServicesNative(JNIEnv *env, jobject obj, jbyteArray address) {
ALOGV("%s:",__FUNCTION__);
@@ -1199,7 +1260,10 @@ static JNINativeMethod sMethods[] = {
{"alarmFiredNative", "()V", (void *) alarmFiredNative},
{"readEnergyInfo", "()I", (void*) readEnergyInfo},
{"dumpNative", "(Ljava/io/FileDescriptor;)V", (void*) dumpNative},
- {"factoryResetNative", "()Z", (void*)factoryResetNative}
+ {"factoryResetNative", "()Z", (void*)factoryResetNative},
+ {"getSocketOptNative", "(III[B)I", (void*) getSocketOptNative},
+ {"setSocketOptNative", "(III[BI)I", (void*) setSocketOptNative}
+
};
int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env)