summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml17
-rw-r--r--res/values/strings.xml11
-rw-r--r--src/com/android/providers/tv/TvProvider.java20
3 files changed, 22 insertions, 26 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d5fef15..fccd6cf 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -19,17 +19,10 @@
<!-- Allows an application to read (but not write) the TV channel/program
data. -->
- <permission android:name="com.android.providers.tv.permission.READ_EPG_DATA"
+ <permission android:name="android.permission.READ_TV_LISTINGS"
android:protectionLevel="dangerous"
- android:label="@string/permlab_readEpgData"
- android:description="@string/permdesc_readEpgData" />
-
- <!-- Allows an application to write (but not read) the TV channel/program
- data. -->
- <permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA"
- android:protectionLevel="dangerous"
- android:label="@string/permlab_writeEpgData"
- android:description="@string/permdesc_writeEpgData" />
+ android:label="@string/permlab_readTvListings"
+ android:description="@string/permdesc_readTvListings" />
<!-- Allows an application to read and write all TV channel/program data.
@hide -->
@@ -53,9 +46,7 @@
android:name="TvProvider"
android:authorities="android.media.tv"
android:exported="true"
- android:syncable="true"
- android:readPermission="com.android.providers.tv.permission.READ_EPG_DATA"
- android:writePermission="com.android.providers.tv.permission.WRITE_EPG_DATA" />
+ android:syncable="true" />
<service android:name="EpgDataCleanupService" />
</application>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2287f7a..6e31bae 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -19,17 +19,10 @@
<!-- Title of an application permission, listed so the user can choose
whether they want to allow the application to do this. -->
- <string name="permlab_readEpgData">read TV programming</string>
+ <string name="permlab_readTvListings">read TV listings</string>
<!-- Description of an application permission, listed so the user can choose
whether they want to allow the application to do this. -->
- <string name="permdesc_readEpgData">Allows the app to read the TV channel/program information stored on your device.</string>
-
- <!-- Title of an application permission, listed so the user can choose
- whether they want to allow the application to do this. -->
- <string name="permlab_writeEpgData">write TV programming</string>
- <!-- Description of an application permission, listed so the user can choose
- whether they want to allow the application to do this. -->
- <string name="permdesc_writeEpgData">Allows the app to provide and modify the TV channel/program information stored on your device.</string>
+ <string name="permdesc_readTvListings">Allows the app to read the TV listings stored on your device.</string>
<!-- Title of an application permission, listed so the user can choose
whether they want to allow the application to do this. -->
diff --git a/src/com/android/providers/tv/TvProvider.java b/src/com/android/providers/tv/TvProvider.java
index 482726b..49f782a 100644
--- a/src/com/android/providers/tv/TvProvider.java
+++ b/src/com/android/providers/tv/TvProvider.java
@@ -254,6 +254,8 @@ public class TvProvider extends ContentProvider {
// Mapping from broadcast genre to canonical genre.
private static Map<String, String> sGenreMap;
+ private static final String PERMISSION_READ_TV_LISTINGS = "android.permission.READ_TV_LISTINGS";
+
private static final String PERMISSION_ACCESS_ALL_EPG_DATA =
"com.android.providers.tv.permission.ACCESS_ALL_EPG_DATA";
@@ -697,8 +699,9 @@ public class TvProvider extends ContentProvider {
if (!TextUtils.isEmpty(selection)) {
throw new SecurityException("Selection not allowed for " + uri);
}
- // Limit the operation only to the data that the calling package owns except for query.
- if (operation.equals(OP_QUERY)) {
+ // Limit the operation only to the data that the calling package owns except for when
+ // the caller tries to read TV listings and has the appropriate permission.
+ if (operation.equals(OP_QUERY) && callerHasReadTvListingsPermission()) {
params.setWhere(BaseTvColumns.COLUMN_PACKAGE_NAME + "=? OR "
+ Channels.COLUMN_SEARCHABLE + "=?", getCallingPackage_(), "1");
@@ -903,6 +906,11 @@ public class TvProvider extends ContentProvider {
return !callerHasAccessAllEpgDataPermission();
}
+ private boolean callerHasReadTvListingsPermission() {
+ return getContext().checkCallingOrSelfPermission(PERMISSION_READ_TV_LISTINGS)
+ == PackageManager.PERMISSION_GRANTED;
+ }
+
private boolean callerHasAccessAllEpgDataPermission() {
return getContext().checkCallingOrSelfPermission(PERMISSION_ACCESS_ALL_EPG_DATA)
== PackageManager.PERMISSION_GRANTED;
@@ -935,8 +943,12 @@ public class TvProvider extends ContentProvider {
SqlParams params = new SqlParams(CHANNELS_TABLE, Channels._ID + "=?",
String.valueOf(channelId));
if (!callerHasAccessAllEpgDataPermission()) {
- params.appendWhere(Channels.COLUMN_PACKAGE_NAME + "=? OR " + Channels.COLUMN_SEARCHABLE
- + "=?", getCallingPackage_(), "1");
+ if (callerHasReadTvListingsPermission()) {
+ params.appendWhere(Channels.COLUMN_PACKAGE_NAME + "=? OR "
+ + Channels.COLUMN_SEARCHABLE + "=?", getCallingPackage_(), "1");
+ } else {
+ params.appendWhere(Channels.COLUMN_PACKAGE_NAME + "=?", getCallingPackage_());
+ }
}
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();