<?xml version='1.0' encoding='utf-8'?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="cc.winboll.studio.contacts">

    <!-- BIND_AUTOFILL_SERVICE -->
    <uses-permission android:name="android.permission.BIND_AUTOFILL_SERVICE"/>

    <!-- 拨打电话 -->
    <uses-permission android:name="android.permission.CALL_PHONE"/>

    <!-- 读取手机状态和身份（API 30+ 需细化权限） -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_NUMBERS"/>

    <!-- 修改系统设置（移除无效的 protectionLevel 声明，该属性由系统定义） -->
    <uses-permission android:name="android.permission.WRITE_SETTINGS"/>

    <!-- 联系人权限（适配 Android 13+ 细分权限） -->
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    <uses-permission android:name="android.permission.GET_CONTACTS"/>

    <!-- 悬浮窗权限（需动态申请） -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <!-- 更改音频设置 -->
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

    <!-- 通话记录权限（适配 Android 13+ 细分权限） -->
    <uses-permission android:name="android.permission.READ_CALL_LOG"/>
    <uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
    <uses-permission android:name="android.permission.GET_CALL_LOG"/>

    <!-- 录音权限 -->
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>

    <!-- 前台服务权限（按业务类型声明） -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>

    <!-- API 30+ 通话筛选服务权限（替代 PROCESS_OUTGOING_CALLS） -->
    <uses-permission android:name="android.permission.BIND_CALL_SCREENING_SERVICE"/>

    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/ic_winboll"
        android:label="@string/app_name"
        android:theme="@style/MyAppTheme"
        android:supportsRtl="true"
        android:networkSecurityConfig="@xml/network_security_config">

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:exported="true">

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

        </activity>

        <activity
            android:name=".activities.CallActivity"
            android:label="CallActivity"
            android:launchMode="singleTask"
            android:exported="true">
        </activity>

        <activity
            android:name=".phonecallui.PhoneCallActivity"
            android:launchMode="singleTask"
            android:exported="true">

            <intent-filter>
                <action android:name="android.intent.action.DIAL"/>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="tel"/>
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.DIAL"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>

        </activity>

        <activity android:name="cc.winboll.studio.contacts.activities.SettingsActivity"/>

        <!-- 主服务：仅 dataSync 类型（与代码中 0x00000008 匹配） -->
        <service
            android:name=".services.MainService"
            android:foregroundServiceType="dataSync"
            android:exported="false" />

        <!-- 辅助服务：dataSync 类型 -->
        <service
            android:name=".services.AssistantService"
            android:foregroundServiceType="dataSync"
            android:exported="false" />

        <!-- 通话UI服务（系统绑定） -->
        <service
            android:name=".phonecallui.PhoneCallService"
            android:permission="android.permission.BIND_INCALL_SERVICE"
            android:exported="false">

            <meta-data
                android:name="android.telecom.IN_CALL_SERVICE_UI"
                android:value="true"/>

            <intent-filter>
                <action android:name="android.telecom.InCallService"/>
            </intent-filter>

        </service>

        <!-- 通话监听服务：phoneCall 类型（与代码中 0x00000020 匹配） -->
        <service
            android:name=".listenphonecall.CallListenerService"
            android:enabled="true"
            android:exported="false"
            android:foregroundServiceType="phoneCall">

            <intent-filter android:priority="1000">
                <action android:name=".service.CallShowService"/>
            </intent-filter>
        </service>

        <!-- API 30+ 通话筛选服务（替代 PROCESS_OUTGOING_CALLS 权限） -->
		<service
			android:name=".services.MyCallScreeningService"
			android:foregroundServiceType="phoneCall"
		    android:permission="android.permission.BIND_CALL_SCREENING_SERVICE"
            android:exported="true">
            <intent-filter>
                <action android:name="android.telecom.CallScreeningService"/>
            </intent-filter>
        </service>

        <receiver android:name=".receivers.MainReceiver">
            <intent-filter>
                <action android:name="cc.winboll.studio.contacts.receivers.MainReceiver"/>
            </intent-filter>
        </receiver>

        <receiver
            android:name=".widgets.APPStatusWidget"
            android:exported="true">

            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
                <action android:name="cc.winboll.studio.contacts.widgets.APPStatusWidget.ACTION_STATUS_ACTIVE"/>
                <action android:name="cc.winboll.studio.contacts.widgets.APPStatusWidget.ACTION_STATUS_NOACTIVE"/>
            </intent-filter>

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/appwidget_provider_info"/>

        </receiver>

        <receiver android:name=".widgets.APPStatusWidgetClickListener">
            <intent-filter>
                <action android:name="cc.winboll.studio.contacts.widgets.APPStatusWidgetClickListener.ACTION_APPICON_CLICK"/>
            </intent-filter>
        </receiver>

        <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_provider"/>

        </provider>

        <activity android:name="cc.winboll.studio.contacts.activities.UnitTestActivity"/>

        <activity android:name="cc.winboll.studio.contacts.activities.AboutActivity"/>

    </application>

</manifest>

