summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kyeongkab.Nam <Kyeongkab.Nam@sony.com> 2021-10-30 06:36:40 +0900
committer Kyeongkab.Nam <Kyeongkab.Nam@sony.com> 2021-11-12 04:02:43 +0900
commit4ddacb909dde67c93d6188d39fd4c63ecff01bdf (patch)
tree24294086a585a749e4c9a9cab353f72a7ea8a34f
parent27c03c7f685a157154fdd5865cceb6e84c8a53cc (diff)
Fix hardware TvInputService binding issue
Bind to hardware TvInputService even after disabled and enabled the service. Bug: 204469566 Test: manual Change-Id: I9d009077a19612fbcaf13b3edc6249a85566c3ef
-rwxr-xr-xservices/core/java/com/android/server/tv/TvInputManagerService.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 36a854e5374c..9760e458ced1 100755
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -315,6 +315,7 @@ public final class TvInputManagerService extends SystemService {
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
userId);
List<TvInputInfo> inputList = new ArrayList<>();
+ List<ComponentName> hardwareComponents = new ArrayList<>();
for (ResolveInfo ri : services) {
ServiceInfo si = ri.serviceInfo;
if (!android.Manifest.permission.BIND_TV_INPUT.equals(si.permission)) {
@@ -325,6 +326,7 @@ public final class TvInputManagerService extends SystemService {
ComponentName component = new ComponentName(si.packageName, si.name);
if (hasHardwarePermission(pm, component)) {
+ hardwareComponents.add(component);
ServiceState serviceState = userState.serviceStateMap.get(component);
if (serviceState == null) {
// New hardware input found. Create a new ServiceState and connect to the
@@ -397,6 +399,15 @@ public final class TvInputManagerService extends SystemService {
}
}
+ // Clean up ServiceState corresponding to the removed hardware inputs
+ Iterator<ServiceState> it = userState.serviceStateMap.values().iterator();
+ while (it.hasNext()) {
+ ServiceState serviceState = it.next();
+ if (serviceState.isHardware && !hardwareComponents.contains(serviceState.component)) {
+ it.remove();
+ }
+ }
+
userState.inputMap.clear();
userState.inputMap = inputMap;
}