FileDocCategorySizeDatePackage
WifiP2pManager.javaAPI DocAndroid 5.1 API60804Thu Mar 12 22:22:44 GMT 2015android.net.wifi.p2p

WifiP2pManager

public class WifiP2pManager extends Object
This class provides the API for managing Wi-Fi peer-to-peer connectivity. This lets an application discover available peers, setup connection to peers and query for the list of peers. When a p2p connection is formed over wifi, the device continues to maintain the uplink connection over mobile or any other available network for internet connectivity on the device.

The API is asynchronous and responses to requests from an application are on listener callbacks provided by the application. The application needs to do an initialization with {@link #initialize} before doing any p2p operation.

Most application calls need a {@link ActionListener} instance for receiving callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}. Action callbacks indicate whether the initiation of the action was a success or a failure. Upon failure, the reason of failure can be one of {@link #ERROR}, {@link #P2P_UNSUPPORTED} or {@link #BUSY}.

An application can initiate discovery of peers with {@link #discoverPeers}. An initiated discovery request from an application stays active until the device starts connecting to a peer ,forms a p2p group or there is an explicit {@link #stopPeerDiscovery}. Applications can listen to {@link #WIFI_P2P_DISCOVERY_CHANGED_ACTION} to know if a peer-to-peer discovery is running or stopped. Additionally, {@link #WIFI_P2P_PEERS_CHANGED_ACTION} indicates if the peer list has changed.

When an application needs to fetch the current list of peers, it can request the list of peers with {@link #requestPeers}. When the peer list is available {@link PeerListListener#onPeersAvailable} is called with the device list.

An application can initiate a connection request to a peer through {@link #connect}. See {@link WifiP2pConfig} for details on setting up the configuration. For communication with legacy Wi-Fi devices that do not support p2p, an app can create a group using {@link #createGroup} which creates an access point whose details can be fetched with {@link #requestGroupInfo}.

After a successful group formation through {@link #createGroup} or through {@link #connect}, use {@link #requestConnectionInfo} to fetch the connection details. The connection info {@link WifiP2pInfo} contains the address of the group owner {@link WifiP2pInfo#groupOwnerAddress} and a flag {@link WifiP2pInfo#isGroupOwner} to indicate if the current device is a p2p group owner. A p2p client can thus communicate with the p2p group owner through a socket connection.

With peer discovery using {@link #discoverPeers}, an application discovers the neighboring peers, but has no good way to figure out which peer to establish a connection with. For example, if a game application is interested in finding all the neighboring peers that are also running the same game, it has no way to find out until after the connection is setup. Pre-association service discovery is meant to address this issue of filtering the peers based on the running services.

With pre-association service discovery, an application can advertise a service for a application on a peer device prior to a connection setup between the devices. Currently, DNS based service discovery (Bonjour) and Upnp are the higher layer protocols supported. Get Bonjour resources at dns-sd.org and Upnp resources at upnp.org As an example, a video application can discover a Upnp capable media renderer prior to setting up a Wi-fi p2p connection with the device.

An application can advertise a Upnp or a Bonjour service with a call to {@link #addLocalService}. After a local service is added, the framework automatically responds to a peer application discovering the service prior to establishing a p2p connection. A call to {@link #removeLocalService} removes a local service and {@link #clearLocalServices} can be used to clear all local services.

An application that is looking for peer devices that support certain services can do so with a call to {@link #discoverServices}. Prior to initiating the discovery, application can add service discovery request with a call to {@link #addServiceRequest}, remove a service discovery request with a call to {@link #removeServiceRequest} or clear all requests with a call to {@link #clearServiceRequests}. When no service requests remain, a previously running service discovery will stop. The application is notified of a result of service discovery request through listener callbacks set through {@link #setDnsSdResponseListeners} for Bonjour or {@link #setUpnpServiceResponseListener} for Upnp.

Note: Registering an application handler with {@link #initialize} requires the permissions {@link android.Manifest.permission#ACCESS_WIFI_STATE} and {@link android.Manifest.permission#CHANGE_WIFI_STATE} to perform any further peer-to-peer operations. Get an instance of this class by calling {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.WIFI_P2P_SERVICE)}. {@see WifiP2pConfig} {@see WifiP2pInfo} {@see WifiP2pGroup} {@see WifiP2pDevice} {@see WifiP2pDeviceList} {@see android.net.wifi.WpsInfo}

Fields Summary
private static final String
TAG
public static final String
WIFI_P2P_STATE_CHANGED_ACTION
Broadcast intent action to indicate whether Wi-Fi p2p is enabled or disabled. An extra {@link #EXTRA_WIFI_STATE} provides the state information as int.
public static final String
EXTRA_WIFI_STATE
The lookup key for an int that indicates whether Wi-Fi p2p is enabled or disabled. Retrieve it with {@link android.content.Intent#getIntExtra(String,int)}.
public static final int
WIFI_P2P_STATE_DISABLED
Wi-Fi p2p is disabled.
public static final int
WIFI_P2P_STATE_ENABLED
Wi-Fi p2p is enabled.
public static final String
WIFI_P2P_CONNECTION_CHANGED_ACTION
Broadcast intent action indicating that the state of Wi-Fi p2p connectivity has changed. One extra {@link #EXTRA_WIFI_P2P_INFO} provides the p2p connection info in the form of a {@link WifiP2pInfo} object. Another extra {@link #EXTRA_NETWORK_INFO} provides the network info in the form of a {@link android.net.NetworkInfo}. A third extra provides the details of the group.
public static final String
EXTRA_WIFI_P2P_INFO
The lookup key for a {@link android.net.wifi.p2p.WifiP2pInfo} object Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
public static final String
EXTRA_NETWORK_INFO
The lookup key for a {@link android.net.NetworkInfo} object associated with the p2p network. Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
public static final String
EXTRA_WIFI_P2P_GROUP
The lookup key for a {@link android.net.wifi.p2p.WifiP2pGroup} object associated with the p2p network. Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
public static final String
WIFI_P2P_PEERS_CHANGED_ACTION
Broadcast intent action indicating that the available peer list has changed. This can be sent as a result of peers being found, lost or updated.

An extra {@link #EXTRA_P2P_DEVICE_LIST} provides the full list of current peers. The full list of peers can also be obtained any time with {@link #requestPeers}.

public static final String
EXTRA_P2P_DEVICE_LIST
The lookup key for a {@link android.net.wifi.p2p.WifiP2pDeviceList} object representing the new peer list when {@link #WIFI_P2P_PEERS_CHANGED_ACTION} broadcast is sent.

Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.

public static final String
WIFI_P2P_DISCOVERY_CHANGED_ACTION
Broadcast intent action indicating that peer discovery has either started or stopped. One extra {@link #EXTRA_DISCOVERY_STATE} indicates whether discovery has started or stopped.

Note that discovery will be stopped during a connection setup. If the application tries to re-initiate discovery during this time, it can fail.

public static final String
EXTRA_DISCOVERY_STATE
The lookup key for an int that indicates whether p2p discovery has started or stopped. Retrieve it with {@link android.content.Intent#getIntExtra(String,int)}.
public static final int
WIFI_P2P_DISCOVERY_STOPPED
p2p discovery has stopped
public static final int
WIFI_P2P_DISCOVERY_STARTED
p2p discovery has started
public static final String
WIFI_P2P_THIS_DEVICE_CHANGED_ACTION
Broadcast intent action indicating that this device details have changed.
public static final String
EXTRA_WIFI_P2P_DEVICE
The lookup key for a {@link android.net.wifi.p2p.WifiP2pDevice} object Retrieve with {@link android.content.Intent#getParcelableExtra(String)}.
public static final String
WIFI_P2P_PERSISTENT_GROUPS_CHANGED_ACTION
Broadcast intent action indicating that remembered persistent groups have changed.
public static final String
EXTRA_HANDOVER_MESSAGE
The lookup key for a handover message returned by the WifiP2pService.
IWifiP2pManager
mService
private static final int
BASE
public static final int
DISCOVER_PEERS
public static final int
DISCOVER_PEERS_FAILED
public static final int
DISCOVER_PEERS_SUCCEEDED
public static final int
STOP_DISCOVERY
public static final int
STOP_DISCOVERY_FAILED
public static final int
STOP_DISCOVERY_SUCCEEDED
public static final int
CONNECT
public static final int
CONNECT_FAILED
public static final int
CONNECT_SUCCEEDED
public static final int
CANCEL_CONNECT
public static final int
CANCEL_CONNECT_FAILED
public static final int
CANCEL_CONNECT_SUCCEEDED
public static final int
CREATE_GROUP
public static final int
CREATE_GROUP_FAILED
public static final int
CREATE_GROUP_SUCCEEDED
public static final int
REMOVE_GROUP
public static final int
REMOVE_GROUP_FAILED
public static final int
REMOVE_GROUP_SUCCEEDED
public static final int
REQUEST_PEERS
public static final int
RESPONSE_PEERS
public static final int
REQUEST_CONNECTION_INFO
public static final int
RESPONSE_CONNECTION_INFO
public static final int
REQUEST_GROUP_INFO
public static final int
RESPONSE_GROUP_INFO
public static final int
ADD_LOCAL_SERVICE
public static final int
ADD_LOCAL_SERVICE_FAILED
public static final int
ADD_LOCAL_SERVICE_SUCCEEDED
public static final int
REMOVE_LOCAL_SERVICE
public static final int
REMOVE_LOCAL_SERVICE_FAILED
public static final int
REMOVE_LOCAL_SERVICE_SUCCEEDED
public static final int
CLEAR_LOCAL_SERVICES
public static final int
CLEAR_LOCAL_SERVICES_FAILED
public static final int
CLEAR_LOCAL_SERVICES_SUCCEEDED
public static final int
ADD_SERVICE_REQUEST
public static final int
ADD_SERVICE_REQUEST_FAILED
public static final int
ADD_SERVICE_REQUEST_SUCCEEDED
public static final int
REMOVE_SERVICE_REQUEST
public static final int
REMOVE_SERVICE_REQUEST_FAILED
public static final int
REMOVE_SERVICE_REQUEST_SUCCEEDED
public static final int
CLEAR_SERVICE_REQUESTS
public static final int
CLEAR_SERVICE_REQUESTS_FAILED
public static final int
CLEAR_SERVICE_REQUESTS_SUCCEEDED
public static final int
DISCOVER_SERVICES
public static final int
DISCOVER_SERVICES_FAILED
public static final int
DISCOVER_SERVICES_SUCCEEDED
public static final int
PING
public static final int
RESPONSE_SERVICE
public static final int
SET_DEVICE_NAME
public static final int
SET_DEVICE_NAME_FAILED
public static final int
SET_DEVICE_NAME_SUCCEEDED
public static final int
DELETE_PERSISTENT_GROUP
public static final int
DELETE_PERSISTENT_GROUP_FAILED
public static final int
DELETE_PERSISTENT_GROUP_SUCCEEDED
public static final int
REQUEST_PERSISTENT_GROUP_INFO
public static final int
RESPONSE_PERSISTENT_GROUP_INFO
public static final int
SET_WFD_INFO
public static final int
SET_WFD_INFO_FAILED
public static final int
SET_WFD_INFO_SUCCEEDED
public static final int
START_WPS
public static final int
START_WPS_FAILED
public static final int
START_WPS_SUCCEEDED
public static final int
START_LISTEN
public static final int
START_LISTEN_FAILED
public static final int
START_LISTEN_SUCCEEDED
public static final int
STOP_LISTEN
public static final int
STOP_LISTEN_FAILED
public static final int
STOP_LISTEN_SUCCEEDED
public static final int
SET_CHANNEL
public static final int
SET_CHANNEL_FAILED
public static final int
SET_CHANNEL_SUCCEEDED
public static final int
GET_HANDOVER_REQUEST
public static final int
GET_HANDOVER_SELECT
public static final int
RESPONSE_GET_HANDOVER_MESSAGE
public static final int
INITIATOR_REPORT_NFC_HANDOVER
public static final int
RESPONDER_REPORT_NFC_HANDOVER
public static final int
REPORT_NFC_HANDOVER_SUCCEEDED
public static final int
REPORT_NFC_HANDOVER_FAILED
public static final int
ERROR
Passed with {@link ActionListener#onFailure}. Indicates that the operation failed due to an internal error.
public static final int
P2P_UNSUPPORTED
Passed with {@link ActionListener#onFailure}. Indicates that the operation failed because p2p is unsupported on the device.
public static final int
BUSY
Passed with {@link ActionListener#onFailure}. Indicates that the operation failed because the framework is busy and unable to service the request
public static final int
NO_SERVICE_REQUESTS
Passed with {@link ActionListener#onFailure}. Indicates that the {@link #discoverServices} failed because no service requests are added. Use {@link #addServiceRequest} to add a service request.
public static final int
MIRACAST_DISABLED
public static final int
MIRACAST_SOURCE
public static final int
MIRACAST_SINK
Constructors Summary
public WifiP2pManager(IWifiP2pManager service)
Create a new WifiP2pManager instance. Applications use {@link android.content.Context#getSystemService Context.getSystemService()} to retrieve the standard {@link android.content.Context#WIFI_P2P_SERVICE Context.WIFI_P2P_SERVICE}.

param
service the Binder interface
hide
- hide this because it takes in a parameter of type IWifiP2pManager, which is a system private class.



                                                  
       
        mService = service;
    
Methods Summary
public voidaddLocalService(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.nsd.WifiP2pServiceInfo servInfo, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Register a local service for service discovery. If a local service is registered, the framework automatically responds to a service discovery request from a peer.

The function call immediately returns after sending a request to add a local service to the framework. The application is notified of a success or failure to add service through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

The service information is set through {@link WifiP2pServiceInfo}.
or its subclass calls {@link WifiP2pUpnpServiceInfo#newInstance} or {@link WifiP2pDnsSdServiceInfo#newInstance} for a Upnp or Bonjour service respectively

The service information can be cleared with calls to {@link #removeLocalService} or {@link #clearLocalServices}.

param
c is the channel created at {@link #initialize}
param
servInfo is a local service information.
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        checkServiceInfo(servInfo);
        c.mAsyncChannel.sendMessage(ADD_LOCAL_SERVICE, 0, c.putListener(listener), servInfo);
    
public voidaddServiceRequest(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.nsd.WifiP2pServiceRequest req, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Add a service discovery request.

The function call immediately returns after sending a request to add service discovery request to the framework. The application is notified of a success or failure to add service through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

After service discovery request is added, you can initiate service discovery by {@link #discoverServices}.

The added service requests can be cleared with calls to {@link #removeServiceRequest(Channel, WifiP2pServiceRequest, ActionListener)} or {@link #clearServiceRequests(Channel, ActionListener)}.

param
c is the channel created at {@link #initialize}
param
req is the service discovery request.
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        checkServiceRequest(req);
        c.mAsyncChannel.sendMessage(ADD_SERVICE_REQUEST, 0,
                c.putListener(listener), req);
    
public voidcancelConnect(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Cancel any ongoing p2p group negotiation

The function call immediately returns after sending a connection cancellation request to the framework. The application is notified of a success or failure to initiate cancellation through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(CANCEL_CONNECT, 0, c.putListener(listener));
    
private static voidcheckChannel(android.net.wifi.p2p.WifiP2pManager$Channel c)

        if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
    
private static voidcheckP2pConfig(WifiP2pConfig c)

        if (c == null) throw new IllegalArgumentException("config cannot be null");
        if (TextUtils.isEmpty(c.deviceAddress)) {
            throw new IllegalArgumentException("deviceAddress cannot be empty");
        }
    
private static voidcheckServiceInfo(android.net.wifi.p2p.nsd.WifiP2pServiceInfo info)

        if (info == null) throw new IllegalArgumentException("service info is null");
    
private static voidcheckServiceRequest(android.net.wifi.p2p.nsd.WifiP2pServiceRequest req)

        if (req == null) throw new IllegalArgumentException("service request is null");
    
public voidclearLocalServices(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Clear all registered local services of service discovery.

The function call immediately returns after sending a request to clear all local services to the framework. The application is notified of a success or failure to add service through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(CLEAR_LOCAL_SERVICES, 0, c.putListener(listener));
    
public voidclearServiceRequests(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Clear all registered service discovery requests.

The function call immediately returns after sending a request to clear all service discovery requests to the framework. The application is notified of a success or failure to add service through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(CLEAR_SERVICE_REQUESTS,
                0, c.putListener(listener));
    
public voidconnect(android.net.wifi.p2p.WifiP2pManager$Channel c, WifiP2pConfig config, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Start a p2p connection to a device with the specified configuration.

The function call immediately returns after sending a connection request to the framework. The application is notified of a success or failure to initiate connect through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

Register for {@link #WIFI_P2P_CONNECTION_CHANGED_ACTION} intent to determine when the framework notifies of a change in connectivity.

If the current device is not part of a p2p group, a connect request initiates a group negotiation with the peer.

If the current device is part of an existing p2p group or has created a p2p group with {@link #createGroup}, an invitation to join the group is sent to the peer device.

param
c is the channel created at {@link #initialize}
param
config options as described in {@link WifiP2pConfig} class
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        checkP2pConfig(config);
        c.mAsyncChannel.sendMessage(CONNECT, 0, c.putListener(listener), config);
    
public voidcreateGroup(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Create a p2p group with the current device as the group owner. This essentially creates an access point that can accept connections from legacy clients as well as other p2p devices.

Note: This function would normally not be used unless the current device needs to form a p2p connection with a legacy client

The function call immediately returns after sending a group creation request to the framework. The application is notified of a success or failure to initiate group creation through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

Application can request for the group details with {@link #requestGroupInfo}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(CREATE_GROUP, WifiP2pGroup.PERSISTENT_NET_ID,
                c.putListener(listener));
    
public voiddeletePersistentGroup(android.net.wifi.p2p.WifiP2pManager$Channel c, int netId, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Delete a stored persistent group from the system settings.

The function call immediately returns after sending a persistent group removal request to the framework. The application is notified of a success or failure to initiate group removal through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

The persistent p2p group list stored in the system can be obtained by {@link #requestPersistentGroupInfo(Channel, PersistentGroupInfoListener)} and a network id can be obtained by {@link WifiP2pGroup#getNetworkId()}.

param
c is the channel created at {@link #initialize}
param
netId he network id of the p2p group.
param
listener for callbacks on success or failure. Can be null.
hide

        checkChannel(c);
        c.mAsyncChannel.sendMessage(DELETE_PERSISTENT_GROUP, netId, c.putListener(listener));
    
public voiddiscoverPeers(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Initiate peer discovery. A discovery process involves scanning for available Wi-Fi peers for the purpose of establishing a connection.

The function call immediately returns after sending a discovery request to the framework. The application is notified of a success or failure to initiate discovery through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

The discovery remains active until a connection is initiated or a p2p group is formed. Register for {@link #WIFI_P2P_PEERS_CHANGED_ACTION} intent to determine when the framework notifies of a change as peers are discovered.

Upon receiving a {@link #WIFI_P2P_PEERS_CHANGED_ACTION} intent, an application can request for the list of peers using {@link #requestPeers}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(DISCOVER_PEERS, 0, c.putListener(listener));
    
public voiddiscoverServices(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Initiate service discovery. A discovery process involves scanning for requested services for the purpose of establishing a connection to a peer that supports an available service.

The function call immediately returns after sending a request to start service discovery to the framework. The application is notified of a success or failure to initiate discovery through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

The services to be discovered are specified with calls to {@link #addServiceRequest}.

The application is notified of the response against the service discovery request through listener callbacks registered by {@link #setServiceResponseListener} or {@link #setDnsSdResponseListeners}, or {@link #setUpnpServiceResponseListener}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(DISCOVER_SERVICES, 0, c.putListener(listener));
    
public android.os.MessengergetMessenger()
Get a reference to WifiP2pService handler. This is used to establish an AsyncChannel communication with WifiService

return
Messenger pointing to the WifiP2pService handler
hide

        try {
            return mService.getMessenger();
        } catch (RemoteException e) {
            return null;
        }
    
public voidgetNfcHandoverRequest(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$HandoverMessageListener listener)
Get a handover request message for use in WFA NFC Handover transfer.

hide

        checkChannel(c);
        c.mAsyncChannel.sendMessage(GET_HANDOVER_REQUEST, 0, c.putListener(listener));
    
public voidgetNfcHandoverSelect(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$HandoverMessageListener listener)
Get a handover select message for use in WFA NFC Handover transfer.

hide

        checkChannel(c);
        c.mAsyncChannel.sendMessage(GET_HANDOVER_SELECT, 0, c.putListener(listener));
    
public android.os.MessengergetP2pStateMachineMessenger()
Get a reference to P2pStateMachine handler. This is used to establish a priveleged AsyncChannel communication with WifiP2pService.

return
Messenger pointing to the WifiP2pService handler
hide

        try {
            return mService.getP2pStateMachineMessenger();
        } catch (RemoteException e) {
            return null;
        }
    
private android.net.wifi.p2p.WifiP2pManager$ChannelinitalizeChannel(android.content.Context srcContext, android.os.Looper srcLooper, android.net.wifi.p2p.WifiP2pManager$ChannelListener listener, android.os.Messenger messenger)

        if (messenger == null) return null;

        Channel c = new Channel(srcContext, srcLooper, listener);
        if (c.mAsyncChannel.connectSync(srcContext, c.mHandler, messenger)
                == AsyncChannel.STATUS_SUCCESSFUL) {
            return c;
        } else {
            return null;
        }
    
public android.net.wifi.p2p.WifiP2pManager$Channelinitialize(android.content.Context srcContext, android.os.Looper srcLooper, android.net.wifi.p2p.WifiP2pManager$ChannelListener listener)
Registers the application with the Wi-Fi framework. This function must be the first to be called before any p2p operations are performed.

param
srcContext is the context of the source
param
srcLooper is the Looper on which the callbacks are receivied
param
listener for callback at loss of framework communication. Can be null.
return
Channel instance that is necessary for performing any further p2p operations

        return initalizeChannel(srcContext, srcLooper, listener, getMessenger());
    
public android.net.wifi.p2p.WifiP2pManager$ChannelinitializeInternal(android.content.Context srcContext, android.os.Looper srcLooper, android.net.wifi.p2p.WifiP2pManager$ChannelListener listener)
Registers the application with the Wi-Fi framework. Enables system-only functionality.

hide

        return initalizeChannel(srcContext, srcLooper, listener, getP2pStateMachineMessenger());
    
public voidinitiatorReportNfcHandover(android.net.wifi.p2p.WifiP2pManager$Channel c, java.lang.String handoverSelect, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)

hide

        checkChannel(c);
        Bundle bundle = new Bundle();
        bundle.putString(EXTRA_HANDOVER_MESSAGE, handoverSelect);
        c.mAsyncChannel.sendMessage(INITIATOR_REPORT_NFC_HANDOVER, 0,
                c.putListener(listener), bundle);
    
public voidlisten(android.net.wifi.p2p.WifiP2pManager$Channel c, boolean enable, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)

hide

        checkChannel(c);
        c.mAsyncChannel.sendMessage(enable ? START_LISTEN : STOP_LISTEN,
                0, c.putListener(listener));
    
public voidremoveGroup(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Remove the current p2p group.

The function call immediately returns after sending a group removal request to the framework. The application is notified of a success or failure to initiate group removal through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(REMOVE_GROUP, 0, c.putListener(listener));
    
public voidremoveLocalService(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.nsd.WifiP2pServiceInfo servInfo, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Remove a registered local service added with {@link #addLocalService}

The function call immediately returns after sending a request to remove a local service to the framework. The application is notified of a success or failure to add service through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

param
c is the channel created at {@link #initialize}
param
servInfo is the local service information.
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        checkServiceInfo(servInfo);
        c.mAsyncChannel.sendMessage(REMOVE_LOCAL_SERVICE, 0, c.putListener(listener), servInfo);
    
public voidremoveServiceRequest(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.nsd.WifiP2pServiceRequest req, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Remove a specified service discovery request added with {@link #addServiceRequest}

The function call immediately returns after sending a request to remove service discovery request to the framework. The application is notified of a success or failure to add service through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

param
c is the channel created at {@link #initialize}
param
req is the service discovery request.
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        checkServiceRequest(req);
        c.mAsyncChannel.sendMessage(REMOVE_SERVICE_REQUEST, 0,
                c.putListener(listener), req);
    
public voidrequestConnectionInfo(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ConnectionInfoListener listener)
Request device connection info.

param
c is the channel created at {@link #initialize}
param
listener for callback when connection info is available. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(REQUEST_CONNECTION_INFO, 0, c.putListener(listener));
    
public voidrequestGroupInfo(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$GroupInfoListener listener)
Request p2p group info.

param
c is the channel created at {@link #initialize}
param
listener for callback when group info is available. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(REQUEST_GROUP_INFO, 0, c.putListener(listener));
    
public voidrequestPeers(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$PeerListListener listener)
Request the current list of peers.

param
c is the channel created at {@link #initialize}
param
listener for callback when peer list is available. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(REQUEST_PEERS, 0, c.putListener(listener));
    
public voidrequestPersistentGroupInfo(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$PersistentGroupInfoListener listener)
Request a list of all the persistent p2p groups stored in system.

param
c is the channel created at {@link #initialize}
param
listener for callback when persistent group info list is available. Can be null.
hide

        checkChannel(c);
        c.mAsyncChannel.sendMessage(REQUEST_PERSISTENT_GROUP_INFO, 0, c.putListener(listener));
    
public voidresponderReportNfcHandover(android.net.wifi.p2p.WifiP2pManager$Channel c, java.lang.String handoverRequest, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)

hide

        checkChannel(c);
        Bundle bundle = new Bundle();
        bundle.putString(EXTRA_HANDOVER_MESSAGE, handoverRequest);
        c.mAsyncChannel.sendMessage(RESPONDER_REPORT_NFC_HANDOVER, 0,
                c.putListener(listener), bundle);
    
public voidsetDeviceName(android.net.wifi.p2p.WifiP2pManager$Channel c, java.lang.String devName, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Set p2p device name.

hide
param
c is the channel created at {@link #initialize}
param
listener for callback when group info is available. Can be null.

        checkChannel(c);
        WifiP2pDevice d = new WifiP2pDevice();
        d.deviceName = devName;
        c.mAsyncChannel.sendMessage(SET_DEVICE_NAME, 0, c.putListener(listener), d);
    
public voidsetDnsSdResponseListeners(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$DnsSdServiceResponseListener servListener, android.net.wifi.p2p.WifiP2pManager$DnsSdTxtRecordListener txtListener)
Register a callback to be invoked on receiving Bonjour service discovery response.

see {@link #discoverServices} for the detail.

param
c
param
servListener is for listening to a Bonjour service response
param
txtListener is for listening to a Bonjour TXT record response

        checkChannel(c);
        c.mDnsSdServRspListener = servListener;
        c.mDnsSdTxtListener = txtListener;
    
public voidsetMiracastMode(int mode)
Internal use only @hide

         
        
        try {
            mService.setMiracastMode(mode);
        } catch(RemoteException e) {
           // ignore
        }
    
public voidsetServiceResponseListener(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ServiceResponseListener listener)
Register a callback to be invoked on receiving service discovery response. Used only for vendor specific protocol right now. For Bonjour or Upnp, use {@link #setDnsSdResponseListeners} or {@link #setUpnpServiceResponseListener} respectively.

see {@link #discoverServices} for the detail.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on receiving service discovery response.

        checkChannel(c);
        c.mServRspListener = listener;
    
public voidsetUpnpServiceResponseListener(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$UpnpServiceResponseListener listener)
Register a callback to be invoked on receiving upnp service discovery response.

see {@link #discoverServices} for the detail.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on receiving service discovery response.

        checkChannel(c);
        c.mUpnpServRspListener = listener;
    
public voidsetWFDInfo(android.net.wifi.p2p.WifiP2pManager$Channel c, WifiP2pWfdInfo wfdInfo, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)

hide

        checkChannel(c);
        c.mAsyncChannel.sendMessage(SET_WFD_INFO, 0, c.putListener(listener), wfdInfo);
    
public voidsetWifiP2pChannels(android.net.wifi.p2p.WifiP2pManager$Channel c, int lc, int oc, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)

hide

        checkChannel(c);
        Bundle p2pChannels = new Bundle();
        p2pChannels.putInt("lc", lc);
        p2pChannels.putInt("oc", oc);
        c.mAsyncChannel.sendMessage(SET_CHANNEL, 0, c.putListener(listener), p2pChannels);
    
public voidstartWps(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.WpsInfo wps, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Start a Wi-Fi Protected Setup (WPS) session.

The function call immediately returns after sending a request to start a WPS session. Currently, this is only valid if the current device is running as a group owner to allow any new clients to join the group. The application is notified of a success or failure to initiate WPS through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

hide

        checkChannel(c);
        c.mAsyncChannel.sendMessage(START_WPS, 0, c.putListener(listener), wps);
    
public voidstopPeerDiscovery(android.net.wifi.p2p.WifiP2pManager$Channel c, android.net.wifi.p2p.WifiP2pManager$ActionListener listener)
Stop an ongoing peer discovery

The function call immediately returns after sending a stop request to the framework. The application is notified of a success or failure to initiate stop through listener callbacks {@link ActionListener#onSuccess} or {@link ActionListener#onFailure}.

param
c is the channel created at {@link #initialize}
param
listener for callbacks on success or failure. Can be null.

        checkChannel(c);
        c.mAsyncChannel.sendMessage(STOP_DISCOVERY, 0, c.putListener(listener));