Search in sources :

Example 91 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project nfcspy by sinpolib.

the class ActivityManageP2P method handleBroadcast.

void handleBroadcast(Intent intent) {
    closeProgressDialog();
    final String action = intent.getAction();
    if (WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
        int state = intent.getIntExtra(EXTRA_WIFI_STATE, -1);
        if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
            p2p.isWifiP2pEnabled = true;
        } else {
            showMessage(R.string.event_p2p_disable);
            resetData();
        }
    } else if (WIFI_P2P_PEERS_CHANGED_ACTION.equals(action)) {
        new Wifip2pRequestPeers(eventHelper).execute(p2p);
    } else if (WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
        WifiP2pDevice me = (WifiP2pDevice) intent.getParcelableExtra(EXTRA_WIFI_P2P_DEVICE);
        thisDevice.setText(getWifiP2pDeviceInfo(me));
    }
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice)

Example 92 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project android_packages_apps_Settings by SudaMod.

the class WifiP2pSettings method handlePeersChanged.

private void handlePeersChanged() {
    mPeerCategoryController.removeAllChildren();
    mConnectedDevices = 0;
    if (DBG)
        Log.d(TAG, "List of available peers");
    for (WifiP2pDevice peer : mPeers.getDeviceList()) {
        if (DBG)
            Log.d(TAG, "-> " + peer);
        mPeerCategoryController.addChild(new WifiP2pPeer(getPrefContext(), peer));
        if (peer.status == WifiP2pDevice.CONNECTED)
            mConnectedDevices++;
    }
    if (DBG)
        Log.d(TAG, " mConnectedDevices " + mConnectedDevices);
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice)

Example 93 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project platform_packages_apps_Settings by BlissRoms.

the class P2pThisDevicePreferenceControllerTest method updateDeviceName_hasName_shouldUseName.

@Test
public void updateDeviceName_hasName_shouldUseName() {
    WifiP2pDevice device = new WifiP2pDevice();
    device.deviceAddress = "address";
    device.deviceName = "name";
    mController.displayPreference(mPreferenceScreen);
    mController.updateDeviceName(device);
    assertThat(mPreference.getTitle()).isEqualTo(device.deviceName);
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice) Test(org.junit.Test)

Example 94 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project platform_packages_apps_Settings by BlissRoms.

the class P2pThisDevicePreferenceControllerTest method updateDeviceName_emptyName_shouldUseIpAddress.

@Test
public void updateDeviceName_emptyName_shouldUseIpAddress() {
    WifiP2pDevice device = new WifiP2pDevice();
    device.deviceAddress = "address";
    mController.displayPreference(mPreferenceScreen);
    mController.updateDeviceName(device);
    assertThat(mPreference.getTitle()).isEqualTo(device.deviceAddress);
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice) Test(org.junit.Test)

Example 95 with WifiP2pDevice

use of android.net.wifi.p2p.WifiP2pDevice in project platform_packages_apps_Settings by BlissRoms.

the class WifiP2pSettings method handlePeersChanged.

private void handlePeersChanged() {
    mPeerCategoryController.removeAllChildren();
    mConnectedDevices = 0;
    if (DBG)
        Log.d(TAG, "List of available peers");
    for (WifiP2pDevice peer : mPeers.getDeviceList()) {
        if (DBG)
            Log.d(TAG, "-> " + peer);
        mPeerCategoryController.addChild(new WifiP2pPeer(getPrefContext(), peer));
        if (peer.status == WifiP2pDevice.CONNECTED)
            mConnectedDevices++;
    }
    if (DBG)
        Log.d(TAG, " mConnectedDevices " + mConnectedDevices);
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice)

Aggregations

WifiP2pDevice (android.net.wifi.p2p.WifiP2pDevice)101 Test (org.junit.Test)18 WifiDisplay (android.hardware.display.WifiDisplay)12 ArrayList (java.util.ArrayList)8 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 RemoteDisplay (android.media.RemoteDisplay)3 StackTraceElement (java.lang.StackTraceElement)3 WifiP2pDeviceList (android.net.wifi.p2p.WifiP2pDeviceList)2