Skip to content
CARP Docs
Ask AISystemLightDark
On this page

Communication Sampling Package

Collect phone calls, text messages and calendar events in a CARP Mobile Sensing study.

Copy MarkdownOpen inOpen in GitHubView as MarkdownOpen in Scira AIOpen in ChatGPTOpen in ClaudeOpen in Cursor

carp_communication_package adds the phone's call log, its text messages (SMS) and its calendar events to a CARP Mobile Sensing (CAMS) study. Use it in studies of social behavior and daily routines, such as how often a participant calls, texts or has appointments.

Calls and text messages come from Android only, because iOS gives apps no access to them. Calendar events come from Android and iOS. The package reads the call log with the call_e_log plugin, text messages with another_telephony and calendars with device_calendar_plus.

pub.devAPI referenceGitHub

Google Play restrictions

Google Play treats the SMS and Call Log permissions as restricted: only apps with an approved use can request them. Research is not one of the exceptions, and an app that requests them can be rejected. To publish an app that collects only the calendar, see Google Play policy.

Features

Phone calls

The calls in the call log since the last collection: call type, duration, number and contact name. Android only.

Text messages

The messages in the inbox and the sent folder, with the other party's number, the text and the delivery status. Android only.

Calendar

The events in all calendars on the phone, including recurring and all-day events. Android and iOS.

Privacy

With the default privacy schema in the protocol, phone numbers, contact names, message texts and event titles are stored as SHA-1 hashes.

Measure types

Measure typeDataAndroidiOS
dk.cachet.carp.phonelogThe calls in the call log since the last runYesNo
dk.cachet.carp.textmessagelogAll messages in the inbox and the sent folderYesNo
dk.cachet.carp.textmessageEach text message as it arrivesYesNo
dk.cachet.carp.calendarThe calendar events since the last runYesYes

dk.cachet.carp.textmessage is event-based; the other three are one-time measures that collect once each time their task is triggered. For the difference, see Event-based and one-time measures.

Known issues in version 2.1.0

The call and message times in the phone log and the text message log fall in January 1970, and TEXT_MESSAGE adds no measurements. See Calls and text messages for how to recover the times.

Requirements

ComponentRequirement
Dart SDK3.10 or later
Flutter3.38.1 or later
carp_mobile_sensing2.2.0 or later
AndroidAPI level 24 (Android 7.0) or later
iOS15.0 or later (calendar only)

How it works

Adding the package to a study takes three steps:

  1. Register the package

    Registering CommunicationSamplingPackage makes the four measure types known to CAMS and adds their privacy transformers to the default privacy schema.

  2. Add the measures to a protocol

    The measures run on the phone, the protocol's primary device. Trigger the one-time measures repeatedly, for example every few hours.

  3. Deploy the protocol

    CAMS asks the participant for the phone, SMS and calendar permissions that the measures need, and then collects data each time a trigger fires.

This protocol collects the calendar every 3 hours and hashes event titles and descriptions:

CarpMobileSensing.ensureInitialized();
SamplingPackageRegistry().register(CommunicationSamplingPackage());

final protocol = SmartphoneStudyProtocol(
  ownerId: 'owner@example.com',
  name: 'Calendar events',
  dataEndPoint: SQLiteDataEndPoint(),
  privacySchemaName: PrivacySchema.DEFAULT,
);
final phone = Smartphone();
protocol.addPrimaryDevice(phone);

protocol.addTaskControl(
  PeriodicTrigger(period: const Duration(hours: 3)),
  BackgroundTask(
    measures: [Measure(type: CommunicationSamplingPackage.CALENDAR)],
  ),
  phone,
);

Next steps

Installation

Add the package to a CAMS app and configure Android and iOS.

Quickstart

Build an app that collects calls, messages and calendar events.

Calls and text messages

What the call and message measures collect, and their data.

Privacy

Hash phone numbers, message texts and event titles before storage.

Quick links

Page · DocumentationCARP DocumentationPage · DocumentationIntroductionPage · DocumentationQuickstartPage · DocumentationTerminologyPage · DocumentationArchitecture