Search in sources :

Example 6 with WifiDisplay

use of android.hardware.display.WifiDisplay in project platform_frameworks_base by android.

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)

Example 7 with WifiDisplay

use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.

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.endTag(null, "display-manager-state");
    serializer.endDocument();
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay)

Example 8 with WifiDisplay

use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.

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

Example 9 with WifiDisplay

use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.

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

Example 10 with WifiDisplay

use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.

the class MediaRouter method updateWifiDisplayStatus.

static void updateWifiDisplayStatus(WifiDisplayStatus newStatus) {
    final WifiDisplayStatus oldStatus = sStatic.mLastKnownWifiDisplayStatus;
    // TODO Naive implementation. Make this smarter later.
    boolean wantScan = false;
    boolean blockScan = false;
    WifiDisplay[] oldDisplays = oldStatus != null ? oldStatus.getRememberedDisplays() : WifiDisplay.EMPTY_ARRAY;
    WifiDisplay[] newDisplays;
    WifiDisplay[] availableDisplays;
    WifiDisplay activeDisplay;
    if (newStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON) {
        newDisplays = newStatus.getRememberedDisplays();
        availableDisplays = newStatus.getAvailableDisplays();
        activeDisplay = newStatus.getActiveDisplay();
    } else {
        newDisplays = availableDisplays = WifiDisplay.EMPTY_ARRAY;
        activeDisplay = null;
    }
    for (int i = 0; i < newDisplays.length; i++) {
        final WifiDisplay d = newDisplays[i];
        final boolean available = findMatchingDisplay(d, availableDisplays) != null;
        RouteInfo route = findWifiDisplayRoute(d);
        if (route == null) {
            route = makeWifiDisplayRoute(d, available);
            addRouteStatic(route);
            wantScan = true;
        } else {
            updateWifiDisplayRoute(route, d, available, newStatus);
        }
        if (d.equals(activeDisplay)) {
            selectRouteStatic(route.getSupportedTypes(), route);
            // Don't scan if we're already connected to a wifi display,
            // the scanning process can cause a hiccup with some configurations.
            blockScan = true;
        }
    }
    for (int i = 0; i < oldDisplays.length; i++) {
        final WifiDisplay d = oldDisplays[i];
        final WifiDisplay newDisplay = findMatchingDisplay(d, newDisplays);
        if (newDisplay == null) {
            removeRoute(findWifiDisplayRoute(d));
        }
    }
    if (wantScan && !blockScan) {
        sStatic.mDisplayService.scanWifiDisplays();
    }
    sStatic.mLastKnownWifiDisplayStatus = newStatus;
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay) WifiDisplayStatus(android.hardware.display.WifiDisplayStatus)

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