Background Data Collection
Data collection from most data sources in Avicenna happens behind the scenes and without any participant involvement. After participants join your study and give consents, if your study involves any of the automated data sources, Avicenna will be continuously running on the participant's phone, capturing data, encrypting them, and uploading them to the server.
While this is very useful to minimize the participants’ burden and prevent the Hawthorne effect, it goes against how most apps work. Both Android and iOS are designed such that when a user doesn't use an app very often, the operating system stops and terminates it.
There are many factors which determine the condition and time based on which the operating system should terminate an app, including but not limited to:
- How much resources (e.g. battery or processing power) is the app using?
- The version of the Android or iOS.
- How much battery has remained?
- Is there any intensive important app currently running (e.g. Skype video call)?
- Make and model of the phone.
Based on these and other similar factors, Android and iOS might decide to terminate Avicenna in order to free space for other more important apps. This in turn leads to incomplete data for your study.
We are always working to prevent app termination like this as much as possible. For the most parts, you need not to worry about the details. At the same time, there are a few items discussed below which are important to konw in order to improve the data quality.
Keeping the Study Light
One of the essential factors which cause an app to be terminated is the amount of resources it consumes. If the data sources which you monitor for your study generate lots of data, Avicenna will use more resources for storage, encryption, compaction, 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.
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, Magnetometer, 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, magnetometer, 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, magnetometer, and gyroscope) or software-based sensors (i.e. linear acceleration, gravity, and orientation). Collecting all these sensors 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 alive 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:
|Avicenna App for iOS Requesting GPS Permission for Background Activity|
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
Report page shows
all the data points that have been seen by Avicenna, but not necessarily
collected. As explained above, the location data are collected only if the
study, you are participating in, explicitly requests for GPS data. Even in that
case, the data uploaded and shared by researchers are based on the conditions
defined in the consent form. Otherwise, the location data are received by the
Avicenna app and is subsequently discarded, so neither Avicenna nor researchers have
access to this information.
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, at the moment 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.
|Avicenna App for iOS Notifies Participant After Termination|
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 who wish to run continuously in the background are required to have a Sticky Notification: a permanent notification which is shown on the top of the screen is like normal Android notifications but cannot be dismissed by the user.
|Avicenna App for Android Showing a Sticky Notification|
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.
|Avicenna App Allows Participants to Decide Whether Sticky Notifications Should be Used or Not|
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. Android allows users to disable Battery Optimization for their apps. When a participant joins your study using his or her Android phone, Avicenna shows them a notification and asks them to disable the Battery Optimization for the Avicenna app:
|Avicenna instructs participants to disable Battery Optimization|
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
|Battery Optimization screen - All apps option|
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 excludes Avicenna from battery optimization on
this phone. This, in turn, will allow Avicenna to run and operate in the
background as expected:
|Battery Optimization screen - Dont Optimize option|
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.