Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d644700 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add more information for bond and acl state change"

parents 53da132b 7358daa4
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -278,7 +278,8 @@ static void device_found_callback(int num_properties,
}
}


static void bond_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
static void bond_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
                                        bt_bond_state_t state) {
                                        bt_bond_state_t state,
                                        int fail_reason) {
  CallbackEnv sCallbackEnv(__func__);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbackEnv.valid()) return;


@@ -297,11 +298,14 @@ static void bond_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
                                   (jbyte*)bd_addr);
                                   (jbyte*)bd_addr);


  sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_bondStateChangeCallback,
  sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_bondStateChangeCallback,
                               (jint)status, addr.get(), (jint)state);
                               (jint)status, addr.get(), (jint)state,
                               (jint)fail_reason);
}
}


static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
                                       bt_acl_state_t state, bt_hci_error_code_t hci_reason) {
                                       bt_acl_state_t state,
                                       int transport_link_type,
                                       bt_hci_error_code_t hci_reason) {
  if (!bd_addr) {
  if (!bd_addr) {
    ALOGE("Address is null in %s", __func__);
    ALOGE("Address is null in %s", __func__);
    return;
    return;
@@ -320,7 +324,8 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr,
                                   (jbyte*)bd_addr);
                                   (jbyte*)bd_addr);


  sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_aclStateChangeCallback,
  sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_aclStateChangeCallback,
                               (jint)status, addr.get(), (jint)state, (jint)hci_reason);
                               (jint)status, addr.get(), (jint)state,
                               (jint)transport_link_type, (jint)hci_reason);
}
}


