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

Commit d826a2de authored by Sherry Huang's avatar Sherry Huang
Browse files

TIS: Include ALWAYS_BOUND_TV_INPUT permission

Patch for preventing TIS being destoryed when TIF calls unbindService by introduce android.permission.ALWAYS_BOUND_TV_INPUT.

Test: verified by vendor
Flag: EXEMPT bugfix
Bug: b/332201346

Change-Id: I87fef6291aa70be4c9aecd4dcc40ffc05666d485
parent 592fca97
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -5410,6 +5410,15 @@
    <permission android:name="android.permission.BIND_TV_INPUT"
    <permission android:name="android.permission.BIND_TV_INPUT"
        android:protectionLevel="signature|privileged" />
        android:protectionLevel="signature|privileged" />


    <!-- This permission is required among systems services to always keep the
         binding with TvInputManagerService.
         <p>This should only be used by the OEM TvInputService.
         <p>Protection level: signature|privileged|vendorPrivileged
         @hide
    -->
    <permission android:name="android.permission.ALWAYS_BOUND_TV_INPUT"
        android:protectionLevel="signature|privileged|vendorPrivileged" />

    <!-- Must be required by a {@link android.media.tv.interactive.TvInteractiveAppService}
    <!-- Must be required by a {@link android.media.tv.interactive.TvInteractiveAppService}
         to ensure that only the system can bind to it.
         to ensure that only the system can bind to it.
         <p>Protection level: signature|privileged
         <p>Protection level: signature|privileged
+7 −1
Original line number Original line Diff line number Diff line
@@ -341,10 +341,16 @@ public final class TvInputManagerService extends SystemService {
        }, UserHandle.ALL, intentFilter, null, null);
        }, UserHandle.ALL, intentFilter, null, null);
    }
    }


    private static boolean hasAlwaysBoundPermission(PackageManager pm, ComponentName component) {
        return pm.checkPermission(android.Manifest.permission.ALWAYS_BOUND_TV_INPUT,
                component.getPackageName()) == PackageManager.PERMISSION_GRANTED;
    }

    private static boolean hasHardwarePermission(PackageManager pm, ComponentName component) {
    private static boolean hasHardwarePermission(PackageManager pm, ComponentName component) {
        return pm.checkPermission(android.Manifest.permission.TV_INPUT_HARDWARE,
        return pm.checkPermission(android.Manifest.permission.TV_INPUT_HARDWARE,
                component.getPackageName()) == PackageManager.PERMISSION_GRANTED;
                component.getPackageName()) == PackageManager.PERMISSION_GRANTED;
    }
    }

    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private void buildTvInputListLocked(int userId, String[] updatedPackages) {
    private void buildTvInputListLocked(int userId, String[] updatedPackages) {
        UserState userState = getOrCreateUserStateLocked(userId);
        UserState userState = getOrCreateUserStateLocked(userId);
@@ -3526,7 +3532,7 @@ public final class TvInputManagerService extends SystemService {
                continue;
                continue;
            }
            }
            ComponentName component = new ComponentName(si.packageName, si.name);
            ComponentName component = new ComponentName(si.packageName, si.name);
            if (hasHardwarePermission(pm, component)) {
            if (!hasAlwaysBoundPermission(pm, component) && hasHardwarePermission(pm, component)) {
                updateServiceConnectionLocked(component, userId);
                updateServiceConnectionLocked(component, userId);
            }
            }
        }
        }