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

    <!-- 网络 -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <!-- 语音助手核心 -->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.CAPTURE_AUDIO_HOTWORD" />

    <!-- 后台服务 -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

    <!-- 推送 -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- 锁屏交互 -->
    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />

    <!-- 激进保活 -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

    <!-- 查询其他应用（检查默认助手设置） -->
    <queries>
        <intent>
            <action android:name="android.service.voice.VoiceInteractionService" />
        </intent>
    </queries>

    <application
        android:name=".CyreneApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.Cyrene"
        android:usesCleartextTraffic="true">

        <!-- 全屏主界面 -->
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustNothing"
            android:theme="@style/Theme.Cyrene">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- VoiceInteractionService：系统语音助手 -->
        <service
            android:name=".service.CyreneVoiceInteractionService"
            android:exported="true"
            android:permission="android.permission.BIND_VOICE_INTERACTION">

            <meta-data
                android:name="android.voice_interaction"
                android:resource="@xml/voice_interaction_config" />

            <intent-filter>
                <action android:name="android.service.voice.VoiceInteractionService" />
            </intent-filter>
        </service>

        <!-- VoiceInteractionSessionService -->
        <service
            android:name=".service.CyreneSessionService"
            android:exported="true"
            android:permission="android.permission.BIND_VOICE_INTERACTION" />

        <!-- AccessibilityService：读取屏幕内容 -->
        <service
            android:name=".service.CyreneAccessibilityService"
            android:exported="true"
            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/accessibility_config" />
        </service>

        <!-- WebSocket 后台保活 -->
        <service
            android:name=".service.WebSocketKeepAliveService"
            android:exported="false"
            android:foregroundServiceType="dataSync|specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="websocket_keepalive_for_push_message_delivery" />
        </service>

        <!-- 开机自启 -->
        <receiver
            android:name=".service.BootReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <!-- 定时保活唤醒 -->
        <receiver
            android:name=".service.KeepAliveReceiver"
            android:exported="false" />

        <!-- FileProvider：日志分享 -->
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

    </application>

</manifest>
