<?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">
    <!-- Touchscreen is enabled by default but not always needed -->
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <!-- https://developer.android.com/develop/ui/views/notifications/notification-permission-->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
    <!-- Necessary for gaining read/write access to "Android/data/de.marmaro.krt.ffupdater/files/"
         on older devices. For Amazon devices, I have to download the APK files into this folder
         or I'll get a "Permission Denial: reading ... DownloadProvider uri ... requires
         android.permission.ACCESS_ALL_DOWNLOADS or grantUriPermission()" exception. -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <uses-permission android:name="android.permission.ENFORCE_UPDATE_OWNERSHIP" />

    <!-- Shizuku needs API 23, but I still want to use API 21-->
    <uses-sdk tools:overrideLibrary="rikka.shizuku.api, rikka.shizuku.provider, rikka.shizuku.shared, rikka.shizuku.aidl" />


    <!-- If FFUpdater wants to check if an app is installed, this app must be listed here -->
    <!-- https://developer.android.com/about/versions/11/privacy/package-visibility -->
    <queries>
        <package android:name="com.brave.browser" />
        <package android:name="com.brave.browser_beta" />
        <package android:name="com.brave.browser_nightly" />
        <package android:name="com.duckduckgo.mobile.android" />
        <package android:name="com.fsck.k9" />
        <package android:name="com.kiwibrowser.browser" />
        <package android:name="com.stoutner.privacybrowser.standard" />
        <package android:name="com.vivaldi.browser" />
        <package android:name="de.marmaro.krt.ffupdater" />
        <package android:name="eu.faircode.email" />
        <package android:name="io.github.forkmaintainers.iceraven" />
        <package android:name="mozilla.lockbox" />
        <package android:name="org.bromite.bromite" />
        <package android:name="org.bromite.webview" />
        <package android:name="org.chromium.chrome" />
        <package android:name="org.chromium.thorium" />
        <package android:name="org.cromite.cromite" />
        <package android:name="org.mozilla.fenix" />
        <package android:name="org.mozilla.fennec_fdroid" />
        <package android:name="org.mozilla.firefox" />
        <package android:name="org.mozilla.firefox_beta" />
        <package android:name="org.mozilla.focus" />
        <package android:name="org.mozilla.focus.beta" />
        <package android:name="org.mozilla.klar" />
        <package android:name="org.mozilla.rocket" />
        <package android:name="net.thunderbird.android" />
        <package android:name="net.thunderbird.android.beta" />
        <package android:name="org.torproject.android" />
        <package android:name="org.torproject.torbrowser" />
        <package android:name="org.torproject.torbrowser_alpha" />
        <package android:name="org.ungoogled.chromium.stable" />
        <package android:name="us.spotco.fennec_dos" />
        <package android:name="us.spotco.mulch" />
        <package android:name="us.spotco.mulch_wv" />
    </queries>

    <application
        android:name=".FFUpdater"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:usesCleartextTraffic="false"
        tools:targetApi="S">
        <activity
            android:name=".activity.add.AddAppActivity"
            android:label="@string/add_app_activity__label"
            android:launchMode="singleTop"
            android:theme="@style/add_app__theme" />
        <activity
            android:name=".crash.CrashReportActivity"
            android:label="@string/crash_report_activity__label"
            android:theme="@style/crash_report__theme" />
        <activity
            android:name=".activity.settings.SettingsActivity"
            android:label="@string/settings_activity__label"
            android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar" />
        <activity
            android:name=".activity.download.DownloadActivity"
            android:label="@string/download_activity__label"
            android:launchMode="singleTop"
            android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar" />
        <activity
            android:name=".activity.main.MainActivity"
            android:exported="true"
            android:theme="@style/main_activity__theme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="de.marmaro.krt.ffupdater.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

        <provider
            android:name="rikka.shizuku.ShizukuProvider"
            android:authorities="${applicationId}.shizuku"
            android:multiprocess="false"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.INTERACT_ACROSS_USERS_FULL"
            tools:ignore="MissingClass" />

        <receiver
            android:name=".background.EolAppsWarnerReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>

        <profileable
            android:enabled="true"
            android:shell="true"
            tools:targetApi="q" />

        <service
            android:name="androidx.work.impl.foreground.SystemForegroundService"
            android:foregroundServiceType="dataSync"
            tools:node="merge" />

    </application>

</manifest>