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

Commit bcf95f67 authored by Paul Wang's avatar Paul Wang
Browse files

Replace getService with waitForService

Reduce log spam and error logging as part of the Green Log effort.
IServiceManager#getService is deprecated.

Bug: 224431795
Test: adb shell pkill audioserver
Change-Id: I6cd99ac9ca3a41a299f436e7463924360c972319
parent 00ba629f
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -132,12 +132,10 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger() {
                binder = gAudioFlingerBinder;
            } else {
                sp<IServiceManager> sm = defaultServiceManager();
                do {
                    binder = sm->getService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME));
                    if (binder != nullptr) break;
                    ALOGW("AudioFlinger not published, waiting...");
                    usleep(500000); // 0.5 s
                } while (true);
                binder = sm->waitForService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME));
                if (binder == nullptr) {
                    return nullptr;
                }
            }
            binder->linkToDeath(gAudioFlingerClient);
            const auto afs = interface_cast<media::IAudioFlingerService>(binder);
@@ -864,14 +862,10 @@ const sp<IAudioPolicyService> AudioSystem::get_audio_policy_service() {
        Mutex::Autolock _l(gLockAPS);
        if (gAudioPolicyService == 0) {
            sp<IServiceManager> sm = defaultServiceManager();
            sp<IBinder> binder;
            do {
                binder = sm->getService(String16("media.audio_policy"));
                if (binder != 0)
                    break;
                ALOGW("AudioPolicyService not published, waiting...");
                usleep(500000); // 0.5 s
            } while (true);
            sp<IBinder> binder = sm->waitForService(String16("media.audio_policy"));
            if (binder == nullptr) {
                return nullptr;
            }
            if (gAudioPolicyServiceClient == NULL) {
                gAudioPolicyServiceClient = new AudioPolicyServiceClient();
            }
@@ -2078,8 +2072,7 @@ status_t AudioSystem::getHwOffloadFormatsSupportedForBluetoothMedia(
        return BAD_VALUE;
    }

    const sp<IAudioPolicyService>
            & aps = AudioSystem::get_audio_policy_service();
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return PERMISSION_DENIED;

    std::vector<AudioFormatDescription> formatsAidl;