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

Commit 84d4ef8c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add OK into queue after sendAndroidAt"

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


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


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


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


    private boolean queryRemoteSupportedFeatures() {
    private boolean queryRemoteSupportedFeatures() {
+16 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.bluetooth.BluetoothAssignedNumbers;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClient;
import android.bluetooth.BluetoothHeadsetClient;
import android.bluetooth.BluetoothSinkAudioPolicy;
import android.bluetooth.BluetoothSinkAudioPolicy;
import android.bluetooth.BluetoothStatusCodes;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
@@ -1103,8 +1104,23 @@ public class HeadsetClientStateMachineTest {
                .setInBandRingtonePolicy(BluetoothSinkAudioPolicy.POLICY_ALLOWED)
                .setInBandRingtonePolicy(BluetoothSinkAudioPolicy.POLICY_ALLOWED)
                .build();
                .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);
        mHeadsetClientStateMachine.setAudioPolicy(dummyAudioPolicy);
        verify(mNativeInterface).sendAndroidAt(mTestDevice, "+ANDROID=1,1,2,1");
        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
    @Test