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

Commit a0c85f89 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5087486 from 0a539702 to pi-qpr2-release

Change-Id: I4004032c78dc8bc4930905939bac97653ef2cfe2
parents d6bc8a39 0a539702
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -62,6 +62,15 @@ static void volumeDeviceConnected(
static void volumeDeviceDisconnected(const RawAddress& address);
static void setVolume(int8_t volume);

// Local Variables
// TODO (apanicke): Use a map here to store the callback in order to
// support multi-browsing
SetBrowsedPlayerCb set_browsed_player_cb;
using map_entry = std::pair<std::string, GetFolderItemsCb>;
std::map<std::string, GetFolderItemsCb> get_folder_items_cb_map;
std::map<RawAddress, ::bluetooth::avrcp::VolumeInterface::VolumeChangedCb>
    volumeCallbackMap;

// TODO (apanicke): In the future, this interface should guarantee that
// all calls happen on the JNI Thread. Right now this is very difficult
// as it is hard to get a handle on the JNI thread from here.
@@ -249,6 +258,9 @@ static void cleanupNative(JNIEnv* env, jobject object) {
  std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex);
  std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex);

  get_folder_items_cb_map.clear();
  volumeCallbackMap.clear();

  sServiceInterface->Cleanup();
  env->DeleteGlobalRef(mJavaInterface);
  mJavaInterface = nullptr;
@@ -593,10 +605,6 @@ static std::vector<MediaPlayerInfo> getMediaPlayerList() {
  return ret_list;
}

// TODO (apanicke): Use a map here to store the callback in order to
// support multi-browsing
SetBrowsedPlayerCb set_browsed_player_cb;

static void setBrowsedPlayer(uint16_t player_id, SetBrowsedPlayerCb cb) {
  ALOGD("%s", __func__);
  std::shared_lock<std::shared_timed_mutex> lock(callbacks_mutex);
@@ -623,9 +631,6 @@ static void setBrowsedPlayerResponseNative(JNIEnv* env, jobject object,
  set_browsed_player_cb.Run(success == JNI_TRUE, root, num_items);
}

using map_entry = std::pair<std::string, GetFolderItemsCb>;
std::map<std::string, GetFolderItemsCb> get_folder_items_cb_map;

static void getFolderItemsResponseNative(JNIEnv* env, jobject object,
                                         jstring parent_id, jobject list) {
  ALOGD("%s", __func__);
@@ -751,9 +756,6 @@ static void volumeDeviceConnected(const RawAddress& address) {
                               j_bdaddr, JNI_FALSE);
}

std::map<RawAddress, ::bluetooth::avrcp::VolumeInterface::VolumeChangedCb>
    volumeCallbackMap;

static void volumeDeviceConnected(
    const RawAddress& address,
    ::bluetooth::avrcp::VolumeInterface::VolumeChangedCb cb) {
+11 −6
Original line number Diff line number Diff line
@@ -627,19 +627,24 @@ public class HearingAidService extends ProfileService {
            if (DBG) {
                Log.d(TAG, "Set Hearing Aid audio to disconnected");
            }
            mAudioManager.setHearingAidDeviceConnectionState(mPreviousAudioDevice,
                    BluetoothProfile.STATE_DISCONNECTED);
            boolean suppressNoisyIntent =
                    (getConnectionState(mPreviousAudioDevice) == BluetoothProfile.STATE_CONNECTED);
            mAudioManager.setBluetoothHearingAidDeviceConnectionState(
                    mPreviousAudioDevice, BluetoothProfile.STATE_DISCONNECTED,
                    suppressNoisyIntent, 0);
            mPreviousAudioDevice = null;
        } else {
            if (DBG) {
                Log.d(TAG, "Set Hearing Aid audio to connected");
            }
            if (mPreviousAudioDevice != null) {
                mAudioManager.setHearingAidDeviceConnectionState(mPreviousAudioDevice,
                        BluetoothProfile.STATE_DISCONNECTED);
                mAudioManager.setBluetoothHearingAidDeviceConnectionState(
                        mPreviousAudioDevice, BluetoothProfile.STATE_DISCONNECTED,
                        true, 0);
            }
            mAudioManager.setHearingAidDeviceConnectionState(device,
                    BluetoothProfile.STATE_CONNECTED);
            mAudioManager.setBluetoothHearingAidDeviceConnectionState(
                    device, BluetoothProfile.STATE_CONNECTED,
                    true, 0);
            mPreviousAudioDevice = device;
        }
    }
+6 −4
Original line number Diff line number Diff line
@@ -501,8 +501,9 @@ public class HearingAidServiceTest {
        Assert.assertTrue(mService.getConnectedDevices().contains(mRightDevice));

        // Verify the audio is routed to Hearing Aid Profile
        verify(mAudioManager).setHearingAidDeviceConnectionState(any(BluetoothDevice.class),
                eq(BluetoothProfile.STATE_CONNECTED));
        verify(mAudioManager).setBluetoothHearingAidDeviceConnectionState(
                any(BluetoothDevice.class), eq(BluetoothProfile.STATE_CONNECTED),
                eq(true), eq(0));

        // Send a disconnect request
        Assert.assertTrue("Disconnect failed", mService.disconnect(mLeftDevice));
@@ -549,8 +550,9 @@ public class HearingAidServiceTest {
        Assert.assertFalse(mService.getConnectedDevices().contains(mRightDevice));

        // Verify the audio is not routed to Hearing Aid Profile
        verify(mAudioManager).setHearingAidDeviceConnectionState(any(BluetoothDevice.class),
                eq(BluetoothProfile.STATE_DISCONNECTED));
        verify(mAudioManager).setBluetoothHearingAidDeviceConnectionState(
                any(BluetoothDevice.class), eq(BluetoothProfile.STATE_DISCONNECTED),
                eq(false), eq(0));
    }

    /**