am 3493ee3c: am 02023167: Merge "Introduce "input_id" column to the channels table" into lmp-dev

* commit '3493ee3cc87d35a02ba1b35c3f11572c8511fb66':
  Introduce "input_id" column to the channels table
diff --git a/api/current.txt b/api/current.txt
index 97bd93cd..cecb83a 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -16422,8 +16422,8 @@
     method public static final android.net.Uri buildChannelLogoUri(long);
     method public static final android.net.Uri buildChannelLogoUri(android.net.Uri);
     method public static final android.net.Uri buildChannelUri(long);
-    method public static final android.net.Uri buildChannelsUriForInput(android.content.ComponentName);
-    method public static final android.net.Uri buildChannelsUriForInput(android.content.ComponentName, boolean);
+    method public static final android.net.Uri buildChannelsUriForInput(java.lang.String);
+    method public static final android.net.Uri buildChannelsUriForInput(java.lang.String, boolean);
     method public static final android.net.Uri buildProgramUri(long);
     method public static final android.net.Uri buildProgramsUriForChannel(long);
     method public static final android.net.Uri buildProgramsUriForChannel(android.net.Uri);
@@ -16443,12 +16443,12 @@
     field public static final java.lang.String COLUMN_DESCRIPTION = "description";
     field public static final java.lang.String COLUMN_DISPLAY_NAME = "display_name";
     field public static final java.lang.String COLUMN_DISPLAY_NUMBER = "display_number";
+    field public static final java.lang.String COLUMN_INPUT_ID = "input_id";
     field public static final java.lang.String COLUMN_INTERNAL_PROVIDER_DATA = "internal_provider_data";
     field public static final java.lang.String COLUMN_NETWORK_AFFILIATION = "network_affiliation";
     field public static final java.lang.String COLUMN_ORIGINAL_NETWORK_ID = "original_network_id";
     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_NAME = "service_name";
     field public static final java.lang.String COLUMN_SERVICE_TYPE = "service_type";
     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 ffb6850..8ecf808 100644
--- a/media/java/android/media/tv/TvContract.java
+++ b/media/java/android/media/tv/TvContract.java
@@ -16,7 +16,6 @@
 
 package android.media.tv;
 
-import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.ContentUris;
 import android.media.tv.TvContract.Programs;
@@ -121,26 +120,23 @@
     /**
      * Builds a URI that points to all browsable channels from a given TV input.
      *
-     * @param name {@link ComponentName} of the {@link android.media.tv.TvInputService} that
-     *            implements the given TV input.
+     * @param inputId The ID of the TV input to build a channels URI for.
      */
