<?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:enableOnBackInvokedCallback="true"
          tools:ignore="QueryAllPackagesPermission"
          tools:targetApi="tiramisu">

    <uses-sdk tools:overrideLibrary="io.sentry.android" />

    <queries>
        <intent>
            <action android:name="com.fox2code.mmm.utils.intent.action.OPEN_EXTERNAL" />
        </intent>
    </queries> <!-- Wifi is not the only way to get an internet connection -->
    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" /> <!-- Retrieve online modules -->
    <uses-permission android:name="android.permission.INTERNET" /> <!-- WebView offline webpage support -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- Check if there is modules updates on boot -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <!-- Open config apps for applications -->
    <uses-permission-sdk-23 android:name="android.permission.QUERY_ALL_PACKAGES" /> <!-- Supposed to fix bugs with old firmware, only requested on pre Marshmallow -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- Post background notifications -->
    <uses-permission-sdk-23 android:name="android.permission.POST_NOTIFICATIONS" />

    <application
        android:name=".MainApplication"
        android:allowBackup="false"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/full_backup_content"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="@bool/lang_support_rtl"
        android:testOnly="false"
        android:theme="@style/Theme.MagiskModuleManager"
        android:usesCleartextTraffic="false"
        tools:ignore="ManifestResource"
        tools:replace="android:supportsRtl"
        tools:targetApi="s">
        <activity
            android:name=".SetupActivity"
            android:exported="false"
            android:label="@string/title_activity_setup"
            android:hardwareAccelerated="true"
            android:theme="@style/Theme.MagiskModuleManager.NoActionBar"/>

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

        <activity
            android:name=".settings.SettingsActivity"
            android:exported="true"
            android:label="@string/title_activity_settings"
            android:hardwareAccelerated="true"
            android:parentActivityName=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.APPLICATION_PREFERENCES" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:hardwareAccelerated="true"
            android:exported="true"
            android:label="@string/app_name_short"
            android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".installer.InstallerActivity"
            android:hardwareAccelerated="true"
            android:exported="false"
            android:launchMode="singleTop"
            android:parentActivityName=".MainActivity"
            android:screenOrientation="portrait"
            tools:ignore="LockedOrientationActivity">

            <!--
            <intent-filter>
                <action android:name="${applicationId}.intent.action.INSTALL_MODULE_INTERNAL" />
            </intent-filter>
            -->
        </activity> <!-- We can handle zip files -->
        <activity
            android:name=".utils.ZipFileOpener"
            android:hardwareAccelerated="true"
            android:exported="true"
            android:theme="@style/Theme.MagiskModuleManager">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

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

                <data android:mimeType="application/zip" />
                <data android:mimeType="application/x-zip-compressed" />
                <data android:scheme="content" />
            </intent-filter>
        </activity>
        <activity
            android:name=".markdown.MarkdownActivity"
            android:exported="false"
            android:parentActivityName=".MainActivity"
            android:hardwareAccelerated="true"
            android:theme="@style/Theme.MagiskModuleManager" />
        <activity
            android:name=".androidacy.AndroidacyActivity"
            android:exported="false"
            android:parentActivityName=".MainActivity"
            android:hardwareAccelerated="true"
            android:theme="@style/Theme.MagiskModuleManager">

            <!--
            <intent-filter>
                <action android:name="${applicationId}.intent.action.OPEN_ANDROIDACY_INTERNAL" />
            </intent-filter>
            -->
        </activity>
        <activity
            android:name="com.mikepenz.aboutlibraries.ui.LibsActivity"
            tools:node="remove" />

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge">
            <meta-data
                android:name="androidx.emoji2.text.EmojiCompatInitializer"
                tools:node="remove" />
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                tools:node="remove" />
        </provider>
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.file-provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/shared_file_paths" />
        </provider>

        <meta-data
            android:name="io.sentry.auto-init"
            android:value="false" />
        <meta-data
            android:name="io.sentry.dsn"
            android:value="https://198c68516cb0412b9832204631a3fac8@o993586.ingest.sentry.io/4504069942804480" /> <!-- Sane value, but feel free to lower it -->
        <meta-data
            android:name="io.sentry.traces.sample-rate"
            android:value="0.5" /> <!-- Doesn't actually monitor anything, just used to get the activities the user went through -->
        <meta-data
            android:name="io.sentry.traces.user-interaction.enable"
            android:value="true" /> <!-- Just a screenshot of ONLY the current activity at the time of the crash -->
        <meta-data
            android:name="io.sentry.attach-screenshot"
            android:value="true" /> <!-- Just the current activity at the time of the crash -->
        <meta-data
            android:name="io.sentry.attach-stacktrace"
            android:value="true" /> <!-- Don't send PII, this is actually default but let's be explicit -->
        <meta-data
            android:name="io.sentry.sendDefaultPii"
            android:value="false" />
        <meta-data
            android:name="io.sentry.traces.profiling.sample-rate"
            android:value="0.25" />
    </application>

</manifest>