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

Commit 0a6caf88 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "LeAudio: Fix test flakyness" into tm-qpr-dev

parents aca46b28 374e8df2
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.util.Log;

import com.android.bluetooth.Utils;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;

import java.util.Arrays;

@@ -67,6 +68,16 @@ public class LeAudioNativeInterface {
        }
    }

    /**
     * Set singleton instance.
     */
    @VisibleForTesting
    static void setInstance(LeAudioNativeInterface instance) {
        synchronized (INSTANCE_LOCK) {
            sInstance = instance;
        }
    }

    private byte[] getByteAddress(BluetoothDevice device) {
        if (device == null) {
            return Utils.getBytesFromAddress("00:00:00:00:00:00");
+4 −1
Original line number Diff line number Diff line
@@ -180,8 +180,8 @@ public class LeAudioServiceTest {
        doAnswer(invocation -> mBondedDevices.toArray(new BluetoothDevice[]{})).when(
                mAdapterService).getBondedDevices();

        LeAudioNativeInterface.setInstance(mNativeInterface);
        startService();
        mService.mLeAudioNativeInterface = mNativeInterface;
        mService.mAudioManager = mAudioManager;
        mService.mVolumeControlService = mVolumeControlService;

@@ -217,6 +217,8 @@ public class LeAudioServiceTest {
                .getBondState(any(BluetoothDevice.class));
        doReturn(new ParcelUuid[]{BluetoothUuid.LE_AUDIO}).when(mAdapterService)
                .getRemoteUuids(any(BluetoothDevice.class));

        verify(mNativeInterface, timeout(3000).times(1)).init(any());
    }

    @After
@@ -231,6 +233,7 @@ public class LeAudioServiceTest {
        mTargetContext.unregisterReceiver(mLeAudioIntentReceiver);
        mDeviceQueueMap.clear();
        TestUtils.clearAdapterService(mAdapterService);
        LeAudioNativeInterface.setInstance(null);
    }

    private void startService() throws TimeoutException {