0 votes
by (340 points)

Background:

We're trying to create a utility app that responds to UDP pings to detect the headset on our wifi. This part works fine. The issue is that we can't seem to get it to run without the user wearing the headset all the time.

Problem:

If we leave the headset alone for about 4-5 minutes, the application pauses even though we are using both Wifi Wakelocks and PowerManager wakelocks, and the UDP listener no longer responds. If we put the headset back on, the server 'wakes up' and works until we put the headset down for another 4-5 minutes.

We have the manifest set to:

<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DEVICE_POWER" />

And it appears we are correctly able to access the WifiManager and PowerManager, and call the correct createWifiLock and newWakeLock with the acquire function calls:

static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
static AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
wifiManager = activity.Call<AndroidJavaObject>("getSystemService", "wifi"); 
powerManager = activity.Call<AndroidJavaObject>("getSystemService", "power"); 
wifiLock = wifiManager.Call<AndroidJavaObject>("createWifiLock", 3, "MYTAG"); // 3 = WIFI_MODE_FULL_HIGH_PERF
wifiLock.Call("acquire");
powerLock = powerManager.Call<AndroidJavaObject>("newWakeLock", 1, "MYTAG");  // 1 = PARTIAL_WAKE_LOCK
powerLock.Call("acquire");

However, even with these functions and no errors/crashes, we are unable to get the headset to keep running the process. Is there some other Pico-Specific api function we should be using to keep the background process/thread working?

1 Answer

0 votes
by (39.2k points)

Dear developer,
At present, the Neo 3 series has system limitation. The system will determine whether the current network rate reaches 200KB/s within 5 minutes after the screen is off. If it does not, the wifi will be turned off.
The current solution is to lower the android version of packaged APK below Android 9, then monitoring wifi status, and then turn on wifi again after wifi is off.

by (340 points)

The current solution is to lower the android version of packaged APK below Android 9 by monitoring wifi status, and then turn on wifi again after wifi is off.

How in the world do you do this? Turning the wifi on and off I can see, but not the rest.

by (39.2k points)

Dear developer,
Sorry, Maybe I didn't express clearly.
"The current solution is to lower the android version of packaged APK below Android 9" which means:
Target API Level should lower than Android 9.
enter image description here

Note:
If low version of Android SDK API is used, the following code in the Editor->PXR_BuildProcessor file can be commented out:

UpdateOrCreateAttributeInTag(manifestDoc,"/manifest","application","requestLegacyExternalStorage","true");

enter image description here
enter image description here
However, doing this will cause the SD card directory cannot be accessed directly.

For details, please refer to the following links:
https://developer.pico-interactive.com/docs/en/12058/225685/#_2-2-development-environment-requirements

by (340 points)

So you're saying that the ability to change the Wifi connection from inactive to active is NOT possible with the SDK API version 28 or 29, and is only possible with SDK API version 26 or 27?

The wifi being disconnected is also happening while I have an active, live WebSocket connection, which results in some serious connectivity issues.

by (39.2k points)

Dear developer,
Sorry for the inconvenience.
May I ask whether the device model you use is Neo 3 or Neo 3 Pro?

by (340 points)

We are using the Neo 3 Pro.

I am not having any luck in getting the wifi to remain on - I am getting a android.net.wifi.WIFISTATECHANGED broadcast but even with the proper manifest settings and calls I still get dropped/broken connections.

Could you perhaps create an example project on your Github example repo to show the proper method to keep the wifi on?

If not, when will there be an update to the Neo 3/Neo 3 Pro to address this 5 minute issue of ignoring the wakelocks?

by (39.2k points)

Dear developer,
Sorry for the inconvenience, this is a known issue and is expected to be resolved in the next system release for Neo 3 Pro.

by (340 points)

Has there been any development done on this? The inability to keep the wifi running (and thus breaking our communication pipeline) is causing serious usability issues to the point where management is looking at alternative headset options.

by (39.2k points)

Dear developer,
We sincerely apologize for the inconvenience.
This issue has been fed back to r&d and is expected to be fixed in PUI 4.8.0. But the exact release date of PUI 4.8.0 is uncertain.

...