Merge "Fix hardware TvInputService binding issue" am: e27b9897c3 am: f71ccd329a
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1873994 Change-Id: I3aff7ec77bc4d7bc29453ceabee58de6f949b59b
This commit is contained in:
@@ -315,6 +315,7 @@ public final class TvInputManagerService extends SystemService {
|
|||||||
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
|
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA,
|
||||||
userId);
|
userId);
|
||||||
List<TvInputInfo> inputList = new ArrayList<>();
|
List<TvInputInfo> inputList = new ArrayList<>();
|
||||||
|
List<ComponentName> hardwareComponents = new ArrayList<>();
|
||||||
for (ResolveInfo ri : services) {
|
for (ResolveInfo ri : services) {
|
||||||
ServiceInfo si = ri.serviceInfo;
|
ServiceInfo si = ri.serviceInfo;
|
||||||
if (!android.Manifest.permission.BIND_TV_INPUT.equals(si.permission)) {
|
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);
|
ComponentName component = new ComponentName(si.packageName, si.name);
|
||||||
if (hasHardwarePermission(pm, component)) {
|
if (hasHardwarePermission(pm, component)) {
|
||||||
|
hardwareComponents.add(component);
|
||||||
ServiceState serviceState = userState.serviceStateMap.get(component);
|
ServiceState serviceState = userState.serviceStateMap.get(component);
|
||||||
if (serviceState == null) {
|
if (serviceState == null) {
|
||||||
// New hardware input found. Create a new ServiceState and connect to the
|
// 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.clear();
|
||||||
userState.inputMap = inputMap;
|
userState.inputMap = inputMap;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user