-    public static final Uri buildChannelsUriForInput(ComponentName name) {
-        return buildChannelsUriForInput(name, true);
+    public static final Uri buildChannelsUriForInput(String inputId) {
+        return buildChannelsUriForInput(inputId, true);
     }
 
     /**
      * Builds a URI that points to all or browsable-only channels from a given TV input.
      *
-     * @param name {@link ComponentName} of the {@link android.media.tv.TvInputService} that
-     *            implements the given TV input.
+     * @param inputId The ID of the TV input to build a channels URI for.
      * @param browsableOnly If set to {@code true} the URI points to only browsable channels. If set
      *            to {@code false} the URI points to all channels regardless of whether they are
      *            browsable or not.
      */
-    public static final Uri buildChannelsUriForInput(ComponentName name, boolean browsableOnly) {
+    public static final Uri buildChannelsUriForInput(String inputId, boolean browsableOnly) {
         return new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
-                .appendPath(PATH_INPUT).appendPath(name.getPackageName())
-                .appendPath(name.getClassName()).appendPath(PATH_CHANNEL)
+                .appendPath(PATH_INPUT).appendPath(inputId).appendPath(PATH_CHANNEL)
                 .appendQueryParameter(PARAM_BROWSABLE_ONLY, String.valueOf(browsableOnly)).build();
     }
 
@@ -148,26 +144,26 @@
      * Builds a URI that points to all or browsable-only channels which have programs with the given
      * genre from the given TV input.
      *
-     * @param name {@link ComponentName} of the {@link android.media.tv.TvInputService} that
-     *            implements the given TV input. If null, builds a URI for all the TV inputs.
+     * @param inputId The ID of the TV input to build a channels URI for. If null, builds a URI for
+     *            all the TV inputs.
      * @param genre {@link Programs.Genres} to search.
      * @param browsableOnly If set to {@code true} the URI points to only browsable channels. If set
      *            to {@code false} the URI points to all channels regardless of whether they are
      *            browsable or not.
      * @hide
      */
-    public static final Uri buildChannelsUriForCanonicalGenre(ComponentName name, String genre,
+    public static final Uri buildChannelsUriForCanonicalGenre(String inputId, String genre,
             boolean browsableOnly) {
         if (!Programs.Genres.isCanonical(genre)) {
             throw new IllegalArgumentException("Not a canonical genre: '" + genre + "'");
         }
 
         Uri uri;
-        if (name == null) {
+        if (inputId == null) {
             uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY)
                     .appendPath(PATH_CHANNEL).build();
         } else {
-            uri = buildChannelsUriForInput(name, browsableOnly);
+            uri = buildChannelsUriForInput(inputId, browsableOnly);
         }
         return uri.buildUpon().appendQueryParameter(PARAM_CANONICAL_GENRE, genre).build();
     }
@@ -250,42 +246,25 @@
     }
 
     /**
-     * Extracts the {@link Channels#COLUMN_PACKAGE_NAME} from a given URI.
+     * Extracts the {@link Channels#COLUMN_INPUT_ID} from a given URI.
      *
-     * @param channelsUri A URI constructed by {@link #buildChannelsUriForInput(ComponentName)} or
-     *            {@link #buildChannelsUriForInput(ComponentName, boolean)}.
+     * @param channelsUri A URI constructed by {@link #buildChannelsUriForInput(String)},
+     *            {@link #buildChannelsUriForInput(String, boolean)}, or
+     *            {@link #buildChannelsUriForCanonicalGenre(String, String, boolean)}.
      * @hide
      */
-    public static final String getPackageName(Uri channelsUri) {
+    public static final String getInputId(Uri channelsUri) {
         final List<String> paths = channelsUri.getPathSegments();
-        if (paths.size() < 4) {
+        if (paths.size() < 3) {
             throw new IllegalArgumentException("Not channels: " + channelsUri);
         }
-        if (!PATH_INPUT.equals(paths.get(0)) || !PATH_CHANNEL.equals(paths.get(3))) {
+        if (!PATH_INPUT.equals(paths.get(0)) || !PATH_CHANNEL.equals(paths.get(2))) {
             throw new IllegalArgumentException("Not channels: " + channelsUri);
         }
         return paths.get(1);
     }
 
     /**
-     * Extracts the {@link Channels#COLUMN_SERVICE_NAME} from a given URI.
-     *
-     * @param channelsUri A URI constructed by {@link #buildChannelsUriForInput(ComponentName)} or
-     *            {@link #buildChannelsUriForInput(ComponentName, boolean)}.
-     * @hide
-     */
-    public static final String getServiceName(Uri channelsUri) {
-        final List<String> paths = channelsUri.getPathSegments();
-        if (paths.size() < 4) {
-            throw new IllegalArgumentException("Not channels: " + channelsUri);
-        }
-        if (!PATH_INPUT.equals(paths.get(0)) || !PATH_CHANNEL.equals(paths.get(3))) {
-            throw new IllegalArgumentException("Not channels: " + channelsUri);
-        }
-        return paths.get(2);
-    }
-
-    /**
      * Extracts the {@link Channels#_ID} from a given URI.
      *
      * @param programsUri A URI constructed by {@link #buildProgramsUriForChannel(Uri)} or
@@ -496,15 +475,14 @@
         }
 
         /**
-         * The name of the {@link TvInputService} subclass that provides this TV channel. This
-         * should be a fully qualified class name (such as, "com.example.project.TvInputService").
+         * The ID of the TV input that provides this TV channel.
          * <p>
          * This is a required field.
          * </p><p>
          * Type: TEXT
          * </p>
          */
-        public static final String COLUMN_SERVICE_NAME = "service_name";
+        public static final String COLUMN_INPUT_ID = "input_id";
 
         /**
          * The predefined type of this TV channel.