Search in sources :

Example 66 with WifiDisplay

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

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

Example 67 with WifiDisplay

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

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

Example 68 with WifiDisplay

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

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 69 with WifiDisplay

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

the class WifiDisplayAdapter method fixRememberedDisplayNamesFromAvailableDisplaysLocked.

private void fixRememberedDisplayNamesFromAvailableDisplaysLocked() {
    // It may happen that a display name has changed since it was remembered.
    // Consult the list of available displays and update the name if needed.
    // We don't do anything special for the active display here.  The display
    // controller will send a separate event when it needs to be updates.
    boolean changed = false;
    for (int i = 0; i < mRememberedDisplays.length; i++) {
        WifiDisplay rememberedDisplay = mRememberedDisplays[i];
        WifiDisplay availableDisplay = findAvailableDisplayLocked(rememberedDisplay.getDeviceAddress());
        if (availableDisplay != null && !rememberedDisplay.equals(availableDisplay)) {
            if (DEBUG) {
                Slog.d(TAG, "fixRememberedDisplayNamesFromAvailableDisplaysLocked: " + "updating remembered display to " + availableDisplay);
            }
            mRememberedDisplays[i] = availableDisplay;
            changed |= mPersistentDataStore.rememberWifiDisplay(availableDisplay);
        }
    }
    if (changed) {
        mPersistentDataStore.saveIfNeeded();
    }
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay)

Example 70 with WifiDisplay

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

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);
}
Also used : ArrayList(java.util.ArrayList) 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