Search in sources :

Example 1 with WifiDisplayStatus

use of android.hardware.display.WifiDisplayStatus 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)

Example 2 with WifiDisplayStatus

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

the class WiFiDisplayTile method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    WifiDisplayStatus status = (WifiDisplayStatus) intent.getParcelableExtra(DisplayManager.EXTRA_WIFI_DISPLAY_STATUS);
    enabled = status.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON;
    connected = status.getActiveDisplay() != null;
    updateResources();
}
Also used : WifiDisplayStatus(android.hardware.display.WifiDisplayStatus)

Aggregations

WifiDisplayStatus (android.hardware.display.WifiDisplayStatus)2 WifiDisplay (android.hardware.display.WifiDisplay)1