Don't do a wifi p2p scan in MediaRouter if we're already connected
When we're connected to a wifi display already, some configurations might hiccup or otherwise disrupt the media stream if we initiate a new scan. Block the MediaRouter's default scanning behavior if we start up while already connected to a wifi display. (A scan will still occur if the user opens the picker dialog.) Change-Id: I413efa883eec41fe0377da18bcb55bc72e2ac729
This commit is contained in:
@@ -693,7 +693,8 @@ public class MediaRouter {
|
||||
final WifiDisplayStatus oldStatus = sStatic.mLastKnownWifiDisplayStatus;
|
||||
|
||||
// TODO Naive implementation. Make this smarter later.
|
||||
boolean needScan = false;
|
||||
boolean wantScan = false;
|
||||
boolean blockScan = false;
|
||||
WifiDisplay[] oldDisplays = oldStatus != null ?
|
||||
oldStatus.getRememberedDisplays() : new WifiDisplay[0];
|
||||
WifiDisplay[] newDisplays = newStatus.getRememberedDisplays();
|
||||
@@ -706,7 +707,7 @@ public class MediaRouter {
|
||||
if (oldRemembered == null) {
|
||||
addRouteStatic(makeWifiDisplayRoute(d,
|
||||
findMatchingDisplay(d, availableDisplays) != null));
|
||||
needScan = true;
|
||||
wantScan = true;
|
||||
} else {
|
||||
final boolean available = findMatchingDisplay(d, availableDisplays) != null;
|
||||
final RouteInfo route = findWifiDisplayRoute(d);
|
||||
@@ -716,6 +717,10 @@ public class MediaRouter {
|
||||
final RouteInfo activeRoute = findWifiDisplayRoute(d);
|
||||
if (activeRoute != null) {
|
||||
selectRouteStatic(activeRoute.getSupportedTypes(), activeRoute);
|
||||
|
||||
// Don't scan if we're already connected to a wifi display,
|
||||
// the scanning process can cause a hiccup with some configurations.
|
||||
blockScan = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -727,7 +732,7 @@ public class MediaRouter {
|
||||
}
|
||||
}
|
||||
|
||||
if (needScan) {
|
||||
if (wantScan && !blockScan) {
|
||||
sStatic.mDisplayService.scanWifiDisplays();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user