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

    <!-- The device link is iroh over UDP (ADR-0002). -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- One foreground service holds every host's iroh conn (ruling 7);
         dataSync = persistent network link. -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <!-- [impl->REQ-INBOUND-NOTIFS] Inbound agent messages surface on
         per-endpoint notification channels (W5); runtime ask in MainActivity. -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <!-- [impl->REQ-HAZARD-RECEIVER-DOWN] Re-arm the webhook receiver after a
         reboot (BootReceiver -> LinkService.start); without it the always-on
         phone server is dead until the app is next opened. -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <!-- [impl->REQ-HAZARD-RECEIVER-DOWN] OEM battery managers (Motorola
         MotoBatteryCare, field-observed) kill background FGS; this permission
         lets the Hosts screen prompt for an exemption. -->
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

    <application
        android:label="spt-mobile"
        android:theme="@android:style/Theme.Material.Light.NoActionBar">
        <!-- singleTop: a notification tap while the app is up must route
             through onNewIntent (deep-link to the sender's endpoint view),
             not stack a second activity. -->
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- [impl->REQ-PUSH-FOREGROUND-SERVICE] -->
        <service
            android:name="com.sptmobile.link.LinkService"
            android:exported="false"
            android:foregroundServiceType="dataSync" />
        <!-- [impl->REQ-HAZARD-RECEIVER-DOWN] Re-arm the link + webhook receiver
             on boot. exported: BOOT_COMPLETED is a system broadcast, so the
             receiver must be visible to the OS. QUICKBOOT_POWERON covers OEM
             fast-boot (HTC/Moto) that skips the standard BOOT_COMPLETED. -->
        <receiver
            android:name="com.sptmobile.link.BootReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            </intent-filter>
        </receiver>
    </application>

</manifest>
