After the workshop: Source code and installation of the Workshop App¶
We provide the source code and a prebuilt version of the App that we used during the workshop. The App was tested on Galaxy Watch series 4 and 5. It should work with all Smartwatches running WearOS >= 3.5 (e.g., Huawei TicWatch, Pixel Watch, ...). The smartwatches we provided during the workshop were the Galaxy Watch 5 and 5 Pro, running WearOS 4 (corresponds to Android 13). Below, you can find instructions on how to install the App on the Smartwatch using Android Studio.
You can find the source code of the App here: CLAID AMLD 2024 Smartwatch App source
In case you have any questions or encounter issues with the instructions, please contact Patrick: Patrick Langer, planger@ethz.ch
Interested in using CLAID for your projects?
We greatly appreciate if you are considering using CLAID for your own projects. CLAID is made for the community and 100% open-source for non-commercial and even commercial projects under the Apache 2 license. Make sure to check out our cooperation page for more details.
1. Setting up the project in Android Studio¶
Since our App is not available on the Google Play Store, the easiest way to install the App on the Smartwatch is to build it from source and install it via Android Studio. Please follow the instructions below.
Downloading Android Studio¶
Our app project was created using Android Studio 2023.1.1 "Hedgehog". In the best case, we recommend that you use the same Version of Android Studio. Alternatively, use a newer version, but not an older version. You can download Andorid Studio "Hedgehog" using the links below:
Download and execute the installer for your operating system and follow the instructions. For Linux, simply download the tar archive and extract it. If you want another version of Android Studio, check the official archive: Android Studio Archive
Open the project in Android Studio¶
After having installed Android Studio, you need to open our project in Android Studio. Download the "CLAID AMLD 2024 Smartwatch App source" from the link above and extract it to a folder of your choice (either use git clone, or download the zip from the "Code" button). It should look as follows:
Download App project
Download the App project using the link at the beginning of this page. On github, clone the project or simply download the Zip:
Extrac the zip into a folder of your choice. The folder should contain the following files:
Next, open the project with Android Studio. Follow the instructions below:
Open project with Android Studio
Start Android Studio. You should shee the following page:
Click "open", to open an existing project.
Once the file dialog opened, select the project folder which you downloaded from github, i.e., "CLAIDWorkshopGalaxyWatchApp", and press "open":
If asked whether to trust the project, click "Trust Project":
You should now see the opened project in Android Studio:
The project is now ready for you to compile and install it on the Smartwatch. To install it, you have to pair the Smartwatch with Android Studio. Check out the instructions in the next sections.
2. Enabling developer mode on the Smartwatch¶
Before you can pair the Smatwatch with Android Studio, you need to enable the developer mode. Check out the instructions below (5 steps).
Enabling developer mode on the Smartwatch
Open the smartwatch settings (e.g., by pulling down the dropdown menu from the top). You should see the following:
Scroll down to the very end of the settings page and click "About watch":
Scroll down until you see "Software info" and open it:
Scroll down until you see "Software version". Click "Software version" repeatedly (5 - 10 times), until it says "developer mode turned on":
If you go back to the beginning of the settings page, you should now see a new entry "Developer options" below "About watch". We will use the developer options in Section 3.
3. Pairing the Smartwatch and installing the App¶
Once the developer mode is activated, you can pair the Smartwatch with Android Studio on your PC. In the following, you will need both, the Smartwatch and Android Studio. Before you continue, make sure that your PC and the Smartwatch are connected to the same Wifi. Otherwise, Android Studio will not be able to find the Smartwatch.
The first step is to enable ADB over Wifi in the developer options on the Smartwatch:
Enable ADB over Wifi
Please follow the instructions below to prepare pairing the Smartwatch with Android Studio using ADB over Wifi (8 steps, please mind the arrow on the right side to scroll to later steps):
Open the developer options on the smartwatch:
Scroll down until you see ADB debugging. Enable it:
Scroll down until you see "Debug over Wifi" and enable it:
Right below, click on "Wireless debugging"
Enable Wireless debugging:
Enable "Always allow on this network" and press "Allow"
On the same page, you should now see some new options and information. Scroll down and lcick "Pair new device":
You should see the following page. Note down the Wi-Fi pairing code.
Leave this page open from now on! Only when this page is open, you can pair the Smartwatch with Android Studio. qIf the Smartwatch goes into sleep due to inactivty, you might need to reopen this page.
Once the Smartwatch is ready, you can pair it from Android Studio:
Pairing the Smartwatch in Android Studio
Make sure Android Studio is still open, and you opened the Workshop App project as mentioned in Section 1. Follow the steps below (5 steps, please mind the arrow on the right side to scroll to later teps):
In Android Studio, open the Device Manager by clicking on the icon:
Once the Device Manager is opened, first switch to "Physical" mode (indicating you want to use the Device Manager with a real device, and not an Emulator). Next, click "Pair using Wi-Fi":
You should see the following page, showing the Smartwatch as available device. If so, click pair:
If you do not see the Smartwatch on this page, then it either is not connected to the same Wifi, or it went into sleep. In that case, you have to reopen the "Pair with device" page (see step 8 in the "Enable ADB over Wifi" section above).
Enter the pairing code which is shown on the Smartwatch. (Do not enter 153793, this is not your pairing code but just an example).
If successfull, you should see the Smartwatch in Android Studio. Note, that in your case it might not be named "Samsung SM-R910" but likely will have another name.
You can now install the App on the Smartwatch by pressing the "run" button.
Installing the App
Click the "run" button to compile and install the App. This will also automatically start the App on the Smartwatch once it was installed successfully.
Please allow up to 10 minutes for this process. Installing the App might take a long time because the App is quite big. Just keep the process running and do not interrupt it.
When completed, the App will automatically be started on the Smartwatch. You can restart it later without Android Studio by selecting it from the regular App menu. Once the App has started, it will ask you to grant necessary permissions. Please grant all permissions at all times.
Note: If you see error claid 0.0.6.6.1 has requirement protobuf==4.25.3, but you'll have protobuf 4.24.0 which is incompatible
If you see this error, you can safely ignore it :)
Alternative: Installing the App from a prebuilt APK¶
We also provide a prebuilt APK to install the app, which you can download here. However, installing this APK requires using adb manually (i.e., adb install), which involves using the command line terminal. If you are familiar with ADB from the command line, feel free to install the app directly using the APK.
FAQ:¶
Answers to some questions that we encountered before are provided below. If you have any further questions, please do not hesitate to contact us.
How is CLAID included into the Workshop App project?
For your convenience, we included a prebuilt Version of the CLAID framework in the form of an AAR (Android ARchvie) package into the Android Studio project. This way, you do not need to build CLAID from source yourself. The aar package can be found from the "app/libs" folder:
You can see how we include the package from the build.gradle file of the App:
In the future, we will host the CLAID Android AAR package on maven central.
How can we expand the Workshop App, if we build it from source?
If you build the Workshop App from source, you can add new CLAID Modules in Java and Python as you like. Adding new Modules in C++ currently would require you to build the CLAID Android package from source. We are currently expanding on our Tutorials to explain how to add new Modules to existing projects. If you have any questions in the meantime, please do not hesitate to contact us.
Where is the CLAID configuration file?
The CLAID configuration file specifies which CLAID Modules will be loaded once the App starts. During our Workshop, we did not have any Modules enabled by default, but uploaded a configuration file from the CLAID Designer. Hence, the configuration file included with the project is empty. You can, however, also change it to include some Modules by default. You can find it under "app/src/main/assets/CLAIDConfig.json":
What data can be recorded on the Samsung Galaxy Watch?
Regular sensors, some of which you may also know from Android phones, such as Gyroscope, Accelerometer, Microphone, Heart rate etc. are available on the Smartwatch as well. Additionally, Samsung provides the Samsung Priviledged Health SDK (free, but needs to be requested from Samsung), which allows to record the following data types: data available via the Samsung Priviledged Health SDK. Note, that you do not necessarily require the Samsung Health SDK for acceleration and heart rate measurements. However, using the SDK can greatly improve the battery lifetime. If you are interested in using the SDK with CLAID, please contact us. We have closed-source Modules available to use the SDK with CLAID.
What is the battery lifetime when collecting data on the Smartwatch?
This highly depends on what data you are collecting, and how you are doing it. Let's consider recording acceleration data from the Samsung Galaxy Watch 5 as an example. Here, we have 3 options:
- Recording acceleration data synchronous, keeping the CPU active the whole time: Battery lifetime roughly 4-5 hours
- Recording acceleration data asnchronous, waking up the CPU every few seconds: Battery lifetime approximately 10-15 hours (untested yet)
- Recording acceleration data using the Samsung Priviledged Health SDK (can be request from Samsung for free): Battery lifetime 3 days (our preferred solution).
The reason that data collection with the Samsung SDK is so much more efficient is due to the fact that this allows to record data via a second, low-power co-processor on the device. This allows to keep the main CPU (APU - Application Processing Unit) sleeping for the most time.
How is the stability of data collection using CLAID on the Smartwatch?
Collecting data from mobile devices can be very challenging, because those devices are simply not optimized for having long-running applications for data collection running in the background. In fact, recent Android, WearOS iOS versions actively try to limit background processes to a bare minimum to optimize for battery lifetime. However, it is still possible on Android and WearOS to disable and/or circumvent most of these restrictions. We are mainly limited by knowing how to do this, because most of these things are not well documented, if at all. With CLAID, we implement best measures (that we are aware of) to keep the OS from termination our application and having it running as long as possible. In our most recent version of CLAID, we managed to collect data without any interruption continuously for more than 1 month on the Galaxy Watch 5. During that time, our App was never terminated and never stopped running. If our App get's terminated, it usually restarts after a few seconds (and we here, too, implemented measures to make the OS restart our App as soon as possible). If advanced device management is active with CLAID, stability is improved even further and it is possible to prevent even the user from killing or uninstalling the application.