Search in sources :

Example 1 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by ParanoidAndroid.

the class WifiDisplayController method handleConnectionFailure.

private void handleConnectionFailure(boolean timeoutOccurred) {
    Slog.i(TAG, "Wifi display connection failed!");
    if (mDesiredDevice != null) {
        if (mConnectionRetriesLeft > 0) {
            final WifiP2pDevice oldDevice = mDesiredDevice;
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (mDesiredDevice == oldDevice && mConnectionRetriesLeft > 0) {
                        mConnectionRetriesLeft -= 1;
                        Slog.i(TAG, "Retrying Wifi display connection.  Retries left: " + mConnectionRetriesLeft);
                        retryConnection();
                    }
                }
            }, timeoutOccurred ? 0 : CONNECT_RETRY_DELAY_MILLIS);
        } else {
            disconnect();
        }
    }
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice)

Example 2 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by ParanoidAndroid.

the class WifiDisplayController method dump.

@Override
public void dump(PrintWriter pw) {
    pw.println("mWifiDisplayOnSetting=" + mWifiDisplayOnSetting);
    pw.println("mWifiP2pEnabled=" + mWifiP2pEnabled);
    pw.println("mWfdEnabled=" + mWfdEnabled);
    pw.println("mWfdEnabling=" + mWfdEnabling);
    pw.println("mNetworkInfo=" + mNetworkInfo);
    pw.println("mDiscoverPeersInProgress=" + mDiscoverPeersInProgress);
    pw.println("mDiscoverPeersRetriesLeft=" + mDiscoverPeersRetriesLeft);
    pw.println("mDesiredDevice=" + describeWifiP2pDevice(mDesiredDevice));
    pw.println("mConnectingDisplay=" + describeWifiP2pDevice(mConnectingDevice));
    pw.println("mDisconnectingDisplay=" + describeWifiP2pDevice(mDisconnectingDevice));
    pw.println("mCancelingDisplay=" + describeWifiP2pDevice(mCancelingDevice));
    pw.println("mConnectedDevice=" + describeWifiP2pDevice(mConnectedDevice));
    pw.println("mConnectionRetriesLeft=" + mConnectionRetriesLeft);
    pw.println("mRemoteDisplay=" + mRemoteDisplay);
    pw.println("mRemoteDisplayInterface=" + mRemoteDisplayInterface);
    pw.println("mRemoteDisplayConnected=" + mRemoteDisplayConnected);
    pw.println("mRemoteSubmixOn=" + mRemoteSubmixOn);
    pw.println("mAdvertisedDisplay=" + mAdvertisedDisplay);
    pw.println("mAdvertisedDisplaySurface=" + mAdvertisedDisplaySurface);
    pw.println("mAdvertisedDisplayWidth=" + mAdvertisedDisplayWidth);
    pw.println("mAdvertisedDisplayHeight=" + mAdvertisedDisplayHeight);
    pw.println("mAdvertisedDisplayFlags=" + mAdvertisedDisplayFlags);
    pw.println("mAvailableWifiDisplayPeers: size=" + mAvailableWifiDisplayPeers.size());
    for (WifiP2pDevice device : mAvailableWifiDisplayPeers) {
        pw.println("  " + describeWifiP2pDevice(device));
    }
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice)

Example 3 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by ParanoidAndroid.

the class WifiDisplayController method retryConnection.

private void retryConnection() {
    // Cheap hack.  Make a new instance of the device object so that we
    // can distinguish it from the previous connection attempt.
    // This will cause us to tear everything down before we try again.
    mDesiredDevice = new WifiP2pDevice(mDesiredDevice);
    updateConnection();
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice)

Example 4 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by ParanoidAndroid.

the class WifiP2pServiceResponse method newInstance.

