summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Narayan Kamath <narayan@google.com> 2019-03-01 14:37:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-03-01 14:37:00 +0000
commita83d26df5b84ade6b56fe38ace4a2510e99c0443 (patch)
tree47146c2b4e1c255aa3ba6a55a02523d4d14dd5b2
parent36437d7dae834b502968b77310108c900b3900ec (diff)
parentf60a6271ef86ae952c6573fa78b1d86ccb713588 (diff)
Merge "CastTile: stop active projection (if any) on tile clicks"
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
index 51d05c718322..0b1e9c399410 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java
@@ -21,6 +21,7 @@ import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
+import android.media.projection.MediaProjectionInfo;
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.util.Log;
@@ -125,7 +126,30 @@ public class CastTile extends QSTileImpl<BooleanState> {
});
return;
}
- showDetail(true);
+
+ CastDevice activeProjection = getActiveDeviceMediaProjection();
+ if (activeProjection == null) {
+ showDetail(true);
+ } else {
+ mController.stopCasting(activeProjection);
+ }
+ }
+
+ private CastDevice getActiveDeviceMediaProjection() {
+ CastDevice activeDevice = null;
+ for (CastDevice device : mController.getCastDevices()) {
+ if (device.state == CastDevice.STATE_CONNECTED
+ || device.state == CastDevice.STATE_CONNECTING) {
+ activeDevice = device;
+ break;
+ }
+ }
+
+ if (activeDevice != null && activeDevice.tag instanceof MediaProjectionInfo) {
+ return activeDevice;
+ }
+
+ return null;
}
@Override