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

Commit c131eafa authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix hardware TvInputService binding issue" am: e27b9897 am:...

Merge "Fix hardware TvInputService binding issue" am: e27b9897 am: f71ccd32 am: 5cd05e3d am: b159aa06

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1873994

Change-Id: Ic9c4598640e18020507d1d3e17224e34a74490cd
parents c98aebc4 b159aa06
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -317,6 +317,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)) {
@@ -327,6 +328,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
@@ -399,6 +401,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;
    }