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

Commit 0c7cb35f authored by Sal Savage's avatar Sal Savage Committed by Gerrit Code Review
Browse files

Merge changes If9a4f957,If80ac4a5 into main

* changes:
  Add more profile native interfaces
  Mock TelephonyManager in ProfileService tests
parents dd74b362 599fe05a
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothProfile;
import android.os.Handler;
import android.os.Looper;
import android.telephony.TelephonyManager;

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.MediumTest;
@@ -32,11 +33,14 @@ import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.TestUtils;
import com.android.bluetooth.a2dp.A2dpNativeInterface;
import com.android.bluetooth.a2dpsink.A2dpSinkNativeInterface;
import com.android.bluetooth.avrcp.AvrcpNativeInterface;
import com.android.bluetooth.avrcpcontroller.AvrcpControllerNativeInterface;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.csip.CsipSetCoordinatorNativeInterface;
import com.android.bluetooth.hearingaid.HearingAidNativeInterface;
import com.android.bluetooth.hfp.HeadsetNativeInterface;
import com.android.bluetooth.hfpclient.NativeInterface;
import com.android.bluetooth.hid.HidDeviceNativeInterface;
import com.android.bluetooth.hid.HidHostNativeInterface;
import com.android.bluetooth.le_audio.LeAudioNativeInterface;
@@ -74,12 +78,16 @@ public class ProfileServiceTest {
    @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();

    @Mock private DatabaseManager mDatabaseManager;
    @Mock private TelephonyManager mMockTelephonyManager;

    private int[] mProfiles;

    @Mock private A2dpNativeInterface mA2dpNativeInterface;
    @Mock private A2dpSinkNativeInterface mA2dpSinkNativeInterface;
    @Mock private AvrcpNativeInterface mAvrcpNativeInterface;
    @Mock private AvrcpControllerNativeInterface mAvrcpControllerNativeInterface;
    @Mock private HeadsetNativeInterface mHeadsetNativeInterface;
    @Mock private NativeInterface mHeadsetClientNativeInterface;
    @Mock private HearingAidNativeInterface mHearingAidNativeInterface;
    @Mock private HidDeviceNativeInterface mHidDeviceNativeInterface;
    @Mock private HidHostNativeInterface mHidHostNativeInterface;
@@ -138,6 +146,12 @@ public class ProfileServiceTest {
        doReturn(false).when(mAdapterService).isA2dpOffloadEnabled();
        doReturn(false).when(mAdapterService).pbapPseDynamicVersionUpgradeIsEnabled();

        TestUtils.mockGetSystemService(
                mAdapterService,
                "Context.TELEPHONY_SERVICE",
                TelephonyManager.class,
                mMockTelephonyManager);

        mProfiles =
                Arrays.stream(Config.getSupportedProfiles())
                        .filter(
@@ -150,8 +164,11 @@ public class ProfileServiceTest {
        Assert.assertNotNull(AdapterService.getAdapterService());

        A2dpNativeInterface.setInstance(mA2dpNativeInterface);
        A2dpSinkNativeInterface.setInstance(mA2dpSinkNativeInterface);
        AvrcpNativeInterface.setInstance(mAvrcpNativeInterface);
        AvrcpControllerNativeInterface.setInstance(mAvrcpControllerNativeInterface);
        HeadsetNativeInterface.setInstance(mHeadsetNativeInterface);
        /* HeadsetClient */ NativeInterface.setInstance(mHeadsetClientNativeInterface);
        HearingAidNativeInterface.setInstance(mHearingAidNativeInterface);
        HidDeviceNativeInterface.setInstance(mHidDeviceNativeInterface);
        HidHostNativeInterface.setInstance(mHidHostNativeInterface);
@@ -168,8 +185,11 @@ public class ProfileServiceTest {
        mAdapterService = null;
        mProfiles = null;
        A2dpNativeInterface.setInstance(null);
        A2dpSinkNativeInterface.setInstance(null);
        AvrcpNativeInterface.setInstance(null);
        AvrcpControllerNativeInterface.setInstance(null);
        HeadsetNativeInterface.setInstance(null);
        /* HeadsetClient */ NativeInterface.setInstance(null);
        HearingAidNativeInterface.setInstance(null);
        HidDeviceNativeInterface.setInstance(null);
        HidHostNativeInterface.setInstance(null);