将系统服务从 AOSP 构建树移动到可安装的 APK?

Move system service from AOSP build tree to installable APK?

我对 Android 开发非常陌生。我的公司支持我们自己 Android 使用 AOSP 构建树为我们的设备构建我们需要的一些系统服务和正在 AOSP 树中构建的 APK。

但是,我们正计划转向供应商提供的 Android 版本,我们希望从 AOSP 树中删除系统服务并将其移至单独构建和安装的 APK,但仍然可以访问其他已安装应用程序的系统服务。

作为 Android 开发的新手,我什至不知道从哪里开始。 作为第一步,我找到系统服务的 APK 在 AOSP 树中的 generated/output 位置。我将此 APK 安装到我们的设备上。安装似乎有效。但是,当需要使用该系统服务的应用程序运行时,Android 会显示一条关于系统服务如何停止的消息。

1.我需要采取哪些步骤才能完成这项工作?
2. 诊断问题还需要哪些其他信息?我对此很陌生,不知道应该提供哪些信息。

However, we are planning on moving to a vendor supplied Android build and we want to remove a system service from the AOSP tree and move it into a separately build and installed APK, but still be accessible as a system service to other installed applications.

假设您已在 ServiceManager 中进行更改以在 AOSP 中添加您自己的系统服务。是的,可以将您的系统服务移动到单独的 apk。这将减少您的平台依赖性。但是,仍然需要更改 sepolicy(以便在 ServiceManager 中动态添加您的服务)。这是从apk添加系统服务的完整参考: https://devarea.com/aosp-creating-a-system-service/#.XOOD9KRS9EY

The installation appears to have worked. However, when an application runs that needs to use that system service, Android displays a message about how the system service has stopped

请详细说明,您进行了哪些更改,以及系统服务崩溃的根本原因。

  1. What steps do I need to take to make this work?

建议将您的系统服务移动到单独的apk。请参考上面 link 解释创建系统服务(从 apk)。