Remove SoundTriggerMiddleware death notification

The death notifier for the middleware service is unnecessary
- We don't use mService elsewhere (nor check its nullity)
- We re-query the service upon each call

Additionally, creating a new death notifier on each query is redundant,
and results in memory leaks (since each notifier takes state, and we
never unlink to death).

Test: Compiles
Bug: 237968209
Change-Id: Ib53ec65235d4284357e0f6649bb6f65b2de83b99
This commit is contained in:
Atneya Nair
2022-08-03 15:52:45 -07:00
parent e1ea5db7d4
commit e6ac0c57d7

View File

@@ -1963,7 +1963,6 @@ public class SoundTrigger {
}
private static Object mServiceLock = new Object();
private static ISoundTriggerMiddlewareService mService;
/**
* Translate an exception thrown from interaction with the underlying service to an error code.
@@ -2217,20 +2216,12 @@ public class SoundTrigger {
binder =
ServiceManager.getServiceOrThrow(
Context.SOUND_TRIGGER_MIDDLEWARE_SERVICE);
binder.linkToDeath(() -> {
synchronized (mServiceLock) {
mService = null;
}
}, 0);
mService = ISoundTriggerMiddlewareService.Stub.asInterface(binder);
break;
return ISoundTriggerMiddlewareService.Stub.asInterface(binder);
} catch (Exception e) {
Log.e(TAG, "Failed to bind to soundtrigger service", e);
}
}
return mService;
}
}
/**