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

    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true"/>

    <application
        android:allowBackup="true"
        android:fullBackupContent="@xml/backup_descriptor"
        android:hasFragileUserData="true" tools:targetApi="q"
        android:dataExtractionRules="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/Theme.Material3.DynamicColors.Dark"
        android:name=".app.UApp"
        android:label="@string/common.appname"
        android:usesCleartextTraffic="true"
        android:supportsRtl="false"
        android:preserveLegacyExternalStorage="true"
        tools:ignore="UnusedAttribute">

        <meta-data android:name="com.google.android.gms.car.application"
            android:resource="@xml/automotive_app_desc"/>

        <!--Used by Android Auto-->
        <meta-data android:name="com.google.android.gms.car.notification.SmallIcon"
            android:resource="@mipmap/ic_launcher" />

        <activity android:name=".activity.NavigationActivity"
            android:configChanges="orientation|keyboardHidden"
            android:launchMode="singleTask"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.SEARCH"/>
                <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH"/>

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <nav-graph android:value="@navigation/navigation_graph" />
            <meta-data android:name="android.app.default_searchable"
                android:value=".SearchableActivity" />
            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/searchable"/>
        </activity>

        <service
            android:name=".service.DownloadService"
            android:label="Ultrasonic Media Player Service"
            android:exported="false">
        </service>

        <!-- Needs to be exported: https://android.googlesource.com/platform/developers/build/+/4de32d4/prebuilts/gradle/MediaBrowserService/README.md -->
        <service android:name=".playback.PlaybackService"
            android:label="@string/common.appname"
            android:foregroundServiceType="mediaPlayback"
            android:exported="true"
            tools:ignore="ExportedService">

            <intent-filter>
                <action android:name="androidx.media3.session.MediaLibraryService" />
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>

        <receiver android:name=".receiver.UltrasonicIntentReceiver"
            android:exported="true"
            tools:ignore="ExportedReceiver">
            <intent-filter>
                <action android:name="org.moire.ultrasonic.CMD_TOGGLEPAUSE"/>
                <action android:name="org.moire.ultrasonic.CMD_PLAY"/>
                <action android:name="org.moire.ultrasonic.CMD_RESUME_OR_PLAY"/>
                <action android:name="org.moire.ultrasonic.CMD_PAUSE"/>
                <action android:name="org.moire.ultrasonic.CMD_NEXT"/>
                <action android:name="org.moire.ultrasonic.CMD_PREVIOUS"/>
                <action android:name="org.moire.ultrasonic.CMD_STOP"/>
                <action android:name="org.moire.ultrasonic.CMD_PROCESS_KEYCODE"/>
            </intent-filter>
        </receiver>
        <receiver android:name=".receiver.BluetoothIntentReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.bluetooth.device.action.ACL_CONNECTED"/>
                <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/>
                <action android:name="android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED"/>
                <action android:name="android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED"/>
            </intent-filter>
        </receiver>
        <receiver
            android:name=".provider.UltrasonicAppWidgetProvider"
            android:label="Ultrasonic"
            android:exported="false">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
            </intent-filter>

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/appwidget_info"/>
        </receiver>
        <receiver android:name=".receiver.MediaButtonIntentReceiver"
            android:exported="true">
            <intent-filter android:priority="2147483647">
                <action android:name="android.intent.action.MEDIA_BUTTON"/>
            </intent-filter>
        </receiver>
        <provider
            android:name=".provider.SearchSuggestionProvider"
            android:authorities="${applicationId}.provider.SearchSuggestionProvider"
            android:exported="true"
            tools:ignore="ExportedContentProvider" />

        <provider
            android:name=".provider.AlbumArtContentProvider"
            android:authorities="${applicationId}.provider.AlbumArtContentProvider"
            android:exported="true"
            tools:ignore="ExportedContentProvider" />
    </application>

</manifest>
