Sampling Coverage in Mobile Sensing on Android 8 vs. 10

In the original CARP Mobile Sensing (CAMS) paper, we did a study of “sampling coverage”, i.e., to what degree does CAMS collect data points compared to what is expected. For example, if the sampling frequency for location is set to 30 seconds, 120 location data points are expected per hour. 

In the paper, the coverage tests was done on an Android Samsung A3 phone running Android 8, SDK level 26. The following measures were done over a 24 hours period (sampling frequency in parentheses):

  • location (30s)
  • wifi (1m)
  • light (10s)
  • noise (1m)
  • memory (1m)
  • weather (10m)
  • air_quality (10m)

Coverage is calculated per measure on an hourly basis as the ratio of collected data points compared to the expected number.

The results shown below in Fig. 1 revealed that sampling coverage on Android was close to 100%.

Fig. 1 – Sampling coverage for Android 8, SDK level 26. Numbers in cells indicate sampling coverage; 1 indicates 100% coverage, i.e. that all expected data points were collected. 

The way data sampling can be done on Android has, however, significantly changed on Android 10, SDK level 29. Especially, there is a “before and after Android 10” (API level 29), which introduced a number of features and behavior changes to better protect users’ privacy. One of the major changes is that sensors no longer “runs in the background” and that Google recommend to “...only gather sensor data in the foreground“. Given these restrictions, it’s best to detect sensor events either when your app is in the foreground or as part of a foreground service. This also applies for other “sensor”, like location and activity recognition.

For this reason, the recent version of carp_context_package which support collection of context data like location and activity is now made to run as a foreground service. So, when using this sampling package, the entire app should run as a foreground service and keep sampling data even when the app is put in the background.

In order to check this, we re-ran the test from above, now on a Samsung Galaxy S10e Android version 10, SDK level 29.

The results are shown below in Fig. 2.

Fig. 2 – Sampling coverage for Android 10, SDK level 29.

This study reveals two things:

  • Sampling coverage is still close to 100% on most measures (the test was started at 13:15 which explain the missing data in the “13:00” timeslot).
  • The light sensor is not sampling on a regular basis.

Google write that “most device manufacturers use [the light sensor] to control screen brightness“. Hence, in this case with the Samsung Galaxy S10e, it seems like the light sensor is only activated when the screen is turned on and there is a need for adjusting screen brightness.

In conclusion, the recent versions of CAMS and the context package seems to keep data sampling running in the background.

We will, however, keep monitoring these things. And we will also repeat the test on iOS and publish the results in a separate blog post.

Leave a Reply

Your email address will not be published. Required fields are marked *