Add Bluetooth callback for device connection state changed

With the new Multi-A2DP/HFP support, need to add profile connection state
changed callback for every BT device connect/disconnect to profile.

Bug: 76447449
Test: make RunSettingsLibRoboTests ROBOTEST_FILTER=LocalBluetoothProfileManagerTest -j28
Test: make RunSettingsLibRoboTests ROBOTEST_FILTER=BluetoothEventManagerTest -j28
Change-Id: Iaaec369e8d10f9b1270491632fb5c91de1e28571
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java
index d1e37f6..466980c 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java
@@ -15,13 +15,17 @@
  */
 package com.android.settingslib.bluetooth;
 
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.verify;
 
 import android.bluetooth.BluetoothHeadset;
+import android.bluetooth.BluetoothProfile;
 import android.content.Context;
 import android.content.Intent;
 
 import android.telephony.TelephonyManager;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -39,6 +43,8 @@
     private CachedBluetoothDeviceManager mCachedDeviceManager;
     @Mock
     private BluetoothCallback mBluetoothCallback;
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDevice;
 
     private Context mContext;
     private Intent mIntent;
@@ -78,4 +84,19 @@
 
         verify(mBluetoothCallback).onAudioModeChanged();
     }
+
+    /**
+     * dispatchProfileConnectionStateChanged should dispatch to onProfileConnectionStateChanged
+     * callback.
+     */
+    @Test
+    public void dispatchProfileConnectionStateChanged_registerCallback_shouldDispatchCallback() {
+        mBluetoothEventManager.registerCallback(mBluetoothCallback);
+
+        mBluetoothEventManager.dispatchProfileConnectionStateChanged(mCachedBluetoothDevice,
+                BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
+
+        verify(mBluetoothCallback).onProfileConnectionStateChanged(mCachedBluetoothDevice,
+                BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
+    }
 }