<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2015 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.tv" xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GLOBAL_SEARCH" tools:ignore="ProtectedPermissions"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_TV_LISTINGS" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.MODIFY_PARENTAL_CONTROLS" />
    <uses-permission android:name="com.android.providers.tv.permission.READ_EPG_DATA" />
    <uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" />
    <uses-permission android:name="com.android.providers.tv.permission.ACCESS_ALL_EPG_DATA" />
    <uses-permission android:name="com.android.providers.tv.permission.ACCESS_WATCHED_PROGRAMS" />

    <!-- Permissions/feature for USB tuner -->
    <uses-permission android:name="android.permission.DVB_DEVICE" />
    <uses-feature android:name="android.hardware.usb.host" android:required="false" />

    <!-- Limit only for Android TV -->
    <uses-feature android:name="android.software.leanback" android:required="true" />
    <uses-feature android:name="android.software.live_tv" android:required="true" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>

    <!-- Receives input events from the TV app. -->
    <permission android:name="com.android.tv.permission.RECEIVE_INPUT_EVENT"
        android:protectionLevel="signatureOrSystem"
        android:label="@string/permlab_receiveInputEvent"
        android:description="@string/permdesc_receiveInputEvent" tools:ignore="SignatureOrSystemPermissions"/>
    <uses-sdk android:targetSdkVersion="23" android:minSdkVersion="23"/>

    <application android:label="@string/app_name"
        android:name=".TvApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:banner="@drawable/banner"
        android:supportsRtl="true"
        android:theme="@style/Theme.TV">
        <activity android:name="com.android.tv.TvActivity">
            <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="com.android.tv.MainActivity"
            android:configChanges="keyboard|keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
            android:screenOrientation="landscape"
            android:launchMode="singleTask"
            android:resizeableActivity="true"
            android:supportsPictureInPicture="true"
            android:theme="@style/Theme.TV.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/channel" />
                <data android:mimeType="vnd.android.cursor.dir/channel" />
                <data android:mimeType="vnd.android.cursor.item/program" />
                <data android:mimeType="vnd.android.cursor.dir/program" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.media.tv.action.SETUP_INPUTS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="supports_leanback" android:value="true" />
            <meta-data android:name="android.app.searchable"
                android:resource="@xml/searchable" />
        </activity>

        <activity android:name=".LauncherActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

        <activity android:name=".SetupPassthroughActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar">
            <intent-filter>
                <action android:name="com.android.tv.action.LAUNCH_INPUT_SETUP" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".SelectInputActivity"
            android:launchMode="singleTask"
            android:theme="@style/Theme.SelectInputActivity" />

        <activity android:name=".onboarding.OnboardingActivity"
            android:launchMode="singleTop"
            android:theme="@style/Theme.Setup.GuidedStep" />

        <activity android:name=".dvr.ui.DvrActivity"
            android:launchMode="singleTask"
            android:theme="@style/Theme.Leanback.Browse" />

        <provider android:name="com.android.tv.search.LocalSearchProvider"
            android:authorities="com.android.tv.search"
            android:exported="true"
            android:enabled="true" tools:ignore="ExportedContentProvider">
            <meta-data android:name="SupportedSwitchActionType" android:value="CHANNEL|TVINPUT" />
        </provider>

        <service android:name="com.android.tv.recommendation.NotificationService"
             android:exported="false" />

        <receiver android:name="com.android.tv.receiver.BootCompletedReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.android.tv.receiver.PackageIntentsReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <!-- PACKAGE_CHANGED for package enabled/disabled notification -->
                <action android:name="android.intent.action.PACKAGE_CHANGED" />
                <action android:name="android.intent.action.PACKAGE_REMOVED" />
                <data android:scheme="package"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.android.tv.receiver.GlobalKeyReceiver">
            <intent-filter>
                <action android:name="android.intent.action.GLOBAL_BUTTON" />
            </intent-filter>

            <!-- Not directly related to GlobalKeyReceiver but needed to be able to provide our
                content rating definitions to the system service. -->
            <intent-filter>
                <action android:name="android.media.tv.action.QUERY_CONTENT_RATING_SYSTEMS" />
            </intent-filter>
            <meta-data android:name="android.media.tv.metadata.CONTENT_RATING_SYSTEMS"
                    android:resource="@xml/tv_content_rating_systems" />
        </receiver>

        <!-- USB tuner components definition -->
        <activity android:name="com.android.usbtuner.setup.TunerSetupActivity"
            android:label="@string/ut_app_name"
            android:launchMode="singleInstance"
            android:process="com.android.usbtuner"
            android:theme="@style/Theme.Setup.GuidedStep" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
        <activity android:name=".dvr.DvrPlayActivity"/>
        <service android:name="com.android.usbtuner.tvinput.UsbTunerTvInputService"
            android:enabled="false"
            android:process="com.android.usbtuner"
            android:label="@string/ut_app_name"
            android:permission="android.permission.BIND_TV_INPUT" >
            <intent-filter>
                <action android:name="android.media.tv.TvInputService" />
            </intent-filter>
            <meta-data android:name="android.media.tv.input"
                android:resource="@xml/ut_tvinputservice" />
        </service>
        <provider android:name="com.android.usbtuner.UsbTunerPreferenceProvider"
            android:authorities="com.android.usbtuner.preferences"
            android:process="com.android.usbtuner"
            android:exported="false" />
        <!-- UsbInputController should be the same process with MainActivity to check status of MainActivity -->
        <receiver android:name="com.android.usbtuner.UsbInputController"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
                <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
            </intent-filter>
        </receiver>

        <!-- DVR -->
        <service android:name=".dvr.DvrRecordingService" android:label="@string/dvr_service_name"/>
        <receiver android:name=".dvr.DvrStartRecordingReceiver"/>

    </application>
</manifest>