I've got a Galaxy S8 and have come across an interesting situation. Now, either something strange is going on, or I've got no clue how it actually works!
I've downloaded an FTP Server app on my phone which I wanted to leave running in the background. The problem was that, once the screen turned off, the wifi connection would drop after 5 mins and I couldn't connect to my phone.
I had enabled the setting for WiFi to always be connected and I know that the app has both PARTIAL_WAKE_LOCK and WifiLocks so I had expected the connection to remain in place.
I added the app to the list of "Unmonitored Apps" in the battery optimisation settings but this had no effect.
Using adb I could see that the UID of the service holding the WAKE_LOCK was not listed in mDeviceIdleWhitelist so I ran
adb shell dumpsys deviceidle whitelist +PACKAGE_NAME and saw that the UID was now in the list.
After running this command, the app behaves as expected and I can continue to connect once the screen has been off for a while.
So my question is whether there is a difference between "Unmonitored Apps" and the mDeviceIdleWhitelist? If there isn't, is this a bug in the phone software?