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

Commit 39734d2c authored by jiabin's avatar jiabin
Browse files

Use waitForService instead of getService.

ServiceManager.getService is deprecated and it is suggested to use
waitForService.

Bug: 336877913
Test: atest AAudioTests with/without enabling mmap
Change-Id: If1d878f632fc8107ba31fdf5b861c533706c5572
parent f61ea2ad
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -71,18 +71,10 @@ std::shared_ptr<AAudioServiceInterface> AAudioBinderClient::getAAudioService() {
    {
        Mutex::Autolock _l(mServiceLock);
        if (mAdapter == nullptr) {
            sp<IBinder> binder;
            sp<IServiceManager> sm = defaultServiceManager();
            // Try several times to get the service.
            int retries = 4;
            do {
                binder = sm->getService(String16(AAUDIO_SERVICE_NAME)); // This will wait a while.
                if (binder.get() != nullptr) {
                    break;
                }
            } while (retries-- > 0);
            sp<IBinder> binder = sm->waitForService(String16(AAUDIO_SERVICE_NAME));

            if (binder.get() != nullptr) {
            if (binder != nullptr) {
                // Ask for notification if the service dies.
                status_t status = binder->linkToDeath(mAAudioClient);
                // TODO review what we should do if this fails