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

Commit 80d4e5b6 authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Gerrit Code Review
Browse files

Merge "Fix AvrcpBipClientTest" into main

parents 50f7acaf 6ac9d636
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -118,7 +118,9 @@ public class AvrcpBipClient {
    }

    /**
     * Creates a BIP image pull client and connects to a remote device's BIP image push server.
     * Creates a BIP image pull client
     *
     * <p>{@link connectAsync()} must be called separately.
     */
    public AvrcpBipClient(BluetoothDevice remoteDevice, int psm, Callback callback) {
        if (remoteDevice == null) {
@@ -138,7 +140,6 @@ public class AvrcpBipClient {
        Looper looper = mThread.getLooper();

        mHandler = new AvrcpBipClientHandler(looper, this);
        mHandler.obtainMessage(CONNECT).sendToTarget();
    }

    /**
@@ -165,7 +166,7 @@ public class AvrcpBipClient {
    public void shutdown() {
        debug("Shutdown client");
        try {
            mHandler.obtainMessage(DISCONNECT).sendToTarget();
            disconnectAsync();
        } catch (IllegalStateException e) {
            // Means we haven't been started or we're already stopped. Doing this makes this call
            // always safe no matter the state.
@@ -242,6 +243,11 @@ public class AvrcpBipClient {
        }
    }

    /** Connects asynchronously */
    void connectAsync() {
        mHandler.obtainMessage(CONNECT).sendToTarget();
    }

    /**
     * Connects to the remote device's BIP Image Pull server
     */
@@ -316,10 +322,14 @@ public class AvrcpBipClient {
        }
    }

    /** Disconnects asynchronously */
    void disconnectAsync() {
        mHandler.obtainMessage(DISCONNECT).sendToTarget();
    }

    /**
     * Permanently disconnects this client from the remote device's BIP server and notifies of the
     * new connection status.
     *
     */
    private synchronized void disconnect() {
        if (mSession != null) {
+1 −0
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ public class AvrcpCoverArtManager {
        debug("Connect " + device + ", psm: " + psm);
        if (mClients.containsKey(device)) return false;
        AvrcpBipClient client = new AvrcpBipClient(device, psm, new BipClientCallback(device));
        client.connectAsync();
        mClients.put(device, client);
        mBipSessions.put(device, new AvrcpBipSession(device));
        return true;
+7 −6
Original line number Diff line number Diff line
@@ -143,11 +143,12 @@ public class AvrcpBipClientTest {

    @Test
    public void toString_returnsClientInfo() {
        AvrcpBipClient client = new AvrcpBipClient(mTestDevice, TEST_PSM,
                mArtManager.new BipClientCallback(mTestDevice));

        String expected = "<AvrcpBipClient" + " device=" + mTestDevice + " psm="
                + TEST_PSM + " state=" + client.getStateName() + ">";
        assertThat(client.toString()).isEqualTo(expected);
        String expected =
                "<AvrcpBipClient"
                        + (" device=" + mTestDevice)
                        + (" psm=" + TEST_PSM)
                        + (" state=" + mClient.getStateName())
                        + ">";
        assertThat(mClient.toString()).isEqualTo(expected);
    }
}