<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2019 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"
          package="com.android.car.bugreport"
          android:versionCode="14"
          android:versionName="1.7.3">

    <uses-permission android:name="android.car.permission.ACCESS_PRIVATE_DISPLAY_ID"/>
    <uses-permission android:name="android.car.permission.CAR_DRIVING_STATE"/>
    <!-- Allow closing HVAC dialog when showing bugreport activity, used by
         ACTION_CLOSE_SYSTEM_DIALOGS. -->
    <uses-permission android:name="android.car.permission.CONTROL_CAR_CLIMATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_LOGS"/>
    <uses-permission android:name="android.permission.READ_FRAME_BUFFER"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.MANAGE_USERS"/>
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.DUMP"/>
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>
    <uses-permission android:name="android.permission.READ_DEVICE_CONFIG"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"/>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>

    <application android:label="@string/app_name"
                 android:icon="@drawable/ic_launcher"
                 android:requestLegacyExternalStorage="true">
        <activity android:name=".BugReportInfoActivity"
                  android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
                  android:exported="true"
                  android:launchMode="singleInstance">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.VIEW"/>
            </intent-filter>
        </activity>

        <activity android:name=".ChoiceDialogActivity"
            android:theme="@style/DialogWithNullBackground"
            android:exported="true"
            android:launchMode="singleInstance"
            android:excludeFromRecents="true">
            <meta-data android:name="distractionOptimized" android:value="true"/>
            <intent-filter>
                <action android:name="com.android.car.bugreport.action.START_BUG_REPORT" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>

        <!--
          singleInstance allows starting bugreport dialog when BugReportInfoActivity is open.
        -->
        <activity android:name=".BugReportActivity"
                  android:theme="@android:style/Theme.DeviceDefault.Dialog"
                  android:exported="true"
                  android:launchMode="singleInstance"
                  android:excludeFromRecents="true">
            <meta-data android:name="distractionOptimized" android:value="true"/>
            <intent-filter>
                <action android:name="com.android.car.bugreport.action.START_AUDIO_FIRST"/>
            </intent-filter>
        </activity>

        <activity android:name=".ScreenshotActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:exported="true"
            android:launchMode="singleInstance"
            android:excludeFromRecents="true">
            <meta-data android:name="distractionOptimized" android:value="true"/>
        </activity>

        <service android:name=".BugReportService"
                 android:foregroundServiceType="specialUse"
                 android:exported="true">
            <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="com.android.car.bugreport" />
            <intent-filter>
                <action android:name="com.android.car.bugreport.action.START_AUDIO_LATER"/>
                <!-- START_SILENT is deprecated. It's replaced with START_AUDIO_LATER. -->
                <action android:name="com.android.car.bugreport.action.START_SILENT"/>
            </intent-filter>
        </service>

        <service android:name=".ScreenshotService"
            android:foregroundServiceType="specialUse"
            android:exported="true">
            <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="com.android.car.bugreport" />
        </service>

        <service android:name="com.android.car.bugreport.UploadJob"
                 android:permission="android.permission.BIND_JOB_SERVICE"
                 android:exported="false"/>

        <service android:name="com.android.car.bugreport.ExpireOldBugReportsJob"
                 android:permission="android.permission.BIND_JOB_SERVICE"
                 android:exported="false"/>

        <receiver android:name=".StartUpBootReceiver"
                  android:enabled="true"
                  android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <provider android:name="com.android.car.bugreport.BugStorageProvider"
                  android:authorities="com.android.car.bugreport"
                  android:exported="false"
                  android:singleUser="true"
                  android:multiprocess="false">
        </provider>
    </application>
</manifest>
