<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright (C) 2014 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.providers.tv" >

    <!-- Allows an application to read (but not write) all the TV listings.
         This is the only (soon-to-be) public permission among other permissions defined here.
         TODO(jaeseo): Update when b/21959866 is resolved. -->
    <permission android:name="android.permission.READ_TV_LISTINGS"
        android:protectionLevel="dangerous"
        android:label="@string/permlab_readTvListings"
        android:description="@string/permdesc_readTvListings" />

    <!-- Allows an application to read (but not write) its own TV channel/program data.
         @deprecated No longer enforced. -->
    <permission android:name="com.android.providers.tv.permission.READ_EPG_DATA"
        android:protectionLevel="normal"
        android:label="@string/permlab_readEpgData"
        android:description="@string/permdesc_readEpgData" />

    <!-- Allows an application to write (but not read) its own TV channel/program data.
         The write permission is still enforced but the application is not required to declare it as
         the TV player/viewer app grants permission to write through the channel setup flow.
         @hide -->
    <permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA"
        android:protectionLevel="normal"
        android:label="@string/permlab_writeEpgData"
        android:description="@string/permdesc_writeEpgData" />

    <!-- Allows an application to read and write all TV channel/program data.
         @hide -->
    <permission android:name="com.android.providers.tv.permission.ACCESS_ALL_EPG_DATA"
        android:protectionLevel="signature|privileged"
        android:label="@string/permlab_accessAllEpgData"
        android:description="@string/permdesc_accessAllEpgData" />

    <!-- Allows an application to read and write watched programs data.
         @hide -->
    <permission android:name="com.android.providers.tv.permission.ACCESS_WATCHED_PROGRAMS"
        android:protectionLevel="signature|privileged"
        android:label="@string/permlab_accessWatchedPrograms"
        android:description="@string/permdesc_accessWatchedPrograms" />

    <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" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <application android:label="@string/app_label">
        <provider
            android:name="TvProvider"
            android:authorities="android.media.tv"
            android:exported="true"
            android:syncable="true"
            android:writePermission="com.android.providers.tv.permission.WRITE_EPG_DATA">
        <grant-uri-permission android:pathPattern="/channel" />
        <grant-uri-permission android:pathPattern="/program" />
        </provider>

        <service android:name="EpgDataCleanupService" />

        <!-- Handles database upgrades after OTAs -->
        <receiver android:name="TvProviderUpgradeReceiver">
            <!-- This broadcast is sent after the core system has finished
                 booting, before the home app is launched or BOOT_COMPLETED
                 is sent. -->
            <intent-filter>
                <action android:name="android.intent.action.PRE_BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <!-- Deletes transient rows on boot. -->
        <receiver android:name="BootCompletedReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>

        <!-- Removes channels and programs when some package is fully removed. -->
        <receiver android:name="PackageRemovedReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED"/>
                <data android:scheme="package"/>
            </intent-filter>
        </receiver>

        <!-- Removes preview programs, watch next programs, and preview channels when some
             package is disabled. -->
        <receiver android:name="PackageChangedReceiver">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_CHANGED"/>
                <data android:scheme="package"/>
            </intent-filter>
        </receiver>
    </application>
</manifest>