The "Throttling" Problem
The Battery War
For the last decade, Android updates have had one primary goal: Battery Life. The biggest enemy of battery life is the GPS chip. To combat this, Android aggressively "throttles" or kills apps that try to use the GPS while the screen is off.
The Constraints
1. Background Location Limits (Android 8.0+)
If an app is in the background (user switched to another app or screen is off), Android limits location updates to a few times per hour.
- For Drones: This is fatal. We need 5-10 updates per second.
2. Doze Mode
If the phone is stationary for a while (e.g., sitting on the ground), Android enters "Doze."
- Effect: Network access (UDP) is cut. CPU wakes are deferred. The app goes into a coma.
The Solution: Foreground Services
To survive, MAVLink GPS declares itself as a Foreground Service of type location.
The "Sticky" Notification
You will notice a persistent notification in your status bar while the app is running. This is not just for UI; it is a mandatory system flag.
- The Signal: It tells the Android Scheduler: "The user is actively using this app right now, even if they aren't looking at it."
- The Result: The app is elevated to
PERCEPTIBLEpriority (similar to a music player or an active phone call). It is exempt from background location throttling and Doze mode restrictions.
Why Screen-On is Safer
Even with a Foreground Service, some aggressive OEM battery managers (Samsung, Xiaomi) may still kill the USB connection to save power.
- Recommendation: Use the app's "Keep Screen On" setting. This guarantees the highest possible CPU and sensor priority.