/**
     * Create the list of  WifiP2pServiceResponse instance from supplicant event.
     *
     * <pre>The format is as follows.
     * P2P-SERV-DISC-RESP &lt;address&gt; &lt;update indicator&gt; &lt;response data&gt;
     * e.g) P2P-SERV-DISC-RESP 02:03:7f:11:62:da 1 0300000101
     *
     * @param supplicantEvent wpa_supplicant event string.
     * @return if parse failed, return null
     * @hide
     */
public static List<WifiP2pServiceResponse> newInstance(String supplicantEvent) {
    List<WifiP2pServiceResponse> respList = new ArrayList<WifiP2pServiceResponse>();
    String[] args = supplicantEvent.split(" ");
    if (args.length != 4) {
        return null;
    }
    WifiP2pDevice dev = new WifiP2pDevice();
    String srcAddr = args[1];
    dev.deviceAddress = srcAddr;
    //String updateIndicator = args[2];//not used.
    byte[] bin = hexStr2Bin(args[3]);
    if (bin == null) {
        return null;
    }
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bin));
    try {
        while (dis.available() > 0) {
            /*
                 * Service discovery header is as follows.
                 * ______________________________________________________________
                 * |           Length(2byte)     | Type(1byte) | TransId(1byte)}|
                 * ______________________________________________________________
                 * | status(1byte)  |            vendor specific(variable)      |
                 */
            // The length equals to 3 plus the number of octets in the vendor
            // specific content field. And this is little endian.
            int length = (dis.readUnsignedByte() + (dis.readUnsignedByte() << 8)) - 3;
            int type = dis.readUnsignedByte();
            int transId = dis.readUnsignedByte();
            int status = dis.readUnsignedByte();
            if (length < 0) {
                return null;
            }
            if (length == 0) {
                if (status == Status.SUCCESS) {
                    respList.add(new WifiP2pServiceResponse(type, status, transId, dev, null));
                }
                continue;
            }
            if (length > MAX_BUF_SIZE) {
                dis.skip(length);
                continue;
            }
            byte[] data = new byte[length];
            dis.readFully(data);
            WifiP2pServiceResponse resp;
            if (type == WifiP2pServiceInfo.SERVICE_TYPE_BONJOUR) {
                resp = WifiP2pDnsSdServiceResponse.newInstance(status, transId, dev, data);
            } else if (type == WifiP2pServiceInfo.SERVICE_TYPE_UPNP) {
                resp = WifiP2pUpnpServiceResponse.newInstance(status, transId, dev, data);
            } else {
                resp = new WifiP2pServiceResponse(type, status, transId, dev, data);
            }
            if (resp != null && resp.getStatus() == Status.SUCCESS) {
                respList.add(resp);
            }
        }
        return respList;
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (respList.size() > 0) {
        return respList;
    }
    return null;
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice) ByteArrayInputStream(java.io.ByteArrayInputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 5 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project android_frameworks_base by ParanoidAndroid.

the class WifiP2pDeviceList method isGroupOwner.

/** @hide */
public boolean isGroupOwner(String deviceAddress) {
    validateDeviceAddress(deviceAddress);
    WifiP2pDevice device = mDevices.get(deviceAddress);
    if (device == null) {
        throw new IllegalArgumentException("Device not found " + deviceAddress);
    }
    return device.isGroupOwner();
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice)

Aggregations

WifiP2pDevice (android.net.wifi.p2p.WifiP2pDevice)95 Test (org.junit.Test)14 WifiDisplay (android.hardware.display.WifiDisplay)12 Activity (android.app.Activity)7 DialogInterface (android.content.DialogInterface)7 OnClickListener (android.content.DialogInterface.OnClickListener)7 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 Surface (android.view.Surface)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DataInputStream (java.io.DataInputStream)6 IOException (java.io.IOException)6 Inet4Address (java.net.Inet4Address)6 ArrayList (java.util.ArrayList)6 RemoteDisplay (android.media.RemoteDisplay)3 StackTraceElement (java.lang.StackTraceElement)3 ListView (android.widget.ListView)1