58 lines
1.3 KiB
Makefile
Raw Normal View History

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SystemUI-proto
LOCAL_SRC_FILES := $(call all-proto-files-under,src)
LOCAL_PROTOC_OPTIMIZE_TYPE := nano
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors
include $(BUILD_STATIC_JAVA_LIBRARY)
# ------------------
include $(CLEAR_VARS)
LOCAL_USE_AAPT2 := true
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, src)
LOCAL_STATIC_ANDROID_LIBRARIES := \
Plugins for sysui Why this is safe: - To never ever be used in production code, simply for rapid prototyping (multiple checks in place) - Guarded by signature level permission checks, so only matching signed code will be used - Any crashing plugins are auto-disabled and sysui is allowed to continue in peace Now on to what it actually does. Plugins are separate APKs that are expected to implement interfaces provided by SystemUI. Their code is dynamically loaded into the SysUI process which can allow for multiple prototypes to be created and run on a single android build. ------- PluginLifecycle: plugin.onCreate(Context sysuiContext, Context pluginContext); --- This is always called before any other calls pluginListener.onPluginConnected(Plugin p); --- This lets the plugin hook know that a plugin is now connected. ** Any other calls back and forth between sysui/plugin ** pluginListener.onPluginDisconnected(Plugin p); --- Lets the plugin hook know that it should stop interacting with this plugin and drop all references to it. plugin.onDestroy(); --- Finally the plugin can perform any cleanup to ensure that its not leaking into the SysUI process. Any time a plugin APK is updated the plugin is destroyed and recreated to load the new code/resources. ------- Creating plugin hooks: To create a plugin hook, first create an interface in frameworks/base/packages/SystemUI/plugin that extends Plugin. Include in it any hooks you want to be able to call into from sysui and create callback interfaces for anything you need to pass through into the plugin. Then to attach to any plugins simply add a plugin listener and onPluginConnected will get called whenever new plugins are installed, updated, or enabled. Like this example from SystemUIApplication: PluginManager.getInstance(this).addPluginListener(OverlayPlugin.COMPONENT, new PluginListener<OverlayPlugin>() { @Override public void onPluginConnected(OverlayPlugin plugin) { PhoneStatusBar phoneStatusBar = getComponent(PhoneStatusBar.class); if (phoneStatusBar != null) { plugin.setup(phoneStatusBar.getStatusBarWindow(), phoneStatusBar.getNavigationBarView()); } } }, OverlayPlugin.VERSION, true /* Allow multiple plugins */); Note the VERSION included here. Any time incompatible changes in the interface are made, this version should be changed to ensure old plugins aren't accidentally loaded. Since the plugin library is provided by SystemUI, default implementations can be added for new methods to avoid version changes when possible. ------- Implementing a Plugin: See the ExamplePlugin for an example Android.mk on how to compile a plugin. Note that SystemUILib is not static for plugins, its classes are provided by SystemUI. Plugin security is based around a signature permission, so plugins must hold the following permission in their manifest. <uses-permission android:name="com.android.systemui.permission.PLUGIN" /> A plugin is found through a querying for services, so to let SysUI know about it, create a service with a name that points at your implementation of the plugin interface with the action accompanying it: <service android:name=".TestOverlayPlugin"> <intent-filter> <action android:name="com.android.systemui.action.PLUGIN_COMPONENT" /> </intent-filter> </service> Change-Id: I42c573a94907ca7a2eaacbb0a44614d49b8fc26f
2016-08-16 13:17:56 -04:00
SystemUIPluginLib \
Keyguard \
android-support-v7-recyclerview \
android-support-v7-preference \
android-support-v7-appcompat \
android-support-v14-preference \
android-support-v17-leanback
LOCAL_STATIC_JAVA_LIBRARIES := \
framework-protos \
SystemUI-proto
LOCAL_JAVA_LIBRARIES := telephony-common
LOCAL_JAVA_LIBRARIES += android.car
LOCAL_PACKAGE_NAME := SystemUI
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
ifneq ($(INCREMENTAL_BUILDS),)
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_JACK_ENABLED := incremental
LOCAL_DX_FLAGS := --multi-dex
LOCAL_JACK_FLAGS := --multi-dex native
endif
include frameworks/base/packages/SettingsLib/common.mk
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))