Update to Cyanogen Platform SDK



Update to Cyanogen Platform SDK

Written by Adnan Begovic, In Developer

After the announcement of the Platform SDK in May we had a healthy amount of interest from users, CyanogenMod community developers, and third party Android developers. Since then we’ve had a stable release of the first version of the SDK, created further infrastructure to enable easier accessibility and maintenance, and expanded on the features available to third party app developers.

As a recap for release notes, the CM SDK hit a stable branching point for 12.1 on June 22nd, 2015. With this stable branching we’ve introduced a prebuilts repo which can be utilized to reference prebuilt, statically linkable java archives that match the current stable release. Likewise we’ve also updated the platform sdk’s wiki to detail everything from the downloading and including the jar in your own applications to the submission and testing process revolving around the infrastructure of the project.

The current stable SDK release is titled “Apricot”, and the java archive it represents can be found at the prebuilts/current repo and it contains the capability of the CustomTile API which allows your application to post its own toggles to the QS Panel within the quick settings drawer. A usage of the CustomTile API is exemplified by one of our OSS members in recent community releases as the backing framework for Dynamic Tiles. These dynamic tiles within the OS now allow us to see things like active root sessions (per application) within our community builds.


With moving towards the next release named “Boysenberry”, we’ve spent time factoring out one of our most prominent features within the OS known as “Profiles”. The Profiles API has always been hidden away internally in the android framework in CyanogenMod, but we’ll now be looking to expose it to any third party application which may be interested. Originally contributed by community member Martin Long, the Profiles API has allowed for managing different device states and behavior based off of environmental triggers such as bluetooth connecting to a certain device or WiFi disconnecting from a specific AP. Since the Profiles API’s introduction into CyanogenMod, the OS’s settings application has been the primary management tool for any user wanting to create their own device profiles, starting today any application can become a management tool for profiles.

The Profiles API allows you to override numerous default settings for the user depending on a trigger. You can programmatically create a Profile which sets the ring mode on the device to muted, disables WiFi, and switches the devices default data connection to 3G all with a few lines of code.

An example list of override-able settings can be seen here:

  • AirplaneMode

  • Brightness level

  • Audio stream volumes

    • Alarm

    • DTMF

    • Music

    • Notification

    • Phone Ring

    • System sounds

    • Voice call

  • Ring Modes

  • Connection Settings

    • Data Connection (2g/3g/4g)

    • Bluetooth

    • GPS

    • NFC

    • Data sync

    • WiFi

  • Expanded Desktop

  • Doze mode

  • Screen Lock

These settings can quickly be overridden by utilizing the Profile class and the ProfileManager (for publishing). A quick example of creating a profile which overrides the default AirplaneMode setting and then sets the profile to active can be seen below.

private void createOverrideForAPandSetActive() {
    // Get instance of ProfileManager
    ProfileManager profileManager = ProfileManager.getInstance(this);

    // Create new Profile object with name
    Profile profile = new Profile("Custom Profile AP Override");
    // Of type Toggle
    // Where we set the default airplane mode setting to enabled
    AirplaneModeSettings airplaneModeSettings =
            new AirplaneModeSettings(
                AirplaneModeSettings.BooleanState.STATE_ENABLED, true);
    // Add the profile to the internal map
    // And set it active

We’ve also recently supplied new functionality within the CustomTile API, allowing you go as far as publishing RemoteViews as an ExpandedStyle to be shown for when the user interacts with the tile itself. A quick example that inflates a layout containing a button can be seen here:

private void createRemoteViewExpandedTile() {
    // Create a remoteviews object
    RemoteViews contentView = new RemoteViews(getPackageName(),

    // Create intent for the onclick button
    Intent cyngnIntent = new Intent(Intent.ACTION_VIEW)

    // Get a pending intent for the defined intent
    PendingIntent intent = PendingIntent.getActivity(this, 0,
            cyngnIntent, 0);

    // Set the pending intent on the button in our layout
    contentView.setOnClickPendingIntent(R.id.whats_hot_click, intent);

    // Create the new RemoteExpandedStyle
    CustomTile.RemoteExpandedStyle remoteExpandedStyle =
            new CustomTile.RemoteExpandedStyle();

    // Build the custom tile
    CustomTile customTile = new CustomTile.Builder(CMStatusBarTest.this)
        .setLabel("Remote Style From SDK")
        .setOnSettingsClickIntent(new Intent(thiis, DummyClass.class)
        .setContentDescription("Description of content for expanded style")

    // Publish the custom tile
            .publishTile(CUSTOM_TILE_SETTINGS_ID, customTile);


Currently, we’re trending towards a quarterly release cadence for our stable branching and the Profiles API will be constantly worked on and refactored alongside other interface and feature work. However, we’ve made available a bleeding edge java archive which contains access to these new features with our nightly builds on CyanogenMod. The java archive can be found within the future folder of the CMSDK prebuilts with documentation always-up-to-date which can be found on the github page for the project.

Likewise, to help decipher which APIs are available to you at any given point (if at all), we’ve created a copy of the Build API from AOSP allowing you to programmatically compare the devices current API version to see if specific features are available or not.

A simple call to retrieve the SDK constant and comparing it against the Boysenberry API level allows you to see if your application is running on a CyanogenMod device that can support the new SDK feature:

private void removeActiveProfile() {
    // Make sure we're running on BoysenBerry or higher to use Profiles API
        ProfileManager profileManager = ProfileManager.getInstance(this);
        Profile activeProfile = profileManager.getActiveProfile();
        if (activeProfile != null) {

Along with the new tooling available in the SDK, we’ve also expanded our test coverage on the overall project itself. For future submissions or contributions, in an effort to push for a more stable platform, we will be requiring that each change to existing APIs passes the current tests and that any feature or interface change comes supplemented with newer tests. To see more details on the testing package, view the package on Github.

Furthermore we will be partaking in numerous upcoming events to help further provide exposure and developer support.

Upcoming Event Lineup for 2015

August 2015 – Seattle Code Rush hosted by Facebook

August 2015 – Hack the Planet Hosted by Major League Hacking

October 2015 – Big Android BBQ


We are bound to add more events in the near future and if there are any events you would like to see us attend, please send an email to [email protected]

If you have any questions, concerns or comments, feel free to leave a reply down below or if your questions are more developer oriented, please contributed to the Google Group set up for the project.

  • John Smith

    Instead of produce stable snapshot of CM12.1 they are producing SDKs, rewriting apps, inventing wheels. Even their boss, M$ already published W10, but CM team is still chewing snots.

  • Heartbreaker

    shut up

  • King Mo

    I prefer that they are “producing SDKs, rewriting apps, inventing wheels.” All comes down to preference.

  • Damian Carusillo

    Idk, the nightlies for my phone are the most stable i’ve ever had. Clean flashed 7/15 for xt907 and haven’t done anything since. Getting full 24 hours with 2 1/2 screen on time lately! My point is, the label may say nightly, but it’s more stable than stock tbh. Of course, this is only my personal experience. cm could be picking daisies rn and i wouldn’t mind, it’s summer!