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?