MediaRouter: Show "Casting screen" if the app is being mirrored

Bug: 23724473
Change-Id: Ia01981aa5b8062c0469d1992fef8468c0783cd3e
diff --git a/v7/mediarouter/res/values/strings.xml b/v7/mediarouter/res/values/strings.xml
index 88517ba..268715b 100644
--- a/v7/mediarouter/res/values/strings.xml
+++ b/v7/mediarouter/res/values/strings.xml
@@ -54,4 +54,7 @@
 
     <!-- Placeholder text to show when no title/description have been found for a given song/video. [CHAR LIMIT=50] -->
     <string name="mr_controller_no_info_available">No info available</string>
+
+    <!-- Placeholder text indicating that the user is currently casting screen. [CHAR LIMIT=50] -->
+    <string name="mr_controller_casting_screen">Casting screen</string>
 </resources>
diff --git a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
index 7bdafe3..e4526d8 100644
--- a/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
+++ b/v7/mediarouter/src/android/support/v7/app/MediaRouteControllerDialog.java
@@ -616,7 +616,13 @@
                 boolean hasSubtitle = !TextUtils.isEmpty(subtitle);
 
                 if (!hasTitle && !hasSubtitle) {
-                    mTitleView.setText(R.string.mr_controller_no_info_available);
+                    if (mRoute.getPresentationDisplayId()
+                            != MediaRouter.RouteInfo.PRESENTATION_DISPLAY_ID_NONE) {
+                        // The user is currently casting screen.
+                        mTitleView.setText(R.string.mr_controller_casting_screen);
+                    } else {
+                        mTitleView.setText(R.string.mr_controller_no_info_available);
+                    }
                     mTitleView.setEnabled(false);
                     mTitleView.setVisibility(View.VISIBLE);
                     mSubtitleView.setVisibility(View.GONE);
@@ -721,7 +727,7 @@
 
                 ImageView volumeItemIcon =
                         (ImageView) v.findViewById(R.id.mr_volume_item_icon);
-                volumeItemIcon.setAlpha(isEnabled ? 255 : (int)(255 * DISABLED_ALPHA));
+                volumeItemIcon.setAlpha(isEnabled ? 255 : (int) (255 * DISABLED_ALPHA));
             }
             return v;
         }
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java b/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java
index 2881b32..8e5ad25 100644
--- a/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java
+++ b/v7/mediarouter/src/android/support/v7/media/MediaRouteDescriptor.java
@@ -234,7 +234,8 @@
      * Gets the route's presentation display id, or -1 if none.
      */
     public int getPresentationDisplayId() {
-        return mBundle.getInt(KEY_PRESENTATION_DISPLAY_ID, -1);
+        return mBundle.getInt(
+                KEY_PRESENTATION_DISPLAY_ID, MediaRouter.RouteInfo.PRESENTATION_DISPLAY_ID_NONE);
     }
 
     /**
diff --git a/v7/mediarouter/src/android/support/v7/media/MediaRouter.java b/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
index 1b2e9cc..170ee65 100644
--- a/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
+++ b/v7/mediarouter/src/android/support/v7/media/MediaRouter.java
@@ -784,7 +784,7 @@
         private int mVolume;
         private int mVolumeMax;
         private Display mPresentationDisplay;
-        private int mPresentationDisplayId = -1;
+        private int mPresentationDisplayId = PRESENTATION_DISPLAY_ID_NONE;
         private Bundle mExtras;
         private IntentSender mSettingsIntent;
         MediaRouteDescriptor mDescriptor;
@@ -868,6 +868,13 @@
          */
         public static final int PLAYBACK_VOLUME_VARIABLE = 1;
 
+        /**
+         * The default presentation display id indicating no presentation display is associated
+         * with the route.
+         * @hide
+         */
+        public static final int PRESENTATION_DISPLAY_ID_NONE = -1;
+
         static final int CHANGE_GENERAL = 1 << 0;
         static final int CHANGE_VOLUME = 1 << 1;
         static final int CHANGE_PRESENTATION_DISPLAY = 1 << 2;
@@ -1291,6 +1298,14 @@
         }
 
         /**
+         * Gets the route's presentation display id, or -1 if none.
+         * @hide
+         */
+        public int getPresentationDisplayId() {
+            return mPresentationDisplayId;
+        }
+
+        /**
          * Gets a collection of extra properties about this route that were supplied
          * by its media route provider, or null if none.
          */