Use original jni
diff --git a/jni/Android.mk b/jni/Android.mk
index cb5feac..b90926e 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -5,7 +5,6 @@
LOCAL_SRC_FILES:= \
com_android_bluetooth_btservice_AdapterService.cpp \
com_android_bluetooth_hfp.cpp \
- com_android_bluetooth_hfpclient.cpp \
com_android_bluetooth_a2dp.cpp \
com_android_bluetooth_avrcp.cpp \
com_android_bluetooth_hid.cpp \
diff --git a/jni/com_android_bluetooth.h b/jni/com_android_bluetooth.h
index ce3bbb0..506cddd 100644
--- a/jni/com_android_bluetooth.h
+++ b/jni/com_android_bluetooth.h
@@ -1,6 +1,4 @@
/*
- * Copyright (C) 2013 The Linux Foundation. All rights reserved
- * Not a Contribution.
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,8 +33,6 @@
int register_com_android_bluetooth_hfp(JNIEnv* env);
-int register_com_android_bluetooth_hfpclient(JNIEnv* env);
-
int register_com_android_bluetooth_a2dp(JNIEnv* env);
int register_com_android_bluetooth_avrcp(JNIEnv* env);
diff --git a/jni/com_android_bluetooth_a2dp.cpp b/jni/com_android_bluetooth_a2dp.cpp
index 28c03ae..415f6fe 100644
--- a/jni/com_android_bluetooth_a2dp.cpp
+++ b/jni/com_android_bluetooth_a2dp.cpp
@@ -28,7 +28,6 @@
namespace android {
static jmethodID method_onConnectionStateChanged;
static jmethodID method_onAudioStateChanged;
-static jmethodID method_onCheckConnectionPriority;
static const btav_interface_t *sBluetoothA2dpInterface = NULL;
static jobject mCallbacksObj = NULL;
@@ -94,33 +93,10 @@
sCallbackEnv->DeleteLocalRef(addr);
}
-static void bta2dp_connection_priority_callback(bt_bdaddr_t* bd_addr) {
- jbyteArray addr;
-
- ALOGI("%s", __FUNCTION__);
-
- if (!checkCallbackThread()) { \
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); \
- return; \
- }
- addr = sCallbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
- if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr for connection state");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
-
- sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte*) bd_addr);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCheckConnectionPriority, addr);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(addr);
-}
-
static btav_callbacks_t sBluetoothA2dpCallbacks = {
sizeof(sBluetoothA2dpCallbacks),
bta2dp_connection_state_callback,
- bta2dp_audio_state_callback,
- bta2dp_connection_priority_callback
+ bta2dp_audio_state_callback
};
static void classInitNative(JNIEnv* env, jclass clazz) {
@@ -133,9 +109,6 @@
method_onAudioStateChanged =
env->GetMethodID(clazz, "onAudioStateChanged", "(I[B)V");
-
- method_onCheckConnectionPriority =
- env->GetMethodID(clazz, "onCheckConnectionPriority", "([B)V");
/*
if ( (btInf = getBluetoothInterface()) == NULL) {
ALOGE("Bluetooth module is not loaded");
@@ -252,30 +225,18 @@
}
if ( (status = sBluetoothA2dpInterface->disconnect((bt_bdaddr_t *)addr)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed A2DP disconnection, status: %d", status);
+ ALOGE("Failed HF disconnection, status: %d", status);
}
env->ReleaseByteArrayElements(address, addr, 0);
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
-static void allowConnectionNative(JNIEnv *env, jobject object, int is_valid) {
-
- if (!sBluetoothA2dpInterface) {
- ALOGE("sBluetoothA2dpInterface is NULL ");
- return;
- }
-
- sBluetoothA2dpInterface->allow_connection(is_valid);
-
-}
-
static JNINativeMethod sMethods[] = {
{"classInitNative", "()V", (void *) classInitNative},
{"initNative", "()V", (void *) initNative},
{"cleanupNative", "()V", (void *) cleanupNative},
{"connectA2dpNative", "([B)Z", (void *) connectA2dpNative},
{"disconnectA2dpNative", "([B)Z", (void *) disconnectA2dpNative},
- {"allowConnectionNative", "(I)V", (void *) allowConnectionNative},
};
int register_com_android_bluetooth_a2dp(JNIEnv* env)
diff --git a/jni/com_android_bluetooth_avrcp.cpp b/jni/com_android_bluetooth_avrcp.cpp
index e4312d1..c077bc6 100644
--- a/jni/com_android_bluetooth_avrcp.cpp
+++ b/jni/com_android_bluetooth_avrcp.cpp
@@ -28,18 +28,10 @@
namespace android {
static jmethodID method_getRcFeatures;
static jmethodID method_getPlayStatus;
-static jmethodID method_onListPlayerAttributeRequest;
static jmethodID method_getElementAttr;
static jmethodID method_registerNotification;
static jmethodID method_volumeChangeCallback;
static jmethodID method_handlePassthroughCmd;
-static jmethodID method_getFolderItems;
-static jmethodID method_setAddressedPlayer;
-static jmethodID method_onListPlayerAttributeValues;
-static jmethodID method_onGetPlayerAttributeValues;
-static jmethodID method_setPlayerAppSetting;
-static jmethodID method_getplayerattribute_text;
-static jmethodID method_getplayervalue_text;
static const btrc_interface_t *sBluetoothAvrcpInterface = NULL;
static jobject mCallbacksObj = NULL;
@@ -89,115 +81,6 @@
checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
}
-static void btavrcp_get_player_seeting_value_callback(btrc_player_attr_t player_att) {
- ALOGI("%s", __FUNCTION__);
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
- sCallbackEnv->CallVoidMethod(mCallbacksObj ,method_onListPlayerAttributeValues , (jbyte)player_att );
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void btavrcp_get_player_attribute_id_callback() {
- ALOGI("%s", __FUNCTION__);
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
- sCallbackEnv->CallVoidMethod(mCallbacksObj,method_onListPlayerAttributeRequest );
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void btavrcp_getcurrent_player_app_setting_values( uint8_t num_attr,
- btrc_player_attr_t *p_attrs) {
- jintArray attrs;
- ALOGI("%s", __FUNCTION__);
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
- attrs = (jintArray)sCallbackEnv->NewIntArray(num_attr);
- if (!attrs) {
- ALOGE("Fail to new jintArray for attrs");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
- sCallbackEnv->SetIntArrayRegion(attrs, 0, num_attr, (jint *)p_attrs);
- sCallbackEnv->CallVoidMethod(mCallbacksObj,method_onGetPlayerAttributeValues,
- (jbyte)num_attr,attrs );
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(attrs);
-}
-
-static void btavrcp_set_playerapp_setting_value_callback(btrc_player_settings_t *attr)
-{
- jbyteArray attrs_ids;
- jbyteArray attrs_value;
- ALOGI("%s", __FUNCTION__);
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
- attrs_ids = (jbyteArray)sCallbackEnv->NewByteArray(attr->num_attr);
- if (!attrs_ids) {
- ALOGE("Fail to new jintArray for attrs");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
- sCallbackEnv->SetByteArrayRegion(attrs_ids, 0, attr->num_attr, (jbyte *)attr->attr_ids);
- attrs_value = (jbyteArray)sCallbackEnv->NewByteArray(attr->num_attr);
- if (!attrs_value) {
- ALOGE("Fail to new jintArray for attrs");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
- sCallbackEnv->SetByteArrayRegion(attrs_value, 0, attr->num_attr, (jbyte *)attr->attr_values);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_setPlayerAppSetting, (jbyte)attr->num_attr,
- attrs_ids ,attrs_value );
- sCallbackEnv->DeleteLocalRef(attrs_ids);
- sCallbackEnv->DeleteLocalRef(attrs_value);
-}
-
-static void btavrcp_getPlayer_app_attribute_text(uint8_t num , btrc_player_attr_t *att)
-{
- jbyteArray attrs;
- ALOGI("%s", __FUNCTION__);
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
- attrs = (jbyteArray)sCallbackEnv->NewByteArray(num);
- if (!attrs) {
- ALOGE("Fail to new jintArray for attrs");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
- sCallbackEnv->SetByteArrayRegion(attrs, 0, num, (jbyte *)att);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_getplayerattribute_text,(jbyte) num ,attrs );
- sCallbackEnv->DeleteLocalRef(attrs);
-}
-
-static void btavrcp_getPlayer_app_value_text(uint8_t attr_id , uint8_t num_val , uint8_t *value)
-{
- jbyteArray Attr_Value ;
- ALOGI("%s", __FUNCTION__);
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
- Attr_Value = (jbyteArray)sCallbackEnv->NewByteArray(num_val);
- if (!Attr_Value) {
- ALOGE("Fail to new jintArray for attrs");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
- sCallbackEnv->SetByteArrayRegion(Attr_Value, 0, num_val, (jbyte *)value);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_getplayervalue_text,(jbyte) attr_id,
- (jbyte) num_val , Attr_Value );
- sCallbackEnv->DeleteLocalRef(Attr_Value);
-}
-
static void btavrcp_get_element_attr_callback(uint8_t num_attr, btrc_media_attr_t *p_attrs) {
jintArray attrs;
@@ -245,27 +128,6 @@
checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
}
-
-static void btavrcp_get_folder_items_callback(btrc_browse_folderitem_t scope , btrc_getfolderitem_t *param) {
- jint start = param->start_item;
- jint end = param->end_item;
- jint size = param->size;
-
- ALOGI("%s", __FUNCTION__);
- ALOGI("scope: %d", scope);
- ALOGI("start entry: %d", start);
- ALOGI("end entry: %d", end);
- ALOGI("size: %d", size);
-
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
-
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_getFolderItems, (jbyte)scope,
- start, end, size);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
static void btavrcp_passthrough_command_callback(int id, int pressed) {
ALOGI("%s", __FUNCTION__);
@@ -279,35 +141,20 @@
checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
}
-static void btavrcp_set_addressed_player_callback(uint32_t player_id) {
- ALOGI("%s", __FUNCTION__);
- ALOGI("player id: %d", player_id);
-
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
-
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_setAddressedPlayer, (jint)player_id);
-
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
static btrc_callbacks_t sBluetoothAvrcpCallbacks = {
sizeof(sBluetoothAvrcpCallbacks),
btavrcp_remote_features_callback,
btavrcp_get_play_status_callback,
- btavrcp_get_player_attribute_id_callback,
- btavrcp_get_player_seeting_value_callback,
- btavrcp_getcurrent_player_app_setting_values,
- btavrcp_getPlayer_app_attribute_text,
- btavrcp_getPlayer_app_value_text,
- btavrcp_set_playerapp_setting_value_callback,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
btavrcp_get_element_attr_callback,
btavrcp_register_notification_callback,
btavrcp_volume_change_callback,
- btavrcp_passthrough_command_callback,
- btavrcp_get_folder_items_callback,
- btavrcp_set_addressed_player_callback
+ btavrcp_passthrough_command_callback
};
static void classInitNative(JNIEnv* env, jclass clazz) {
@@ -315,36 +162,19 @@
env->GetMethodID(clazz, "getRcFeatures", "([BI)V");
method_getPlayStatus =
env->GetMethodID(clazz, "getPlayStatus", "()V");
- method_onListPlayerAttributeRequest =
- env->GetMethodID(clazz , "onListPlayerAttributeRequest" , "()V");
- method_onListPlayerAttributeValues =
- env->GetMethodID(clazz , "onListPlayerAttributeValues" , "(B)V");
+
method_getElementAttr =
env->GetMethodID(clazz, "getElementAttr", "(B[I)V");
- method_setPlayerAppSetting =
- env->GetMethodID(clazz, "setPlayerAppSetting","(B[B[B)V");
- method_getplayerattribute_text =
- env->GetMethodID(clazz, "getplayerattribute_text" , "(B[B)V");
- method_getplayervalue_text =
- env->GetMethodID(clazz, "getplayervalue_text" , "(BB[B)V");
+
method_registerNotification =
env->GetMethodID(clazz, "registerNotification", "(II)V");
- method_onGetPlayerAttributeValues =
- env->GetMethodID(clazz, "onGetPlayerAttributeValues", "(B[I)V");
+
method_volumeChangeCallback =
env->GetMethodID(clazz, "volumeChangeCallback", "(II)V");
method_handlePassthroughCmd =
env->GetMethodID(clazz, "handlePassthroughCmd", "(II)V");
- //setAddressedPlayer: attributes to pass: Player ID
- method_setAddressedPlayer =
- env->GetMethodID(clazz, "setAddressedPlayer", "(I)V");
-
- //getFolderItems: attributes to pass: Scope, Start, End, Attr Cnt
- method_getFolderItems =
- env->GetMethodID(clazz, "getFolderItems", "(BIII)V");
-
ALOGI("%s: succeeds", __FUNCTION__);
}
@@ -419,244 +249,6 @@
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
-
-static jboolean getListPlayerappAttrRspNative(JNIEnv *env ,jobject object , jbyte numAttr,
- jbyteArray attrIds ) {
- bt_status_t status;
- btrc_player_attr_t *pAttrs = NULL;
- int i;
- jbyte *attr;
-
- if (!sBluetoothAvrcpInterface) return JNI_FALSE;
- if( numAttr > BTRC_MAX_APP_ATTR_SIZE) {
- ALOGE("get_element_attr_rsp: number of attributes exceed maximum");
- return JNI_FALSE;
- }
- ALOGI("getListPlayerappAttrRspNative");
- pAttrs = new btrc_player_attr_t[numAttr];
- if (!pAttrs) {
- ALOGE("getListPlayerappAttrRspNative: not have enough memeory");
- return JNI_FALSE;
- }
- attr = env->GetByteArrayElements(attrIds, NULL);
- if( !attr) {
- delete[] pAttrs;
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE ;
- }
- for (i = 0; i < numAttr; ++i) {
- pAttrs[i] = (btrc_player_attr_t)attr[i];
- }
- if (i < numAttr) {
- delete[] pAttrs;
- env->ReleaseByteArrayElements(attrIds, attr, 0);
- return JNI_FALSE;
- }
- //Call Stack Method
- if ((status = sBluetoothAvrcpInterface->list_player_app_attr_rsp(numAttr, pAttrs)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed getelementattrrsp, status: %d", status);
- }
- delete[] pAttrs;
- env->ReleaseByteArrayElements(attrIds, attr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-
-static jboolean getPlayerAppValueRspNative(JNIEnv *env ,jobject object , jbyte numvalue,
- jbyteArray value)
-{
- bt_status_t status;
- uint8_t *pAttrs = NULL;
- int i;
- jbyte *attr;
-
- if( numvalue > BTRC_MAX_APP_ATTR_SIZE) {
- ALOGE("get_element_attr_rsp: number of attributes exceed maximum");
- return JNI_FALSE;
- }
- pAttrs = new uint8_t[numvalue];
- if (!pAttrs) {
- ALOGE("getPlayerAppValueRspNative: not have enough memeory");
- return JNI_FALSE;
- }
- attr = env->GetByteArrayElements(value, NULL);
- if (!attr) {
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
- for (i = 0; i < numvalue; ++i) {
- pAttrs[i] = (uint8_t)attr[i];
- }
- if (i < numvalue) {
- delete[] pAttrs;
- env->ReleaseByteArrayElements(value, attr, 0);
- return JNI_FALSE;
- }
- if ((status = sBluetoothAvrcpInterface->list_player_app_value_rsp(numvalue, pAttrs)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed get_element_attr_rsp, status: %d", status);
- }
- delete[] pAttrs;
- env->ReleaseByteArrayElements(value, attr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean SendCurrentPlayerValueRspNative(JNIEnv *env, jobject object ,
- jbyte numattr ,jbyteArray value) {
- btrc_player_settings_t *pAttrs = NULL ;
- bt_status_t status;
- int i;
- jbyte *attr;
-
- if( numattr > BTRC_MAX_APP_ATTR_SIZE || numattr == 0) {
- ALOGE("SendCurrentPlayerValueRspNative: number of attributes exceed maximum");
- return JNI_FALSE;
- }
- pAttrs = new btrc_player_settings_t;
- if (!pAttrs) {
- ALOGE("SendCurrentPlayerValueRspNative: not have enough memeory");
- return JNI_FALSE;
- }
- attr = env->GetByteArrayElements(value, NULL);
- if (!attr) {
- delete[] pAttrs;
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
- pAttrs->num_attr = numattr/2 ;
- for(i =0 ; i < numattr; i+=2)
- {
- pAttrs->attr_ids[i/2] = attr[i];
- pAttrs->attr_values[i/2] = attr[i+1];
- }
- if ((status = sBluetoothAvrcpInterface->get_player_app_value_rsp(pAttrs)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed get_element_attr_rsp, status: %d", status);
- }
- delete[] pAttrs;
- env->ReleaseByteArrayElements(value, attr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-
-//JNI Method called to Respond to PDU 0x14
-static jboolean SendSetPlayerAppRspNative(JNIEnv *env, jobject object)
-{
- bt_status_t status;
- btrc_status_t player_rsp = BTRC_STS_NO_ERROR;
- if ((status = sBluetoothAvrcpInterface->set_player_app_value_rsp(player_rsp)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed get_element_attr_rsp, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-
-//JNI Method Called to Respond to PDU 0x15
-static jboolean sendSettingsTextRspNative(JNIEnv *env, jobject object, jint num_attr,
- jbyteArray attr,jint length , jobjectArray textArray ) {
- btrc_player_setting_text_t *pAttrs = NULL;
- bt_status_t status;
- int i;
- jstring text ;
- const char* textStr;
- jbyte *arr ;
- //ALOGE("sendSettingsTextRspNative");
- if (!sBluetoothAvrcpInterface) return JNI_FALSE;
- if (num_attr > BTRC_MAX_ELEM_ATTR_SIZE) {
- ALOGE("get_element_attr_rsp: number of attributes exceed maximum");
- return JNI_FALSE;
- }
- pAttrs = new btrc_player_setting_text_t[num_attr];
- arr = env->GetByteArrayElements(attr, NULL);
- if (!arr) {
- delete[] pAttrs;
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
- for (i = 0; i < num_attr ; ++i) {
- text = (jstring) env->GetObjectArrayElement(textArray, i);
- textStr = env->GetStringUTFChars(text, NULL);
- if (!textStr) {
- ALOGE("get_element_attr_rsp: GetStringUTFChars return NULL");
- env->DeleteLocalRef(text);
- break;
- }
- pAttrs[i].id = arr[i];
- if (strlen(textStr) >= BTRC_MAX_ATTR_STR_LEN) {
- ALOGE("sendSettingsTextRspNative: string length exceed maximum");
- strncpy((char *)pAttrs[i].text, textStr, BTRC_MAX_ATTR_STR_LEN-1);
- pAttrs[i].text[BTRC_MAX_ATTR_STR_LEN-1] = 0;
- } else {
- strcpy((char *)pAttrs[i].text, textStr);
- }
- //Check out if release need to be done in for loop
- env->ReleaseStringUTFChars(text, textStr);
- env->DeleteLocalRef(text);
- }
- //Call Stack Methos to Respond PDU 0x16
- if ((status = sBluetoothAvrcpInterface->get_player_app_attr_text_rsp(num_attr, pAttrs))
- != BT_STATUS_SUCCESS) {
- ALOGE("Failed get_element_attr_rsp, status: %d", status);
- }
- delete[] pAttrs;
- env->ReleaseByteArrayElements(attr, arr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-//JNI Method Called to respond to PDU 0x16
-static jboolean sendValueTextRspNative(JNIEnv *env, jobject object, jint num_attr,
- jbyteArray attr, jint length , jobjectArray textArray ) {
- btrc_player_setting_text_t *pAttrs = NULL;
- bt_status_t status;
- int i;
- jstring text ;
- const char* textStr;
- jbyte *arr ;
-
- //ALOGE("sendValueTextRspNative");
- if (!sBluetoothAvrcpInterface) return JNI_FALSE;
- if (num_attr > BTRC_MAX_ELEM_ATTR_SIZE) {
- ALOGE("sendValueTextRspNative: number of attributes exceed maximum");
- return JNI_FALSE;
- }
- pAttrs = new btrc_player_setting_text_t[num_attr];
- arr = env->GetByteArrayElements(attr, NULL);
- if (!arr) {
- delete[] pAttrs;
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
- for (i = 0; i < num_attr ; ++i) {
- text = (jstring) env->GetObjectArrayElement(textArray, i);
- textStr = env->GetStringUTFChars(text, NULL);
- if (!textStr) {
- ALOGE("sendValueTextRspNative: GetStringUTFChars return NULL");
- env->DeleteLocalRef(text);
- break;
- }
- pAttrs[i].id = arr[i];
- if (strlen(textStr) >= BTRC_MAX_ATTR_STR_LEN) {
- ALOGE("sendValueTextRspNative: string length exceed maximum");
- strncpy((char *)pAttrs[i].text, textStr, BTRC_MAX_ATTR_STR_LEN-1);
- pAttrs[i].text[BTRC_MAX_ATTR_STR_LEN-1] = 0;
- } else {
- strcpy((char *)pAttrs[i].text, textStr);
- }
- env->ReleaseStringUTFChars(text, textStr);
- env->DeleteLocalRef(text);
- }
- //Call Stack Method to Respond to PDU 0x16
- if ((status = sBluetoothAvrcpInterface->get_player_app_value_text_rsp(num_attr, pAttrs))
- != BT_STATUS_SUCCESS) {
- ALOGE("Failed get_element_attr_rsp, status: %d", status);
- }
- delete[] pAttrs;
- env->ReleaseByteArrayElements(attr, arr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
static jboolean getElementAttrRspNative(JNIEnv *env, jobject object, jbyte numAttr,
jintArray attrIds, jobjectArray textArray) {
jint *attr;
@@ -723,45 +315,6 @@
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
-static jboolean registerNotificationPlayerAppRspNative(JNIEnv *env, jobject object ,jint type,
- jbyte numattr ,jbyteArray value) {
- bt_status_t status;
- int i;
- jbyte *attr;
- btrc_register_notification_t *param= NULL;
-
- if( numattr > BTRC_MAX_APP_ATTR_SIZE || numattr == 0) {
- ALOGE("registerNotificationPlayerAppRspNative: number of attributes exceed maximum");
- return JNI_FALSE;
- }
- param = new btrc_register_notification_t;
-
- if (!param) {
- ALOGE("registerNotificationPlayerAppRspNative: not have enough memeory");
- return JNI_FALSE;
- }
- attr = env->GetByteArrayElements(value, NULL);
- if (!attr) {
- delete[] param;
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
- param->player_setting.num_attr = numattr/2;
- for(i =0 ; i < numattr; i+=2)
- {
- param->player_setting.attr_ids[i/2] = attr[i];
- param->player_setting.attr_values[i/2] = attr[i+1];
- }
- //Call Stack Method
- if ((status = sBluetoothAvrcpInterface->register_notification_rsp(BTRC_EVT_APP_SETTINGS_CHANGED,
- (btrc_notification_type_t)type,param)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed get_element_attr_rsp, status: %d", status);
- }
- delete[] param;
- env->ReleaseByteArrayElements(value, attr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
static jboolean registerNotificationRspPlayStatusNative(JNIEnv *env, jobject object,
jint type, jint playStatus) {
bt_status_t status;
@@ -841,172 +394,20 @@
return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
-static jboolean registerNotificationRspAddressedPlayerChangedNative (JNIEnv *env,
- jobject object, jint type, jint playerId) {
- bt_status_t status;
- btrc_register_notification_t param;
-
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __FUNCTION__, sBluetoothAvrcpInterface);
- ALOGI("playerId: %d", playerId);
- if (!sBluetoothAvrcpInterface) return JNI_FALSE;
-
- param.player_id = (uint16_t)playerId;
- if ((status = sBluetoothAvrcpInterface->register_notification_rsp(BTRC_EVT_ADDRESSED_PLAYER_CHANGED,
- (btrc_notification_type_t)type, ¶m)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed registerNotificationRspAddressedPlayerChangedNative, status: %d", status);
- }
-
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-
-}
-
-static jboolean registerNotificationRspAvailablePlayersChangedNative (JNIEnv *env,
- jobject object, jint type) {
- bt_status_t status;
- btrc_register_notification_t param;
-
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __FUNCTION__, sBluetoothAvrcpInterface);
- if (!sBluetoothAvrcpInterface) return JNI_FALSE;
- if ((status = sBluetoothAvrcpInterface->register_notification_rsp(BTRC_EVT_AVAILABLE_PLAYERS_CHANGED,
- (btrc_notification_type_t)type, ¶m)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed registerNotificationRspAvailablePlayersChangedNative, status: %d", status);
- }
-
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-// FolderItems are populated as byte stream from the apps
-static jboolean getFolderItemsRspNative(JNIEnv *env, jobject object, jbyte statusCode, jint uidCounter,
- jint itemCount, jbooleanArray folderItems, jintArray folderItemLengths) {
- bt_status_t status;
- uint8_t *folderElements;
- int32_t *folderElementLengths;
- int32_t count = 0;
- int32_t countElementLength = 0;
- int32_t countTotalBytes = 0;
- int32_t countTemp = 0;
- int32_t checkLength = 0;
- btrc_folder_list_entries_t param;
-
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __FUNCTION__, sBluetoothAvrcpInterface);
- if (!sBluetoothAvrcpInterface) return JNI_FALSE;
-
- folderElements = env->GetBooleanArrayElements(folderItems, NULL);
- if (!folderElements) {
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
-
- folderElementLengths = env->GetIntArrayElements(folderItemLengths, NULL);
- if (!folderElementLengths) {
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
-
- param.status = statusCode;
- param.uid_counter = uidCounter;
- param.item_count = itemCount;
- ALOGI("status: %d, item count: %d", param.status, param.item_count);
- param.p_item_list = new btrc_folder_list_item_t[itemCount];
- ALOGI("Intermediate List entries:");
- for (; count < itemCount; count++) {
- param.p_item_list[count].item_type = folderElements[countTotalBytes]; countTotalBytes++;
- param.p_item_list[count].player.player_id = (uint16_t)(folderElements[countTotalBytes] & 0x00ff); countTotalBytes++;
- param.p_item_list[count].player.player_id += (uint16_t)((folderElements[countTotalBytes] << 8) & 0xff00); countTotalBytes++;
- param.p_item_list[count].player.major_type = folderElements[countTotalBytes]; countTotalBytes++;
- param.p_item_list[count].player.sub_type = (uint32_t)(folderElements[countTotalBytes] & 0x000000ff); countTotalBytes++;
- param.p_item_list[count].player.sub_type += (uint32_t)((folderElements[countTotalBytes] << 8) & 0x0000ff00); countTotalBytes++;
- param.p_item_list[count].player.sub_type += (uint32_t)((folderElements[countTotalBytes] << 16) & 0x00ff0000); countTotalBytes++;
- param.p_item_list[count].player.sub_type += (uint32_t)((folderElements[countTotalBytes] << 24) & 0xff000000); countTotalBytes++;
- param.p_item_list[count].player.play_status = folderElements[countTotalBytes]; countTotalBytes++;
- for (countTemp = 0; countTemp < 16; countTemp ++) {
- param.p_item_list[count].player.features[countTemp] = folderElements[countTotalBytes]; countTotalBytes++;
- }
- param.p_item_list[count].player.name.charset_id = (uint16_t)(folderElements[countTotalBytes] & 0x00ff); countTotalBytes++;
- param.p_item_list[count].player.name.charset_id += (uint16_t)((folderElements[countTotalBytes] << 8) & 0xff00); countTotalBytes++;
- param.p_item_list[count].player.name.str_len = (uint16_t)(folderElements[countTotalBytes] & 0x00ff); countTotalBytes++;
- param.p_item_list[count].player.name.str_len += (uint16_t)((folderElements[countTotalBytes] << 8) & 0xff00); countTotalBytes++;
- param.p_item_list[count].player.name.p_str = new uint8_t[param.p_item_list[count].player.name.str_len];
- for (countTemp = 0; countTemp < param.p_item_list[count].player.name.str_len; countTemp ++) {
- param.p_item_list[count].player.name.p_str[countTemp] = folderElements[countTotalBytes]; countTotalBytes++;
- }
- /*To check if byte feeding went well*/
- checkLength += folderElementLengths[count];
- if (checkLength != countTotalBytes) {
- ALOGE("Error Populating Intermediate Folder Entry");
- ALOGE("checkLength = %u countTotalBytes = %u", checkLength, countTotalBytes);
- }
- ALOGI("entry: %u", count);
- ALOGI("item type: %u", param.p_item_list[count].item_type);
- ALOGI("player id: %u", param.p_item_list[count].player.player_id);
- ALOGI("major type: %u", param.p_item_list[count].player.major_type);
- ALOGI("sub type: %u", param.p_item_list[count].player.sub_type);
- ALOGI("play status: %u", param.p_item_list[count].player.play_status);
- ALOGI("features: ");
- for (countTemp = 0; countTemp < 16; countTemp ++)
- ALOGI("%u", param.p_item_list[count].player.features[countTemp]);
- ALOGI("charset id: %u", param.p_item_list[count].player.name.charset_id);
- ALOGI("name len: %u", param.p_item_list[count].player.name.str_len);
- ALOGI("name: ");
- for (countTemp = 0; countTemp < param.p_item_list[count].player.name.str_len; countTemp ++) {
- ALOGI("%u", param.p_item_list[count].player.name.p_str[countTemp]);
- }
- }
-
- if ((status = sBluetoothAvrcpInterface->get_folder_items_rsp(¶m)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed getFolderItemsRspNative, status: %u", status);
- }
-
- env->ReleaseBooleanArrayElements(folderItems, folderElements, 0);
- env->ReleaseIntArrayElements(folderItemLengths, folderElementLengths, 0);
-
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean setAdressedPlayerRspNative(JNIEnv *env, jobject object, jbyte statusCode) {
- bt_status_t status;
-
- ALOGI("%s: sBluetoothAvrcpInterface: %p", __FUNCTION__, sBluetoothAvrcpInterface);
- if (!sBluetoothAvrcpInterface) return JNI_FALSE;
-
- if ((status = sBluetoothAvrcpInterface->set_addressed_player_rsp((btrc_status_t)statusCode)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed setAdressedPlayerRspNative, status: %d", status);
- }
-
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
static JNINativeMethod sMethods[] = {
{"classInitNative", "()V", (void *) classInitNative},
{"initNative", "()V", (void *) initNative},
{"cleanupNative", "()V", (void *) cleanupNative},
{"getPlayStatusRspNative", "(III)Z", (void *) getPlayStatusRspNative},
{"getElementAttrRspNative", "(B[I[Ljava/lang/String;)Z", (void *) getElementAttrRspNative},
- {"getListPlayerappAttrRspNative", "(B[B)Z", (void *)getListPlayerappAttrRspNative},
- {"getPlayerAppValueRspNative", "(B[B)Z", (void *)getPlayerAppValueRspNative},
{"registerNotificationRspPlayStatusNative", "(II)Z",
(void *) registerNotificationRspPlayStatusNative},
- {"SendCurrentPlayerValueRspNative", "(B[B)Z",
- (void *)SendCurrentPlayerValueRspNative},
- {"registerNotificationPlayerAppRspNative", "(IB[B)Z",
- (void *)registerNotificationPlayerAppRspNative},
{"registerNotificationRspTrackChangeNative", "(I[B)Z",
(void *) registerNotificationRspTrackChangeNative},
- {"SendSetPlayerAppRspNative", "()Z",
- (void *) SendSetPlayerAppRspNative},
- {"sendSettingsTextRspNative" , "(I[BI[Ljava/lang/String;)Z",
- (void *)sendSettingsTextRspNative},
{"registerNotificationRspPlayPosNative", "(II)Z",
(void *) registerNotificationRspPlayPosNative},
{"setVolumeNative", "(I)Z",
- (void *) setVolumeNative},
- {"setAdressedPlayerRspNative", "(B)Z",
- (void *) setAdressedPlayerRspNative},
- {"getFolderItemsRspNative", "(BII[B[I)Z",
- (void *) getFolderItemsRspNative},
- {"registerNotificationRspAddressedPlayerChangedNative", "(II)Z",
- (void *) registerNotificationRspAddressedPlayerChangedNative},
- {"registerNotificationRspAvailablePlayersChangedNative", "(I)Z",
- (void *) registerNotificationRspAvailablePlayersChangedNative},
+ (void *) setVolumeNative}
};
int register_com_android_bluetooth_avrcp(JNIEnv* env)
diff --git a/jni/com_android_bluetooth_btservice_AdapterService.cpp b/jni/com_android_bluetooth_btservice_AdapterService.cpp
index 48e3eb3..28de5ea 100644
--- a/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -1,6 +1,4 @@
/*
- * Copyright (C) 2013 The Linux Foundation. All rights reserved
- * Not a Contribution.
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +17,6 @@
#define LOG_TAG "BluetoothServiceJni"
#include "com_android_bluetooth.h"
#include "hardware/bt_sock.h"
-#include "hardware/bt_mce.h"
#include "utils/Log.h"
#include "utils/misc.h"
#include "cutils/properties.h"
@@ -44,11 +41,9 @@
static jmethodID method_bondStateChangeCallback;
static jmethodID method_aclStateChangeCallback;
static jmethodID method_discoveryStateChangeCallback;
-static jmethodID method_deviceMasInstancesFoundCallback;
static const bt_interface_t *sBluetoothInterface = NULL;
static const btsock_interface_t *sBluetoothSocketInterface = NULL;
-static const btmce_interface_t *sBluetoothMceInterface = NULL;
static JNIEnv *callbackEnv = NULL;
static jobject sJniCallbacksObj;
@@ -350,7 +345,7 @@
checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__);
}
-static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t cod, uint8_t secure) {
+static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t cod) {
jbyteArray addr, devname;
if (!checkCallbackThread()) {
ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
@@ -370,7 +365,7 @@
callbackEnv->SetByteArrayRegion(devname, 0, sizeof(bt_bdname_t), (jbyte*)bdname);
- callbackEnv->CallVoidMethod(sJniCallbacksObj, method_pinRequestCallback, addr, devname, cod, secure);
+ callbackEnv->CallVoidMethod(sJniCallbacksObj, method_pinRequestCallback, addr, devname, cod);
checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__);
callbackEnv->DeleteLocalRef(addr);
@@ -461,78 +456,6 @@
le_test_mode_recv_callback
};
-static void remote_mas_instances_callback(bt_status_t status, bt_bdaddr_t *bd_addr,
- int num_instances, btmce_mas_instance_t *instances)
-{
- if (!checkCallbackThread()) {
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
- return;
- }
-
- ALOGV("%s: Status is: %d, Instances: %d", __FUNCTION__, status, num_instances);
-
- if (status != BT_STATUS_SUCCESS) {
- ALOGE("%s: Status %d is incorrect", __FUNCTION__, status);
- return;
- }
-
- callbackEnv->PushLocalFrame(ADDITIONAL_NREFS);
-
- jbyteArray addr = NULL;
- jobjectArray a_name = NULL;
- jintArray a_scn = NULL;
- jintArray a_masid = NULL;
- jintArray a_msgtype = NULL;
- jclass mclass;
-
- mclass = callbackEnv->FindClass("java/lang/String");
-
- addr = callbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
- if (addr == NULL) goto clean;
-
- callbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte*)bd_addr);
-
- a_name = callbackEnv->NewObjectArray(num_instances, mclass, NULL);
- if (a_name == NULL) goto clean;
-
- a_scn = callbackEnv->NewIntArray(num_instances);
- if (a_scn == NULL) goto clean;
-
- a_masid = callbackEnv->NewIntArray(num_instances);
- if (a_masid == NULL) goto clean;
-
- a_msgtype = callbackEnv->NewIntArray(num_instances);
- if (a_msgtype == NULL) goto clean;
-
- for (int i = 0; i < num_instances; i++) {
- jstring name = callbackEnv->NewStringUTF(instances[i].p_name);
-
- callbackEnv->SetObjectArrayElement(a_name, i, name);
- callbackEnv->SetIntArrayRegion(a_scn, i, 1, &instances[i].scn);
- callbackEnv->SetIntArrayRegion(a_masid, i, 1, &instances[i].id);
- callbackEnv->SetIntArrayRegion(a_msgtype, i, 1, &instances[i].msg_types);
-
- callbackEnv->DeleteLocalRef(name);
- }
-
- callbackEnv->CallVoidMethod(sJniCallbacksObj, method_deviceMasInstancesFoundCallback,
- (jint) status, addr, a_name, a_scn, a_masid, a_msgtype);
- checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__);
-
-clean:
- if (addr != NULL) callbackEnv->DeleteLocalRef(addr);
- if (a_name != NULL) callbackEnv->DeleteLocalRef(a_name);
- if (a_scn != NULL) callbackEnv->DeleteLocalRef(a_scn);
- if (a_masid != NULL) callbackEnv->DeleteLocalRef(a_masid);
- if (a_msgtype != NULL) callbackEnv->DeleteLocalRef(a_msgtype);
- callbackEnv->PopLocalFrame(NULL);
-}
-
-static btmce_callbacks_t sBluetoothMceCallbacks = {
- sizeof(sBluetoothMceCallbacks),
- remote_mas_instances_callback,
-};
-
static void classInitNative(JNIEnv* env, jclass clazz) {
int err;
hw_module_t* module;
@@ -555,7 +478,7 @@
"([B[I[[B)V");
method_deviceFoundCallback = env->GetMethodID(jniCallbackClass, "deviceFoundCallback", "([B)V");
method_pinRequestCallback = env->GetMethodID(jniCallbackClass, "pinRequestCallback",
- "([B[BIZ)V");
+ "([B[BI)V");
method_sspRequestCallback = env->GetMethodID(jniCallbackClass, "sspRequestCallback",
"([B[BIII)V");
@@ -564,11 +487,6 @@
method_aclStateChangeCallback = env->GetMethodID(jniCallbackClass,
"aclStateChangeCallback", "(I[BI)V");
-
- method_deviceMasInstancesFoundCallback = env->GetMethodID(jniCallbackClass,
- "deviceMasInstancesFoundCallback",
- "(I[B[Ljava/lang/String;[I[I[I)V");
-
char value[PROPERTY_VALUE_MAX];
property_get("bluetooth.mock_stack", value, "");
@@ -606,17 +524,6 @@
sBluetoothInterface->get_profile_interface(BT_PROFILE_SOCKETS_ID)) == NULL) {
ALOGE("Error getting socket interface");
}
-
- if ( (sBluetoothMceInterface = (btmce_interface_t *)
- sBluetoothInterface->get_profile_interface(BT_PROFILE_MAP_CLIENT_ID)) == NULL) {
- ALOGE("Error getting mapclient interface");
- } else {
- if ( (sBluetoothMceInterface->init(&sBluetoothMceCallbacks)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to initialize Bluetooth MCE");
- sBluetoothMceInterface = NULL;
- }
- }
-
return JNI_TRUE;
}
return JNI_FALSE;
@@ -899,67 +806,6 @@
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__);
@@ -979,25 +825,6 @@
return result;
}
-static jboolean getRemoteMasInstancesNative(JNIEnv *env, jobject obj, jbyteArray address) {
- ALOGV("%s:",__FUNCTION__);
-
- jbyte *addr = NULL;
- jboolean result = JNI_FALSE;
- if (!sBluetoothMceInterface) return result;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (addr == NULL) {
- jniThrowIOException(env, EINVAL);
- return result;
- }
-
- int ret = sBluetoothMceInterface->get_remote_mas_instances((bt_bdaddr_t *)addr);
- env->ReleaseByteArrayElements(address, addr, NULL);
- result = (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
- return result;
-}
-
static int connectSocketNative(JNIEnv *env, jobject object, jbyteArray address, jint type,
jbyteArray uuidObj, jint channel, jint flag) {
jbyte *addr = NULL, *uuid = NULL;
@@ -1112,13 +939,10 @@
{"pinReplyNative", "([BZI[B)Z", (void*) pinReplyNative},
{"sspReplyNative", "([BIZI)Z", (void*) sspReplyNative},
{"getRemoteServicesNative", "([B)Z", (void*) getRemoteServicesNative},
- {"getRemoteMasInstancesNative", "([B)Z", (void*) getRemoteMasInstancesNative},
{"connectSocketNative", "([BI[BII)I", (void*) connectSocketNative},
{"createSocketChannelNative", "(ILjava/lang/String;[BII)I",
(void*) createSocketChannelNative},
- {"configHciSnoopLogNative", "(Z)Z", (void*) configHciSnoopLogNative},
- {"getSocketOptNative", "(III[B)I", (void*) getSocketOptNative},
- {"setSocketOptNative", "(III[BI)I", (void*) setSocketOptNative}
+ {"configHciSnoopLogNative", "(Z)Z", (void*) configHciSnoopLogNative}
};
int register_com_android_bluetooth_btservice_AdapterService(JNIEnv* env)
@@ -1156,11 +980,6 @@
return JNI_ERR;
}
- if ((status = android::register_com_android_bluetooth_hfpclient(e)) < 0) {
- ALOGE("jni hfp client registration failure, status: %d", status);
- return JNI_ERR;
- }
-
if ((status = android::register_com_android_bluetooth_a2dp(e)) < 0) {
ALOGE("jni a2dp registration failure: %d", status);
return JNI_ERR;
diff --git a/jni/com_android_bluetooth_hfp.cpp b/jni/com_android_bluetooth_hfp.cpp
index 271df0e..a99e9a8 100644
--- a/jni/com_android_bluetooth_hfp.cpp
+++ b/jni/com_android_bluetooth_hfp.cpp
@@ -1,7 +1,4 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
- * Not a Contribution.
- *
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,8 +49,6 @@
static jmethodID method_onAtClcc;
static jmethodID method_onUnknownAt;
static jmethodID method_onKeyPressed;
-static jmethodID method_onCodecNegotiated;
-
static const bthf_interface_t *sBluetoothHfpInterface = NULL;
static jobject mCallbacksObj = NULL;
@@ -201,12 +196,6 @@
checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
}
-static void codec_negotiated_callback(int codec_type) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCodecNegotiated, (jint)codec_type);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
static bthf_callbacks_t sBluetoothHfpCallbacks = {
sizeof(sBluetoothHfpCallbacks),
connection_state_callback,
@@ -224,8 +213,7 @@
at_cops_callback,
at_clcc_callback,
unknown_at_callback,
- key_pressed_callback,
- codec_negotiated_callback
+ key_pressed_callback
};
static void classInitNative(JNIEnv* env, jclass clazz) {
@@ -252,7 +240,6 @@
method_onAtClcc = env->GetMethodID(clazz, "onAtClcc", "()V");
method_onUnknownAt = env->GetMethodID(clazz, "onUnknownAt", "(Ljava/lang/String;)V");
method_onKeyPressed = env->GetMethodID(clazz, "onKeyPressed", "()V");
- method_onCodecNegotiated = env->GetMethodID(clazz, "onCodecNegotiated", "(I)V");
/*
if ( (btInf = getBluetoothInterface()) == NULL) {
@@ -314,23 +301,6 @@
mCallbacksObj = env->NewGlobalRef(object);
}
-static void initializeFeaturesNative(JNIEnv *env, jobject object, jint feature_bitmask) {
- const bt_interface_t* btInf;
- bt_status_t status;
-
- if ( (btInf = getBluetoothInterface()) == NULL) {
- ALOGE("Bluetooth module is not loaded");
- return;
- }
- if (!sBluetoothHfpInterface) return ;
- if (feature_bitmask)
- if ((status = sBluetoothHfpInterface->init_features(feature_bitmask))
- != BT_STATUS_SUCCESS){
- ALOGE("Failed sending feature bitmask, status: %d", status);
- }
- return;
-}
-
static void cleanupNative(JNIEnv *env, jobject object) {
const bt_interface_t* btInf;
bt_status_t status;
@@ -572,7 +542,6 @@
static JNINativeMethod sMethods[] = {
{"classInitNative", "()V", (void *) classInitNative},
{"initializeNative", "()V", (void *) initializeNative},
- {"initializeFeaturesNative", "(I)V", (void *) initializeFeaturesNative},
{"cleanupNative", "()V", (void *) cleanupNative},
{"connectHfpNative", "([B)Z", (void *) connectHfpNative},
{"disconnectHfpNative", "([B)Z", (void *) disconnectHfpNative},
diff --git a/jni/com_android_bluetooth_hfpclient.cpp b/jni/com_android_bluetooth_hfpclient.cpp
deleted file mode 100644
index d02115b..0000000
--- a/jni/com_android_bluetooth_hfpclient.cpp
+++ /dev/null
@@ -1,587 +0,0 @@
-/*
- * Copyright (C) 2013 The Linux Foundation. All rights reserved
- * Not a Contribution.
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "BluetoothHandsfreeClientServiceJni"
-#define LOG_NDEBUG 0
-
-#include "com_android_bluetooth.h"
-#include "hardware/bt_hf_client.h"
-#include "utils/Log.h"
-#include "android_runtime/AndroidRuntime.h"
-
-#define CHECK_CALLBACK_ENV \
- if (!checkCallbackThread()) { \
- ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);\
- return; \
- }
-
-namespace android {
-
-static bthf_client_interface_t *sBluetoothHfpClientInterface = NULL;
-static jobject mCallbacksObj = NULL;
-static JNIEnv *sCallbackEnv = NULL;
-
-static jmethodID method_onConnectionStateChanged;
-static jmethodID method_onAudioStateChanged;
-static jmethodID method_onVrStateChanged;
-static jmethodID method_onNetworkState;
-static jmethodID method_onNetworkRoaming;
-static jmethodID method_onNetworkSignal;
-static jmethodID method_onBatteryLevel;
-static jmethodID method_onCurrentOperator;
-static jmethodID method_onCall;
-static jmethodID method_onCallSetup;
-static jmethodID method_onCallHeld;
-static jmethodID method_onRespAndHold;
-static jmethodID method_onClip;
-static jmethodID method_onCallWaiting;
-static jmethodID method_onCurrentCalls;
-static jmethodID method_onVolumeChange;
-static jmethodID method_onCmdResult;
-static jmethodID method_onSubscriberInfo;
-static jmethodID method_onInBandRing;
-static jmethodID method_onLastVoiceTagNumber;
-
-static bool checkCallbackThread() {
- // Always fetch the latest callbackEnv from AdapterService.
- // Caching this could cause this sCallbackEnv to go out-of-sync
- // with the AdapterService's ENV if an ASSOCIATE/DISASSOCIATE event
- // is received
- sCallbackEnv = getCallbackEnv();
- JNIEnv* env = AndroidRuntime::getJNIEnv();
- if (sCallbackEnv != env || sCallbackEnv == NULL) return false;
- return true;
-}
-
-static void connection_state_cb(bthf_client_connection_state_t state, unsigned int peer_feat, unsigned int chld_feat, bt_bdaddr_t *bd_addr) {
- jbyteArray addr;
-
- CHECK_CALLBACK_ENV
-
- addr = sCallbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
- if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr for connection state");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
-
- sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte*) bd_addr);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onConnectionStateChanged, (jint) state, (jint) peer_feat, (jint) chld_feat, addr);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(addr);
-}
-
-static void audio_state_cb(bthf_client_audio_state_t state, bt_bdaddr_t *bd_addr) {
- jbyteArray addr;
-
- CHECK_CALLBACK_ENV
-
- addr = sCallbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
- if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr for audio state");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
-
- sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte *) bd_addr);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onAudioStateChanged, (jint) state, addr);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(addr);
-}
-
-static void vr_cmd_cb(bthf_client_vr_state_t state) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onVrStateChanged, (jint) state);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void network_state_cb (bthf_client_network_state_t state) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onNetworkState, (jint) state);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void network_roaming_cb (bthf_client_service_type_t type) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onNetworkRoaming, (jint) type);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void network_signal_cb (int signal) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onNetworkSignal, (jint) signal);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void battery_level_cb (int level) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onBatteryLevel, (jint) level);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void current_operator_cb (const char *name) {
- jstring js_name;
-
- CHECK_CALLBACK_ENV
-
- js_name = sCallbackEnv->NewStringUTF(name);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCurrentOperator, js_name);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(js_name);
-}
-
-static void call_cb (bthf_client_call_t call) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCall, (jint) call);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void callsetup_cb (bthf_client_callsetup_t callsetup) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCallSetup, (jint) callsetup);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void callheld_cb (bthf_client_callheld_t callheld) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCallHeld, (jint) callheld);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void resp_and_hold_cb (bthf_client_resp_and_hold_t resp_and_hold) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onRespAndHold, (jint) resp_and_hold);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void clip_cb (const char *number) {
- jstring js_number;
-
- CHECK_CALLBACK_ENV
-
- js_number = sCallbackEnv->NewStringUTF(number);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onClip, js_number);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(js_number);
-}
-
-static void call_waiting_cb (const char *number) {
- jstring js_number;
-
- CHECK_CALLBACK_ENV
-
- js_number = sCallbackEnv->NewStringUTF(number);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCallWaiting, js_number);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(js_number);
-}
-
-static void current_calls_cb (int index, bthf_client_call_direction_t dir,
- bthf_client_call_state_t state,
- bthf_client_call_mpty_type_t mpty,
- const char *number) {
- jstring js_number;
-
- CHECK_CALLBACK_ENV
-
- js_number = sCallbackEnv->NewStringUTF(number);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCurrentCalls, index, dir, state, mpty, js_number);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(js_number);
-}
-
-static void volume_change_cb (bthf_client_volume_type_t type, int volume) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onVolumeChange, (jint) type, (jint) volume);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void cmd_complete_cb (bthf_client_cmd_complete_t type, int cme) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onCmdResult, (jint) type, (jint) cme);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void subscriber_info_cb (const char *name, bthf_client_subscriber_service_type_t type) {
- jstring js_name;
-
- CHECK_CALLBACK_ENV
-
- js_name = sCallbackEnv->NewStringUTF(name);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onSubscriberInfo, js_name, (jint) type);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(js_name);
-}
-
-static void in_band_ring_cb (bthf_client_in_band_ring_state_t in_band) {
- CHECK_CALLBACK_ENV
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onInBandRing, (jint) in_band);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
-}
-
-static void last_voice_tag_number_cb (const char *number) {
- jstring js_number;
-
- CHECK_CALLBACK_ENV
-
- js_number = sCallbackEnv->NewStringUTF(number);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onLastVoiceTagNumber, js_number);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(js_number);
-}
-
-static bthf_client_callbacks_t sBluetoothHfpClientCallbacks = {
- sizeof(sBluetoothHfpClientCallbacks),
- connection_state_cb,
- audio_state_cb,
- vr_cmd_cb,
- network_state_cb,
- network_roaming_cb,
- network_signal_cb,
- battery_level_cb,
- current_operator_cb,
- call_cb,
- callsetup_cb,
- callheld_cb,
- resp_and_hold_cb,
- clip_cb,
- call_waiting_cb,
- current_calls_cb,
- volume_change_cb,
- cmd_complete_cb,
- subscriber_info_cb,
- in_band_ring_cb,
- last_voice_tag_number_cb,
-};
-
-static void classInitNative(JNIEnv* env, jclass clazz) {
- method_onConnectionStateChanged = env->GetMethodID(clazz, "onConnectionStateChanged", "(III[B)V");
- method_onAudioStateChanged = env->GetMethodID(clazz, "onAudioStateChanged", "(I[B)V");
- method_onVrStateChanged = env->GetMethodID(clazz, "onVrStateChanged", "(I)V");
- method_onNetworkState = env->GetMethodID(clazz, "onNetworkState", "(I)V");
- method_onNetworkRoaming = env->GetMethodID(clazz, "onNetworkRoaming", "(I)V");
- method_onNetworkSignal = env->GetMethodID(clazz, "onNetworkSignal", "(I)V");
- method_onBatteryLevel = env->GetMethodID(clazz, "onBatteryLevel", "(I)V");
- method_onCurrentOperator = env->GetMethodID(clazz, "onCurrentOperator", "(Ljava/lang/String;)V");
- method_onCall = env->GetMethodID(clazz, "onCall", "(I)V");
- method_onCallSetup = env->GetMethodID(clazz, "onCallSetup", "(I)V");
- method_onCallHeld = env->GetMethodID(clazz, "onCallHeld", "(I)V");
- method_onRespAndHold = env->GetMethodID(clazz, "onRespAndHold", "(I)V");
- method_onClip = env->GetMethodID(clazz, "onClip", "(Ljava/lang/String;)V");
- method_onCallWaiting = env->GetMethodID(clazz, "onCallWaiting", "(Ljava/lang/String;)V");
- method_onCurrentCalls = env->GetMethodID(clazz, "onCurrentCalls", "(IIIILjava/lang/String;)V");
- method_onVolumeChange = env->GetMethodID(clazz, "onVolumeChange", "(II)V");
- method_onCmdResult = env->GetMethodID(clazz, "onCmdResult", "(II)V");
- method_onSubscriberInfo = env->GetMethodID(clazz, "onSubscriberInfo", "(Ljava/lang/String;I)V");
- method_onInBandRing = env->GetMethodID(clazz, "onInBandRing", "(I)V");
- method_onLastVoiceTagNumber = env->GetMethodID(clazz, "onLastVoiceTagNumber",
- "(Ljava/lang/String;)V");
-
- ALOGI("%s succeeds", __FUNCTION__);
-}
-
-static void initializeNative(JNIEnv *env, jobject object) {
- const bt_interface_t* btInf;
- bt_status_t status;
-
- btInf = getBluetoothInterface();
- if (btInf == NULL) {
- ALOGE("Bluetooth module is not loaded");
- return;
- }
-
- if (sBluetoothHfpClientInterface != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client Interface before initializing");
- sBluetoothHfpClientInterface->cleanup();
- sBluetoothHfpClientInterface = NULL;
- }
-
- if (mCallbacksObj != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client callback object");
- env->DeleteGlobalRef(mCallbacksObj);
- mCallbacksObj = NULL;
- }
-
- sBluetoothHfpClientInterface = (bthf_client_interface_t *)
- btInf->get_profile_interface(BT_PROFILE_HANDSFREE_CLIENT_ID);
- if (sBluetoothHfpClientInterface == NULL) {
- ALOGE("Failed to get Bluetooth HFP Client Interface");
- return;
- }
-
- status = sBluetoothHfpClientInterface->init(&sBluetoothHfpClientCallbacks);
- if (status != BT_STATUS_SUCCESS) {
- ALOGE("Failed to initialize Bluetooth HFP Client, status: %d", status);
- sBluetoothHfpClientInterface = NULL;
- return;
- }
-
- mCallbacksObj = env->NewGlobalRef(object);
-}
-
-static void cleanupNative(JNIEnv *env, jobject object) {
- const bt_interface_t* btInf;
- bt_status_t status;
-
- if ( (btInf = getBluetoothInterface()) == NULL) {
- ALOGE("Bluetooth module is not loaded");
- return;
- }
-
- if (sBluetoothHfpClientInterface != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client Interface...");
- sBluetoothHfpClientInterface->cleanup();
- sBluetoothHfpClientInterface = NULL;
- }
-
- if (mCallbacksObj != NULL) {
- ALOGW("Cleaning up Bluetooth HFP Client callback object");
- env->DeleteGlobalRef(mCallbacksObj);
- mCallbacksObj = NULL;
- }
-}
-
-static jboolean connectNative(JNIEnv *env, jobject object, jbyteArray address) {
- jbyte *addr;
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (!addr) {
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
-
- if ((status = sBluetoothHfpClientInterface->connect((bt_bdaddr_t *)addr)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed AG connection, status: %d", status);
- }
- env->ReleaseByteArrayElements(address, addr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean disconnectNative(JNIEnv *env, jobject object, jbyteArray address) {
- jbyte *addr;
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (!addr) {
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
-
- if ( (status = sBluetoothHfpClientInterface->disconnect((bt_bdaddr_t *)addr)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed AG disconnection, status: %d", status);
- }
- env->ReleaseByteArrayElements(address, addr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean connectAudioNative(JNIEnv *env, jobject object, jbyteArray address) {
- jbyte *addr;
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (!addr) {
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
-
- if ( (status = sBluetoothHfpClientInterface->connect_audio((bt_bdaddr_t *)addr)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed AG audio connection, status: %d", status);
- }
- env->ReleaseByteArrayElements(address, addr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean disconnectAudioNative(JNIEnv *env, jobject object, jbyteArray address) {
- jbyte *addr;
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (!addr) {
- jniThrowIOException(env, EINVAL);
- return JNI_FALSE;
- }
-
- if ( (status = sBluetoothHfpClientInterface->disconnect_audio((bt_bdaddr_t *) addr)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed AG audio disconnection, status: %d", status);
- }
- env->ReleaseByteArrayElements(address, addr, 0);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean startVoiceRecognitionNative(JNIEnv *env, jobject object) {
- bt_status_t status;
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->start_voice_recognition()) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to start voice recognition, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean stopVoiceRecognitionNative(JNIEnv *env, jobject object) {
- bt_status_t status;
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->stop_voice_recognition()) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to stop voice recognition, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean setVolumeNative(JNIEnv *env, jobject object, jint volume_type, jint volume) {
- bt_status_t status;
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->volume_control((bthf_client_volume_type_t) volume_type,
- volume)) != BT_STATUS_SUCCESS) {
- ALOGE("FAILED to control volume, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean dialNative(JNIEnv *env, jobject object, jstring number_str) {
- bt_status_t status;
- const char *number;
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- number = env->GetStringUTFChars(number_str, NULL);
-
- if ( (status = sBluetoothHfpClientInterface->dial(number)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to dial, status: %d", status);
- }
- env->ReleaseStringUTFChars(number_str, number);
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean dialMemoryNative(JNIEnv *env, jobject object, jint location) {
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->dial_memory((int)location)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to dial from memory, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean handleCallActionNative(JNIEnv *env, jobject object, jint action, jint index) {
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->handle_call_action((bthf_client_call_action_t)action, (int)index)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to enter private mode, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean queryCurrentCallsNative(JNIEnv *env, jobject object) {
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->query_current_calls()) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to query current calls, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean queryCurrentOperatorNameNative(JNIEnv *env, jobject object) {
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->query_current_operator_name()) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to query current operator name, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean retrieveSubscriberInfoNative(JNIEnv *env, jobject object) {
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->retrieve_subscriber_info()) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to retrieve subscriber info, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean sendDtmfNative(JNIEnv *env, jobject object, jbyte code) {
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->send_dtmf((char)code)) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to send DTMF, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static jboolean requestLastVoiceTagNumberNative(JNIEnv *env, jobject object) {
- bt_status_t status;
-
- if (!sBluetoothHfpClientInterface) return JNI_FALSE;
-
- if ( (status = sBluetoothHfpClientInterface->request_last_voice_tag_number()) != BT_STATUS_SUCCESS) {
- ALOGE("Failed to request last Voice Tag number, status: %d", status);
- }
- return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
-}
-
-static JNINativeMethod sMethods[] = {
- {"classInitNative", "()V", (void *) classInitNative},
- {"initializeNative", "()V", (void *) initializeNative},
- {"cleanupNative", "()V", (void *) cleanupNative},
- {"connectNative", "([B)Z", (void *) connectNative},
- {"disconnectNative", "([B)Z", (void *) disconnectNative},
- {"connectAudioNative", "([B)Z", (void *) connectAudioNative},
- {"disconnectAudioNative", "([B)Z", (void *) disconnectAudioNative},
- {"startVoiceRecognitionNative", "()Z", (void *) startVoiceRecognitionNative},
- {"stopVoiceRecognitionNative", "()Z", (void *) stopVoiceRecognitionNative},
- {"setVolumeNative", "(II)Z", (void *) setVolumeNative},
- {"dialNative", "(Ljava/lang/String;)Z", (void *) dialNative},
- {"dialMemoryNative", "(I)Z", (void *) dialMemoryNative},
- {"handleCallActionNative", "(II)Z", (void *) handleCallActionNative},
- {"queryCurrentCallsNative", "()Z", (void *) queryCurrentCallsNative},
- {"queryCurrentOperatorNameNative", "()Z", (void *) queryCurrentOperatorNameNative},
- {"retrieveSubscriberInfoNative", "()Z", (void *) retrieveSubscriberInfoNative},
- {"sendDtmfNative", "(B)Z", (void *) sendDtmfNative},
- {"requestLastVoiceTagNumberNative", "()Z",
- (void *) requestLastVoiceTagNumberNative},
-};
-
-int register_com_android_bluetooth_hfpclient(JNIEnv* env)
-{
- return jniRegisterNativeMethods(env, "com/android/bluetooth/hfpclient/HandsfreeClientStateMachine",
- sMethods, NELEM(sMethods));
-}
-
-} /* namespace android */
diff --git a/jni/com_android_bluetooth_hid.cpp b/jni/com_android_bluetooth_hid.cpp
old mode 100644
new mode 100755
index 684af23..96795e0
--- a/jni/com_android_bluetooth_hid.cpp
+++ b/jni/com_android_bluetooth_hid.cpp
@@ -36,7 +36,6 @@
static jmethodID method_onConnectStateChanged;
static jmethodID method_onGetProtocolMode;
static jmethodID method_onGetReport;
-static jmethodID method_onGetIdleTime;
static jmethodID method_onVirtualUnplug;
static const bthh_interface_t *sBluetoothHidInterface = NULL;
@@ -97,29 +96,6 @@
sCallbackEnv->DeleteLocalRef(addr);
}
-static void get_idle_time_callback(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_time) {
- jbyteArray addr;
-
- CHECK_CALLBACK_ENV
- if (hh_status != BTHH_OK) {
- ALOGE("BTHH Status is not OK!");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
-
- addr = sCallbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
- if (!addr) {
- ALOGE("Fail to new jbyteArray bd addr for get protocal mode callback");
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- return;
- }
- sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte *) bd_addr);
-
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onGetIdleTime, addr, (jint) idle_time);
- checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
- sCallbackEnv->DeleteLocalRef(addr);
-}
-
static void virtual_unplug_callback(bt_bdaddr_t *bd_addr, bthh_status_t hh_status) {
ALOGD("call to virtual_unplug_callback");
jbyteArray addr;
@@ -159,7 +135,7 @@
connection_state_callback,
NULL,
get_protocol_mode_callback,
- get_idle_time_callback,
+ NULL,
NULL,
virtual_unplug_callback
};
@@ -173,7 +149,6 @@
method_onConnectStateChanged = env->GetMethodID(clazz, "onConnectStateChanged", "([BI)V");
method_onGetProtocolMode = env->GetMethodID(clazz, "onGetProtocolMode", "([BI)V");
- method_onGetIdleTime = env->GetMethodID(clazz, "onGetIdleTime", "([BI)V");
method_onVirtualUnplug = env->GetMethodID(clazz, "onVirtualUnplug", "([BI)V");
/*
@@ -457,7 +432,7 @@
const char *c_report = env->GetStringUTFChars(report, NULL);
if ( (status = sBluetoothHidInterface->send_data((bt_bdaddr_t *) addr, (char*) c_report)) !=
BT_STATUS_SUCCESS) {
- ALOGE("Failed send data, status: %d", status);
+ ALOGE("Failed set report, status: %d", status);
ret = JNI_FALSE;
}
env->ReleaseStringUTFChars(report, c_report);
@@ -467,73 +442,6 @@
}
-static jboolean getIdleTimeNative(JNIEnv *env, jobject object, jbyteArray address) {
- bt_status_t status;
- jbyte *addr;
- jboolean ret = JNI_TRUE;
- if (!sBluetoothHidInterface) return JNI_FALSE;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (!addr) {
- ALOGE("Bluetooth device address null");
- return JNI_FALSE;
- }
-
- if ( (status = sBluetoothHidInterface->get_idle_time((bt_bdaddr_t *) addr)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed get idle time, status: %d", status);
- ret = JNI_FALSE;
- }
- env->ReleaseByteArrayElements(address, addr, 0);
-
- return ret;
-}
-
-static jboolean setIdleTimeNative(JNIEnv *env, jobject object, jbyteArray address, jbyte idle_time) {
- bt_status_t status;
- jbyte *addr;
- jboolean ret = JNI_TRUE;
- if (!sBluetoothHidInterface) return JNI_FALSE;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (!addr) {
- ALOGE("Bluetooth device address null");
- return JNI_FALSE;
- }
-
- if ( (status = sBluetoothHidInterface->set_idle_time((bt_bdaddr_t *) addr, idle_time)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed set idle time, status: %d", status);
- ret = JNI_FALSE;
- }
- env->ReleaseByteArrayElements(address, addr, 0);
-
- return ret;
-}
-
-static jboolean setPriorityNative(JNIEnv *env, jobject object, jbyteArray address, jint priority) {
- bt_status_t status;
- jbyte *addr;
- jboolean ret = JNI_TRUE;
- if (!sBluetoothHidInterface) return JNI_FALSE;
-
- addr = env->GetByteArrayElements(address, NULL);
- if (!addr) {
- ALOGE("Bluetooth device address null");
- return JNI_FALSE;
- }
-
- if ( (status = sBluetoothHidInterface->set_priority((bt_bdaddr_t *) addr, priority)) !=
- BT_STATUS_SUCCESS) {
- ALOGE("Failed set priority, status: %d", status);
- ret = JNI_FALSE;
- }
- env->ReleaseByteArrayElements(address, addr, 0);
-
- return ret;
-}
-
-
static JNINativeMethod sMethods[] = {
{"classInitNative", "()V", (void *) classInitNative},
{"initializeNative", "()V", (void *) initializeNative},
@@ -546,9 +454,6 @@
{"getReportNative", "([BBBI)Z", (void *) getReportNative},
{"setReportNative", "([BBLjava/lang/String;)Z", (void *) setReportNative},
{"sendDataNative", "([BLjava/lang/String;)Z", (void *) sendDataNative},
- {"getIdleTimeNative", "([B)Z", (void *) getIdleTimeNative},
- {"setIdleTimeNative", "([BB)Z", (void *) setIdleTimeNative},
- {"setPriorityNative", "([BI)Z", (void *) setPriorityNative},
};
int register_com_android_bluetooth_hid(JNIEnv* env)
diff --git a/jni/com_android_bluetooth_pan.cpp b/jni/com_android_bluetooth_pan.cpp
index 500fd91..62e1c5c 100644
--- a/jni/com_android_bluetooth_pan.cpp
+++ b/jni/com_android_bluetooth_pan.cpp
@@ -56,13 +56,13 @@
return true;
}
-static void control_state_callback(btpan_control_state_t state, int local_role, bt_status_t error,
+static void control_state_callback(btpan_control_state_t state, bt_status_t error, int local_role,
const char* ifname) {
debug("state:%d, local_role:%d, ifname:%s", state, local_role, ifname);
CHECK_CALLBACK_ENV
jstring js_ifname = sCallbackEnv->NewStringUTF(ifname);
- sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onControlStateChanged, (jint)local_role, (jint)state,
- (jint)error, js_ifname);
+ sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onControlStateChanged, (jint)state, (jint)error,
+ (jint)local_role, js_ifname);
sCallbackEnv->DeleteLocalRef(js_ifname);
}