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

Commit 3b17b7d4 authored by Kihong Seong's avatar Kihong Seong
Browse files

Enable HFP Hf for all targets and fix HeadsetClientStateMachineTest

Bug: 237467631
Test: atest HeadsetClientStateMachineTest
Change-Id: I6383b42d03fa86d59e246e0228befa7dfa581cc5
parent 2324ad0d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26,8 +26,10 @@
    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
        <option name="run-command" value="settings put global ble_scan_always_enabled 0" />
        <option name="run-command" value="su u$(am get-current-user)_system svc bluetooth disable" />
        <option name="run-command" value="setprop bluetooth.profile.hfp.hf.enabled true" />
        <option name="teardown-command" value="su u$(am get-current-user)_system svc bluetooth enable" />
        <option name="teardown-command" value="settings put global ble_scan_always_enabled 1" />
        <option name="teardown-command" value="setprop bluetooth.profile.hfp.hf.enabled false" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.FolderSaver">
        <option name="device-path" value="/data/vendor/ssrdump" />
+8 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;

import org.hamcrest.core.AllOf;
import org.hamcrest.core.IsInstanceOf;
@@ -54,6 +55,8 @@ public class HeadsetClientStateMachineTest {
    private BluetoothDevice mTestDevice;
    private Context mTargetContext;

    @Mock
    private AdapterService mAdapterService;
    @Mock
    private Resources mMockHfpResources;
    @Mock
@@ -69,7 +72,7 @@ public class HeadsetClientStateMachineTest {
            * 3 / 2;

    @Before
    public void setUp() {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getTargetContext();
        Assume.assumeTrue("Ignore test when HeadsetClientService is not enabled",
                HeadsetClientService.isEnabled());
@@ -85,6 +88,8 @@ public class HeadsetClientStateMachineTest {
        when(mMockHfpResources.getBoolean(R.bool.hfp_clcc_poll_during_call)).thenReturn(true);
        when(mMockHfpResources.getInteger(R.integer.hfp_clcc_poll_interval_during_call))
                .thenReturn(2000);

        TestUtils.setAdapterService(mAdapterService);
        mNativeInterface = spy(NativeInterface.getInstance());

        // This line must be called to make sure relevant objects are initialized properly
@@ -104,11 +109,12 @@ public class HeadsetClientStateMachineTest {
    }

    @After
    public void tearDown() {
    public void tearDown() throws Exception {
        if (!HeadsetClientService.isEnabled()) {
            return;
        }
        TestUtils.waitForLooperToFinishScheduledTask(mHandlerThread.getLooper());
        TestUtils.clearAdapterService(mAdapterService);
        mHeadsetClientStateMachine.doQuit();
        mHandlerThread.quit();
    }