To handle this, plugins have a couple lines of defense to ensure these don’t create any security holes.
Whenever loading a code from another APK into a privileged process like SysUI, there are serious security concerns to be addressed. This figure shows an overview of how the plugin compiling/loading flow works. The plugins are compiled against a set of relatively stable (and version tagged) interfaces, that the implementations are provided by SysUI. Plugins are APKs that contain code and resources that can be dynamically loaded into SystemUI. This is required to ensure you don’t actually include the plugin library in your plugin APK. Once it is included change its scope from Compile to Provided in the project structure (you may need to build once before changing to provided).
Once you have the jar you are going to compile against, you need to include it in your android studio project as a file dependency. $ frameworks/base/packages/SystemUI/plugin/update_plugin_lib.sh However if you recently changed one of the plugin interfaces, you might want to build an updated version, you can use the following script to do so. Generally you can grab a recent plugin lib from jmonk’s experimental directory. To be able to implement a plugin, you’ll need a jar file that contains the plugin classes for compilation. class ) public interface MyPlugin extends Plugin Compiling against Plugin APIs They are tagged using annotations like the following. If a plugin makes use of the other versioned interface, they can use DependsOn to indicate their dependence. All classes that are in the plugin library should be tagged with a version, they should also be tagged with an action if they are the root interface for the Plugin. Incompatible changes are changes to the signature of any of the interface methods, or the addition of a new method that doesn’t have a default implementation. Every time the interface changes in an incompatible way, the version should be incremented. The most important part of interfaces is the version included in them. The main interface (entry point) for the plugin should extend the interface Plugin so that you can listen for it. They should be placed in the plugin library, under or sub-packages. This interface should be relatively stable so that many different plugins will work across multiple different builds.Īll interfaces need to be independent and not reference classes from SysUI. The first step of adding a plugin hook to SysUI is to define the interface layer between the plugin and SysUI. Adding Plugin HooksĮxisting plugin hooks can be found here. You can distribute early prototype directly to those that need to see it either through drive or email, and only show it to dogfooders when ready.
Plugins keep the experimental and turbulent code outside of master and only on the devices which need to use the prototype. This is done by creating a basic set of interfaces that the plugins can expect to be in SysUI, then the portion of code controlled by the interface can be iterated on faster than currently. Plugins are APKs that will be installable only on Build.IS_DEBUGGABLE (dogfood) builds, that can change the behavior of SystemUI at runtime. Plugins provide an easy way to rapidly prototype SystemUI features.