如何在Android框架中添加系统服务 [英] How to add a system service to the Android Framework

查看:25
本文介绍了如何在Android框架中添加系统服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加自己的框架代码,该代码在 Androidsystem_server"(处理所有系统级服务)中运行.我的服务加载了一个 JNI 库,该库与我添加到内核中的驱动程序对话.该服务旨在允许应用程序向其注册侦听器以从驱动程序获取更新.我发现了一篇很好的博客文章(http://www.androidenea.com/2009/12/adding-system-server-to-android.html) 解释了如何添加系统服务,但我无法让它完全工作.

首先,该帖子提到应该使用适当的"Android.mk 文件来编写客户端/测试应用程序,但没有给出示例.当我尝试构建它时,我收到构建错误,说它找不到我添加的服务.有人可以举例说明这可能是什么样子吗?

此外,我想在供应商目录(或 froyo 中的设备目录)而不是在 Android 开源代码中实现这一点.博客文章提到了这个的正确位置是供应商目录,但没有给出它应该是什么样子的例子.有人知道吗?

有关在 Android 中实现您自己的系统服务的任何其他信息都会有所帮助.同样,我的具体工作流程是:

Android App -> System Service -> JNI (native) library -> Device Driver

解决方案

Texas Instruments 提供了一个很好的例子:

http://processors.wiki.ti.com/index.php/Android-Adding_SystemService

此外,CyanogenMod SystemServer.java 还具有动态加载系统服务的代码,如 config.xml 中的数组config_vendorServices"中定义的那样(参见 core/res/res/values/config.xml),我认为可以使用覆盖覆盖在供应商或设备目录中.这是一个特定于 CyanogenMod 的添加,在此提交中添加:

https://github.com/CyanogenMod/android_frameworks_base/commit/88fff90131f54d45dc496c45127ac1d16ad257df"/p>

I want to add my own framework code that runs in the Android "system_server" (handles all the system level services). My service loads a JNI library that talks to a driver I have added to the kernel. The service is designed to allow an app to register a listener with it to get updates from the driver. I found a pretty good blog post (http://www.androidenea.com/2009/12/adding-system-server-to-android.html) that explains how to add a system service, but I cannot get it completely working.

First of all, the post mentions that an "appropriate" Android.mk file should be used to write the client/test application, but does not give an example of this. When I try to build it, I get build errors saying it can't find the service I have added. Could someone give an example of what this might look like?

Also, I'd like to implement this in the vendor directory (or device directory in froyo) rather than in the Android open source code. The blog post mentions that the proper place for this is the vendor directory, but does not give an example of what this should look like. Anyone know?

ANY additional information on implementing your own system service in Android would be helpful. Again my specific workflow is:

Android App -> System Service -> JNI (native) library -> Device Driver

解决方案

Texas instruments has provided a nice example:

http://processors.wiki.ti.com/index.php/Android-Adding_SystemService

Additionally, the CyanogenMod SystemServer.java has also code for dynamically loading system services as defined in the array "config_vendorServices" in config.xml (see core/res/res/values/config.xml), which I believe can be overwritten in the vendor or device directories using the overlays. This is a CyanogenMod-specific addition, added in this commit:

https://github.com/CyanogenMod/android_frameworks_base/commit/88fff90131f54d45dc496c45127ac1d16ad257df

这篇关于如何在Android框架中添加系统服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