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

Commit b70a169c authored by tim peng's avatar tim peng Committed by Automerger Merge Worker
Browse files

Merge "No feedback when attempting to transfer to an unpowered BT device" into...

Merge "No feedback when attempting to transfer to an unpowered BT device" into rvc-dev am: 064a8277 am: 585d6df2 am: 4d3d4360 am: a62ea2f0

Change-Id: Ifd4645fa9598ea99bffe90355f19fd502f079455
parents f7e0d7da a62ea2f0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ public class LocalMediaManager implements BluetoothCallback {
                    ((BluetoothMediaDevice) device).getCachedDevice();
            if (!cachedDevice.isConnected() && !cachedDevice.isBusy()) {
                mOnTransferBluetoothDevice = connectDevice;
                device.setState(MediaDeviceState.STATE_CONNECTING);
                cachedDevice.connect();
                return;
            }
@@ -394,6 +395,7 @@ public class LocalMediaManager implements BluetoothCallback {
            dispatchDeviceListUpdate();
            if (mOnTransferBluetoothDevice != null && mOnTransferBluetoothDevice.isConnected()) {
                connectDevice(mOnTransferBluetoothDevice);
                mOnTransferBluetoothDevice.setState(MediaDeviceState.STATE_CONNECTED);
                mOnTransferBluetoothDevice = null;
            }
        }
@@ -539,6 +541,14 @@ public class LocalMediaManager implements BluetoothCallback {

        @Override
        public void onDeviceAttributesChanged() {
            if (mOnTransferBluetoothDevice != null
                    && !((BluetoothMediaDevice) mOnTransferBluetoothDevice).getCachedDevice()
                    .isBusy()
                    && !mOnTransferBluetoothDevice.isConnected()) {
                // Failed to connect
                mOnTransferBluetoothDevice.setState(MediaDeviceState.STATE_DISCONNECTED);
                mOnTransferBluetoothDevice = null;
            }
            dispatchDeviceAttributesChanged();
        }
    }
+20 −0
Original line number Diff line number Diff line
@@ -483,6 +483,26 @@ public class LocalMediaManagerTest {
        verify(mCallback).onDeviceAttributesChanged();
    }

    @Test
    public void onDeviceAttributesChanged_failingTransferring_shouldResetState() {
        final MediaDevice currentDevice = mock(MediaDevice.class);
        final MediaDevice device = mock(BluetoothMediaDevice.class);
        final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class);
        mLocalMediaManager.mMediaDevices.add(device);
        mLocalMediaManager.mMediaDevices.add(currentDevice);
        when(device.getId()).thenReturn(TEST_DEVICE_ID_1);
        when(currentDevice.getId()).thenReturn(TEST_CURRENT_DEVICE_ID);
        when(((BluetoothMediaDevice) device).getCachedDevice()).thenReturn(cachedDevice);
        when(cachedDevice.isConnected()).thenReturn(false);
        when(cachedDevice.isBusy()).thenReturn(false);

        mLocalMediaManager.registerCallback(mCallback);
        mLocalMediaManager.connectDevice(device);

        mLocalMediaManager.mDeviceAttributeChangeCallback.onDeviceAttributesChanged();
        verify(device).setState(LocalMediaManager.MediaDeviceState.STATE_DISCONNECTED);
    }

    @Test
    public void onRequestFailed_checkDevicesState() {
        mLocalMediaManager.mMediaDevices.add(mInfoMediaDevice1);