<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2013 – 2015 Ricki Hirner (bitfire web engineering).
  ~ All rights reserved. This program and the accompanying materials
  ~ are made available under the terms of the GNU Public License v3.0
  ~ which accompanies this distribution, and is available at
  ~ http://www.gnu.org/licenses/gpl.html
-->
<manifest package="com.etesync.syncadapter"
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:installLocation="internalOnly">

    <!-- normal permissions -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
    <uses-permission android:name="android.permission.READ_SYNC_STATS"/>
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>

    <!-- account management permissions not required for own accounts since API level 22 -->
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" android:maxSdkVersion="22"/>
    <uses-permission android:name="android.permission.GET_ACCOUNTS" android:maxSdkVersion="22"/>
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" android:maxSdkVersion="22"/>

    <!--
         for writing external log files; permission only required for SDK <= 18 because since then,
         writing to app-private directory doesn't require extra permissions
    -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>

    <!-- Used for external log and vcf import. -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <!-- other permissions -->
    <!-- android.permission-group.CONTACTS -->
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    <!-- android.permission-group.CALENDAR -->
    <uses-permission android:name="android.permission.READ_CALENDAR"/>
    <uses-permission android:name="android.permission.WRITE_CALENDAR"/>

    <!-- ical4android declares task access permissions -->

    <application
        android:name=".App"
        android:allowBackup="true"
        android:fullBackupContent="false"
        android:networkSecurityConfig="@xml/network_security_config"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:ignore="UnusedAttribute">

        <receiver
            android:name=".App$AppUpdatedReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REPLACED" />
                <data android:scheme="package" android:path="com.etesync.syncadapter" />
            </intent-filter>
        </receiver>

        <receiver
            android:name=".AccountSettings$AppUpdatedReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REPLACED" />
                <data android:scheme="package" android:path="com.etesync.syncadapter" />
            </intent-filter>
        </receiver>

        <service
            android:name=".syncadapter.AccountAuthenticatorService"
            android:exported="false">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator"/>
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/account_authenticator"/>
        </service>

        <!-- Normal account -->
        <service
            android:name=".syncadapter.CalendarsSyncAdapterService"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/sync_calendars" />
        </service>
        <service
            android:name=".syncadapter.TasksSyncAdapterService"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter"/>
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/sync_tasks"/>
        </service>

        <service
            android:name=".syncadapter.TasksOrgSyncAdapterService"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter"/>
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/sync_tasks_org"/>
        </service>


        <!-- Address book account -->
        <service
            android:name=".syncadapter.NullAuthenticatorService"
            android:exported="true">   <!-- Since Android 11, this must be true so that Google Contacts shows the address book accounts -->
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator"/>
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/account_authenticator_address_book"/>
        </service>
        <provider
            android:authorities="@string/address_books_authority"
            android:exported="false"
            android:label="@string/address_books_authority_title"
            android:name=".syncadapter.AddressBookProvider"
            android:multiprocess="false"/>
        <service
            android:name=".syncadapter.AddressBooksSyncAdapterService"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter"/>
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/sync_address_books"/>
        </service>

        <service
            android:name=".syncadapter.ContactsSyncAdapterService"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter"/>
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/sync_contacts"/>
            <meta-data
                android:name="android.provider.CONTACTS_STRUCTURE"
                android:resource="@xml/contacts"/>
        </service>


        <service
            android:name=".AccountUpdateService"
            android:enabled="true">
        </service>

        <receiver android:name=".PackageChangedReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED"/>
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED"/>
                <data android:scheme="package"/>
            </intent-filter>
        </receiver>

        <activity
            android:name=".ui.AccountsActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity
            android:name=".ui.AboutActivity"
            android:exported="false"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"
            android:parentActivityName=".ui.AccountsActivity"/>

        <activity
            android:name=".syncadapter.SyncNotification$NotificationHandlerActivity"
            android:exported="false"
            android:theme="@style/Theme.Transparent" />

        <activity
            android:name=".ui.AppSettingsActivity"
            android:exported="false"
            android:label="@string/app_settings"
            android:parentActivityName=".ui.AccountsActivity"/>

        <activity android:name=".ui.PermissionsActivity"
            android:exported="false"
                  android:label="@string/permissions_title"
                  android:parentActivityName=".ui.AccountsActivity"/>

        <activity
            android:name=".ui.setup.LoginActivity"
            android:exported="false"
            android:label="@string/login_title"
            android:parentActivityName=".ui.AccountsActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
            </intent-filter>
        </activity>

        <activity
            android:name=".ui.AccountActivity"
            android:exported="false"
            android:parentActivityName=".ui.AccountsActivity">
        </activity>
        <activity
            android:name=".ui.ViewCollectionActivity"
            android:exported="false"
            />
        <activity
            android:name=".ui.CollectionMembersActivity"
            android:exported="false"
            />
        <activity
            android:name=".ui.JournalItemActivity"
            android:exported="false"
            />
        <activity
            android:name=".ui.importlocal.ImportActivity"
            android:exported="false"
            />
        <activity
            android:name=".ui.AccountSettingsActivity"
            android:exported="false"
            />
        <activity
            android:name=".ui.ChangeEncryptionPasswordActivity"
            android:exported="false"
            />
        <activity
            android:name=".ui.CreateCollectionActivity"
            android:exported="false"
            />
        <activity
            android:name=".ui.EditCollectionActivity"
            android:exported="false"
            />

        <activity
            android:name=".ui.DebugInfoActivity"
            android:exported="true"
            android:label="@string/debug_info_title">
        </activity>

        <activity
            android:name=".ui.WebViewActivity"
            android:exported="false"
            />

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="@string/authority_log_provider"
            android:grantUriPermissions="true"
            android:exported="false">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/log_paths" />
        </provider>
    </application>

</manifest>
