static jmethodID method_pinRequestCallback;
static jmethodID method_sspRequestCallback;
static jmethodID method_bondStateChangeCallback;
+static jmethodID method_aclStateChangeCallback;
static jmethodID method_discoveryStateChangeCallback;
static const bt_interface_t *sBluetoothInterface = NULL;
callbackEnv->DeleteLocalRef(addr);
}
+static void acl_state_changed_callback(bt_status_t status, bt_bdaddr_t *bd_addr,
+ bt_acl_state_t state)
+{
+ jbyteArray addr;
+ int i;
+ if (!checkCallbackThread()) {
+ LOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__);
+ return;
+ }
+ if (!bd_addr) {
+ LOGE("Address is null in %s", __FUNCTION__);
+ return;
+ }
+ addr = callbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
+ if (addr == NULL) {
+ LOGE("Address allocation failed in %s", __FUNCTION__);
+ return;
+ }
+ callbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte *)bd_addr);
+
+ callbackEnv->CallVoidMethod(sJniCallbacksObj, method_aclStateChangeCallback, (jint) status,
+ addr, (jint)state);
+ checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__);
+ callbackEnv->DeleteLocalRef(addr);
+}
+
static void discovery_state_changed_callback(bt_discovery_state_t state) {
jbyteArray addr;
if (!checkCallbackThread()) {
pin_request_callback,
ssp_request_callback,
bond_state_changed_callback,
+ acl_state_changed_callback,
callback_thread_event,
};
method_bondStateChangeCallback = env->GetMethodID(jniCallbackClass,
"bondStateChangeCallback", "(I[BI)V");
+ method_aclStateChangeCallback = env->GetMethodID(jniCallbackClass,
+ "aclStateChangeCallback", "(I[BI)V");
char value[PROPERTY_VALUE_MAX];
property_get("bluetooth.mock_stack", value, "");
mBondStateMachine.bondStateChangeCallback(status, address, newState);
}
+ void aclStateChangeCallback(int status, byte[] address, int newState) {
+ mRemoteDevices.aclStateChangeCallback(status, address, newState);
+ }
+
void stateChangeCallback(int status) {
mAdapterStateMachine.stateChangeCallback(status);
}
mContext.sendBroadcast(intent, mAdapterService.BLUETOOTH_ADMIN_PERM);
}
+ void aclStateChangeCallback(int status, byte[] address, int newState) {
+ BluetoothDevice device = getDevice(address);
+
+ if (device == null) {
+ errorLog("aclStateChangeCallback: Device is NULL");
+ return;
+ }
+
+ Intent intent = null;
+ if (newState == AbstractionLayer.BT_ACL_STATE_CONNECTED) {
+ intent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED);
+ debugLog("aclStateChangeCallback: State:Connected to Device:" + device);
+ } else {
+ intent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED);
+ debugLog("aclStateChangeCallback: State:DisConnected to Device:" + device);
+ }
+ intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+ mContext.sendBroadcast(intent, mAdapterService.BLUETOOTH_PERM);
+ }
void fetchUuids(BluetoothDevice device) {
if (mSdpTracker.contains(device)) return;