0

Unknown size limit of API: android.net.wifi.aware.DiscoverySession.sendMessage causes System.err

Link to documentation: https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])

Sending 620bytes of data using the child class of DiscoverySession;
PublishDiscoverySession.sendMessage

Logcat:
2025-02-04 15:59:06.890 21620-21728 MainActivity net.mobilewebprint.nan D Attempting to send message of size: 620 bytes 2025-02-04 15:59:06.893 21620-21728 System.err net.mobilewebprint.nan W java.lang.IllegalArgumentException: Message length longer than supported by device characteristics

The API works for very small msg size of 10bytes.

What's the system limit on this API? How do I find out what is supported max size based on device characteristics?

Details
Wi-Fi Connectivity / Bluetooth, Android Version:15, Pixel 7 Pro

Tried smaller size. The API works for very small msg size of 10bytes.

Here is the exception value after failed call.

java.lang.IllegalArgumentException: Message length longer than supported by device characteristics
Remote stack trace:
    at com.android.server.wifi.aware.WifiAwareServiceImpl.sendMessage(WifiAwareServiceImpl.java:640)
    at android.net.wifi.aware.IWifiAwareManager$Stub.onTransact(IWifiAwareManager.java:528)
    at android.os.Binder.execTransactInternal(Binder.java:1411)
    at android.os.Binder.execTransact(Binder.java:1350)

stackTrace = {StackTraceElement[13]@29776} 
 0 = {StackTraceElement@29791} "android.os.Parcel.createExceptionOrNull(Parcel.java:3234)"
 1 = {StackTraceElement@29792} "android.os.Parcel.createException(Parcel.java:3214)"
 2 = {StackTraceElement@29793} "android.os.Parcel.readException(Parcel.java:3197)"
 3 = {StackTraceElement@29794} "android.os.Parcel.readException(Parcel.java:3139)"
 4 = {StackTraceElement@29795} "android.net.wifi.aware.IWifiAwareManager$Stub$Proxy.sendMessage(IWifiAwareManager.java:1024)"
 5 = {StackTraceElement@29796} "android.net.wifi.aware.WifiAwareManager.sendMessage(WifiAwareManager.java:750)"
 6 = {StackTraceElement@29797} "android.net.wifi.aware.DiscoverySession.sendMessage(DiscoverySession.java:229)"
 7 = {StackTraceElement@29798} "android.net.wifi.aware.DiscoverySession.sendMessage(DiscoverySession.java:261)"
 8 = {StackTraceElement@29799} "net.mobilewebprint.nan.MainActivity.sendCameraMessage(MainActivity.java:1790)"
 9 = {StackTraceElement@29800} "net.mobilewebprint.nan.WebRTCCameraFragment$2$1.onSetSuccess(WebRTCCameraFragment.java:397)"
 10 = {StackTraceElement@29801} "org.webrtc.PeerConnection.nativeSetLocalDescription(Native Method)"
 11 = {StackTraceElement@29802} "org.webrtc.PeerConnection.setLocalDescription(PeerConnection.java:886)"
 12 = {StackTraceElement@29803} "net.mobilewebprint.nan.WebRTCCameraFragment$2.onCreateSuccess(WebRTCCameraFragment.java:393)"

1 Answer 1

0

Might be a bit late now, but I found this bit of code which suggests the getMaxServiceSpecificInfoLength() is used to determine the max message length.

Doing some testing using a binary search type method and it seems to be correct. On my Pixel 3 the max was 270 bytes and on my Pixel 7 it was 255.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.