<?xml version="1.0" encoding="utf-8"?>

<!--
 * Copyright (C) 2010-2012 Ciaran Gultnieks
 * Copyright (C) 2013-2017 Peter Serwylo
 * Copyright (C) 2014-2015 Daniel Martí
 * Copyright (C) 2014-2018 Hans-Christoph Steiner
 * Copyright (C) 2016 Dominik Schürmann
 * Copyright (C) 2018 Torsten Grote
 * Copyright (C) 2018 Senecto Limited
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="org.fdroid.fdroid"
    android:installLocation="auto">

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

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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <!-- Some Android ROMs still require Bluetooth permission above SDK 30 -->
    <uses-permission
        android:name="android.permission.BLUETOOTH"
        android:maxSdkVersion="32" />
    <uses-permission
        android:name="android.permission.BLUETOOTH_ADMIN"
        android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <!-- used only for finding other devices to swap apps with -->
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
                     android:usesPermissionFlags="neverForLocation" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission
        android:name="android.permission.USB_PERMISSION"
        android:maxSdkVersion="22" /><!-- maybe unnecessary -->

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

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

    <application>

        <activity
            android:name=".nearby.SwapWorkflowActivity"
            android:configChanges="orientation|keyboardHidden"
            android:exported="false"
            android:label="@string/swap"
            android:launchMode="singleTask"
            android:parentActivityName=".views.main.MainActivity"
            android:screenOrientation="portrait"></activity>

        <activity
            android:name=".panic.PanicPreferencesActivity"
            android:exported="false"
            android:label="@string/panic_settings"
            android:parentActivityName=".views.main.MainActivity">
            <intent-filter>
                <action android:name="info.guardianproject.panic.action.CONNECT" />
                <action android:name="info.guardianproject.panic.action.DISCONNECT" />

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

        <activity
            android:name=".panic.SelectInstalledAppsActivity"
            android:exported="false"
            android:parentActivityName=".panic.PanicPreferencesActivity" />

        <activity
            android:name=".panic.PanicResponderActivity"
            android:exported="true"
            android:noHistory="true"
            android:theme="@android:style/Theme.NoDisplay">

            <!-- this can never have launchMode singleTask or singleInstance! -->
            <intent-filter>
                <action android:name="info.guardianproject.panic.action.TRIGGER" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".panic.ExitActivity"
            android:exported="false"
            android:theme="@android:style/Theme.NoDisplay" />

        <activity
            android:name=".panic.CalculatorActivity"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_calculator_launcher"
            android:label="@string/hiding_calculator">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <!--https://developer.android.com/guide/components/broadcast-exceptions -->
        <receiver
            android:name=".nearby.UsbDeviceAttachedReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>
            <meta-data
                android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
                android:resource="@xml/device_filter" />
        </receiver>
        <receiver
            android:name=".nearby.UsbDeviceDetachedReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
            </intent-filter>
            <meta-data
                android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
                android:resource="@xml/device_filter" />
        </receiver>
        <receiver
            android:name=".nearby.UsbDeviceMediaMountedReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_EJECT" />
                <action android:name="android.intent.action.MEDIA_REMOVED" />
                <action android:name="android.intent.action.MEDIA_MOUNTED" />
                <action android:name="android.intent.action.MEDIA_BAD_REMOVAL" />

                <data android:scheme="content" />
                <data android:scheme="file" />
            </intent-filter>
        </receiver>

        <service
            android:name=".nearby.SwapService"
            android:exported="false" />
        <service
            android:name=".nearby.LocalRepoService"
            android:exported="false" />
        <service
            android:name=".nearby.TreeUriScannerIntentService"
            android:permission="android.permission.BIND_JOB_SERVICE"
            android:exported="false" />
        <service
            android:name=".nearby.SDCardScannerService"
            android:permission="android.permission.BIND_JOB_SERVICE"
            android:exported="false" />

    </application>

</manifest>
