Replacing getActiveDevice by btAdapter.getActiveDevices()

BluetoothProfile.getActiveDevice() is hidden, packages
should call BluetoothAdapter.getActiveDevices(profile)
instead.

Tag: #feature
Bug: 200202780
Test: build
Change-Id: Ie8589eb2a949300e8d43daaee02587b8d6b0ae23
diff --git a/PMC/src/com/android/pmc/A2dpReceiver.java b/PMC/src/com/android/pmc/A2dpReceiver.java
index 4728830..f610788 100644
--- a/PMC/src/com/android/pmc/A2dpReceiver.java
+++ b/PMC/src/com/android/pmc/A2dpReceiver.java
@@ -404,7 +404,7 @@
         List<BluetoothCodecConfig> codecsSelectableCapabilities = new ArrayList<>();
 
         if (mBluetoothA2dp != null) {
-            BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
+            BluetoothDevice activeDevice = getA2dpActiveDevice();
             if (activeDevice == null) {
                 Log.e(TAG, "getCodecValue: Active device is null");
                 return null;
@@ -478,13 +478,13 @@
         }
 
         if (mBluetoothA2dp != null) {
-            BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
+            BluetoothDevice activeDevice = getA2dpActiveDevice();
             if (activeDevice == null) {
                 Log.e(TAG, "setCodecValue: Active device is null. Codec is not set.");
                 return false;
             }
             Log.d(TAG, "setCodecConfigPreference()");
-            mBluetoothA2dp.setCodecConfigPreference(mBluetoothA2dp.getActiveDevice(), codecConfig);
+            mBluetoothA2dp.setCodecConfigPreference(getA2dpActiveDevice(), codecConfig);
         } else {
             Log.e(TAG, "mBluetoothA2dp is null. Codec is not set");
             return false;
@@ -509,6 +509,15 @@
         return true;
     }
 
+    private BluetoothDevice getA2dpActiveDevice() {
+        if (mBluetoothAdapter == null) {
+            return null;
+        }
+        List<BluetoothDevice> activeDevices =
+                mBluetoothAdapter.getActiveDevices(BluetoothProfile.A2DP);
+        return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
+    }
+
     /**
      * Method to verify if the codec config values are changed
      *