• radar-base@kcl.ac.uk | radar-base@thehyve.nl
  • KCL +44 (0)20 7848 0924 | The Hyve +31 (0)30 700 9713

Blog

KCL internship: Adding support for Google Sleep, Activity, and Places API in RADAR-Base pRMT application
Development, News

KCL internship: Adding support for Google Sleep, Activity, and Places API in RADAR-Base pRMT application

Introduction:


Hi, Aditya here. This year, I worked as an intern at RADAR-base. My work involved refining the pRMT functionality to monitor users’ sleep and activity data and collecting user location information by extending pRMT support for new plugins.

The RADAR-base Passive Mobile App (pRMT) is the hub for collecting background sensor data and provides data streams from both on-phone sensors and the capability to collect data from a number of wearable devices. This application depends on plugins to collect information.

It already supports many plugins that provide various data fetched from wearables and smartphones. It would be nice if it also supported tracking the data Sleep, Activity, and Location data from smartphones. This is where Google API integration helped to extend the pRMT functionality.

Tasks:

  1. Extend pRMT support for Google Sleep API data as a separate plugin.
  2. Extend pRMT support for Google Activity recognition data as a separate plugin.

In addition, I have successfully incorporated support for the Google Places API into RADAR-pRMT.

These tasks have been listed as Idea 6 in the finalized project ideas for GSOC 2023.

Plugins implemented:

Pull Requests:

The major pull requests dedicated to these tasks are:

Below, you’ll find additional in-depth details regarding the three recently introduced plugins:

1. Google Sleep:

Google Sleep

The Google Sleep plugin extracts the user’s sleep data from the Google Sleep API. Sleep data is presented in the format of SleepSegmentEvents and SleepClassifyEvents. The outcome of sleep detection relies on sampled device motion and ambient light measurements from the previous day.

• SleepSegmentEvent:

AVRO Schema: sleep_segment_event

Collects the user’s sleep start time, end time, and Sleep Classification Status.
Sleep Classification Status: A status code indicating whether the system successfully detected sleep and gathered sleep data. The possible values are:
SUCCESSFUL
MISSING_DATA
NOT_DETECTED


If the status is SUCCESSFUL or MISSING_DATA, the time returned corresponds to when the system detects that the user begins sleeping and when the user stops sleeping and wakes up

• SleepClassificationEvent:

AVRO SCHEMA: sleep_classify_event

This represents a sleep classification event, including the classification timestamp, sleep confidence, and supporting data such as device motion and ambient light level. Classification events are reported at regular intervals.
Light: Indicates the brightness of the space around the device, based on the device’s ambient light sensor readings.
Motion: Represents the amount of device motion, based on the device’s accelerometer readings.
SleepConfidence: This value returns the sleep confidence score between 0 and 1.

2. Google Activity:

Google Activity

The Google Activity plugin retrieves the user’s sleep data from the Google Activity Recognition API.
This plugin collects the data in the form of google_activity_transition_event.

• GoogleActivityTransitionEvent:

AVRO SCHEMA: google_activity_transition_event

Activity Type: The detected activity of the device. This includes:
IN_VEHICLE
ON_BICYCLE
ON_FOOT
RUNNING
STILL
WALKING

Transition Type: The transition associated with an activity whether it is ENTER or EXIT

3. Google Places:

Google Places

pRMT already supports phone_relative_location tracking, but this plugin was added to extend that functionality by collecting information about the types of places where the device is present and other supporting information.

• GooglePlacesInfo:

AVRO SCHEMA: google_places_info

This plugin actively collects information about the locations where the user’s device was last known to be present and indicates the relative likelihood for each location.
This plugin captures the subsequent data:
Places Types: Type of the place from the 139 predefined types where the user’s device is last known to be located.
City: The city provided corresponds to the present location of the user’s device.
State: The state indicated corresponds to the ongoing location of the user’s device.
Country: The country identified corresponds to the existing location of the user’s device.
Place Id: An exclusive identifier is allocated to each place within the Google Places database.
Place Likelihood: The likelihood assigned provides a relative probability of the place being the most suitable match among the compilation of returned locations.

Two situations collect places data:

  1. Every 600 seconds.
  2. When the device’s location changes.

The PhoneLocationManager broadcasts the location update whenever the device’s location changes.

NOTE: The Google Places plugin refrains from automatically retrieving data fields such as City, State, Country, and PlaceId by default, as part of its commitment to respecting user privacy. To access these specific data, you must explicitly retrieve them, which involves updating the Firebase Remote Config parameters.

My internship experience at RADAR-base:

I am delighted to share my experience during my RADAR-base internship. Thanks to the collaborative efforts of the team and the invaluable mentorship provided by Yatharth Ranjan, Joris Borgdorff, and Pauline Conde, the project was a resounding success.
I particularly appreciate the insightful code reviews I received, and I would like to extend my special thanks to Amos Folarin for providing me with this opportunity.
Every Wednesday, I eagerly look forward to the radar-interns meeting, which infuses excitement and enjoyment into my week. Working alongside such an exceptional team has been an extraordinary experience.
Working with such awesome developers greatly enhanced my learning and growth. This enriching experience will undoubtedly benefit my future career.
I’m grateful to RADAR-base for this incredible opportunity.