Search in sources :

Example 6 with ActionListener

use of android.net.wifi.p2p.WifiP2pManager.ActionListener in project android_frameworks_base by ResurrectionRemix.

the class WifiDisplayController method updateWfdEnableState.

private void updateWfdEnableState() {
    if (mWifiDisplayOnSetting && mWifiP2pEnabled) {
        // WFD should be enabled.
        if (!mWfdEnabled && !mWfdEnabling) {
            mWfdEnabling = true;
            WifiP2pWfdInfo wfdInfo = new WifiP2pWfdInfo();
            wfdInfo.setWfdEnabled(true);
            wfdInfo.setDeviceType(WifiP2pWfdInfo.WFD_SOURCE);
            wfdInfo.setSessionAvailable(true);
            wfdInfo.setControlPort(DEFAULT_CONTROL_PORT);
            wfdInfo.setMaxThroughput(MAX_THROUGHPUT);
            mWifiP2pManager.setWFDInfo(mWifiP2pChannel, wfdInfo, new ActionListener() {

                @Override
                public void onSuccess() {
                    if (DEBUG) {
                        Slog.d(TAG, "Successfully set WFD info.");
                    }
                    if (mWfdEnabling) {
                        mWfdEnabling = false;
                        mWfdEnabled = true;
                        reportFeatureState();
                        updateScanState();
                    }
                }

                @Override
                public void onFailure(int reason) {
                    if (DEBUG) {
                        Slog.d(TAG, "Failed to set WFD info with reason " + reason + ".");
                    }
                    mWfdEnabling = false;
                }
            });
        }
    } else {
        // WFD should be disabled.
        if (mWfdEnabled || mWfdEnabling) {
            WifiP2pWfdInfo wfdInfo = new WifiP2pWfdInfo();
            wfdInfo.setWfdEnabled(false);
            mWifiP2pManager.setWFDInfo(mWifiP2pChannel, wfdInfo, new ActionListener() {

                @Override
                public void onSuccess() {
                    if (DEBUG) {
                        Slog.d(TAG, "Successfully set WFD info.");
                    }
                }

                @Override
                public void onFailure(int reason) {
                    if (DEBUG) {
                        Slog.d(TAG, "Failed to set WFD info with reason " + reason + ".");
                    }
                }
            });
        }
        mWfdEnabling = false;
        mWfdEnabled = false;
        reportFeatureState();
        updateScanState();
        disconnect();
    }
}
Also used : ActionListener(android.net.wifi.p2p.WifiP2pManager.ActionListener) WifiP2pWfdInfo(android.net.wifi.p2p.WifiP2pWfdInfo)

Example 7 with ActionListener

use of android.net.wifi.p2p.WifiP2pManager.ActionListener in project android_frameworks_base by ResurrectionRemix.

the class WifiDisplayController method tryDiscoverPeers.

private void tryDiscoverPeers() {
    mWifiP2pManager.discoverPeers(mWifiP2pChannel, new ActionListener() {

        @Override
        public void onSuccess() {
            if (DEBUG) {
                Slog.d(TAG, "Discover peers succeeded.  Requesting peers now.");
            }
            if (mDiscoverPeersInProgress) {
                requestPeers();
            }
        }

        @Override
        public void onFailure(int reason) {
            if (DEBUG) {
                Slog.d(TAG, "Discover peers failed with reason " + reason + ".");
            }
        // Ignore the error.
        // We will retry automatically in a little bit.
        }
    });
    // Retry discover peers periodically until stopped.
    mHandler.postDelayed(mDiscoverPeers, DISCOVER_PEERS_INTERVAL_MILLIS);
}
Also used : ActionListener(android.net.wifi.p2p.WifiP2pManager.ActionListener)

Example 8 with ActionListener

use of android.net.wifi.p2p.WifiP2pManager.ActionListener in project android_frameworks_base by DirtyUnicorns.

the class WifiDisplayController method tryDiscoverPeers.

private void tryDiscoverPeers() {
    mWifiP2pManager.discoverPeers(mWifiP2pChannel, new ActionListener() {

        @Override
        public void onSuccess() {
            if (DEBUG) {
                Slog.d(TAG, "Discover peers succeeded.  Requesting peers now.");
            }
            if (mDiscoverPeersInProgress) {
                requestPeers();
            }
        }

        @Override
        public void onFailure(int reason) {
            if (DEBUG) {
                Slog.d(TAG, "Discover peers failed with reason " + reason + ".");
            }
        // Ignore the error.
        // We will retry automatically in a little bit.
        }
    });
    // Retry discover peers periodically until stopped.
    mHandler.postDelayed(mDiscoverPeers, DISCOVER_PEERS_INTERVAL_MILLIS);
}
Also used : ActionListener(android.net.wifi.p2p.WifiP2pManager.ActionListener)

Example 9 with ActionListener

