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

<!--
Copyright 2019 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.chromium.weblayer.client">

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <uses-permission-sdk-23 android:name="android.permission.BLUETOOTH"/>
    <uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
    <uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_CONNECT"/>
    <!--
      Bluetooth scanning is used to implement the Web Bluetooth API, which is
      not intended to allow sites to derive location and so can accept a
      filtered view of devices.
    -->
    <uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_SCAN"
                            android:usesPermissionFlags="neverForLocation"/>

    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-permission android:name="android.permission.NFC"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <!-- Augmented reality support.
         A note to clients: for AR to work, there must be manifest entries present for
         com.google.ar.core and com.google.ar.core.min_apk_version. These can be merged
         from the arcore client library or added manually. If being added manually,
         the following is recommended:

           <meta-data android:name="com.google.ar.core"
                      android:value="optional" />
           <meta-data android:name="com.google.ar.core.min_apk_version"
                      android:value="1" />
    -->
    <queries>
        <package android:name="com.google.ar.core" />
    </queries>

    <application>
        <!-- The following service entries exist in order to allow us to
             start more than one sandboxed process. -->

        <!-- NOTE: If you change the values of "android:process" for any of the below services,
             you also need to update kHelperProcessExecutableName in chrome_constants.cc. -->
        {% set num_sandboxed_services = 40 %}
        <meta-data android:name="org.chromium.content.browser.NUM_SANDBOXED_SERVICES"
                   android:value="{{ num_sandboxed_services }}"/>
        {% for i in range(num_sandboxed_services) %}
        <service android:name="org.chromium.weblayer.ChildProcessService$Sandboxed{{ i }}"
                 android:process=":sandboxed_process{{ i }}"
                 android:isolatedProcess="true"
                 android:exported="false" />
        {% endfor %}

        {% set num_privileged_services = 5 %}
        <meta-data android:name="org.chromium.content.browser.NUM_PRIVILEGED_SERVICES"
                   android:value="{{ num_privileged_services }}"/>
        {% for i in range(num_privileged_services) %}
        <service android:name="org.chromium.weblayer.ChildProcessService$Privileged{{ i }}"
                 android:process=":privileged_process{{ i }}"
                 android:isolatedProcess="false"
                 android:exported="false" />
        {% endfor %}

        <provider android:name="org.chromium.weblayer.WebLayerFileProvider"
            android:authorities="${applicationId}.org.chromium.weblayer.client.FileProvider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/weblayer_file_paths" />
        </provider>

        <activity android:name="org.chromium.weblayer.SettingsActivity"
            android:theme="@style/Theme.WebLayer.Settings"
            android:exported="false">
        </activity>

        <activity android:name="org.chromium.weblayer.SiteSettingsActivity"
            android:theme="@style/Theme.WebLayer.Settings"
            android:exported="false">
        </activity>

        <receiver android:name="org.chromium.weblayer.BroadcastReceiver"
            android:exported="false">
            <intent-filter>
                <!-- these need to be in sync with DownloadImpl.java-->
                <action android:name="org.chromium.weblayer.downloads.OPEN"/>
                <action android:name="org.chromium.weblayer.downloads.DELETE"/>
                <action android:name="org.chromium.weblayer.downloads.PAUSE"/>
                <action android:name="org.chromium.weblayer.downloads.RESUME"/>
                <action android:name="org.chromium.weblayer.downloads.CANCEL"/>
                <!-- this needs to be in sync with IntentUtils.java-->
                <action android:name="org.chromium.weblayer.intent_utils.ACTIVATE_TAB"/>
                <!-- this needs to be in sync with MediaStreamManager.java-->
                <!-- TODO(estade): deprecated, remove in M88. -->
                <action android:name="org.chromium.weblayer.webrtc.ACTIVATE_TAB"/>
            </intent-filter>
        </receiver>

        <service android:name="org.chromium.weblayer.MediaSessionService"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_BUTTON" />
            </intent-filter>
        </service>

        <service android:name="org.chromium.weblayer.RemoteMediaService"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_BUTTON" />
            </intent-filter>
        </service>

        <!-- Service for decoding images in a sandboxed process. -->
        <service
            android:name="org.chromium.weblayer.ImageDecoderService"
            android:exported="false"
            android:isolatedProcess="true"
            android:process=":decoder_service" />

        <!-- Used for GPay Dynamic Update -->
        <service
            android:name="org.chromium.weblayer.GooglePayDataCallbacksServiceWrapper"
            android:permission="com.google.android.gms.permission.BIND_PAYMENTS_CALLBACK_SERVICE"
            android:exported="true">
            <intent-filter>
              <action android:name="com.google.android.gms.wallet.callback.PAYMENT_DATA_CALLBACKS"/>
            </intent-filter>
        </service>

        <!-- GooglePay payment app support -->
        <meta-data
            android:name="com.google.android.gms.wallet.api.enabled"
            android:value="true" />

        <!-- Service used by payment apps to notify the browser about changes in user selected
             payment method, shipping address, or shipping option. -->
        <service
            android:name="org.chromium.weblayer.PaymentDetailsUpdateServiceWrapper"
            android:exported="true">
            <intent-filter>
                <action android:name="org.chromium.intent.action.UPDATE_PAYMENT_DETAILS"/>
            </intent-filter>
        </service>

        <!-- Cast support -->
        <!-- TODO(crbug.com/1148410): remove this. -->
        <meta-data
            android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
            android:value="org.chromium.components.media_router.caf.CastOptionsProvider"/>
    </application>
</manifest>