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

    <!-- Foreground-app detection. PACKAGE_USAGE_STATS is privileged (granted by
         the privapp allowlist); its appop then resolves through the permission. -->
    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
    <!-- Lets the polling service start the lock Activity from the background, and
         is granted outright by the platform certificate (signature|appop). -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
    <uses-permission android:name="com.failure.vanta.permission.CONFIG" />

    <queries>
        <intent>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent>
    </queries>

    <application
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher"
        android:allowBackup="false"
        android:supportsRtl="true"
        android:directBootAware="false"
        android:theme="@style/Theme.VantaGuard">

        <service
            android:name=".GuardService"
            android:exported="false"
            android:foregroundServiceType="specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="system_app_lock" />
        </service>

        <receiver android:name=".BootReceiver" android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>

        <!-- The lock, thrown over a protected app. Its own task, never in recents,
             no transition, so it appears instantly and leaves no trace. -->
        <activity
            android:name=".LockActivity"
            android:exported="false"
            android:excludeFromRecents="true"
            android:taskAffinity=""
            android:launchMode="singleInstance"
            android:noHistory="true"
            android:showOnLockScreen="false"
            android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density|uiMode|keyboardHidden"
            android:theme="@style/Theme.VantaGuard.Lock" />

        <activity
            android:name=".GuardActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize"
            android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density|uiMode">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.android.settings.action.EXTRA_SETTINGS" />
            </intent-filter>
            <meta-data android:name="com.android.settings.category"
                android:value="com.android.settings.category.ia.security" />
            <meta-data android:name="com.android.settings.title"
                android:resource="@string/settings_tile_title" />
            <meta-data android:name="com.android.settings.summary"
                android:resource="@string/settings_tile_summary" />
            <meta-data android:name="com.android.settings.icon"
                android:resource="@drawable/ic_guard_tile" />
        </activity>
    </application>
</manifest>
