Upload
adnan-begovic
View
312
Download
3
Embed Size (px)
Citation preview
Cyanogen Inc. Proprietary & Confidential
Platform SDKby Adnan Begovic
Cyanogen Inc. Proprietary & Confidential
Background
What is CyanogenMod?
CyanogenMod (pronounced /saɪ.ˈæn.oʊ.ˌdʒɛn.mɒd/), usually abbreviated to CM, is an open-source operating system for smartphones and tablet computers, based on the Android mobile platform. It is developed as free and open source software based on the official releases of Android by Google, with added original and third-party code. It is based on a rolling release development model.
Cyanogen Inc. Proprietary & Confidential
Background
CyanogenMod User Base:● 50+ million users● Users in 190+ different countries● Localized to 50+ languages via automated crowdin
system
Cyanogen Inc. Proprietary & Confidential
Background
CyanogenMod Developer base:● Numerous active core developers/maintainers
○ Maintain devices○ Maintain documentation for features and device specs○ Maintain and manage their own user bases○ Maintain crowdin○ File and resolve bugs reported by community users
● ~163 devices supported● Receive a substantial amount of OSS contributions
from outside sources.
Cyanogen Inc. Proprietary & Confidential
Developer Base
Cyanogen Inc. Proprietary & Confidential
Crowdsourcing Android Development
Cyanogen Inc. Proprietary & Confidential
An Example Community Contribution
Cyanogen Inc. Proprietary & Confidential
Topics
● OS development is intimidating● Treehacks Hackathon learnings● Cyanogen Platform
○ Infrastructure○ Framework library○ SDK○ Resource Package
● Using the SDK (QST examples)● Contributing API’s
Cyanogen Inc. Proprietary & Confidential
Contributing to an OS
The Treehacks experience
Treehacks:● 500+ person hackathon with students from all over the country.● Workshops to get a meaningful contribution to the OSS project
CyanogenMod.● Open to Stanford students, external students, and outside developers.
Cyanogen Inc. Proprietary & Confidential
Treehacks Experience
Winning Project: CyanTranslate
Using CyanogenMod, the winners modified the Android operating system and created several new built-in features for manipulating text. By highlighting text and hitting a button, the user can take advantage of these features. The new features include:
Automatic translation between languages
● One-tap Google search● UrbanDictionary definition lookup● Book information lookup
Cyanogen Inc. Proprietary & Confidential
Treehacks Experience
Cyanogen Inc. Proprietary & Confidential
Treehacks FeedbackPositives Negatives
Open platform High ramp up time
Good infrastructure● Gerrit Code Review● Github mirroring
Massive code base● ~1281 github repos● 100+ android packages● 25+ Gb repo size
Build environment documentation● https://wiki.cyanogenmod.org
High barrier of entry in understanding Android’s core implementations
Cyanogen Inc. Proprietary & Confidential
Treehacks Experience
- How to decrease the barrier to entry?
- How to extend the CM experience for 3rd party developers?
Cyanogen Inc. Proprietary & Confidential
The Cyanogen Platform
Cyanogen Inc. Proprietary & Confidential
Cyanogen Platform
The new, more approachable, infrastructure:● CyanogenMod Platform Library● CyanogenMod Resource Package● CyanogenMod Platform SDK
Application
Cyanogen Platform SDK
Platform API Core
Resource Package
Android OS
Cyanogen Inc. Proprietary & Confidential
Cyanogen Platform Library
Framework library similar to Android’s Framework JAR.
● Contains System Binder Services that get spun up and managed by Android’s SystemServer.
● Contains the implementation, state management, and persisting of data for a specific API feature.
● Leveraging Android’s powerful IPC framework for interaction between an application and the system process.
Further information: Understanding the Structure
Cyanogen Inc. Proprietary & Confidential
Cyanogen Resource Package
Contains exported resources and CyanogenMod specific permissions to be leveraged by the Application and framework.
● ex: ○ cyanogenmod.permission.PUBLISH_CUSTOM_TILE○ cyanogenmod_system_label
Cyanogen Inc. Proprietary & Confidential
Cyanogen Platform SDK
A library that can be included in your application to interact with CM specific binder services to gain extra functionality.
● Provides objects, object builder’s, helper methods, and simple interfaces to push or receive data from the platform library.
Cyanogen Inc. Proprietary & Confidential
Using the SDK
Custom Quick Tiles API Example:● Allows your application to publish a Quick Tile to be hosted in the QS
Panel.○ Patterns similar to Notification and NotificationManager
Cyanogen Inc. Proprietary & Confidential
Exploration for an API
Bike O’Clock● Using Quick Settings Tiles to surface commonly
used actions.
Cyanogen Inc. Proprietary & Confidential
Using the SDK
Creating a CustomTile:
CustomTile customTile = new CustomTile.Builder(mContext)
.setLabel("custom label")
.setContentDescription("custom description")
.setOnClickIntent(pendingIntent)
.setOnSettingsClickIntent(intent)
.setOnClickUri(Uri.parse("custom uri"))
.setIcon(R.drawable.ic_launcher)
.build();
Cyanogen Inc. Proprietary & Confidential
Using the SDK
Cyanogen Inc. Proprietary & Confidential
Using the SDK
Publishing: CMStatusBarManager.getInstance(this)
.publishTile(CUSTOM_TILE_ID, mCustomTile);
Removing: CMStatusBarManager.getInstance(this)
.removeTile(CUSTOM_TILE_ID, mCustomTile);
Requires: <uses-permission android:name="cyanogenmod.permission.PUBLISH_CUSTOM_TILE" />
Cyanogen Inc. Proprietary & Confidential
Contributing
Cyanogen Inc. Proprietary & Confidential
Making a change
repo init -u git://github.com/CyanogenMod/android.git -b cm-12.1
repo sync
repo start changes vendor/cmsdk
https://www.github.com/CyanogenMod/cm_platform_sdk
Cyanogen Inc. Proprietary & Confidential
Contributing
Application
Cyanogen Platform SDK
Platform API Core
Community API Core
gerrit (code review, unit tests)
Interface Changes
Unit Tests
SDK Methods
CTS
SDK methods added to Platform SDK project
API added along side core
Interfaces added to nightly builds
API Council (Change Control Board)API Check-API
Android OS
Cyanogen Inc. Proprietary & Confidential
Contributing
Documentation generation is automated!● make org.cyanogenmod.platform.sdk-docs
● Published directly from gerrit merge to github pages
Docs: http://cyanogenmod.github.io/cm_platform_sdk/reference/packages.html
Cyanogen Inc. Proprietary & Confidential
Contribute New APIs & Write More Functional Apps
Cyanogen Inc. Proprietary & Confidential
Questions?
Join the G+ Community: http://bit.ly/1FC6lJI
Cyanogen Inc. Proprietary & Confidential
Appendix for QA
Cyanogen Inc. Proprietary & Confidential
Security
vendor/cm/overlay <!-- Defines external services to be started by the SystemServer at boot. The service itself
should publish as a binder services in its onStart -->
<string-array name="config_externalCMServices">
<item>org.cyanogenmod.platform.internal.CMStatusBarManagerService</item>
</string-array>
vendor/cm/sepolicy/servicecontexts cmstatusbar u:object_r:system_server_service:s0
Cyanogen Inc. Proprietary & Confidential
Security
Selinux service_contexts● service_contexts is used for translating service names into selinux labels.● MAC check to the svc_can_register function in
service_manager.
https://android.googlesource.com/platform/frameworks/native/+/69154df