<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sptmobile.app"
    android:versionCode="9"
    android:versionName="1.1.1" >

    <uses-sdk
        android:minSdkVersion="26"
        android:targetSdkVersion="34" />

    <!-- 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" />

    <permission
        android:name="com.sptmobile.app.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.sptmobile.app.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" />

    <application
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:debuggable="true"
        android:extractNativeLibs="false"
        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="com.sptmobile.app.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>

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="com.sptmobile.app.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>

        <service
            android:name="androidx.room.MultiInstanceInvalidationService"
            android:directBootAware="true"
            android:exported="false" />

        <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>