static void discovery_state_changed_callback(bt_discovery_state_t state) {
static void discovery_state_changed_callback(bt_discovery_state_t state) {
@@ -840,10 +845,10 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
      env->GetMethodID(jniCallbackClass, "sspRequestCallback", "([B[BIII)V");
      env->GetMethodID(jniCallbackClass, "sspRequestCallback", "([B[BIII)V");


  method_bondStateChangeCallback =
  method_bondStateChangeCallback =
      env->GetMethodID(jniCallbackClass, "bondStateChangeCallback", "(I[BI)V");
      env->GetMethodID(jniCallbackClass, "bondStateChangeCallback", "(I[BII)V");


  method_aclStateChangeCallback =
  method_aclStateChangeCallback =
      env->GetMethodID(jniCallbackClass, "aclStateChangeCallback", "(I[BII)V");
      env->GetMethodID(jniCallbackClass, "aclStateChangeCallback", "(I[BIII)V");


  method_linkQualityReportCallback = env->GetMethodID(
  method_linkQualityReportCallback = env->GetMethodID(
      jniCallbackClass, "linkQualityReportCallback", "(JIIIIII)V");
      jniCallbackClass, "linkQualityReportCallback", "(JIIIIII)V");
+2 −2
Original line number Original line Diff line number Diff line
@@ -426,7 +426,7 @@ final class BondStateMachine extends StateMachine {
                + state2str(newState));
                + state2str(newState));
    }
    }


    void bondStateChangeCallback(int status, byte[] address, int newState) {
    void bondStateChangeCallback(int status, byte[] address, int newState, int hciReason) {
        BluetoothDevice device = mRemoteDevices.getDevice(address);
        BluetoothDevice device = mRemoteDevices.getDevice(address);


        if (device == null) {
        if (device == null) {
@@ -437,7 +437,7 @@ final class BondStateMachine extends StateMachine {
        }
        }


        infoLog("bondStateChangeCallback: Status: " + status + " Address: " + device + " newState: "
        infoLog("bondStateChangeCallback: Status: " + status + " Address: " + device + " newState: "
                + newState);
                + newState + " hciReason: " + hciReason);


        Message msg = obtainMessage(BONDING_STATE_CHANGE);
        Message msg = obtainMessage(BONDING_STATE_CHANGE);
        msg.obj = device;
        msg.obj = device;
+6 −4
Original line number Original line Diff line number Diff line
@@ -63,12 +63,14 @@ final class JniCallbacks {
        mBondStateMachine.pinRequestCallback(address, name, cod, min16Digits);
        mBondStateMachine.pinRequestCallback(address, name, cod, min16Digits);
    }
    }


    void bondStateChangeCallback(int status, byte[] address, int newState) {
    void bondStateChangeCallback(int status, byte[] address, int newState, int hciReason) {
        mBondStateMachine.bondStateChangeCallback(status, address, newState);
        mBondStateMachine.bondStateChangeCallback(status, address, newState, hciReason);
    }
    }


    void aclStateChangeCallback(int status, byte[] address, int newState, int hciReason) {
    void aclStateChangeCallback(int status, byte[] address, int newState,
        mRemoteDevices.aclStateChangeCallback(status, address, newState, hciReason);
            int transportLinkType, int hciReason) {
        mRemoteDevices.aclStateChangeCallback(status, address, newState,
                transportLinkType, hciReason);
    }
    }


    void stateChangeCallback(int status) {
    void stateChangeCallback(int status) {
+8 −6
Original line number Original line Diff line number Diff line
@@ -608,7 +608,8 @@ final class RemoteDevices {
        }
        }
    }
    }


    void aclStateChangeCallback(int status, byte[] address, int newState, int hciReason) {
    void aclStateChangeCallback(int status, byte[] address, int newState,
                                int transportLinkType, int hciReason) {
        BluetoothDevice device = getDevice(address);
        BluetoothDevice device = getDevice(address);


        if (device == null) {
        if (device == null) {
@@ -649,7 +650,9 @@ final class RemoteDevices {
            }
            }
            debugLog(
            debugLog(
                    "aclStateChangeCallback: Adapter State: " + BluetoothAdapter.nameForState(state)
                    "aclStateChangeCallback: Adapter State: " + BluetoothAdapter.nameForState(state)
                            + " Disconnected: " + device);
                            + " Disconnected: " + device
                            + " transportLinkType: " + transportLinkType
                            + " hciReason: " + hciReason);
        }
        }


        int connectionState = newState == AbstractionLayer.BT_ACL_STATE_CONNECTED
        int connectionState = newState == AbstractionLayer.BT_ACL_STATE_CONNECTED
@@ -663,10 +666,9 @@ final class RemoteDevices {
                sAdapterService.obfuscateAddress(device), classOfDevice, metricId);
                sAdapterService.obfuscateAddress(device), classOfDevice, metricId);


        if (intent != null) {
        if (intent != null) {
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
            intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device)
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
                .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT)
                    | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                .addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
            sAdapterService.sendBroadcast(intent, sAdapterService.BLUETOOTH_PERM);
            sAdapterService.sendBroadcast(intent, sAdapterService.BLUETOOTH_PERM);


            synchronized (sAdapterService.getBluetoothConnectionCallbacks()) {
            synchronized (sAdapterService.getBluetoothConnectionCallbacks()) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -118,10 +118,10 @@ public class BondStateMachineTest {
        verify(mAdapterService, times(1)).removeBondNative(eq(TEST_BT_ADDR_BYTES_2));
        verify(mAdapterService, times(1)).removeBondNative(eq(TEST_BT_ADDR_BYTES_2));


        mBondStateMachine.bondStateChangeCallback(AbstractionLayer.BT_STATUS_SUCCESS,
        mBondStateMachine.bondStateChangeCallback(AbstractionLayer.BT_STATUS_SUCCESS,
                TEST_BT_ADDR_BYTES, BOND_NONE);
                TEST_BT_ADDR_BYTES, BOND_NONE, 0);
        TestUtils.waitForLooperToFinishScheduledTask(mBondStateMachine.getHandler().getLooper());
        TestUtils.waitForLooperToFinishScheduledTask(mBondStateMachine.getHandler().getLooper());
        mBondStateMachine.bondStateChangeCallback(AbstractionLayer.BT_STATUS_SUCCESS,
        mBondStateMachine.bondStateChangeCallback(AbstractionLayer.BT_STATUS_SUCCESS,
                TEST_BT_ADDR_BYTES_2, BOND_NONE);
                TEST_BT_ADDR_BYTES_2, BOND_NONE, 0);
        TestUtils.waitForLooperToFinishScheduledTask(mBondStateMachine.getHandler().getLooper());
        TestUtils.waitForLooperToFinishScheduledTask(mBondStateMachine.getHandler().getLooper());


        // Try to pair these two devices again, createBondNative() should be invoked.
        // Try to pair these two devices again, createBondNative() should be invoked.
Loading