Add logs to debug MapClientTest failure
Bug: 264224883
Test: atest MapClientTest
Change-Id: Id30ca695574e0605393e8a79fa67a80894884a4a
diff --git a/android/app/src/com/android/bluetooth/mapclient/MapClientService.java b/android/app/src/com/android/bluetooth/mapclient/MapClientService.java
index 12a1161..0ddb25d 100644
--- a/android/app/src/com/android/bluetooth/mapclient/MapClientService.java
+++ b/android/app/src/com/android/bluetooth/mapclient/MapClientService.java
@@ -166,6 +166,9 @@
}
private synchronized void addDeviceToMapAndConnect(BluetoothDevice device) {
+ if (Utils.isInstrumentationTestMode()) {
+ Log.d(TAG, "addDeviceToMapAndConnect: device=" + device, new Exception());
+ }
// When creating a new statemachine, its state is set to CONNECTING - which will trigger
// connect.
MceStateMachine mapStateMachine = new MceStateMachine(this, device);
@@ -365,6 +368,9 @@
}
removeUncleanAccounts();
mMapInstanceMap.clear();
+ if (Utils.isInstrumentationTestMode()) {
+ Log.d(TAG, "cleanup() called.", new Exception());
+ }
// TODO(b/72948646): should be moved to stop()
setMapClientService(null);
}
diff --git a/android/app/tests/unit/src/com/android/bluetooth/mapclient/MapClientTest.java b/android/app/tests/unit/src/com/android/bluetooth/mapclient/MapClientTest.java
index c78616e..3249a42 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/mapclient/MapClientTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/mapclient/MapClientTest.java
@@ -24,6 +24,7 @@
import android.bluetooth.IBluetoothMapClient;
import android.content.Context;
import android.os.UserHandle;
+import android.util.Log;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.MediumTest;
@@ -122,6 +123,8 @@
// is the statemachine created
Map<BluetoothDevice, MceStateMachine> map = mService.getInstanceMap();
+ Log.d("MapClientTest", "map=" + map);
+
Assert.assertEquals(1, map.size());
Assert.assertNotNull(map.get(device));
TestUtils.waitForLooperToFinishScheduledTask(mService.getMainLooper());