use of android.hardware.display.WifiDisplay in project android_frameworks_base by AOSPA.
the class WifiDisplayController method handleScanResults.
private void handleScanResults() {
final int count = mAvailableWifiDisplayPeers.size();
final WifiDisplay[] displays = WifiDisplay.CREATOR.newArray(count);
for (int i = 0; i < count; i++) {
WifiP2pDevice device = mAvailableWifiDisplayPeers.get(i);
displays[i] = createWifiDisplay(device);
updateDesiredDevice(device);
}
mHandler.post(new Runnable() {
@Override
public void run() {
mListener.onScanResults(displays);
}
});
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by AOSPA.
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.startTag(null, "display-states");
for (Map.Entry<String, DisplayState> entry : mDisplayStates.entrySet()) {
final String uniqueId = entry.getKey();
final DisplayState state = entry.getValue();
serializer.startTag(null, "display");
serializer.attribute(null, "unique-id", uniqueId);
state.saveToXml(serializer);
serializer.endTag(null, "display");
}
serializer.endTag(null, "display-states");
serializer.endTag(null, "display-manager-state");
serializer.endDocument();
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by AOSPA.
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;
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by ResurrectionRemix.
the class WifiDisplayAdapter method fixRememberedDisplayNamesFromAvailableDisplaysLocked.
private void fixRememberedDisplayNamesFromAvailableDisplaysLocked() {
// It may happen that a display name has changed since it was remembered.
// Consult the list of available displays and update the name if needed.
// We don't do anything special for the active display here. The display
// controller will send a separate event when it needs to be updates.
boolean changed = false;
for (int i = 0; i < mRememberedDisplays.length; i++) {
WifiDisplay rememberedDisplay = mRememberedDisplays[i];
WifiDisplay availableDisplay = findAvailableDisplayLocked(rememberedDisplay.getDeviceAddress());
if (availableDisplay != null && !rememberedDisplay.equals(availableDisplay)) {
if (DEBUG) {
Slog.d(TAG, "fixRememberedDisplayNamesFromAvailableDisplaysLocked: " + "updating remembered display to " + availableDisplay);
}
mRememberedDisplays[i] = availableDisplay;
changed |= mPersistentDataStore.rememberWifiDisplay(availableDisplay);
}
}
if (changed) {
mPersistentDataStore.saveIfNeeded();
}
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by ResurrectionRemix.
the class WifiDisplayAdapter method updateDisplaysLocked.
private void updateDisplaysLocked() {
List<WifiDisplay> displays = new ArrayList<WifiDisplay>(mAvailableDisplays.length + mRememberedDisplays.length);
boolean[] remembered = new boolean[mAvailableDisplays.length];
for (WifiDisplay d : mRememberedDisplays) {
boolean available = false;
for (int i = 0; i < mAvailableDisplays.length; i++) {
if (d.equals(mAvailableDisplays[i])) {
remembered[i] = available = true;
break;
}
}
if (!available) {
displays.add(new WifiDisplay(d.getDeviceAddress(), d.getDeviceName(), d.getDeviceAlias(), false, false, true));
}
}
for (int i = 0; i < mAvailableDisplays.length; i++) {
WifiDisplay d = mAvailableDisplays[i];
displays.add(new WifiDisplay(d.getDeviceAddress(), d.getDeviceName(), d.getDeviceAlias(), true, d.canConnect(), remembered[i]));
}
mDisplays = displays.toArray(WifiDisplay.EMPTY_ARRAY);
}
Aggregations