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

Commit 52848fcc authored by Dongwon Kang's avatar Dongwon Kang Committed by Android (Google) Code Review
Browse files

Merge "TIF: Unbind the service only when it is bound"

parents 35d648f3 81e3c3e6
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -445,6 +445,7 @@ public final class TvInputManagerService extends SystemService {

        // Unregister all callbacks and unbind all services.
        for (ServiceState serviceState : userState.serviceStateMap.values()) {
            if (serviceState.service != null) {
                if (serviceState.callback != null) {
                    try {
                        serviceState.service.unregisterCallback(serviceState.callback);
@@ -454,6 +455,7 @@ public final class TvInputManagerService extends SystemService {
                }
                mContext.unbindService(serviceState.connection);
            }
        }
        userState.serviceStateMap.clear();
    }

@@ -1974,7 +1976,12 @@ public final class TvInputManagerService extends SystemService {
                Slog.d(TAG, "onServiceConnected(component=" + component + ")");
            }
            synchronized (mLock) {
                UserState userState = getOrCreateUserStateLocked(mUserId);
                UserState userState = mUserStates.get(mUserId);
                if (userState == null) {
                    // The user was removed while connecting.
                    mContext.unbindService(this);
                    return;
                }
                ServiceState serviceState = userState.serviceStateMap.get(mComponent);
                serviceState.service = ITvInputService.Stub.asInterface(service);