Android WiFi Aware - Error when creating multiple connections

81 views Asked by At

Similarly to the question presented there, I'm currently developing an Android App that utilizes Wi-Fi Aware API in order to establish device-to-device connections. After the Discovery process is completed (via Publish/Subscribe mechanism) and devices know its peers, I'm able to open a device-to-device connection to exchange data.

However, this expected behaviour only happens when I'm testing in a scenario with a pair of devices, device A and B, where A acts as the Publisher and B as the Subscriber (for example). If I test with a third device - device C - acting as a Subscriber, I am not able to open a connection between device A and C.

On the Publisher (Device A) I get these two error messages: 2024-01-24 14:45:20.054 1656-2060 WifiAwareDataPathStMgr system_server E selectInterfaceForRequest: req=AwareNetworkRequestInformation: state=103, ns=WifiAwareNetworkSpecifier [type=0, role=1, clientId=254, sessionId=255, peerId=413, peerMac=<null>, securityConfig=WifiAwareDataPathSecurityConfig [cipherSuite=1, passphrase=<non-null>, PMK=<null>, PMKID=<null>], port=43619, transportProtocol=-1, channel=0, forceChannel=false], uid=10248, packageName=com.example.mscwfa1, interfaceName=null, pubSubId=1, specifiedPeerInstanceId=1, specifiedPeerDiscoveryMac=42F0F09263F4, equivalentSpecifiers=[NetworkRequest [ REQUEST id=3075, [ Transports: WIFI_AWARE Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Specifier: <WifiAwareNetworkSpecifier [type=0, role=1, clientId=254, sessionId=255, peerId=413, peerMac=<null>, securityConfig=WifiAwareDataPathSecurityConfig [cipherSuite=1, passphrase=<non-null>, PMK=<null>, PMKID=<null>], port=43619, transportProtocol=-1, channel=0, forceChannel=false]> Uid: 10248 RequestorUid: 10248 RequestorPkg: com.example.mscwfa1 UnderlyingNetworks: Null] ], ], NdpInfos[] - no interfaces available!

2024-01-24 14:45:20.063 1656-2060 WifiAwareDataPathStMgr system_server E WifiAwareNetworkFactory.releaseNetworkFor: networkRequest=NetworkRequest [ REQUEST id=3075, [ Transports: WIFI_AWARE Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Specifier: <WifiAwareNetworkSpecifier [type=0, role=1, clientId=254, sessionId=255, peerId=413, peerMac=<null>, securityConfig=WifiAwareDataPathSecurityConfig [cipherSuite=1, passphrase=<non-null>, PMK=<null>, PMKID=<null>], port=43619, transportProtocol=-1, channel=0, forceChannel=false]> Uid: 10248 RequestorUid: 10248 RequestorPkg: com.example.mscwfa1 UnderlyingNetworks: Null] ] not in cache!?

And on the second Subscriber (Device C), I get the NetworkCallback.onUnavailable and this error message:

2024-01-24 14:45:20.440 1746-2653 WifiAwareDataPathStMgr system_server E WifiAwareNetworkFactory.releaseNetworkFor: networkRequest=NetworkRequest [ REQUEST id=3546, [ Transports: WIFI_AWARE Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Specifier: <WifiAwareNetworkSpecifier [type=0, role=0, clientId=253, sessionId=255, peerId=388, peerMac=<null>, securityConfig=WifiAwareDataPathSecurityConfig [cipherSuite=1, passphrase=<non-null>, PMK=<null>, PMKID=<null>], port=0, transportProtocol=-1, channel=0, forceChannel=false]> Uid: 10248 RequestorUid: 10248 RequestorPkg: com.example.mscwfa1 UnderlyingNetworks: Null] ] not in cache!?

In Android API Level 31+, is there any limitation in ConnectivityManager about how many simultaneous Networks I may have? If not, why am I getting the "No Interfaces Available" error and consequently the callback onUnavailable on the Network I requested?

1

There are 1 answers

0
JX23 On

The interface error is hardware limit, you can check the limit per device like this

wifiAwareManager = (WifiAwareManager) context.getSystemService(Context.WIFI_AWARE_SERVICE);

    // Check if Wi-Fi Aware is supported on this device
    if (wifiAwareManager.isAvailable()) {

        Characteristics characteristics = wifiAwareManager.getCharacteristics();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {

            assert characteristics != null;
            Log.d(TAG,String.format(
                    "isAwarePairingSupported() - %b \n" +
                            "isInstantCommunicationModeSupported() - %b \n" +
                            "isSetChannelOnDataPathSupported() - %b \n" +
                            "getNumberOfSupportedDataInterfaces - %d \n" +
                            "getNumberOfSupportedDataPaths - %d \n",
                    characteristics.isAwarePairingSupported(),
                    characteristics.isInstantCommunicationModeSupported(),
                    wifiAwareManager.isSetChannelOnDataPathSupported(),
                    characteristics.getNumberOfSupportedDataInterfaces(),
                    characteristics.getNumberOfSupportedDataPaths()
            ));
        }
        Log.d(TAG, String.format("getAvailableDataPathsCount() = %d \n" +
                        "getAvailableSubscribeSessionsCount() = %d \n" +
                        "getAvailablePublishSessionsCount() = %d\n",
                wifiAwareManager.getAvailableAwareResources().getAvailableDataPathsCount(),
                wifiAwareManager.getAvailableAwareResources().getAvailableSubscribeSessionsCount(),
                wifiAwareManager.getAvailableAwareResources().getAvailablePublishSessionsCount()));
    } else {
        wifiAwareManagerStatus = false;
        Log.d("wifiAwareManager", "not available");
        // Wi-Fi Aware is not available on this device
    }

Supported Data Paths and Supported Data Interfaces are different things, you can have a device act as a publisher for X ammount of subscribers, where the X is the Supported Data Interfaces, only with 1 interface

enter image description here