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

Commit 51bc048e authored by Myles Watson's avatar Myles Watson Committed by Android (Google) Code Review
Browse files

Merge "audio client: Use AServiceManager_waitForService" into tm-qpr-dev

parents 136c4d51 6e6cea50
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -55,9 +55,8 @@ BluetoothAudioClientInterface::BluetoothAudioClientInterface(
}

bool BluetoothAudioClientInterface::is_aidl_available() {
  auto service = AServiceManager_checkService(
  return AServiceManager_isDeclared(
      kDefaultAudioProviderFactoryInterface.c_str());
  return (service != nullptr);
}

std::vector<AudioCapabilities>
@@ -72,7 +71,7 @@ BluetoothAudioClientInterface::GetAudioCapabilities(SessionType session_type) {
    return capabilities;
  }
  auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(
      ::ndk::SpAIBinder(AServiceManager_getService(
      ::ndk::SpAIBinder(AServiceManager_waitForService(
          kDefaultAudioProviderFactoryInterface.c_str())));

  if (provider_factory == nullptr) {
@@ -91,16 +90,15 @@ BluetoothAudioClientInterface::GetAudioCapabilities(SessionType session_type) {
}

void BluetoothAudioClientInterface::FetchAudioProvider() {
  if (!is_aidl_available()) {
    LOG(ERROR) << __func__ << ": aidl is not supported on this platform.";
    return;
  }
  if (provider_ != nullptr) {
    LOG(WARNING) << __func__ << ": refetch";
  } else if (!is_aidl_available()) {
    // AIDL availability should only be checked at the beginning.
    // When refetching, AIDL may not be ready *yet* but it's expected to be
    // available later.
    return;
  }
  auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(
      ::ndk::SpAIBinder(AServiceManager_getService(
      ::ndk::SpAIBinder(AServiceManager_waitForService(
          kDefaultAudioProviderFactoryInterface.c_str())));

  if (provider_factory == nullptr) {