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

Commit c524c3a0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add OK into queue after sendAndroidAt" am: 84d4ef8c

parents ddbdea69 84d4ef8c
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -343,7 +343,8 @@ public class HeadsetClientStateMachine extends StateMachine {
        mPendingAction = new Pair<Integer, Object>(NO_ACTION, 0);
    }

    private void addQueuedAction(int action) {
    @VisibleForTesting
    void addQueuedAction(int action) {
        addQueuedAction(action, 0);
    }

@@ -2197,7 +2198,7 @@ public class HeadsetClientStateMachine extends StateMachine {
        logD("setAudioPolicy: " + policies);
        mHsClientAudioPolicy = policies;

        if (mAudioPolicyRemoteSupported != BluetoothStatusCodes.FEATURE_SUPPORTED) {
        if (getAudioPolicyRemoteSupported() != BluetoothStatusCodes.FEATURE_SUPPORTED) {
            Log.e(TAG, "Audio Policy feature not supported!");
            return;
        }
@@ -2205,7 +2206,9 @@ public class HeadsetClientStateMachine extends StateMachine {
        if (!mNativeInterface.sendAndroidAt(mCurrentDevice,
                "+ANDROID=" + createMaskString(policies))) {
            Log.e(TAG, "ERROR: Couldn't send call audio policies");
            return;
        }
        addQueuedAction(SEND_ANDROID_AT_COMMAND);
    }

    private boolean queryRemoteSupportedFeatures() {
+16 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.bluetooth.BluetoothAssignedNumbers;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClient;
import android.bluetooth.BluetoothSinkAudioPolicy;
import android.bluetooth.BluetoothStatusCodes;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
@@ -1103,8 +1104,23 @@ public class HeadsetClientStateMachineTest {
                .setInBandRingtonePolicy(BluetoothSinkAudioPolicy.POLICY_ALLOWED)
                .build();

        // Test if not support audio policy feature
        mHeadsetClientStateMachine.setAudioPolicyRemoteSupported(false);
        mHeadsetClientStateMachine.setAudioPolicy(dummyAudioPolicy);
        verify(mNativeInterface, never()).sendAndroidAt(mTestDevice, "+ANDROID=1,1,2,1");
        Assert.assertEquals(0, mHeadsetClientStateMachine.mQueuedActions.size());

        // Test setAudioPolicy
        mHeadsetClientStateMachine.setAudioPolicyRemoteSupported(true);
        mHeadsetClientStateMachine.setAudioPolicy(dummyAudioPolicy);
        verify(mNativeInterface).sendAndroidAt(mTestDevice, "+ANDROID=1,1,2,1");
        Assert.assertEquals(1, mHeadsetClientStateMachine.mQueuedActions.size());
        mHeadsetClientStateMachine.mQueuedActions.clear();

        // Test if fail to sendAndroidAt
        doReturn(false).when(mNativeInterface).sendAndroidAt(anyObject(), anyString());
        mHeadsetClientStateMachine.setAudioPolicy(dummyAudioPolicy);
        Assert.assertEquals(0, mHeadsetClientStateMachine.mQueuedActions.size());
    }

    @Test