Written by: Russell Borja
The Secure Work Space (SWS) for BlackBerry Enterprise Service 12 (BES12) provides an ideal solution for compartmentalizing applications between work and personal usage. In addition to the integrated enterprise-level applications such as email, calendar, and web browser, the user can also install third-party applications through secure wrapping. The applications installed on the work space contain data that cannot be accessed on the personal side, which is useful for keeping client information confidential and secure.
One core application that is missing from the packaged suite is a native camera app that is dedicated to the work space. With built-in cameras on all modern day smartphones, it is easy for customers to send digital media amongst one another whether it’s for sharing documents or previewing prototypes. Regardless, from a security standpoint many companies still experience leaks of confidential information through media transfer. This is why it is paramount to have a native camera application in the Secure Work Space which will encrypt captured files and render them inaccessible from the personal side, minimizing the risk of tampering and misuse.
Many third-party camera apps will work on the Secure Work Space as long as their APK’s (Android application package) are properly signed and wrapped. However, some of them are incompatible with the SWS encryption and will merely save a copy of the media files on the personal side. Others will simply fail at attaching the media files onto the work space and basically double as a secondary personal camera. In order to leverage the advantages of the SWS without the advertisements and unnecessary features that often come with third-party apps, it is best to create a custom camera app from the ground up. Fortunately, the Android Developer pages contain comprehensive demos and detailed instructions to build some of the basic components of the platform, including the camera. It is important to develop a customized camera feature rather than invoke the native camera app as the latter already resides in the personal side. Creating the camera app is simply a matter of making a few small changes to Android’s existing sample code and wrapping it for the SWS.
Building a Secure Camera App
Thanks to Android’s open-source agreement, we do not need to reinvent the wheel as there are already samples we can use to build the camera app.
1. Open Android Studio (recommended) or Eclipse and create a new Android project.
2. In the AndroidManifest.xml, add the following tags under <manifest> to ensure your application has the proper hardware permissions:
<uses-feature android:name=”android.hardware.camera” />
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />
<uses-permission android:name=”android.permission.CAMERA” />
<uses-feature android:name=”android.hardware.camera.autofocus” />
3. Visit the Camera Developer guide and copy and paste the sample code under Building a Camera App subsection in your MainActivity.java file.
4. Follow the detailed instructions on creating a preview class, building a preview layout, and finally capturing and saving the files on the device.
- When it comes to identifying where the captured files should reside, make sure that the variable mediaStorageDir points to DIRECTORY_DCIM, the default location for all Digital Camera Images.
5. Create an XML layout for the camera preview by copying the layout code provided in the sample. This will display the user interface controls for taking a picture.
6. Remember to release the camera every time it is not being used in the onPause() method in order for other applications to invoke the camera in the future.
Broadcasting Media Intent
A very important feature that allows this application to be compatible with the Secure Work Space is its ability to display the captured images in the Shared Media Folder. To enable this feature, one must broadcast the ACTION_MEDIA_SCANNER_SCAN_FILE intent. Simply add the following function to the MainActivity class and call it from the PictureCallback:
After building this app and retrieving the signed APK file, it can then be wrapped and deployed from the BES to be used for the Secure Work Space. You should now be able to take photos in the work side and share them securely without the images being visible on the personal side. For the complete Android project, please refer to the Secure-Work-Space subfolder on BlackBerry’s Github.