use of android.hardware.display.WifiDisplay in project android_frameworks_base by AOSPA.
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());
}
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by AOSPA.
the class WifiDisplayController method advertiseDisplay.
private void advertiseDisplay(final WifiDisplay display, final Surface surface, final int width, final int height, final int flags) {
if (!Objects.equal(mAdvertisedDisplay, display) || mAdvertisedDisplaySurface != surface || mAdvertisedDisplayWidth != width || mAdvertisedDisplayHeight != height || mAdvertisedDisplayFlags != flags) {
final WifiDisplay oldDisplay = mAdvertisedDisplay;
final Surface oldSurface = mAdvertisedDisplaySurface;
mAdvertisedDisplay = display;
mAdvertisedDisplaySurface = surface;
mAdvertisedDisplayWidth = width;
mAdvertisedDisplayHeight = height;
mAdvertisedDisplayFlags = flags;
mHandler.post(new Runnable() {
@Override
public void run() {
if (oldSurface != null && surface != oldSurface) {
mListener.onDisplayDisconnected();
} else if (oldDisplay != null && !oldDisplay.hasSameAddress(display)) {
mListener.onDisplayConnectionFailed();
}
if (display != null) {
if (!display.hasSameAddress(oldDisplay)) {
mListener.onDisplayConnecting(display);
} else if (!display.equals(oldDisplay)) {
// The address is the same but some other property such as the
// name must have changed.
mListener.onDisplayChanged(display);
}
if (surface != null && surface != oldSurface) {
mListener.onDisplayConnected(display, surface, width, height, flags);
}
}
}
});
}
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by AOSPA.
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 AOSPA.
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);
}
use of android.hardware.display.WifiDisplay in project android_frameworks_base by crdroidandroid.
the class MediaRouter method selectRouteStatic.
static void selectRouteStatic(int types, @NonNull RouteInfo route, boolean explicit) {
Log.v(TAG, "Selecting route: " + route);
assert (route != null);
final RouteInfo oldRoute = sStatic.mSelectedRoute;
if (oldRoute == route)
return;
if (!route.matchesTypes(types)) {
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.mDeviceAddress != null;
if (activeDisplay != null || oldRouteHasAddress || newRouteHasAddress) {
if (newRouteHasAddress && !matchesDeviceAddress(activeDisplay, route)) {
if (sStatic.mCanConfigureWifiDisplays) {
sStatic.mDisplayService.connectWifiDisplay(route.mDeviceAddress);
} else {
Log.e(TAG, "Cannot connect to wifi displays because this process " + "is not allowed to do so.");
}
} else if (activeDisplay != null && !newRouteHasAddress) {
sStatic.mDisplayService.disconnectWifiDisplay();
}
}
sStatic.setSelectedRoute(route, explicit);
if (oldRoute != null) {
dispatchRouteUnselected(types & oldRoute.getSupportedTypes(), oldRoute);
if (oldRoute.resolveStatusCode()) {
dispatchRouteChanged(oldRoute);
}
}
if (route != null) {
if (route.resolveStatusCode()) {
dispatchRouteChanged(route);
}
dispatchRouteSelected(types & route.getSupportedTypes(), route);
}
// The behavior of active scans may depend on the currently selected route.
sStatic.updateDiscoveryRequest();
}
Aggregations