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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
        tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <!-- Agent 的应用发现与可见性自检需要完整应用列表，launcher queries 不能覆盖该能力。 -->
    <uses-permission
        android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />
    <uses-permission android:name="android.permission.VIBRATE" />

    <permission
        android:name="fuck.andes.permission.CONTROL_ACCESSIBILITY_PROTECTION"
        android:protectionLevel="signature" />

    <uses-permission android:name="fuck.andes.permission.CONTROL_ACCESSIBILITY_PROTECTION" />

    <queries>
        <package android:name="com.google.android.googlequicksearchbox" />
        <intent>
            <action android:name="android.speech.RecognitionService" />
        </intent>
        <intent>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent>
    </queries>

    <application
        android:name=".FuckAndesApp"
        android:allowBackup="false"
        android:description="@string/xposed_description"
        android:enableOnBackInvokedCallback="true"
        android:hasCode="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher_round">

        <activity
            android:name=".ui.MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.FuckAndes"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".agent.voice.EtaVoiceAssistActivity"
            android:excludeFromRecents="true"
            android:exported="true"
            android:noHistory="true"
            android:process=":voice"
            android:showWhenLocked="true"
            android:theme="@style/Theme.EtaVoiceAssistBridge">
            <intent-filter>
                <action android:name="android.intent.action.ASSIST" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <service
            android:name=".agent.voice.EtaVoiceInteractionService"
            android:exported="true"
            android:label="@string/voice_interaction_service_label"
            android:permission="android.permission.BIND_VOICE_INTERACTION"
            android:process=":voice">
            <intent-filter>
                <action android:name="android.service.voice.VoiceInteractionService" />
            </intent-filter>
            <meta-data
                android:name="android.voice_interaction"
                android:resource="@xml/voice_interaction_service" />
        </service>

        <service
            android:name=".agent.voice.EtaVoiceInteractionSessionService"
            android:exported="true"
            android:permission="android.permission.BIND_VOICE_INTERACTION"
            android:process=":voice_session" />

        <service
            android:name=".agent.voice.EtaRecognitionService"
            android:exported="true"
            android:label="@string/recognition_service_label"
            android:permission="android.permission.BIND_SPEECH_RECOGNITION_SERVICE"
            android:process=":recognition">
            <intent-filter>
                <action android:name="android.speech.RecognitionService" />
            </intent-filter>
            <meta-data
                android:name="android.speech"
                android:resource="@xml/recognition_service" />
        </service>

        <service
            android:name=".agent.voice.EtaAssistantOverlayService"
            android:exported="false" />

        <service
            android:name=".agent.runtime.AgentRuntimeService"
            android:exported="true"
            tools:ignore="ExportedService" />

        <service
            android:name=".agent.accessibility.AgentAccessibilityService"
            android:exported="true"
            android:label="@string/agent_accessibility_label"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>
            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/agent_accessibility_service" />
        </service>

        <service
            android:name=".agent.device.AgentNotificationHistoryService"
            android:exported="false"
            android:label="@string/notification_history_service_label"
            android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
            <intent-filter>
                <action android:name="android.service.notification.NotificationListenerService" />
            </intent-filter>
        </service>

        <provider
            android:name=".agent.accessibility.AgentAccessibilityHealthProvider"
            android:authorities="fuck.andes.accessibility.health"
            android:exported="true"
            android:grantUriPermissions="false"
            android:permission="android.permission.MANAGE_ACCESSIBILITY" />
    </application>

</manifest>
