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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />

    <!-- Needed to prompt the user to give permission to install a downloaded apk -->
    <uses-permission-sdk-23 android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

    <application
        android:name=".FenixApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/NormalTheme"
        android:usesCleartextTraffic="true"
        tools:ignore="UnusedAttribute">

        <!--
          We inherited this entry (${applicationId}.App) from Fennec. We need to keep this as our
          main launcher to avoid launcher icons on the home screen disappearing for all our users
          on a Fennec build.

          !!HERE BE DRAGONS!!
          We need the targetActivity to be IntentReceiverActivity so that we can check if we have
          a migration in progress. If not, the HomeActivity is invoked.
        -->
        <activity-alias
            android:name="${applicationId}.App"
            android:targetActivity=".IntentReceiverActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

            <meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />
        </activity-alias>

        <!--
          Fennec declared entry for homescreen pinned shortcuts.
        -->
        <activity-alias
            android:name="org.mozilla.gecko.BrowserApp"
            android:targetActivity=".IntentReceiverActivity"
            android:exported="true">
        </activity-alias>

        <activity
            android:name=".HomeActivity"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|layoutDirection|smallestScreenSize|screenLayout"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="fenix"
                    android:host="home"/>
                <data android:scheme="fenix"
                      android:host="settings"/>
                <data android:scheme="fenix"
                    android:host="turn_on_sync"/>
                <data android:scheme="fenix"
                    android:host="settings_search_engine"/>
                <data android:scheme="fenix"
                    android:host="settings_accessibility"/>
                <data android:scheme="fenix"
                    android:host="settings_delete_browsing_data"/>
                <data android:scheme="fenix"
                    android:host="enable_private_browsing"/>
                <data android:scheme="fenix"
                    android:host="open"/>
                <data android:scheme="fenix"
                    android:host="make_default_browser"/>
            </intent-filter>
        </activity>

        <activity
            android:name=".customtabs.ExternalAppBrowserActivity"
            android:autoRemoveFromRecents="false"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|layoutDirection|smallestScreenSize|screenLayout"
            android:exported="false"
            android:label="@string/app_name"
            android:persistableMode="persistNever"
            android:taskAffinity=""
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />

        <activity android:name=".IntentReceiverActivity" android:theme="@style/Theme.Transparent">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="mozilla.components.pwa.category.SHORTCUT" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>

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

                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="http" />
                <data android:scheme="https" />
                <data android:mimeType="text/html" />
                <data android:mimeType="text/plain" />
                <data android:mimeType="application/xhtml+xml" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                android:resource="@xml/searchable"/>

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

            <intent-filter>
                <action android:name="mozilla.components.feature.pwa.VIEW_PWA" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="https" />
            </intent-filter>

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

            <intent-filter>
                <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>

            <meta-data
                android:name="com.android.systemui.action_assist_icon"
                android:resource="@mipmap/ic_launcher" />

        </activity>

        <activity
                android:name=".migration.MigrationProgressActivity"
                android:launchMode="singleInstance"
                android:exported="false">
        </activity>

        <activity android:name=".widget.VoiceSearchActivity" />

        <activity
            android:name=".browser.BrowserPerformanceTestActivity"
            android:enabled="${isRaptorEnabled}"
            android:exported="${isRaptorEnabled}" />

        <activity
            android:name=".settings.account.AuthCustomTabActivity"
            android:autoRemoveFromRecents="false"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|layoutDirection|smallestScreenSize|screenLayout"
            android:exported="false"
            android:taskAffinity=""
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />

        <activity android:name=".settings.account.AuthIntentReceiverActivity"
            android:exported="false" />

        <activity android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
            android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>

        <activity android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
            android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>

        <service
            android:name=".customtabs.CustomTabsService"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.support.customtabs.action.CustomTabsService" />
            </intent-filter>
        </service>

        <service android:name=".downloads.DownloadService" />
        <receiver
            android:name="org.mozilla.gecko.search.SearchWidgetProvider">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/search_widget_info" />
        </receiver>

        <service android:name=".session.SessionNotificationService"
                android:exported="false" />

        <service
            android:name=".components.FirebasePush"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <meta-data
            android:name="firebase_messaging_auto_init_enabled"
            android:value="true" />
        <meta-data
            android:name="firebase_analytics_collection_enabled"
            android:value="false" />
    </application>

</manifest>
