Replace sessionStateMap with sessionTokens.
Change-Id: I6ec3390ca31cd17da35f0b0b83b1b09600d7d6d1
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 16ed7fe..75e5857 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -197,8 +197,8 @@
UserState userState = getUserStateLocked(userId);
ServiceState serviceState = userState.serviceStateMap.get(name);
if (serviceState == null) {
- throw new IllegalStateException("Service state not found for " + name + " (userId=" +
- userId + ")");
+ throw new IllegalStateException("Service state not found for " + name + " (userId="
+ + userId + ")");
}
return serviceState;
}
@@ -233,8 +233,8 @@
if (serviceState == null) {
return;
}
- boolean isStateEmpty = serviceState.clients.size() == 0
- && serviceState.sessionStateMap.size() == 0;
+ boolean isStateEmpty = serviceState.clients.isEmpty()
+ && serviceState.sessionTokens.isEmpty();
if (serviceState.service == null && !isStateEmpty && userId == mCurrentUserId) {
// This means that the service is not yet connected but its state indicates that we
// have pending requests. Then, connect the service.
@@ -263,7 +263,9 @@
}
private void createSessionInternalLocked(ITvInputService service, final IBinder sessionToken,
- final SessionState sessionState, final int userId) {
+ final int userId) {
+ final SessionState sessionState =
+ getUserStateLocked(userId).sessionStateMap.get(sessionToken);
if (DEBUG) {
Log.d(TAG, "createSessionInternalLocked(name=" + sessionState.name.getClassName()
+ ")");
@@ -319,10 +321,10 @@
UserState userState = getUserStateLocked(userId);
SessionState sessionState = userState.sessionStateMap.remove(sessionToken);
- // Also remove the session state from the session state map of the current service.
+ // Also remove the session token from the session token list of the current service.
ServiceState serviceState = userState.serviceStateMap.get(sessionState.name);
if (serviceState != null) {
- serviceState.sessionStateMap.remove(sessionToken);
+ serviceState.sessionTokens.remove(sessionToken);
}
updateServiceConnectionLocked(sessionState.name, userId);
}
@@ -465,11 +467,11 @@
serviceState = new ServiceState(name, resolvedUserId);
userState.serviceStateMap.put(name, serviceState);
}
- serviceState.sessionStateMap.put(sessionToken, sessionState);
+ serviceState.sessionTokens.add(sessionToken);
if (serviceState.service != null) {
createSessionInternalLocked(serviceState.service, sessionToken,
- sessionState, resolvedUserId);
+ resolvedUserId);
} else {
updateServiceConnectionLocked(name, resolvedUserId);
}
@@ -580,8 +582,7 @@
private final class ServiceState {
private final List<IBinder> clients = new ArrayList<IBinder>();
- private final ArrayMap<IBinder, SessionState> sessionStateMap = new ArrayMap<IBinder,
- SessionState>();
+ private final List<IBinder> sessionTokens = new ArrayList<IBinder>();
private final ServiceConnection connection;
private ITvInputService service;
@@ -637,10 +638,8 @@
}
// And create sessions, if any.
- for (Map.Entry<IBinder, SessionState> entry : serviceState.sessionStateMap
- .entrySet()) {
- createSessionInternalLocked(serviceState.service, entry.getKey(),
- entry.getValue(), mUserId);
+ for (IBinder sessionToken : serviceState.sessionTokens) {
+ createSessionInternalLocked(serviceState.service, sessionToken, mUserId);
}
}
}