use of android.hardware.display.WifiDisplay in project android_frameworks_base by crdroidandroid.
the class PersistentDataStore method loadRememberedWifiDisplaysFromXml.
private void loadRememberedWifiDisplaysFromXml(XmlPullParser parser) throws IOException, XmlPullParserException {
final int outerDepth = parser.getDepth();
while (XmlUtils.nextElementWithin(parser, outerDepth)) {
if (parser.getName().equals("wifi-display")) {
String deviceAddress = parser.getAttributeValue(null, "deviceAddress");
String deviceName = parser.getAttributeValue(null, "deviceName");
String deviceAlias = parser.getAttributeValue(null, "deviceAlias");
if (deviceAddress == null || deviceName == null) {
throw new XmlPullParserException("Missing deviceAddress or deviceName attribute on wifi-display.");
}
if (findRememberedWifiDisplay(deviceAddress) >= 0) {
throw new XmlPullParserException("Found duplicate wifi display device address.");
}
mRememberedWifiDisplays.add(new WifiDisplay(deviceAddress, deviceName, deviceAlias, false, false, false));
}
}
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by crdroidandroid.
the class MediaRouter method updateWifiDisplayStatus.
static void updateWifiDisplayStatus(WifiDisplayStatus status) {
WifiDisplay[] displays;
WifiDisplay activeDisplay;
if (status.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON) {
displays = status.getDisplays();
activeDisplay = status.getActiveDisplay();
// Filter the list down to just the active display.
if (!sStatic.mCanConfigureWifiDisplays) {
if (activeDisplay != null) {
displays = new WifiDisplay[] { activeDisplay };
} else {
displays = WifiDisplay.EMPTY_ARRAY;
}
}
} else {
displays = WifiDisplay.EMPTY_ARRAY;
activeDisplay = null;
}
String activeDisplayAddress = activeDisplay != null ? activeDisplay.getDeviceAddress() : null;
// Add or update routes.
for (int i = 0; i < displays.length; i++) {
final WifiDisplay d = displays[i];
if (shouldShowWifiDisplay(d, activeDisplay)) {
RouteInfo route = findWifiDisplayRoute(d);
if (route == null) {
route = makeWifiDisplayRoute(d, status);
addRouteStatic(route);
} else {
String address = d.getDeviceAddress();
boolean disconnected = !address.equals(activeDisplayAddress) && address.equals(sStatic.mPreviousActiveWifiDisplayAddress);
updateWifiDisplayRoute(route, d, status, disconnected);
}
if (d.equals(activeDisplay)) {
selectRouteStatic(route.getSupportedTypes(), route, false);
}
}
}
// Remove stale routes.
for (int i = sStatic.mRoutes.size(); i-- > 0; ) {
RouteInfo route = sStatic.mRoutes.get(i);
if (route.mDeviceAddress != null) {
WifiDisplay d = findWifiDisplay(displays, route.mDeviceAddress);
if (d == null || !shouldShowWifiDisplay(d, activeDisplay)) {
removeRouteStatic(route);
}
}
}
// Remember the current active wifi display address so that we can infer disconnections.
// TODO: This hack will go away once all of this is moved into the media router service.
sStatic.mPreviousActiveWifiDisplayAddress = activeDisplayAddress;
}
Aggregations