Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -35,11 +35,17 @@ 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 {
classInitNative();
if (Utils.isInstrumentationTestMode()) {
Log.w(TAG, "App is instrumented. Skip loading the native");
} else {
classInitNative();
}
}
private CsipSetCoordinatorNativeInterface() {
......@@ -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.
*
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment