Sunday 3 May 2015

Inside CyanogenMod

Inside CyanogenMod

Root your way inside the most popular Android hack with Mayank Sharma.

The CyanogenMod project is the quintessential open source success story. It's got open source code, an individual hacker burning the midnight oil, and community endorsement that led the project to the big leagues. From a forum board to the executive board, the CyanogenMod project has come a long way riding on the shoulder of its community of users and developers.

With over 12 million active users as of June 2014, CyanogenMod is the most popular free and open source aftermarket firmware for Android smartphones and tablets. The tricked-out version of Android replaces the stock OS that ships with your device and essentially gives you more control over it.


CyanogenMod is built upon the open source release of Google's Android, known as the Android Open Source Project (AOSP). In 2008, developers found a way to gain root access to the HTC Dream G1, which shipped with Android 1.0. This allowed those with the technical know-how to replace the stock Android with a customised flavour of their own built atop the AOSR This development spawned a community of modders who showcased their mods at places like the XDA Developers forum. Steve Kondik was one such developer. He called himself Cyanogen online, and therefore named his creation CyanogenMod.

CyanogenMod quickly grew in popularity and started to attract modifications and improvements from other developers as well. Kondik rallied a bunch of active contributors into the CyanogenMod Core Team to accept code based on the feedback from their community of users.

Anatomy of a hack


CyanogenMod officially supports over 200 devices and there are experimental builds for a lot more, which is an incredible achievement once you take into account the elaborate process it takes to get CyanogenMod to run on a device. Add to this the fact that the developers have to create a different version of CyanogenMod for each new Android release, and that each device has different hardware components, and you have some idea of the scale of the job.

To keep up with the proliferation of Android devices, the CyanogenMod team is divided into various device maintainers, who manage the code for different devices and make sure the device they're in charge of runs CyanogenMod properly. One such device manager is Chirayu Desai, who is currently in the last year of high school. The young padawan is in-charge of "almost all' supported Sony devices. However, he got his start with another device. Recounting the start of his association with the project, which dates back to before Android 4.0 Ice Cream Sandwich (ICS) was released in 2011, Desai says "I had a Samsung Galaxy Tab, which was one of the first Android tablets, and it shipped with Android 2.3, which was not something you would like using on a tablet."

Desai almost immediately swapped out the stock Android and replaced it with CyanogenMod: "When ICS was announced, I collaborated with some other developers, and seeing that it was working on two other very similar devices (the Nexus S and Galaxy S) we wanted to get it working on the Tab too."

That’s when he started porting the current release of CyanogenMod: "When it was in a decent state, I contacted the CyanogenMod developers and was able to get it officially supported."

We asked Desai to outline the process a developer needs to go through to port CyanogenMod to a device: ‘One of the first things that you need to find out is what hardware the device has, and what information can you get about that - what System-on-Chip (SoC), which sensors, etc. Then you need to see what kind of source code is available from the concerned OEMs, and for devices similar to the one you are working on, which is to say, other devices that have the same or a very similar SoC. Then you put everything together, adapt it for the Android version you're porting, and for standard interfaces as needed.” Since the project supports a lot of devices and many different hardware platforms and shares code between them, Desai adds that the developers also "have to keep in mind that if our device needs a 'hack' somewhere it should not affect the others. Every release breaks things in ways that can be fixed, worked around, or need a hack - it varies a lot by device."

The empire strikes back


CyanogenMod owes its existence to the open source vanilla Android, but Google adds a different flavour to the mix. CyanogenMod initially bundled Google's proprietary apps, Gmail, Calendar, and others along with its software, but Google intervened with a cease-and-desist letter and prevented the project from distributing its mod until the project stopped including Google's apps in CyanogenMod.

The two also had an exchange over CyanogenMod’s installer. The project pulled it voluntarily from the Play Store after Google communicated that it was at odds with its terms, since it encouraged users to void their warranty. Despite these run-ins, many mobile commentators have said that Google has borrowed several features from its popular replacement.

“Google's methodology seems to be re-imagining community-driven features, much like we re-imagine their Android updates", said Steve Kondik in an email exchange with us. 'One of the earliest examples of this was incognito mode on the Android browser, prior to Chrome for Android. The implementations were different, but the idea - privacy on mobile browsing -was the same."

