<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

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

    <!-- Allows for storing and retrieving screenshots -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="28" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Used by sentry. -->
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <!-- Needed to prompt the user to give permission for camera access -->
    <uses-permission android:name="android.permission.CAMERA" />

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

    <!-- This is needed because the android.permission.CAMERA above automatically
    adds a requirements for camera hardware and we don't want add those restrictions -->
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />

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

    <uses-feature android:name="android.hardware.fingerprint" android:required="false"/>

    <uses-permission-sdk-23 android:name="android.permission.USE_FINGERPRINT"/>

    <!-- Permission needed to publish the app on Samsung AppStore -->
    <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>

    <!-- Needed to interact with all apps installed on a device -->
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <!-- Needed to post notifications on devices with Android 13 and later-->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <!-- Needed for uploading media files on devices with Android 13 and later. -->
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />

    <!-- Needed to support Credential Manager with Android 14 and later. -->
    <uses-permission android:name="android.permission.CREDENTIAL_MANAGER_SET_ORIGIN" />
    <uses-permission android:name="android.permission.CREDENTIAL_MANAGER_QUERY_CANDIDATE_CREDENTIALS" />

    <application
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.App.Starting"
        android:name=".FocusApplication"
        android:enableOnBackInvokedCallback="false"
        android:usesCleartextTraffic="true"
        android:networkSecurityConfig="@xml/network_security_config"
        tools:ignore="UnusedAttribute">

        <activity
            android:name=".activity.IntentReceiverActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <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.ASSIST" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".activity.MainActivity"
            android:launchMode="singleTask"
            android:exported="true"
            android:windowSoftInputMode="adjustResize"
            android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize"
            android:resizeableActivity="true"
            android:supportsPictureInPicture="true">
            <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>

        <activity android:name=".activity.CustomTabActivity"
            android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
            android:exported="false"
            android:taskAffinity=""
            android:persistableMode="persistNever"
            android:autoRemoveFromRecents="false"
            android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize"
            android:resizeableActivity="true"
            android:supportsPictureInPicture="true"
            android:theme="@style/AppTheme" />

        <activity android:name=".activity.TextActionActivity"
            android:label="${textSelectionSearchAction}"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.PROCESS_TEXT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="text/plain" />
            </intent-filter>
        </activity>

        <activity android:name=".activity.EraseShortcutActivity"
            android:theme="@android:style/Theme.Translucent" />

        <activity android:name=".activity.EraseAndOpenShortcutActivity"
            android:theme="@android:style/Theme.Translucent" />

        <activity
            android:name=".searchwidget.VoiceSearchActivity"
            android:excludeFromRecents="true"
            android:taskAffinity=""
            android:theme="@style/Theme.AppCompat.Translucent" />

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

        <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"
            android:exported="false"
            android:foregroundServiceType="dataSync" />

        <service android:name=".media.MediaSessionService"
            android:foregroundServiceType="mediaPlayback"
            android:exported="false" />

        <service
            android:name=".session.SessionNotificationService"
            android:exported="false"
            android:foregroundServiceType="specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="This foreground service allows users to easily remove private tabs from the notification" />
        </service>

        <meta-data android:name="android.webkit.WebView.MetricsOptOut"
                   android:value="true" />

        <receiver
            android:name=".searchwidget.SearchWidgetProvider"
            android:exported="true">
            <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>

        <!-- Removes the default Workmanager initialization so that we can use on-demand initializer. -->
        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge" >
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup"
                tools:node="remove" />
        </provider>

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge">
            <!-- Disables automatic initialization of EmojiCompat -->
            <meta-data
                android:name="androidx.emoji2.text.EmojiCompatInitializer"
                tools:node="remove" />
        </provider>


    </application>

</manifest>
