<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- SDD-trace: SRS-045 (protocol adapter dials TeamSpeak-compatible
         server) / SAD-032 (protocol-adapter isolation). Also supports
         SRS-130 network-failure error reporting. Required for the
         protocol layer to dial a TeamSpeak-compatible server over UDP. -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- SRS-100: Network diagnostics. Allows the core to query active
         network type and state for the diagnostic export. -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!-- SDD-115: Prevent CPU sleep during active voice sessions.
         Keeps the audio pipeline running when the screen locks. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <!-- SRS-025: Haptic feedback on PTT key press. Enables
         VibrationEffect for transmit-mode tactile confirmation. -->
    <uses-permission android:name="android.permission.VIBRATE" />

    <!-- SDD-trace: SDD-106 AndroidPermissionRequester.
         Required for the audio engine (chanora_audio) to open the
         capture stream for voice transmission. The runtime grant
         must still be requested; this declaration only allows the
         app to ask. -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <!-- SDD-trace: SDD-107 AndroidVoiceForegroundService (item 3).
         Required on API 28+ to start a foreground service that keeps
         the voice session alive while the UI is backgrounded. -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

    <!-- SDD-trace: SDD-107 AndroidVoiceForegroundService (item 3).
         Required on API 34+ when the foreground service declares
         foregroundServiceType="microphone". Declared here for the
         entire API ladder; the platform ignores it on older releases. -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

    <!-- SDD-trace: SDD-107 AndroidVoiceForegroundService (item 6).
         Required on API 33+ to display the ongoing voice-session
         notification. Runtime-requested via AndroidPermissionRequester
         (SDD-106); denial does not block the service. -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- SDD-trace: SDD-108 AndroidAudioModeController.
         Required for AudioManager.setMode(MODE_IN_COMMUNICATION) and
         related in-call audio routing operations. -->
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

    <!-- SDD-trace: SDD-110 AndroidBluetoothScoController.
         BLUETOOTH_ADMIN required for startBluetoothSco() / stopBluetoothSco()
         on API 23-30. Superseded by BLUETOOTH_CONNECT on API 31+. -->
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
        android:maxSdkVersion="30" />

    <!-- SDD-trace: SDD-110 AndroidBluetoothScoController.
         BLUETOOTH required to query BluetoothAdapter on API < 31. -->
    <uses-permission android:name="android.permission.BLUETOOTH"
        android:maxSdkVersion="30" />

    <!-- SDD-trace: Android Oboe voice backend; supports SCO/BLE
         headset routing on API 31+. Declared here so the platform
         allows querying / connecting to bonded Bluetooth audio devices
         for the voice session. -->
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

    <!-- SDD-105: Application class loads chanora_bridge native library before MainActivity onCreate -->
    <application
        android:label="Chanora"
        android:name="app.chanora.chanora_flutter.ChanoraApplication"
        android:icon="@mipmap/ic_launcher"
        android:enableOnBackInvokedCallback="true">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:taskAffinity=""
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!-- SDD-trace: SDD-107 AndroidVoiceForegroundService (item 2).
             Manifest declaration for the foreground service that owns
             the Android voice-session lifecycle. The Kotlin class is
             owned by Wave 2B-2 (apps/chanora_flutter/android/app/src/main/kotlin/).
             android:foregroundServiceType="microphone" is required by
             API 30+ to gate background microphone access; ignored on
             API 28-29 where capture is permitted without it. -->
        <service
            android:name="app.chanora.chanora_flutter.AndroidVoiceForegroundService"
            android:exported="false"
            android:foregroundServiceType="microphone" />

        <!-- flutter_foreground_task: keeps the Flutter engine alive when
             connected to a server so voice chat is not killed in background. -->
        <service
            android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
            android:exported="false"
            android:foregroundServiceType="dataSync" />

        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <!-- Required to query activities that can process text, see:
         https://developer.android.com/training/package-visibility and
         https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.

         In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT"/>
            <data android:mimeType="text/plain"/>
        </intent>
    </queries>
</manifest>
