<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
    <!-- Android 10 and later only let an app open a screen from the background when it may draw over other
         apps. the install script grants it; on Android 9 it is not needed. -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

    <uses-feature android:name="android.software.leanback" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />

    <application
        android:allowBackup="false"
        android:banner="@drawable/banner"
        android:icon="@drawable/banner"
        android:label="@string/app_name">

        <!-- The settings screen: the app's own tile and, on the cleanyourtv launcher, its module card. -->
        <activity
            android:name=".SettingsActivity"
            android:exported="true"
            android:theme="@android:style/Theme.DeviceDefault.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="com.gathin.tvhome.category.DOCK_CARD" />
            </intent-filter>
            <meta-data android:name="com.gathin.tvhome.card" android:resource="@xml/module_card" />
        </activity>

        <!-- The "off the air" screen: translucent, so the picture underneath shows through as it fades out. -->
        <activity
            android:name=".StaticActivity"
            android:exported="false"
            android:excludeFromRecents="true"
            android:launchMode="singleInstance"
            android:noHistory="true"
            android:screenOrientation="landscape"
            android:theme="@style/Static" />

        <!-- Keeps the screen-on receiver registered: SCREEN_ON cannot be received from the manifest. Exported only
             to callers holding WRITE_SECURE_SETTINGS (the adb shell), so the install script can start it. -->
        <service
            android:name=".WatchService"
            android:exported="true"
            android:permission="android.permission.WRITE_SECURE_SETTINGS"
            android:foregroundServiceType="specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="Plays a short static effect when the screen turns on" />
        </service>

        <receiver
            android:name=".BootReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>
    </application>
</manifest>
