The internet of things (IoT) is growing at an incredible pace, but something very dangerous is lurking behind billions of smart devices…. unsecured software! At BlackBerry, we have been working tirelessly to save the world from this emerging threat, and to make BlackBerry Dynamics and BlackBerry Unified Endpoint Manager (UEM) the premier solution for IoT security and device management.
How can developers secure their IoT applications?
Today, I’ll talk to you about how you can use BlackBerry Dynamics to secure your IoT application. Using our tools, you will be able to assign policies to your app, track app analytics, preconfigure endpoints with app config, and more! To do this, we will use the Android Things framework, which allows you to use the core Android framework to build software for your IoT hardware. In this example, I installed Android Things onto a Raspberry Pi, but you can use any board compatible with Android Things, plus whatever sensors and accessories you want to play with.
What You Need
To get started, you will need to meet the following prerequisites:
- Set up your Raspberry Pi (or another board compatible with Android Things)
- Download and Install Android Studio
- Download and Install the BlackBerry Dynamics SDK for Android
- Create a new Android Things project (or use a sample project) in Android Studio
- (Optional) Set up a BlackBerry UEM or BlackBerry UEM Cloud server. You can get a trial license
Securing Your IoT Application
Developers familiar with our SDK will recognize how easy it is to get started with our development tools using the steps below:
- Open your project and import the ‘gd’ and ‘gd_backup_support’ libraries from the BlackBerry Dynamics SDK
- In Android Studio, click File -> New -> Import Module, and then enter the local path to the ‘gd’ folder found in the BlackBerry Dynamics SDK (…/BlackBerry_Dynamics_for_Android/sdk/libs/handheld/gd)
- Repeat the above step for the ‘gd_backup_support’ folder
(…/BlackBerry_Dynamics_for_Android/sdk/libs/handheld/gd_backup_support)
- Add the modules that you just imported as dependencies to this project by going to File -> Project Structure and then clicking the ‘Dependencies’ tab for your app Module. Click the ‘+’ button to add the gd and gd_backup_support as module dependencies.
- If you have declared support for your application to participate in the backup and restore infrastructure, i.e. you’ve set the android:allowBackup=”true” attribute in your AndroidManifest.xml file, then include the following line in your manifest under the <application> tag::
<!-- points to rules from support lib for Auto Backup --> android:fullBackupContent="@xml/gd_backup_scheme">
- If you have declared support for right-to-left (RTL) layouts, i.e. set the android:supportsRtl=”true” attribute in your AndroidManifest.xml file, then include the following line in your manifest under the <application> tag:
<!-- keep higher priority manifest value --> tools:replace=”android:supportsRtl”
- Create a new Assets folder in your project, and then create a file called ‘settings.json’ within this folder. You can do this by right clicking your app, then selecting New -> Folder -> Assets folder. After the folder is created, right click it and select New -> File -> and then name the file ‘settings.json’. ‘
- Enter the following information in the newly created settings.json file:
{ "GDLibraryMode": "GDEnterprise", "GDApplicationID": "com.blackberry.things", // "GDApplicationVersion": "1.0.0.0" }
*Note that your GDApplicationID must be unique to your application. It is used when registering your app on the BlackBerry UEM console.
- Add the v7 appcompat library to your project to allow the BlackBerry Dynamics authentication screen to inflate when your app runs. To do this, simply add the following line to your app’s build.gradle file under ‘dependencies’:
implementation 'com.android.support:appcompat-v7:26+'
- Implement the GDStateListener in your launch activity (flagged in the manifest with the IOT_LAUNCHER attribute) and implement the methods for this interface (you can leave them blank for now, as seen below). Finally, call GDAndroid.getInstance.activityInit(this) from your onCreate() method.