Add TvProvider methods to block or unblock package, get blocked packages
Test: gts-tradefed run gts -m GtsTvTestCases
Bug: 36697660
Change-Id: I6464542820a4b56e3145eecdf28ebd422a567040
diff --git a/api/system-current.txt b/api/system-current.txt
index ed486b8..52fc8db 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -26492,6 +26492,7 @@
field public static final java.lang.String ACTION_PREVIEW_PROGRAM_BROWSABLE_DISABLED = "android.media.tv.action.PREVIEW_PROGRAM_BROWSABLE_DISABLED";
field public static final java.lang.String ACTION_WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED = "android.media.tv.action.WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED";
field public static final java.lang.String AUTHORITY = "android.media.tv";
+ field public static final java.lang.String EXTRA_BLOCKED_PACKAGES = "android.media.tv.extra.BLOCKED_PACKAGES";
field public static final java.lang.String EXTRA_CHANNEL_ID = "android.media.tv.extra.CHANNEL_ID";
field public static final java.lang.String EXTRA_COLUMN_NAME = "android.media.tv.extra.COLUMN_NAME";
field public static final java.lang.String EXTRA_DATA_TYPE = "android.media.tv.extra.DATA_TYPE";
@@ -26499,9 +26500,16 @@
field public static final java.lang.String EXTRA_EXISTING_COLUMN_NAMES = "android.media.tv.extra.EXISTING_COLUMN_NAMES";
field public static final java.lang.String EXTRA_PACKAGE_NAME = "android.media.tv.extra.PACKAGE_NAME";
field public static final java.lang.String EXTRA_PREVIEW_PROGRAM_ID = "android.media.tv.extra.PREVIEW_PROGRAM_ID";
+ field public static final java.lang.String EXTRA_RESULT_CODE = "android.media.tv.extra.RESULT_CODE";
field public static final java.lang.String EXTRA_WATCH_NEXT_PROGRAM_ID = "android.media.tv.extra.WATCH_NEXT_PROGRAM_ID";
field public static final java.lang.String METHOD_ADD_COLUMN = "add_column";
+ field public static final java.lang.String METHOD_BLOCK_PACKAGE = "block_package";
+ field public static final java.lang.String METHOD_GET_BLOCKED_PACKAGES = "get_blocked_packages";
field public static final java.lang.String METHOD_GET_COLUMNS = "get_columns";
+ field public static final java.lang.String METHOD_UNBLOCK_PACKAGE = "unblock_package";
+ field public static final int RESULT_ERROR_INVALID_ARGUMENT = 2; // 0x2
+ field public static final int RESULT_ERROR_IO = 1; // 0x1
+ field public static final int RESULT_OK = 0; // 0x0
}
public static abstract interface TvContract.BaseTvColumns implements android.provider.BaseColumns {
@@ -26532,7 +26540,6 @@
field public static final java.lang.String COLUMN_SEARCHABLE = "searchable";
field public static final java.lang.String COLUMN_SERVICE_ID = "service_id";
field public static final java.lang.String COLUMN_SERVICE_TYPE = "service_type";
- field public static final java.lang.String COLUMN_SYSTEM_APPROVED = "system_approved";
field public static final java.lang.String COLUMN_TRANSIENT = "transient";
field public static final java.lang.String COLUMN_TRANSPORT_STREAM_ID = "transport_stream_id";
field public static final java.lang.String COLUMN_TYPE = "type";
diff --git a/media/java/android/media/tv/TvContract.java b/media/java/android/media/tv/TvContract.java
index 6635b5f..defd652 100644
--- a/media/java/android/media/tv/TvContract.java
+++ b/media/java/android/media/tv/TvContract.java
@@ -161,6 +161,38 @@
"android.media.tv.extra.WATCH_NEXT_PROGRAM_ID";
/**
+ * The key for a bundle parameter containing the result code of a method call as an integer.
+ *
+ * @see #RESULT_OK
+ * @see #RESULT_ERROR_IO
+ * @see #RESULT_ERROR_INVALID_ARGUMENT
+ * @hide
+ */
+ @SystemApi
+ public static final String EXTRA_RESULT_CODE = "android.media.tv.extra.RESULT_CODE";
+
+ /**
+ * The result code for a successful execution without error.
+ * @hide
+ */
+ @SystemApi
+ public static final int RESULT_OK = 0;
+
+ /**
+ * The result code for a failure from I/O operation.
+ * @hide
+ */
+ @SystemApi
+ public static final int RESULT_ERROR_IO = 1;
+
+ /**
+ * The result code for a failure from invalid argument.
+ * @hide
+ */
+ @SystemApi
+ public static final int RESULT_ERROR_INVALID_ARGUMENT = 2;
+
+ /**
* The method name to get existing columns in the given table of the specified content provider.
*
* <p>The method caller must provide the following parameter:
@@ -209,6 +241,78 @@
public static final String METHOD_ADD_COLUMN = "add_column";
/**
+ * The method name to get all the blocked packages. When a package is blocked, all the data for
+ * preview programs/channels and watch next programs belonging to this package in the content
+ * provider will be cleared. Once a package is blocked, {@link SecurityException} will be thrown
+ * for all the requests to preview programs/channels and watch next programs via
+ * {@link android.content.ContentProvider} from it.
+ *
+ * <p>The returned {@link android.os.Bundle} will include all the blocked package names with the
+ * key {@link #EXTRA_BLOCKED_PACKAGES}.
+ *
+ * @see ContentResolver#call(Uri, String, String, Bundle)
+ * @see #EXTRA_BLOCKED_PACKAGES
+ * @see #METHOD_BLOCK_PACKAGE
+ * @see #METHOD_UNBLOCK_PACKAGE
+ * @hide
+ */
+ @SystemApi
+ public static final String METHOD_GET_BLOCKED_PACKAGES = "get_blocked_packages";
+
+ /**
+ * The method name to block the access from the given package. When a package is blocked, all
+ * the data for preview programs/channels and watch next programs belonging to this package in
+ * the content provider will be cleared. Once a package is blocked, {@link SecurityException}
+ * will be thrown for all the requests to preview programs/channels and watch next programs via
+ * {@link android.content.ContentProvider} from it.
+ *
+ * <p>The method caller must provide the following parameter:
+ * <ul>
+ * <li>{@code arg}: The package name to be added as blocked package {@link String}.</li>
+ * </ul>
+ *
+ * <p>The returned {@link android.os.Bundle} will include an integer code denoting whether the
+ * execution is successful or not with the key {@link #EXTRA_RESULT_CODE}. If {@code arg} is
+ * empty, the result code will be {@link #RESULT_ERROR_INVALID_ARGUMENT}. If success, the result
+ * code will be {@link #RESULT_OK}. Otherwise, the result code will be {@link #RESULT_ERROR_IO}.
+ *
+ * @see ContentResolver#call(Uri, String, String, Bundle)
+ * @see #EXTRA_RESULT_CODE
+ * @see #METHOD_GET_BLOCKED_PACKAGES
+ * @see #METHOD_UNBLOCK_PACKAGE
+ * @hide
+ */
+ @SystemApi
+ public static final String METHOD_BLOCK_PACKAGE = "block_package";
+
+ /**
+ * The method name to unblock the access from the given package. When a package is blocked, all
+ * the data for preview programs/channels and watch next programs belonging to this package in
+ * the content provider will be cleared. Once a package is blocked, {@link SecurityException}
+ * will be thrown for all the requests to preview programs/channels and watch next programs via
+ * {@link android.content.ContentProvider} from it.
+ *
+ * <p>The method caller must provide the following parameter:
+ * <ul>
+ * <li>{@code arg}: The package name to be removed from blocked list as a {@link String}.
+ * </li>
+ * </ul>
+ *
+ * <p>The returned {@link android.os.Bundle} will include an integer code denoting whether the
+ * execution is successful or not with the key {@link #EXTRA_RESULT_CODE}. If {@code arg} is
+ * empty, the result code will be {@link #RESULT_ERROR_INVALID_ARGUMENT}. If success, the result
+ * code will be {@link #RESULT_OK}. Otherwise, the result code will be {@link #RESULT_ERROR_IO}.
+ *
+ * @see ContentResolver#call(Uri, String, String, Bundle)
+ * @see #EXTRA_RESULT_CODE
+ * @see #METHOD_GET_BLOCKED_PACKAGES
+ * @see #METHOD_BLOCK_PACKAGE
+ * @hide
+ */
+ @SystemApi
+ public static final String METHOD_UNBLOCK_PACKAGE = "unblock_package";
+
+ /**
* The key for a returned {@link Bundle} value containing existing column names in the given
* table as an {@link ArrayList} of {@link String}.
*
@@ -253,6 +357,16 @@
public static final String EXTRA_DEFAULT_VALUE = "android.media.tv.extra.DEFAULT_VALUE";
/**
+ * The key for a returned {@link Bundle} value containing all the blocked package names as an
+ * {@link ArrayList} of {@link String}.
+ *
+ * @see #METHOD_GET_BLOCKED_PACKAGES
+ * @hide
+ */
+ @SystemApi
+ public static final String EXTRA_BLOCKED_PACKAGES = "android.media.tv.extra.BLOCKED_PACKAGES";
+
+ /**
* An optional query, update or delete URI parameter that allows the caller to specify TV input
* ID to filter channels.
* @hide
@@ -2184,19 +2298,6 @@
*/
public static final String COLUMN_TRANSIENT = "transient";
- /**
- * The flag indicating whether this TV channel is approved to be shown by the system.
- *
- * <p>A value of 1 indicates that the channel is approved to be shown by the system, and a
- * value of 0 indicates that the channel is blocked by system. If not specified, this value
- * is set to 0 (not approved) by default.
- *
- * <p>Type: INTEGER (boolean)
- * @hide
- */
- @SystemApi
- public static final String COLUMN_SYSTEM_APPROVED = "system_approved";
-
private Channels() {}
/**