Passive App Plugin Development Case Study

This guide will take you through the development of a new passive app plugin with examples of how we developed the Faros plugin.

Initialise plugin repository

To get started, clone the Template plugin repository.

The following steps describe how to set up your own device repository by refactoring the template. For renaming the package and classes (steps 3 and 4), use the refactor functionality of Android Studio (shift-F6). This also renames all references to the packages and classes.

  1. Change directory name (radar-android-template => radar-android-faros)
  2. Open the project in Android Studio.
  3. Rename the package (org.radarbase.passive.template => org.radarbase.passive.bittium).
  4. Rename the following classes. e.g.:
    • TemplateDeviceManager => FarosDeviceManager
    • TemplateDeviceServiceProvider => FarosProvider
    • TemplateDeviceService => FarosService
    • TemplateDeviceStatus => FarosDeviceStatus
  5. Edit build.gradle and input the configuration parameters

    ......
    //---------------------------------------------------------------------------//
    // Configuration                                                             //
    //---------------------------------------------------------------------------//
    
    group = 'org.radarbase'
    ext.moduleName = 'radar-android-faros'
    ext.description = 'Faros plugin for RADAR passive remote monitoring app'
    ext.githubRepoName = 'RADAR-BASE/radar-android-faros'
    .....
  6. Edit strings.xml to give your device a label and description (used in the DeviceServiceProvider)

    <resources>
        <string name="farosLabel">Faros</string>
        <string name="farosDescription">Collects data from Faros 90/180/360. The connection is made over Bluetooth using the location permission. Location
            information is not stored.
        </string>
    </resources>
  7. Edit AndroidManifest.xml to put in the references of package and service. 

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="org.radarbase.passive.bittium" >
        <application android:allowBackup="true">
            <service android:name=".FarosService"/>
        </application>
    </manifest>
    • package refers to the name given to the package (step 3)
    • service android:name refers to the DeviceService class (step 4)

When you have completed the refactoring, your project should look like this in Android Studio. Check if everything is renamed properly by building the app with Gradle (./gradlew build).

Develop the plugin

The plugin contains at least four classes, that each extend base classes from the RADAR-Android-Commons repository.

We explain the purpose of each class below.

DeviceManager

The heart and lungs of the plugin. The connection and data handling logic should be placed here.

DeviceService

Creates the DeviceManager.

DeviceServiceProvider

The provider talks to the main pRMT app and contains the device configuration parameters.

DeviceStatus

Reports the device values to the pRMT app. For example the battery level should be configured here.

Existing Plugins

As an example, you could look at the plugins that have already been developed.