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.
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.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
powerLock = powerManager.Call<AndroidJavaObject>("newWakeLock", 1, "MYTAG"); // 1 = PARTIAL_WAKE_LOCK
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?