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

Commit e6ac0c57 authored by Atneya Nair's avatar Atneya Nair
Browse files

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
parent e1ea5db7
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -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;
        }

    }

    /**