Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct usage of wifi RTT ranging in Android 9

Android 9 (Pie) introduces wifi RTT ranging for the purpose of wifi-based gelolocation.

In versions up until Android 8 (Oreo), applications would periodically request wifi scans. This functionality is being massively throttled in Android 9: a foreground app can now request a maximum of 4 scans in a 2-minute window; background apps are restricted to one scan per 30 minutes for all background apps combined. The only way to avoid this throttling is the NETWORK_SETTINGS permission, which, however, is a signature permission (I take that to mean it needs to be signed with the same key as the OS build, regardless of whether it’s a system app) and thus not available to third-party apps.

I understand that wifi RTT ranging can only be initiated with a ScanResult, thus I’d need to run a wifi scan first. However, I could presumably bypass the throttle by reusing the same scan result for a couple of RTT ranging requests, at the expense of not getting new wifis for some time.

However, the docs also mention throttling for wifi RTT ranging, however, without specifying what the limits are.

Finally, WifiManager.startScan() is deprecated and apps may no longer be able to start scans in future releases.

Questions:

  • What are the limits for requesting wifi RTT ranging?
  • What is the correct way to obtain a ScanResult, which I need to start an RTT ranging request?
like image 212
user149408 Avatar asked Aug 20 '18 20:08

user149408


1 Answers

I haven't seen any documentation of the limits, but from Android source code you see at least these:

  • background apps are limited to ranging once per 30 minutes
  • max 20 ranging requests can be in queue per app

Source code of Wifi RTT service implementation is here: https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/android-9.0.0_r3/service/java/com/android/server/wifi/rtt/RttServiceImpl.java

Google has closed most of the WiFi throttling threads in Issue Tracked with comment "will be used to improve future Android version", but there are active like this: https://issuetracker.google.com/issues/112688545 Could you raise your question there?

like image 59
marko.tm Avatar answered Dec 29 '22 11:12

marko.tm