<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.hackernet.wireguardtv.debug"
    android:versionCode="1"
    android:versionName="1.0.0" >

    <uses-sdk
        android:minSdkVersion="22"
        android:targetSdkVersion="34" />

    <!-- TV App Deklaration -->
    <uses-feature
        android:name="android.software.leanback"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <!-- VPN Permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />

    <!-- Storage Permission für Datei-Import (vor Android 11) -->
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32" />

    <!-- Boot Receiver für Auto-Connect -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <permission
        android:name="de.hackernet.wireguardtv.debug.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
        android:protectionLevel="signature" />

    <uses-permission android:name="de.hackernet.wireguardtv.debug.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" />

    <application
        android:allowBackup="true"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:banner="@drawable/banner"
        android:debuggable="true"
        android:extractNativeLibs="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:supportsRtl="true"
        android:theme="@style/Theme.WireGuardTV" >

        <!-- TV Launcher Activity -->
        <activity
            android:name="de.hackernet.wireguardtv.ui.MainActivity"
            android:configChanges="keyboard|keyboardHidden|navigation"
            android:exported="true"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Tunnel hinzufügen/bearbeiten -->
        <activity
            android:name="de.hackernet.wireguardtv.ui.TunnelEditorActivity"
            android:exported="false"
            android:parentActivityName="de.hackernet.wireguardtv.ui.MainActivity"
            android:screenOrientation="landscape" />

        <!-- Einstellungen -->
        <activity
            android:name="de.hackernet.wireguardtv.ui.SettingsActivity"
            android:exported="false"
            android:parentActivityName="de.hackernet.wireguardtv.ui.MainActivity"
            android:screenOrientation="landscape"
            android:theme="@style/Theme.WireGuardTV.Settings" />

        <!-- Datei-Import -->
        <activity
            android:name="de.hackernet.wireguardtv.ui.FileImportActivity"
            android:exported="false"
            android:parentActivityName="de.hackernet.wireguardtv.ui.MainActivity"
            android:screenOrientation="landscape" />

        <!-- VPN Service -->
        <service
            android:name="de.hackernet.wireguardtv.vpn.WireGuardTunnelService"
            android:exported="false"
            android:foregroundServiceType="specialUse"
            android:permission="android.permission.BIND_VPN_SERVICE" >
            <intent-filter>
                <action android:name="android.net.VpnService" />
            </intent-filter>

            <meta-data
                android:name="android.net.VpnService.SUPPORTS_ALWAYS_ON"
                android:value="true" />
        </service>

        <!-- WebServer Service -->
        <service
            android:name="de.hackernet.wireguardtv.web.WebServerService"
            android:exported="false"
            android:foregroundServiceType="specialUse" />

        <!-- Boot Receiver -->
        <receiver
            android:name="de.hackernet.wireguardtv.receiver.BootReceiver"
            android:enabled="true"
            android:exported="true" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <!-- Tile Service für Quick Settings (falls unterstützt) -->
        <service
            android:name="de.hackernet.wireguardtv.tile.VpnTileService"
            android:exported="true"
            android:icon="@drawable/ic_vpn"
            android:label="@string/tile_name"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE" >
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="de.hackernet.wireguardtv.debug.androidx-startup"
            android:exported="false" >
            <meta-data
                android:name="androidx.emoji2.text.EmojiCompatInitializer"
                android:value="androidx.startup" />
            <meta-data
                android:name="androidx.lifecycle.ProcessLifecycleInitializer"
                android:value="androidx.startup" />
            <meta-data
                android:name="androidx.profileinstaller.ProfileInstallerInitializer"
                android:value="androidx.startup" />
        </provider>

        <uses-library
            android:name="androidx.window.extensions"
            android:required="false" />
        <uses-library
            android:name="androidx.window.sidecar"
            android:required="false" />

        <service
            android:name="com.wireguard.android.backend.GoBackend$VpnService"
            android:exported="false"
            android:permission="android.permission.BIND_VPN_SERVICE" >
            <intent-filter>
                <action android:name="android.net.VpnService" />
            </intent-filter>
        </service>

        <receiver
            android:name="androidx.profileinstaller.ProfileInstallReceiver"
            android:directBootAware="false"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.DUMP" >
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.INSTALL_PROFILE" />
            </intent-filter>
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.SKIP_FILE" />
            </intent-filter>
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.SAVE_PROFILE" />
            </intent-filter>
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.BENCHMARK_OPERATION" />
            </intent-filter>
        </receiver>
    </application>

</manifest>