<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:installLocation="auto">

    <!-- Vulkan 1.0 -->
    <uses-feature
        android:name="android.hardware.vulkan.version"
        android:version="0x400000"
        android:required="true" />

    <!-- OpenGL ES 3.2 -->
    <uses-feature
        android:glEsVersion="0x00030002"
        android:required="false" />

    <!-- Touchscreen support -->
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <!-- Game controller support -->
    <uses-feature
        android:name="android.hardware.bluetooth"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.gamepad"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.usb.host"
        android:required="false" />

    <!-- External mouse input events -->
    <uses-feature
        android:name="android.hardware.type.pc"
        android:required="false" />

    <!-- Audio recording support -->
    <!-- if you want to capture audio, uncomment this. -->
    <!-- Disable for the time being as it looks like some antiviruses consider Vita3K as a malware because of it -->
    <uses-feature
        android:name="android.hardware.microphone"
        android:required="false" />

    <!-- Camera support -->
    <!-- if you want to record video, uncomment this. -->
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />

    <!-- Allow downloading to the external storage on Android 5.1 and older -->
    <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> -->
    <!-- For android API <= 29 (Up to Android 10), use Legacy storage, otherwise use the MANAGE_EXTERNAL_STORAGE permission -->
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="29" />
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="29" />
    <uses-permission
        android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
        android:minSdkVersion="30" />

    <!-- Allow access to Bluetooth devices -->
    <!-- Currently this is just for Steam Controller support and requires setting SDL_HINT_JOYSTICK_HIDAPI_STEAM -->
    <!-- <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> -->
    <!-- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> -->

    <!-- Allow access to the vibrator -->
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

    <uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name = "android.permission.INTERNET"/>

    <!-- if you want to capture audio, uncomment this. -->
    <!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->

    <!-- Create a Java class extending SDLActivity and place it in a
         directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java

         then replace "SDLActivity" with the name of your class (e.g. "MyGame")
         in the XML below.
         An example Java class can be found in README-android.md

         The requestLegacyExternalStorage parameter only has an effect when running on Android <= 10
    -->
    <application android:name=".Vita3KApplication"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="true"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:hardwareAccelerated="true"
        android:appCategory="game"
        android:isGame="true"
        android:hasFragileUserData="true"
        android:localeConfig="@xml/locales_config"
        android:requestLegacyExternalStorage="true"
        tools:targetApi="q">

        <!-- Main Compose UI activity (launcher) -->
        <activity android:name=".MainActivity"
            android:theme="@style/Theme.Vita3K.Starting"
            android:exported="true"
            android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|uiMode|layoutDirection|locale|keyboard|keyboardHidden"
            tools:targetApi="r">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- SDL game rendering activity -->
        <activity android:name=".Emulator"
            android:alwaysRetainTaskState="true"
            android:launchMode="singleTop"
            android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
            android:preferMinimalPostProcessing="true"
            android:theme="@style/Theme.Design.NoActionBar"
            android:exported="true"
            tools:targetApi="r">

            <!-- USB device handling -->
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>

        </activity>

        <service
            android:name=".InstallForegroundService"
            android:exported="false"
            android:foregroundServiceType="dataSync" />
    </application>

</manifest>
