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

Commit c663ccee authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "BtProfileConnectionInfo update api review"

parents 36011ac6 8b2de65b
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.BtProfileConnectionInfo;
import android.media.BluetoothProfileConnectionInfo;
import android.os.HandlerThread;
import android.util.Log;

@@ -477,7 +477,7 @@ public class A2dpService extends ProfileService {
            boolean stopAudio = forceStopPlayingAudio || (getConnectionState(previousActiveDevice)
                        != BluetoothProfile.STATE_CONNECTED);
            mAudioManager.handleBluetoothActiveDeviceChanged(null, previousActiveDevice,
                    BtProfileConnectionInfo.a2dpInfo(!stopAudio, -1));
                    BluetoothProfileConnectionInfo.createA2dpInfo(!stopAudio, -1));

            synchronized (mStateMachines) {
                // Make sure the Active device in native layer is set to null and audio is off
@@ -591,7 +591,7 @@ public class A2dpService extends ProfileService {
            // change, so the Audio Service can reset accordingly the audio
            // feeding parameters in the Audio HAL to the Bluetooth stack.
            mAudioManager.handleBluetoothActiveDeviceChanged(newActiveDevice, previousActiveDevice,
                    BtProfileConnectionInfo.a2dpInfo(true, rememberedVolume));
                    BluetoothProfileConnectionInfo.createA2dpInfo(true, rememberedVolume));
        }
        return true;
    }
@@ -981,7 +981,7 @@ public class A2dpService extends ProfileService {
        // is left unused until there)
        if (isActiveDevice(device)) {
            mAudioManager.handleBluetoothActiveDeviceChanged(device, device,
                    BtProfileConnectionInfo.a2dpInfo(false, -1));
                    BluetoothProfileConnectionInfo.createA2dpInfo(false, -1));
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.BtProfileConnectionInfo;
import android.media.BluetoothProfileConnectionInfo;
import android.os.HandlerThread;
import android.os.ParcelUuid;
import android.util.Log;
@@ -707,7 +707,7 @@ public class HearingAidService extends ProfileService {
                    + ". Stop audio: " + stopAudio);
        }
        mAudioManager.handleBluetoothActiveDeviceChanged(device, mPreviousAudioDevice,
                BtProfileConnectionInfo.hearingAidInfo(!stopAudio));
                BluetoothProfileConnectionInfo.createHearingAidInfo(!stopAudio));
        mPreviousAudioDevice = device;
    }

+8 −5
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.BtProfileConnectionInfo;
import android.media.BluetoothProfileConnectionInfo;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -688,7 +688,7 @@ public class LeAudioService extends ProfileService {
                            + " isLeOutput: false");
            }
            mAudioManager.handleBluetoothActiveDeviceChanged(mActiveAudioInDevice,previousInDevice,
                    BtProfileConnectionInfo.leAudio(false, false));
                    BluetoothProfileConnectionInfo.createLeAudioInfo(false, false));

            return true;
        }
@@ -750,7 +750,8 @@ public class LeAudioService extends ProfileService {
                            + " isLeOutput: true");
            }
            mAudioManager.handleBluetoothActiveDeviceChanged(mActiveAudioOutDevice,
                    previousOutDevice, BtProfileConnectionInfo.leAudio(suppressNoisyIntent, true));
                    previousOutDevice,
                    BluetoothProfileConnectionInfo.createLeAudioInfo(suppressNoisyIntent, true));
            return true;
        }
        Log.d(TAG, "updateActiveOutDevice: Nothing to do.");
@@ -1042,7 +1043,8 @@ public class LeAudioService extends ProfileService {
                        BluetoothDevice previousDevice = mActiveAudioOutDevice;
                        mActiveAudioOutDevice = device;
                        mAudioManager.handleBluetoothActiveDeviceChanged(mActiveAudioOutDevice,
                                previousDevice, BtProfileConnectionInfo.leAudio(false, true));
                                previousDevice,
                                BluetoothProfileConnectionInfo.createLeAudioInfo(false, true));
                    }
                }
            } else {
@@ -1052,7 +1054,8 @@ public class LeAudioService extends ProfileService {
                        BluetoothDevice previousDevice = mActiveAudioOutDevice;
                        mActiveAudioOutDevice = null;
                        mAudioManager.handleBluetoothActiveDeviceChanged(mActiveAudioOutDevice,
                                previousDevice, BtProfileConnectionInfo.leAudio(true, true));
                                previousDevice,
                                BluetoothProfileConnectionInfo.createLeAudioInfo(true, true));
                    }
                }
            }
+3 −3
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.BtProfileConnectionInfo;
import android.media.BluetoothProfileConnectionInfo;
import android.os.Looper;
import android.os.ParcelUuid;
import android.sysprop.BluetoothProperties;
@@ -524,7 +524,7 @@ public class HearingAidServiceTest {

        // Verify the audio is routed to Hearing Aid Profile
        verify(mAudioManager).handleBluetoothActiveDeviceChanged(
                any(BluetoothDevice.class), eq(null), any(BtProfileConnectionInfo.class));
                any(BluetoothDevice.class), eq(null), any(BluetoothProfileConnectionInfo.class));

        // Send a disconnect request
        Assert.assertTrue("Disconnect failed", mService.disconnect(mLeftDevice));
@@ -572,7 +572,7 @@ public class HearingAidServiceTest {

        // Verify the audio is not routed to Hearing Aid Profile
        verify(mAudioManager).handleBluetoothActiveDeviceChanged(
                eq(null), any(BluetoothDevice.class), any(BtProfileConnectionInfo.class));
                eq(null), any(BluetoothDevice.class), any(BluetoothProfileConnectionInfo.class));
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.BtProfileConnectionInfo;
import android.media.BluetoothProfileConnectionInfo;
import android.os.ParcelUuid;

import androidx.test.InstrumentationRegistry;