use of android.net.wifi.p2p.WifiP2pManager.ActionListener in project android_frameworks_base by AOSPA.

the class WifiDisplayController method updateWfdEnableState.

private void updateWfdEnableState() {
    if (mWifiDisplayOnSetting && mWifiP2pEnabled) {
        // WFD should be enabled.
        if (!mWfdEnabled && !mWfdEnabling) {
            mWfdEnabling = true;
            WifiP2pWfdInfo wfdInfo = new WifiP2pWfdInfo();
            wfdInfo.setWfdEnabled(true);
            wfdInfo.setDeviceType(WifiP2pWfdInfo.WFD_SOURCE);
            wfdInfo.setSessionAvailable(true);
            wfdInfo.setControlPort(DEFAULT_CONTROL_PORT);
            wfdInfo.setMaxThroughput(MAX_THROUGHPUT);
            mWifiP2pManager.setWFDInfo(mWifiP2pChannel, wfdInfo, new ActionListener() {

                @Override
                public void onSuccess() {
                    if (DEBUG) {
                        Slog.d(TAG, "Successfully set WFD info.");
                    }
                    if (mWfdEnabling) {
                        mWfdEnabling = false;
                        mWfdEnabled = true;
                        reportFeatureState();
                        updateScanState();
                    }
                }

                @Override
                public void onFailure(int reason) {
                    if (DEBUG) {
                        Slog.d(TAG, "Failed to set WFD info with reason " + reason + ".");
                    }
                    mWfdEnabling = false;
                }
            });
        }
    } else {
        // WFD should be disabled.
        if (mWfdEnabled || mWfdEnabling) {
            WifiP2pWfdInfo wfdInfo = new WifiP2pWfdInfo();
            wfdInfo.setWfdEnabled(false);
            mWifiP2pManager.setWFDInfo(mWifiP2pChannel, wfdInfo, new ActionListener() {

                @Override
                public void onSuccess() {
                    if (DEBUG) {
                        Slog.d(TAG, "Successfully set WFD info.");
                    }
                }

                @Override
                public void onFailure(int reason) {
                    if (DEBUG) {
                        Slog.d(TAG, "Failed to set WFD info with reason " + reason + ".");
                    }
                }
            });
        }
        mWfdEnabling = false;
        mWfdEnabled = false;
        reportFeatureState();
        updateScanState();
        disconnect();
    }
}
Also used : ActionListener(android.net.wifi.p2p.WifiP2pManager.ActionListener) WifiP2pWfdInfo(android.net.wifi.p2p.WifiP2pWfdInfo)

Example 10 with ActionListener

use of android.net.wifi.p2p.WifiP2pManager.ActionListener in project android_frameworks_base by crdroidandroid.

the class WifiDisplayController method tryDiscoverPeers.

private void tryDiscoverPeers() {
    mWifiP2pManager.discoverPeers(mWifiP2pChannel, new ActionListener() {

        @Override
        public void onSuccess() {
            if (DEBUG) {
                Slog.d(TAG, "Discover peers succeeded.  Requesting peers now.");
            }
            if (mDiscoverPeersInProgress) {
                requestPeers();
            }
        }

        @Override
        public void onFailure(int reason) {
            if (DEBUG) {
                Slog.d(TAG, "Discover peers failed with reason " + reason + ".");
            }
        // Ignore the error.
        // We will retry automatically in a little bit.
        }
    });
    // Retry discover peers periodically until stopped.
    mHandler.postDelayed(mDiscoverPeers, DISCOVER_PEERS_INTERVAL_MILLIS);
}
Also used : ActionListener(android.net.wifi.p2p.WifiP2pManager.ActionListener)

Aggregations

ActionListener (android.net.wifi.p2p.WifiP2pManager.ActionListener)20 WifiP2pConfig (android.net.wifi.p2p.WifiP2pConfig)7 WifiDisplay (android.hardware.display.WifiDisplay)6 WpsInfo (android.net.wifi.WpsInfo)6 WifiP2pDevice (android.net.wifi.p2p.WifiP2pDevice)6 GroupInfoListener (android.net.wifi.p2p.WifiP2pManager.GroupInfoListener)6 PeerListListener (android.net.wifi.p2p.WifiP2pManager.PeerListListener)6 WifiP2pWfdInfo (android.net.wifi.p2p.WifiP2pWfdInfo)6 Surface (android.view.Surface)6 Inet4Address (java.net.Inet4Address)6 RemoteDisplay (android.media.RemoteDisplay)3 StackTraceElement (java.lang.StackTraceElement)3 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 OnCancelListener (android.content.DialogInterface.OnCancelListener)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 WifiP2pGroup (android.net.wifi.p2p.WifiP2pGroup)1 WifiP2pInfo (android.net.wifi.p2p.WifiP2pInfo)1 WifiP2pManager (android.net.wifi.p2p.WifiP2pManager)1