## 3 Method
### Data Reliability  
The two main functionalities that the system must provide are _data acquisition_ and support for _data labeling. Data acquisition_ includes interfacing with the sensors embedded in the smartphone, managing the connection with the paired smartwatch, and storing the data acquired by the sensors. _Data labeling_ includes the user interface setting the beginning and end times of a given activity performed by a human subject.  
These two functionalities may result in a single application running on a smartphone. Using only one application would result in the following usage scenario: The user uses the application's user interface to specify the activity he/she will perform and then starts the registration and puts the smartphone in the designated place, for example, in her trouser pocket. When the user completes the activity, he/she picks up the smartphone from his/her trouser pocket and then stops recording. This usage scenario has a significant drawback: the data recorded from when the user starts recording to when he/she puts the smartphone in her pocket and, vice versa, the data recorded from when he/she picks up the smartphone from her pocket to when he/she stops recording are incorrectly labeled. These data are in fact labeled as belonging to the activity performed. To overcome this problem, we decided to operate a separation of concerns by assigning the responsibility of data acquisition and data labeling to two different software components, each of them reified by a different application. The idea is that these two applications should be executed in two different smartphones. In this way, the user exploits the acquisition application to start the recording of sensors. Once started, the user may place the smartphone in the designated location, for example, his/her trouser pocket. Then, the user exploits the labeling application running on a second smartphone to specify from time to time the activity that is being performed.  
Two key aspects need to be considered to ensure that the process of recording and labeling data is properly implemented: Firstly, the two smartphones hosting the acquisition and labeling applications  
Figure 1: From requirements to design choices.  
should be synchronized in accordance with a common clock time; secondly, the data recorded by the sensors and the activities carried out by the subjects should have a unique subject identifier.  
Clock synchronization between the two applications allows acquired data to be easily matched with the beginning and end time labels of the corresponding activity. For the implementation, we decided to use the currentTimeMillis() [45] method of the System class provided by the Java SDK (Java Software Development Kit), which allows the current time to be obtained in milliseconds. For the correct synchronization of the two smartphones, it is necessary that their wall-clock times are set by the same NTP server, so that the wall-clock times are the same and the currentTimeMillis() method returns consistent values from the two devices.  
Concerning the identifiers, users are required to input their unique identifiers each time they start a new acquisition and labeling session. Identifiers along with timestamps are then used to store recordings as described in Section 5.  
Clearly, the two applications can run on the same smartphone, but this use case would cause incorrect labels to be assigned to the recorded data.