Another feature Kondik points out is the Android Quick Shortcuts: "Not only did we have a working implementation before Google, called Notification Power Widgets, but even after Google implemented their own system in Android Jellybean, a single tap in their implementation would launch the Wi-Fi settings (for example), whereas in CyanogenMod, that same tap would immediately toggle Wi-Fi on or off. As we look at Google's implementation in Android Lollipop, you can see that they've adopted the same behavioural change." In the end, he sums up, 'it's always nice to see this cycle of changes between community projects and Google alike."

CyanogenMod's co-founder and CTO Steve Kondik and CEO Kirt McMaster

An Inc.ling


One of the core issues that the project's leadership has been working to address is to simplify the process of getting their mod onto a device. Given that the process of replacing the firmware on a device requires considerable technical expertise, the project is doing well to have won such a large userbase. Also, the CyanogenMod project has always been vocal about its ambition of being more than just a software mod. In a Wired article in 2011, Chris Soyers, who has been associated with the project for a long time, said that one of the project’s biggest dreams is to see a phone ship with CyanogenMod on it.

In fact, these were the two main catalysts that propelled Kondik to act on his plans to commercialise CyanogenMod. Cyanogen Inc. was announced in September 2013 and managed to raise $7 million (about £4.6 million) from venture capitalists and another $23 million (about £15 million) later that year. Kondik says that having a company with full-time staff and dedicated resources enables them to make bets on larger projects, particularly those that would take too high of an investment from the community alone, or would be a challenge to coordinate.

'The enhanced theming capabilities that we bought last year and the Encrypted Text Messaging (partnering with Open Whisper Systems) the year before are both examples of these larger long-term and impactful projects,’ he illustrates. Furthermore, he adds that since the code is open source, these new additions are not only beneficial to the company but to the community as well.

Having a company also allows them to impress upon device vendors their approach to total access to the hardware "without voiding the warranty and preventing support for hardware issues," explains Kondik, adding that the community will "not only benefit from the tighter integration that such partnerships naturally bring, but also gives them peace of mind and a larger value when they begin tinkering with their devices."

Soon after the company's formation there were concerns among the CyanogenMod community following the announcement that it plans to adopt closed-source licensing for some of the future developments. Kondik responded to the concerns and made it clear that the company had no plans to close-source any of the existing stuff. He also reaffirmed their commitment to the community and explain how the dual licensing model will offer "a stronger degree of protection for contributors'' and also gives the company a competitive edge.

One such closed-sourced product is the CyanogenMod installer. It's an easy-to-use app that lets you install CyanogenMod onto your device in a couple of simple steps. Kondik explains why the installer is currently only available for Windows and Mac OS X: “When we were building the installer we took a look at our user demographic from our IRC support, user forums and community website. By and large those who were hitting obstacles during a manual command-line install came from the Windows and Mac families - and as such, we focussed our first releases of the installer to those platforms." That said, Kondik adds that while a Linux version of the installer is on their roadmap, "given the task of deciding where to use our resources, the other two platforms carry priority."

Since the formation of the for-profit enterprise, instead of one product, the team now works on two release branches - CyanogenMod and Cyanogen OS. CyanogenMod is the open-source, community-driven Android OS that's supported by Cyanogen Inc. On the other hand, Cyanogen OS is the commercially-distributed operating system that comes with proprietary features, services and enhancements. Cyanogen OS is what you get when you buy a device that ships with CyanogenMod pre-installed.

Going places


As CyanogenMod enters its second year of existence, the company has inked deals with a bunch of device vendors who are already shipping smartphones preinstalled with Cyanogen OS all around the world. Their latest handset, the Micromax Yureka Yu, has hit a chord in priceconscious markets like India, and Google is also aggressively targeting India with its low-cost Android One devices, and interestingly these devices are now officially supported by the CyanogenMod project.

So can we expect a Cyanogen-branded phone in the near future? ‘We are very aware of our strengths, and currently that is in the scope of software and web services around them,’ explains Kondik adding that "the hardware manufacturing market is a game of volumes and margins, and not something we’d jump into without a team dedicated to figuring out all the intricacies and hurdles around it.’

For now, the team plans to stick to software and relegate the hardware bits to experienced hardware partners. 'We want to see CyanogenMod, and our commercial offering Cyanogen OS, perceived as a premium OS, a must-have, instead of the underdog perception that followed coming from a community project. [We're] continuing to push forward what makes CyanogenMod so great - that fearlessness to innovate and improve upon the Android experience”.