Search in sources :

Example 51 with WifiDisplay

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

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

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

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

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

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

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

the class PersistentDataStore method dump.

public void dump(PrintWriter pw) {
    pw.println("PersistentDataStore");
    pw.println("  mLoaded=" + mLoaded);
    pw.println("  mDirty=" + mDirty);
    pw.println("  RememberedWifiDisplays:");
    int i = 0;
    for (WifiDisplay display : mRememberedWifiDisplays) {
        pw.println("    " + i++ + ": " + display);
    }
    pw.println("  DisplayStates:");
    i = 0;
    for (Map.Entry<String, DisplayState> entry : mDisplayStates.entrySet()) {
        pw.println("    " + i++ + ": " + entry.getKey());
        entry.getValue().dump(pw, "      ");
    }
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay) HashMap(java.util.HashMap) Map(java.util.Map)

Example 55 with WifiDisplay

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

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