Add a receiver to launch Output Switcher dialog

-The receiver launches dialog with TYPE_APPLICATION_OVERLAY window
type
-Add receiver in manifest
-Add bindMediaOutDialogReceiver() for Dagger

Bug: 155822415
Test: build pass

Merged-In: Icb5a1f241e644307491030ed721939c18269ff86
Change-Id: Icb5a1f241e644307491030ed721939c18269ff86
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 6e74184..0490c7a 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -781,5 +781,12 @@
             </intent-filter>
         </receiver>
 
+        <receiver android:name=".media.dialog.MediaOutDialogReceiver"
+                  android:exported="true">
+            <intent-filter>
+                <action android:name="com.android.systemui.action.LAUNCH_MEDIA_OUTPUT_DIALOG" />
+            </intent-filter>
+        </receiver>
+
     </application>
 </manifest>
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java
index 6e8d63b..307362f 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java
@@ -18,6 +18,7 @@
 
 import android.content.BroadcastReceiver;
 
+import com.android.systemui.media.dialog.MediaOutDialogReceiver;
 import com.android.systemui.screenshot.ActionProxyReceiver;
 import com.android.systemui.screenshot.DeleteScreenshotReceiver;
 import com.android.systemui.screenshot.SmartActionsReceiver;
@@ -59,4 +60,13 @@
     public abstract BroadcastReceiver bindSmartActionsReceiver(
             SmartActionsReceiver broadcastReceiver);
 
+    /**
+     *
+     */
+    @Binds
+    @IntoMap
+    @ClassKey(MediaOutDialogReceiver.class)
+    public abstract BroadcastReceiver bindMediaOutDialogReceiver(
+            MediaOutDialogReceiver broadcastReceiver);
+
 }
diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutDialogReceiver.kt b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutDialogReceiver.kt
new file mode 100644
index 0000000..d607713
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutDialogReceiver.kt
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.android.systemui.media.dialog
+
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import android.text.TextUtils
+import com.android.settingslib.media.MediaOutputSliceConstants
+import javax.inject.Inject
+
+/**
+ * BroadcastReceiver for handling media output intent
+ */
+class MediaOutDialogReceiver @Inject constructor(
+    private var mediaOutputDialogFactory: MediaOutputDialogFactory
+) : BroadcastReceiver() {
+    override fun onReceive(context: Context, intent: Intent) {
+        if (TextUtils.equals(MediaOutputSliceConstants.ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG,
+                        intent.action)) {
+            mediaOutputDialogFactory.create(
+                    intent.getStringExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME), false)
+        }
+    }
+}