I tried to make the same as background location example, and can confirm that the app with foreground service (UDP intranet networking) at phones (Samsung A23 (Android 14) and Xiaomi Redmi Note 10 Pro (Android 13)), at both the app is set up not to be blocked by the OS in power:
1. The network data is transceived OK all the time (via B4A-bridge logs), including after the switched off screen. But only from Samsung.
2. Xiaomi in 4-5 mins - stopped the data transmission, resumes only if to switch the screen on, but after off again - stop in some seconds.
3. Voice messages are playable only if the screen is on. Despite the wakelocks.