use of android.hardware.display.WifiDisplay in project android_frameworks_base by crdroidandroid.
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 crdroidandroid.
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;
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by crdroidandroid.
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 crdroidandroid.
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 crdroidandroid.
the class WifiDisplayAdapter method requestRenameLocked.
public void requestRenameLocked(String address, String alias) {
if (DEBUG) {
Slog.d(TAG, "requestRenameLocked: address=" + address + ", alias=" + alias);
}
if (alias != null) {
alias = alias.trim();
if (alias.isEmpty() || alias.equals(address)) {
alias = null;
}
}
WifiDisplay display = mPersistentDataStore.getRememberedWifiDisplay(address);
if (display != null && !Objects.equal(display.getDeviceAlias(), alias)) {
display = new WifiDisplay(address, display.getDeviceName(), alias, false, false, false);
if (mPersistentDataStore.rememberWifiDisplay(display)) {
mPersistentDataStore.saveIfNeeded();
updateRememberedDisplaysLocked();
scheduleStatusChangedBroadcastLocked();
}
}
if (mActiveDisplay != null && mActiveDisplay.getDeviceAddress().equals(address)) {
renameDisplayDeviceLocked(mActiveDisplay.getFriendlyDisplayName());
}
}
Aggregations