Search in sources :

Example 76 with WifiDisplay

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));
        }
    }
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 77 with WifiDisplay

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;
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay)

Aggregations

WifiDisplay (android.hardware.display.WifiDisplay)77 WifiP2pDevice (android.net.wifi.p2p.WifiP2pDevice)12 Surface (android.view.Surface)12 HashMap (java.util.HashMap)10 Map (java.util.Map)10 WpsInfo (android.net.wifi.WpsInfo)6 WifiP2pConfig (android.net.wifi.p2p.WifiP2pConfig)6 ActionListener (android.net.wifi.p2p.WifiP2pManager.ActionListener)6 GroupInfoListener (android.net.wifi.p2p.WifiP2pManager.GroupInfoListener)6 PeerListListener (android.net.wifi.p2p.WifiP2pManager.PeerListListener)6 RemoteException (android.os.RemoteException)6 Inet4Address (java.net.Inet4Address)6 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)6 ArrayList (java.util.ArrayList)5 RemoteDisplay (android.media.RemoteDisplay)3 StackTraceElement (java.lang.StackTraceElement)3 WifiDisplayStatus (android.hardware.display.WifiDisplayStatus)1 MediaRouter (android.media.MediaRouter)1 RouteInfo (android.media.MediaRouter.RouteInfo)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1