<?xml version="1.0" encoding="utf-8"?>
<!--
  TimeLimit Copyright <C> 2019 - 2024 Jonas Lochmann
  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 version 3 of the License.

  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, see <https://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- suppress DeprecatedClassUsageInspection -->
    <uses-permission
        android:name="android.permission.GET_TASKS"
        android:maxSdkVersion="20" />
    <uses-permission
        android:name="android.permission.PACKAGE_USAGE_STATS"
        tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
    <!-- for the categories which are limited to a wifi network -->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.NFC" />

    <uses-feature android:name="android.hardware.telephony" android:required="false" />
    <uses-feature android:name="android.software.leanback" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
    <uses-feature android:name="android.hardware.nfc" android:required="false" />
    <uses-feature android:name="android.hardware.usb.host" android:required="false" />

    <meta-data android:name="isMonitoringTool" android:value="child_monitoring" />

    <application
        android:banner="@drawable/banner"
        android:name=".Application"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:enableOnBackInvokedCallback="true"
        tools:targetApi="tiramisu">

        <!-- UI -->

        <activity
            android:exported="true"
            android:launchMode="singleTop"
            android:taskAffinity=":main"
            android:name=".ui.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <!--
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
                -->
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.lock.LockActivity"
            android:autoRemoveFromRecents="true"
            android:excludeFromRecents="true"
            android:exported="false"
            android:resizeableActivity="false"
            android:supportsPictureInPicture="false"
            android:taskAffinity=":lock"
            tools:ignore="UnusedAttribute" />

        <activity
            tools:ignore="UnusedAttribute"
            android:excludeFromRecents="true"
            android:autoRemoveFromRecents="true"
            android:taskAffinity=":annoy"
            android:showOnLockScreen="true"
            android:exported="false"
            android:name=".ui.manipulation.AnnoyActivity" />

        <activity
            android:exported="true"
            tools:ignore="UnusedAttribute"
            android:enabled="false"
            android:excludeFromRecents="true"
            android:autoRemoveFromRecents="true"
            android:taskAffinity=":dummyhome"
            android:launchMode="singleTop"
            android:theme="@style/AppHomescreenTheme"
            android:name=".ui.homescreen.HomescreenActivity">

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

        <activity
            android:name=".ui.update.UpdateActivity"
            android:exported="false"
            android:excludeFromRecents="true"
            android:taskAffinity=":update"
            android:launchMode="singleTop" />

        <activity
            android:name=".ui.widget.config.WidgetConfigActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
            </intent-filter>
        </activity>

        <activity
            android:name=".ui.diagnose.exception.DiagnoseExceptionActivity"
            android:theme="@style/AppTheme.Translucent"
            android:exported="false"
            android:excludeFromRecents="true"
            android:taskAffinity=":exception"
            android:launchMode="singleTop" />

        <!-- system integration -->

        <receiver android:name=".integration.platform.android.receiver.BootReceiver" android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <receiver android:name=".integration.platform.android.receiver.UpdateReceiver" android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>

        <service
            android:foregroundServiceType="systemExempted"
            android:name=".integration.platform.android.BackgroundService"
            android:exported="false" />

        <service
            android:name=".integration.platform.android.BackgroundActionService"
            android:exported="false" />

        <receiver
            android:exported="false"
            android:name=".integration.platform.android.AdminReceiver"
            android:description="@string/admin_description"
            android:label="@string/app_name"
            android:permission="android.permission.BIND_DEVICE_ADMIN">
            <meta-data
                android:name="android.app.device_admin"
                android:resource="@xml/admin" />

            <intent-filter>
                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
            </intent-filter>
        </receiver>

        <receiver android:name=".ui.widget.TimesWidgetProvider" android:exported="false">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
                android:resource="@xml/times_widget_info" />
        </receiver>

        <service
            android:exported="false"
            android:name=".integration.platform.android.NotificationListener"
            android:label="@string/app_name"
            android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
            <intent-filter>
                <action android:name="android.service.notification.NotificationListenerService" />
            </intent-filter>
        </service>

        <service android:name=".integration.platform.android.AccessibilityService"
            android:exported="false"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">

            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>

            <meta-data android:name="android.accessibilityservice"
                android:resource="@xml/accesibility" />

        </service>

        <service android:name=".ui.widget.TimesWidgetService"
            android:exported="false"
            android:permission="android.permission.BIND_REMOTEVIEWS"/>

    </application>

</manifest>
