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

Commit 9c027641 authored by You Kim's avatar You Kim Committed by Gerrit Code Review
Browse files

Incorrect cache key in ConnectionServiceRepository

Pair of commponentName and userHandle is correct cache key.
ConnectionService can be leaked after unbind.

Change-Id: Ib2896917fd28ba45c5371aa7c6b2eb3a0c867eb8
parent 302e70c9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ final class ConnectionServiceRepository {
                @Override
                public void onUnbind(ConnectionServiceWrapper service) {
                    synchronized (mLock) {
                        mServiceCache.remove(service.getComponentName());
                        Pair<ComponentName, UserHandle> cacheKey = Pair.create(
                                service.getComponentName(), service.getUserHandle());
                        mServiceCache.remove(cacheKey);
                    }
                }
            };
+5 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ abstract class ServiceBinder {
    private ServiceConnection mServiceConnection;

    /** {@link UserHandle} to use for binding, to support work profiles and multi-user. */
    private UserHandle mUserHandle;
    private final UserHandle mUserHandle;

    /** The binder provided by {@link ServiceConnection#onServiceConnected} */
    private IBinder mBinder;
@@ -253,6 +253,10 @@ abstract class ServiceBinder {
        return mComponentName;
    }

    final UserHandle getUserHandle() {
        return mUserHandle;
    }

    final boolean isServiceValid(String actionName) {
        if (mBinder == null) {
            Log.w(this, "%s invoked while service is unbound", actionName);