<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />

    <!-- Phase-2 "phone hands" (native device actions, §3b / §4B). Each capability
         is requested at runtime the first time it's used; Jarvis acts only on an
         explicit command. -->
    <!-- call(number) — direct dial. CALL_PHONE does NOT trigger the sideload
         install block (only SMS + Call-LOG permissions do), so direct calling is
         kept. Falls back to ACTION_DIAL if the permission isn't granted. -->
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <!-- get_location + new_location event (FusedLocation), foreground only -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <!-- SMS reading (RECEIVE_SMS/READ_SMS) is the ONE thing Android hard-blocks on
         sideload. It returns via the default-SMS-role flow (RoleManager ROLE_SMS),
         which grants full SMS access even off-Play — a separate build task. -->
    <!-- open_camera (still/video). The Intent path itself needs no CAMERA
         permission; declared for the future in-app capture path. -->
    <uses-permission android:name="android.permission.CAMERA" />
    <!-- take_screenshot — MediaProjection foreground service (Android 14+) -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
    <!-- open_app(target) label->package resolution (sideloaded build; Play would
         require a declaration, but this app is not distributed via Play). -->
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />

    <application
        android:label="jarvis"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <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>
        <!-- Foreground service (type microphone) that the `record` plugin runs
             while a voice session is capturing. The plugin ships the service
             class but does not declare it; we declare it here with the
             microphone type required by Android 14+. -->
        <service
            android:name="com.llfbandit.record.service.AudioRecordingService"
            android:foregroundServiceType="microphone"
            android:exported="false"
            android:stopWithTask="true" />
        <!-- take_screenshot: MediaProjection capture runs in this foreground
             service (Android 14+ requires an FGS of type mediaProjection to be
             running BEFORE MediaProjection.getMediaProjection is called). -->
        <service
            android:name=".ScreenCaptureService"
            android:foregroundServiceType="mediaProjection"
            android:exported="false"
            android:stopWithTask="true" />
        <!-- SMS receiver removed with the SMS permissions (sideload install block).
             SmsReceiver.kt stays in the tree, unregistered, for the future
             default-SMS-role path. -->
        <!-- 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>
    <!-- Package/intent visibility (Android 11+). QUERY_ALL_PACKAGES above already
         grants full visibility for open_app; these narrow the common device
         actions so intent resolution works even without it. -->
    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT"/>
            <data android:mimeType="text/plain"/>
        </intent>
        <!-- open_url / navigate (http/https, geo:, google.navigation:) -->
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="geo" />
        </intent>
        <!-- call -->
        <intent>
            <action android:name="android.intent.action.DIAL" />
            <data android:scheme="tel" />
        </intent>
        <!-- open_camera (still + video) -->
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE" />
        </intent>
        <intent>
            <action android:name="android.media.action.VIDEO_CAPTURE" />
        </intent>
        <intent>
            <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
        </intent>
        <!-- set_timer -->
        <intent>
            <action android:name="android.intent.action.SET_TIMER" />
        </intent>
    </queries>
</manifest>
