From 80a46198fcef9a346af27e18900a462fae1623ff Mon Sep 17 00:00:00 2001 From: timhypeng Date: Mon, 14 Sep 2020 16:01:45 +0800 Subject: [PATCH] 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 --- packages/SystemUI/AndroidManifest.xml | 7 ++++ .../DefaultBroadcastReceiverBinder.java | 10 +++++ .../media/dialog/MediaOutDialogReceiver.kt | 39 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutDialogReceiver.kt diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 6e74184cef026..0490c7acab8d1 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -781,5 +781,12 @@ + + + + + + diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultBroadcastReceiverBinder.java index 6e8d63b2c5168..307362fe790eb 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 @@ package com.android.systemui.dagger; 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 class DefaultBroadcastReceiverBinder { 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 0000000000000..d60771394dedc --- /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) + } + } +}