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();
}
}
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);
}
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);
}
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();
}
}
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);
}
Aggregations