<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="android.ext.services"
    android:versionCode="309999900"
    android:versionName="2019-09"
    coreApp="true">

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

    <uses-permission android:name="android.permission.MONITOR_DEFAULT_SMS_PACKAGE" />
    <uses-permission android:name="android.permission.REQUEST_NOTIFICATION_ASSISTANT_SERVICE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
    <!-- INTERNET permission is restricted to TextClassifier downloader process only -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Remove unused permissions merged from WorkManager library -->
    <uses-permission android:name="android.permission.WAKE_LOCK" tools:node="remove" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" tools:node="remove" />
    <!-- Need this permission to receive the Boot-Completed broadcast -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <application
        android:name=".ExtServicesApplication"
        android:label="@string/app_name"
        android:forceQueryable="true"
        android:supportsRtl="true">

        <processes>
            <!-- Deny INTERNET permission for all processes by default -->
            <deny-permission android:name="android.permission.INTERNET" />
            <process />
            <process android:process=":modelDownloaderServiceProcess">
                <allow-permission android:name="android.permission.INTERNET" />
            </process>
            <process android:process=".adservices">
                <allow-permission android:name="android.permission.INTERNET" />
            </process>
        </processes>

        <service android:name=".storage.CacheQuotaServiceImpl"
             android:exported="true"
             android:directBootAware="true"
             android:permission="android.permission.BIND_CACHE_QUOTA_SERVICE">
            <intent-filter>
                <action android:name="android.app.usage.CacheQuotaService" />
            </intent-filter>
        </service>

        <service android:name=".resolver.LRResolverRankerService"
                 android:exported="true"
                 android:directBootAware="true"
                 android:permission="android.permission.BIND_RESOLVER_RANKER_SERVICE">
            <intent-filter android:priority="-1">
                <action android:name="android.service.resolver.ResolverRankerService" />
            </intent-filter>
        </service>

        <service android:name=".notification.Assistant"
                 android:label="@string/notification_assistant"
                 android:directBootAware="true"
                 android:permission="android.permission.BIND_NOTIFICATION_ASSISTANT_SERVICE"
                 android:exported="true">
            <intent-filter>
                <action android:name="android.service.notification.NotificationAssistantService" />
            </intent-filter>
        </service>

        <service android:name=".autofill.AutofillFieldClassificationServiceImpl"
             android:exported="true"
             android:directBootAware="true"
             android:permission="android.permission.BIND_AUTOFILL_FIELD_CLASSIFICATION_SERVICE">
            <intent-filter>
                <action android:name="android.service.autofill.AutofillFieldClassificationService" />
            </intent-filter>
            <meta-data
                android:name="android.autofill.field_classification.default_algorithm"
                android:resource="@string/autofill_field_classification_default_algorithm" />
            <meta-data
                android:name="android.autofill.field_classification.available_algorithms"
                android:resource="@array/autofill_field_classification_available_algorithms" />
        </service>

        <service android:name=".watchdog.ExplicitHealthCheckServiceImpl"
                 android:exported="true"
                 android:directBootAware="true"
                 android:permission="android.permission.BIND_EXPLICIT_HEALTH_CHECK_SERVICE">
            <intent-filter>
                <action android:name="android.service.watchdog.ExplicitHealthCheckService" />
            </intent-filter>
        </service>

        <activity android:name="com.android.textclassifier.notification.CopyCodeActivity"
                  android:exported="false"
                  android:directBootAware="true"
                  android:theme="@android:style/Theme.NoDisplay"/>

        <!-- DirectBootAware is disabled below as it shouldn't be used if the device is locked -->
        <service
            android:name="com.android.textclassifier.DefaultTextClassifierService"
            android:directBootAware="false"
            android:exported="true"
            android:permission="android.permission.BIND_TEXTCLASSIFIER_SERVICE">
            <intent-filter>
                <action android:name="android.service.textclassifier.TextClassifierService"/>
            </intent-filter>
        </service>

        <service android:name="com.android.textclassifier.downloader.ModelDownloaderService"
                 android:exported="false"
                 android:directBootAware="false"
                 android:process=":modelDownloaderServiceProcess">
        </service>

        <service android:name=".autofill.InlineSuggestionRenderServiceImpl"
                 android:exported="true"
                 android:directBootAware="true"
                 android:permission="android.permission.BIND_INLINE_SUGGESTION_RENDER_SERVICE">
            <intent-filter>
                <action android:name="android.service.autofill.InlineSuggestionRenderService" />
            </intent-filter>
        </service>

        <service android:name=".displayhash.DisplayHashingServiceImpl"
            android:exported="true"
            android:directBootAware="true"
            android:permission="android.permission.BIND_DISPLAY_HASHING_SERVICE">
            <intent-filter>
                <action android:name="android.service.displayhash.DisplayHashingService" />
            </intent-filter>
        </service>

        <!-- Remove the default WorkManager and Startup initializers and use on-demand
             initialization instead. This gives us more control on when initialization
             happens, e.g. when the user is unlocked.
        -->
        <provider
            android:name="androidx.work.impl.WorkManagerInitializer"
            android:authorities="${applicationId}.workmanager-init"
            tools:node="remove" />
        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            tools:node="remove" />

        <receiver android:name=".common.AdServicesFilesCleanupBootCompleteReceiver"
                  android:enabled="@bool/enableAdServicesDataCleanupReceiver"
                  android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>
        <service android:name="android.ext.services.common.AdServicesAppsearchDeleteJob"
                 android:enabled="@bool/enableAdServicesDataCleanupReceiver"
                 android:permission="android.permission.BIND_JOB_SERVICE"
                 android:exported="false">
        </service>
    </application>
</manifest>
