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

Commit 545cd756 authored by Bhushan Shinkar's avatar Bhushan Shinkar
Browse files

Adding a delay after calling startService() to prevent potential failure...

Adding a delay after calling startService() to prevent potential failure caused by delayed responses.

Bug:308388378
Change-Id: If758a99011a4a52575bbf4a91c9f19d1ef4702d7
Test: atest HeadsetClientServiceTest
Flag: EXEMPT test only change
parent 739ba89b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.bluetooth.hfpclient;

import static android.content.pm.PackageManager.FEATURE_WATCH;
import java.util.concurrent.TimeUnit;

import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
@@ -63,6 +64,7 @@ public class HeadsetClientServiceTest {
    private boolean mIsHeadsetClientServiceStarted;

    private static final int STANDARD_WAIT_MILLIS = 1000;
    private static final int SERVICE_START_WAIT_MILLIS = 100;

    @Mock private AdapterService mAdapterService;
    @Mock private HeadsetClientStateMachine mStateMachine;
@@ -124,6 +126,8 @@ public class HeadsetClientServiceTest {
    public void testUpdateBatteryLevel() throws Exception {
        startService();

        // Adding a wait to prevent potential failure caused by delayed broadcast intent.
        TimeUnit.MILLISECONDS.sleep(SERVICE_START_WAIT_MILLIS);
        // Put mock state machine
        BluetoothDevice device =
                BluetoothAdapter.getDefaultAdapter().getRemoteDevice("00:01:02:03:04:05");