Background Data Collection

Data collection from most data sources in Avicenna happens behind the scenes without any participant involvement. After participants join your study and give consent, if your study involves any automated data sources, Avicenna will continuously run on the participant’s phone, capturing data, encrypting it, and uploading it to the server.

While this minimizes participants’ burden and helps prevent the Hawthorne effect, it differs from how most apps work. Both Android and iOS are designed to stop and terminate apps that users don’t actively use. Based on various factors, the operating system may decide to terminate Avicenna to free resources for other, more important apps. This can result in incomplete data for your study.

There are many factors that determine when and under what conditions the operating system may terminate an app, including but not limited to:

  • The amount of resources the app is using (e.g., battery or processing power)
  • The version of Android or iOS on the device
  • The remaining battery level
  • The operation of other intensive or important apps running
  • The make and model of the phone

We are always working to prevent app termination like this as much as possible. For the most part, you don’t need to worry about the details. At the same time, there are a few items discussed below that are important to know in order to improve the data quality.

Keeping the Study Light

One of the essential factors that can cause an app to be terminated is the amount of resources it consumes. If the data sources which you monitor for your study generate large amounts of data, Avicenna will use more resources for storage, encryption, compression, and upload. This, in turn, will increase the chances of app termination. Therefore, you need to to make sure your study only collects data from the necessary data sources.

On the other hand, not all data sources generate the same size of data. For example, the pedometer generates a record every time a step is captured, or GPS generates less than 50 records once every 5 minutes (a cycle). However, some data sources such as Accelerometer, Gyroscope, Magnetic Field, and other software- or hardware-based motion sensors generate thousands of records per cycle. Using such data sources in your study can increase the chance of the app being terminated.

In most cases, it’s better to replace raw motion-sensor data (accelerometer, magnetic field, gyroscope, linear acceleration, gravity, and orientation) with their high-level equivalent data sources (motion-based activity recognition and pedometer). They can provide you with the data which are easier to analyze, and multiple orders of magnitude smaller in volume.

Even if you have to collect raw motion-sensor data, you probably need either the raw data from hardware (i.e. accelerometer, magnetic field, and gyroscope) or software-based sensors (i.e. linear acceleration, gravity, and orientation). Collecting all this data is almost always unnecessary as the software-based sensors can be derived from the raw data from the hardware.

Background Activity in iOS

iOS is very strict on applications that perform background activity. In the App Store’s App Review guidelines, Apple has defined a few categories, and only apps in those categories are allowed to perform any background activity. Unfortunately, research applications are not one of those categories, though location-aware applications are. In other words, while an application is actively using GPS, it can remain active in the background and perform other tasks as well.

Avicenna uses the category of “GPS-based apps” to remain active while not being visible. That means it requires actively using GPS in order to perform any task in the background. Therefore, if your study uses continuous monitoring of data sources, whether including GPS or not, Avicenna will ask the participant for GPS permission:

If your study does monitor GPS, Avicenna will capture accurate GPS records and upload them periodically together with other data sources. If your study does not require GPS, Avicenna “pretends” to be using GPS by asking for very coarse GPS location, but it does not store nor upload those GPS data. This allows Avicenna to remain active in the background to record and upload other requested data sources while minimizing battery consumption.

Reports Section of Avicenna iOS App

To illustrate the location from which the Avicenna app has received the data, we have added a page to Avicenna iOS app called Reports. The Report page shows all the data points that have been seen by Avicenna, but not necessarily collected.

Handling App Termination in iOS

Avicenna in iOS automatically detects if it’s been terminated by the iOS operating system or not. If yes, it shows a message to the user asking them to open Avicenna. Clicking that notification will simply open the Avicenna app which is enough for Avicenna to resume its operation. Avicenna only sends one notification when it detects the app is terminated. If the user discards this message, Avicenna will not send any additional reminder. If the user opens the Avicenna app and iOS terminates the app again, Avicenna will prompt another notification to the user.

[!note]
In iOS, swiping up to close an app (force-quitting) is treated the same as app termination by the operating system.

Background Activity in Android

Android handles background applications differently than iOS. Therefore, the model described for Avicenna iOS does not apply to Android users. In Android, applications that wish to run continuously in the background are required to have a Sticky Notification: a permanent notification shown on the top of the screen that cannot be dismissed by the user.

Sticky Notifications

Such notifications tell Android “this application is performing an important task for the user, and it should not be terminated as long as possible”.

Sticky Notifications can be annoying for some users and might force them to drop out of the study. Therefore, Avicenna allows users to disable Sticky Notifications through Avicenna Settings if they choose to. Of course, disabling Sticky Notifications will make the app subject to termination by Android, and can impact the data collection for the study. While Avicenna informs the user about such impact, it respects their choice if they decide to disable Sticky Notifications.

Battery Optimization

The behavior of the phones we explained above, where Android and iOS terminate the apps that are not used by the user recently, is called Battery Optimization. This process may differ slightly across different devices and manufacturers. Android allows users to disable Battery Optimization for their apps. When a participant joins your study using their Android phone, Avicenna shows them a notification and asks them to disable the Battery Optimization for the Avicenna app:

Clicking on this notification will open the Battery optimization page. The participant should first open the dropdown on the top of the screen and select All apps:

In the list of all apps, the participant should search and find Avicenna and tap on it, and then choose Don't Optimize in the dialog that opens. Pressing Done will save this setting and exclude Avicenna from battery optimization on that phone. This, in turn, will allow Avicenna to run and operate in the background as expected:

While the above setting exists on all Android devices, not all Android manufacturers, such as Huawei or Samsung, respect these settings. Different manufacturers often have their settings to disable Battery Optimization.

When the Avicenna app detects that it’s not operating as expected, it assumes such manufacturer settings prevent the operation. Therefore, it shows instructions to the participants relative to the type of phone they are using. You can also find these manufacturer-specific settings in the following sections.