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

Commit 46ff10fe authored by William Escande's avatar William Escande
Browse files

CsipSetCoordinator: stop calling NativeInterface in test

Bug: 295237486
Test: atest CsipSetCoordinatorServiceTest
Test: atest CsipSetCoordinatorStateMachineTest
Change-Id: Id6bc62a225422cd7325830e43781a5c9d3913d49
parent d11378c7
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -35,12 +35,18 @@ public class CsipSetCoordinatorNativeInterface {
    private static final boolean DBG = false;
    private BluetoothAdapter mAdapter;

    @GuardedBy("INSTANCE_LOCK") private static CsipSetCoordinatorNativeInterface sInstance;
    @GuardedBy("INSTANCE_LOCK")
    private static CsipSetCoordinatorNativeInterface sInstance;

    private static final Object INSTANCE_LOCK = new Object();

    static {
        if (Utils.isInstrumentationTestMode()) {
            Log.w(TAG, "App is instrumented. Skip loading the native");
        } else {
            classInitNative();
        }
    }

    private CsipSetCoordinatorNativeInterface() {
        mAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -61,6 +67,14 @@ public class CsipSetCoordinatorNativeInterface {
        }
    }

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

    /**
     * Initializes the native interface.
     *
+2 −1
Original line number Diff line number Diff line
@@ -103,8 +103,8 @@ public class CsipSetCoordinatorServiceTest {

        mAdapter = BluetoothAdapter.getDefaultAdapter();

        CsipSetCoordinatorNativeInterface.setInstance(mCsipSetCoordinatorNativeInterface);
        startService();
        mService.mCsipSetCoordinatorNativeInterface = mCsipSetCoordinatorNativeInterface;
        mService.mServiceFactory = mServiceFactory;
        when(mServiceFactory.getLeAudioService()).thenReturn(mLeAudioService);

@@ -158,6 +158,7 @@ public class CsipSetCoordinatorServiceTest {
        }

        stopService();
        CsipSetCoordinatorNativeInterface.setInstance(null);
        mTargetContext.unregisterReceiver(mCsipSetCoordinatorIntentReceiver);
        TestUtils.clearAdapterService(mAdapterService);
        mIntentQueue.clear();