Loading android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +3 −1 Original line number Diff line number Diff line Loading @@ -387,7 +387,9 @@ class PhonePolicy { connectOtherProfile(device); } if (nextState == BluetoothProfile.STATE_DISCONNECTED) { if (profileId == BluetoothProfile.A2DP) { if (profileId == BluetoothProfile.A2DP && (prevState == BluetoothProfile.STATE_CONNECTING || prevState == BluetoothProfile.STATE_DISCONNECTING)) { mDatabaseManager.setDisconnection(device); } handleAllProfilesDisconnected(device); Loading android/app/tests/unit/src/com/android/bluetooth/btservice/PhonePolicyTest.java +13 −1 Original line number Diff line number Diff line Loading @@ -233,7 +233,7 @@ public class PhonePolicyTest { verify(mDatabaseManager, never()).setConnection(eq(connectionOrder.get(2)), anyBoolean()); verify(mDatabaseManager, never()).setConnection(eq(connectionOrder.get(3)), anyBoolean()); // Disconnect a2dp for the device // Disconnect a2dp for the device from previous STATE_CONNECTED when(mHeadsetService.getConnectionState(connectionOrder.get(1))).thenReturn( BluetoothProfile.STATE_DISCONNECTED); intent = new Intent(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED); Loading @@ -244,6 +244,18 @@ public class PhonePolicyTest { mPhonePolicy.getBroadcastReceiver().onReceive(null /* context */, intent); waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); // Verify that we do not call setConnection, nor setDisconnection on disconnect // from previous STATE_CONNECTED verify(mDatabaseManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).setConnection( connectionOrder.get(1), true); verify(mDatabaseManager, never()).setDisconnection(connectionOrder.get(1)); // Disconnect a2dp for the device from previous STATE_DISCONNECTING intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, BluetoothProfile.STATE_DISCONNECTING); mPhonePolicy.getBroadcastReceiver().onReceive(null /* context */, intent); waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); // Verify that we do not call setConnection, but instead setDisconnection on disconnect verify(mDatabaseManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).setConnection( connectionOrder.get(1), true); Loading Loading
android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +3 −1 Original line number Diff line number Diff line Loading @@ -387,7 +387,9 @@ class PhonePolicy { connectOtherProfile(device); } if (nextState == BluetoothProfile.STATE_DISCONNECTED) { if (profileId == BluetoothProfile.A2DP) { if (profileId == BluetoothProfile.A2DP && (prevState == BluetoothProfile.STATE_CONNECTING || prevState == BluetoothProfile.STATE_DISCONNECTING)) { mDatabaseManager.setDisconnection(device); } handleAllProfilesDisconnected(device); Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/PhonePolicyTest.java +13 −1 Original line number Diff line number Diff line Loading @@ -233,7 +233,7 @@ public class PhonePolicyTest { verify(mDatabaseManager, never()).setConnection(eq(connectionOrder.get(2)), anyBoolean()); verify(mDatabaseManager, never()).setConnection(eq(connectionOrder.get(3)), anyBoolean()); // Disconnect a2dp for the device // Disconnect a2dp for the device from previous STATE_CONNECTED when(mHeadsetService.getConnectionState(connectionOrder.get(1))).thenReturn( BluetoothProfile.STATE_DISCONNECTED); intent = new Intent(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED); Loading @@ -244,6 +244,18 @@ public class PhonePolicyTest { mPhonePolicy.getBroadcastReceiver().onReceive(null /* context */, intent); waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); // Verify that we do not call setConnection, nor setDisconnection on disconnect // from previous STATE_CONNECTED verify(mDatabaseManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).setConnection( connectionOrder.get(1), true); verify(mDatabaseManager, never()).setDisconnection(connectionOrder.get(1)); // Disconnect a2dp for the device from previous STATE_DISCONNECTING intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, BluetoothProfile.STATE_DISCONNECTING); mPhonePolicy.getBroadcastReceiver().onReceive(null /* context */, intent); waitForLooperToFinishScheduledTask(mHandlerThread.getLooper()); // Verify that we do not call setConnection, but instead setDisconnection on disconnect verify(mDatabaseManager, timeout(ASYNC_CALL_TIMEOUT_MILLIS).times(1)).setConnection( connectionOrder.get(1), true); Loading