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

<!-- Copyright 2024 The Chromium Authors. All rights reserved.
     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"
          xmlns:tools="http://schemas.android.com/tools"
          package="org.chromium.chromecast.shell">

    <uses-sdk android:minSdkVersion="24"/>

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>

    <!-- Needed because CastWebContentsActivity sets orientation to landscape. -->
    <uses-feature android:name="android.hardware.screen.landscape" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>

    <application android:name="org.chromium.chromecast.shell.CastBrowserApplication"
                 android:icon="@drawable/ic_settings_cast">
        <service android:name="org.chromium.chromecast.shell.CastBrowserService"
                 android:process=":cast_browser_process"
                 android:hardwareAccelerated="true"
                 android:label="Cast Web Browser"
                 android:exported="true"
                 android:foregroundServiceType="mediaPlayback"
                 tools:ignore="ExportedService">
             <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                       android:value="cast" />
            <intent-filter>
                <action android:name="com.google.cast.action.START_CAST_BROWSER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>

        <activity android:name="org.chromium.chromecast.shell.CastWebContentsActivity"
                  android:theme="@style/CastShellTheme"
                  android:exported="true"
                  android:hardwareAccelerated="true"
                  android:launchMode="singleInstance"
                  android:process=":cast_browser_process"
                  android:screenOrientation="landscape"
                  android:taskAffinity=".CastWebContentsActivity"
                  android:supportsPictureInPicture="true"
                  android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|screenLayout|smallestScreenSize|uiMode"
                  android:excludeFromRecents="false"
                  android:noHistory="false"
                  android:showWhenLocked="true">
        </activity>

        <service android:name="org.chromium.chromecast.shell.TaskRemovedMonitorService"
                 android:process=":cast_browser_process"
                 android:exported="false">
        </service>

        <!-- The following service entries exist in order to allow us to
             start more than one sandboxed process. -->
        {% set num_sandboxed_services = 40 %}
        <meta-data android:name="org.chromium.content.browser.NUM_SANDBOXED_SERVICES"
                   android:value="{{ num_sandboxed_services }}"/>
        <meta-data android:name="org.chromium.content.browser.SANDBOXED_SERVICES_NAME"
                     android:value="org.chromium.content.app.SandboxedProcessService"/>

        {% for i in range(num_sandboxed_services) %}
        <service android:name="org.chromium.content.app.SandboxedProcessService{{ i }}"
                 android:process=":sandboxed_process{{ i }}"
                 android:permission="org.chromium.chromecast.shell.permission.SANDBOX"
                 android:isolatedProcess="true"
                 android:exported="false" />
        {% endfor %}

        {% for i in range(2) %}
        <service android:name="org.chromium.content.app.NativeOnlySandboxedProcessService{{ i }}"
                 android:process=":sandboxed_process{{ i }}"
                 android:permission="org.chromium.chromecast.shell.permission.SANDBOX"
                 android:isolatedProcess="true"
                 android:nativeService="true"
                 android:exported="false" >
             <property android:name="android.app.PROPERTY_NATIVE_SERVICE_LIBRARY_NAME"
                       android:value="lib{{ library_name }}.so" />
             <property android:name="android.app.PROPERTY_NATIVE_SERVICE_FUNCTION_NAME"
                       android:value="NativeChildProcessService_onCreate" />
        </service>
        {% endfor %}

        {% set num_privileged_services = 5 %}
        <meta-data android:name="org.chromium.content.browser.NUM_PRIVILEGED_SERVICES"
                   android:value="{{ num_privileged_services }}"/>
        <meta-data android:name="org.chromium.content.browser.PRIVILEGED_SERVICES_NAME"
                   android:value="org.chromium.content.app.PrivilegedProcessService"/>

        {% for i in range(num_privileged_services) %}
        <service android:name="org.chromium.content.app.PrivilegedProcessService{{ i }}"
                 android:process=":privileged_process{{ i }}"
                 android:isolatedProcess="false"
                 android:exported="false" />
        {% endfor %}
    </application>

</manifest>
