use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.
the class MediaRouter method updateWifiDisplayStatus.
static void updateWifiDisplayStatus(WifiDisplayStatus newStatus) {
final WifiDisplayStatus oldStatus = sStatic.mLastKnownWifiDisplayStatus;
// TODO Naive implementation. Make this smarter later.
boolean wantScan = false;
boolean blockScan = false;
WifiDisplay[] oldDisplays = oldStatus != null ? oldStatus.getRememberedDisplays() : WifiDisplay.EMPTY_ARRAY;
WifiDisplay[] newDisplays;
WifiDisplay[] availableDisplays;
WifiDisplay activeDisplay;
if (newStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON) {
newDisplays = newStatus.getRememberedDisplays();
availableDisplays = newStatus.getAvailableDisplays();
activeDisplay = newStatus.getActiveDisplay();
} else {
newDisplays = availableDisplays = WifiDisplay.EMPTY_ARRAY;
activeDisplay = null;
}
for (int i = 0; i < newDisplays.length; i++) {
final WifiDisplay d = newDisplays[i];
final boolean available = findMatchingDisplay(d, availableDisplays) != null;
RouteInfo route = findWifiDisplayRoute(d);
if (route == null) {
route = makeWifiDisplayRoute(d, available);
addRouteStatic(route);
wantScan = true;
} else {
updateWifiDisplayRoute(route, d, available, newStatus);
}
if (d.equals(activeDisplay)) {
selectRouteStatic(route.getSupportedTypes(), route);
// Don't scan if we're already connected to a wifi display,
// the scanning process can cause a hiccup with some configurations.
blockScan = true;
}
}
for (int i = 0; i < oldDisplays.length; i++) {
final WifiDisplay d = oldDisplays[i];
final WifiDisplay newDisplay = findMatchingDisplay(d, newDisplays);
if (newDisplay == null) {
removeRoute(findWifiDisplayRoute(d));
}
}
if (wantScan && !blockScan) {
sStatic.mDisplayService.scanWifiDisplays();
}
sStatic.mLastKnownWifiDisplayStatus = newStatus;
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.
the class MediaRouter method selectRouteStatic.
static void selectRouteStatic(int types, RouteInfo route) {
final RouteInfo oldRoute = sStatic.mSelectedRoute;
if (oldRoute == route)
return;
if ((route.getSupportedTypes() & types) == 0) {
Log.w(TAG, "selectRoute ignored; cannot select route with supported types " + typesToString(route.getSupportedTypes()) + " into route types " + typesToString(types));
return;
}
final RouteInfo btRoute = sStatic.mBluetoothA2dpRoute;
if (btRoute != null && (types & ROUTE_TYPE_LIVE_AUDIO) != 0 && (route == btRoute || route == sStatic.mDefaultAudioVideo)) {
try {
sStatic.mAudioService.setBluetoothA2dpOn(route == btRoute);
} catch (RemoteException e) {
Log.e(TAG, "Error changing Bluetooth A2DP state", e);
}
}
final WifiDisplay activeDisplay = sStatic.mDisplayService.getWifiDisplayStatus().getActiveDisplay();
final boolean oldRouteHasAddress = oldRoute != null && oldRoute.mDeviceAddress != null;
final boolean newRouteHasAddress = route != null && route.mDeviceAddress != null;
if (activeDisplay != null || oldRouteHasAddress || newRouteHasAddress) {
if (newRouteHasAddress && !matchesDeviceAddress(activeDisplay, route)) {
sStatic.mDisplayService.connectWifiDisplay(route.mDeviceAddress);
} else if (activeDisplay != null && !newRouteHasAddress) {
sStatic.mDisplayService.disconnectWifiDisplay();
}
}
if (oldRoute != null) {
dispatchRouteUnselected(types & oldRoute.getSupportedTypes(), oldRoute);
}
sStatic.mSelectedRoute = route;
if (route != null) {
dispatchRouteSelected(types & route.getSupportedTypes(), route);
}
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.
the class PersistentDataStore method saveToXml.
private void saveToXml(XmlSerializer serializer) throws IOException {
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, "display-manager-state");
serializer.startTag(null, "remembered-wifi-displays");
for (WifiDisplay display : mRememberedWifiDisplays) {
serializer.startTag(null, "wifi-display");
serializer.attribute(null, "deviceAddress", display.getDeviceAddress());
serializer.attribute(null, "deviceName", display.getDeviceName());
if (display.getDeviceAlias() != null) {
serializer.attribute(null, "deviceAlias", display.getDeviceAlias());
}
serializer.endTag(null, "wifi-display");
}
serializer.endTag(null, "remembered-wifi-displays");
serializer.endTag(null, "display-manager-state");
serializer.endDocument();
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.
the class PersistentDataStore method applyWifiDisplayAliases.
public WifiDisplay[] applyWifiDisplayAliases(WifiDisplay[] displays) {
WifiDisplay[] results = displays;
if (results != null) {
int count = displays.length;
for (int i = 0; i < count; i++) {
WifiDisplay result = applyWifiDisplayAlias(displays[i]);
if (result != displays[i]) {
if (results == displays) {
results = new WifiDisplay[count];
System.arraycopy(displays, 0, results, 0, count);
}
results[i] = result;
}
}
}
return results;
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.
the class PersistentDataStore method rememberWifiDisplay.
public boolean rememberWifiDisplay(WifiDisplay display) {
loadIfNeeded();
int index = findRememberedWifiDisplay(display.getDeviceAddress());
if (index >= 0) {
WifiDisplay other = mRememberedWifiDisplays.get(index);
if (other.equals(display)) {
// already remembered without change
return false;
}
mRememberedWifiDisplays.set(index, display);
} else {
mRememberedWifiDisplays.add(display);
}
setDirty();
return true;
}
Aggregations