<?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.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.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />

    <application
        android:name=".DuobibiApplication"
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:supportsRtl="true"
        android:theme="@style/Theme.duobibi"
        android:usesCleartextTraffic="false"
        tools:targetApi="34">

        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/Theme.duobibi">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- 无障碍服务:监听窗口切换,驱动比价浮窗显隐 + 抓取当前页面控件树 -->
        <service
            android:name=".service.PriceBotAccessibilityService"
            android:exported="true"
            android:label="@string/app_name"
            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_service_config" />
        </service>

        <!-- 比价浮窗前台服务 -->
        <service
            android:name=".service.FloatingWindowService"
            android:exported="false"
            android:foregroundServiceType="specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="商品价格识别浮窗" />
        </service>

        <!-- 小米推送回调 receiver。SDK 内置组件由 aar 的 manifest merge 自动注入,
             此处只需注册业务方自家的 PushMessageReceiver 子类,监听 3 个固定 action。 -->
        <receiver
            android:name=".push.MiPushReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="com.xiaomi.mipush.RECEIVE_MESSAGE" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.xiaomi.mipush.MESSAGE_ARRIVED" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.xiaomi.mipush.ERROR" />
            </intent-filter>
        </receiver>

        <!-- 心跳定时器接收 AlarmManager 唤起,触发后台上报。exported=false,只接受自家 alarm。 -->
        <receiver
            android:name=".heartbeat.HeartbeatReceiver"
            android:exported="false" />

        <!-- 极光一键登录:中国移动授权页(SDK 自带类)
             SDK 自己 manifest 已声明 unspecified,tools:replace 强制覆盖为竖屏 + dialog 主题 -->
        <activity
            android:name="com.cmic.gen.sdk.view.GenLoginAuthActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@style/ActivityDialogStyle"
            tools:replace="android:screenOrientation,android:theme" />
        <!-- 极光一键登录:中国电信授权页 -->
        <activity
            android:name="cn.jiguang.verifysdk.CtLoginActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@style/ActivityDialogStyle"
            tools:replace="android:screenOrientation,android:theme" />
        <!-- 联通授权页由 jverification SDK 内置,无需在此声明。 -->

        <!-- 极光 SDK AppKey / Channel,来自 app/build.gradle.kts manifestPlaceholders -->
        <meta-data
            android:name="JPUSH_APPKEY"
            android:value="${JPUSH_APPKEY}" />
        <meta-data
            android:name="JPUSH_CHANNEL"
            android:value="${JPUSH_CHANNEL}" />

    </application>

</manifest>
