[英]How do I integrate a system app on Android 9
I've been creating a system app on a debug board used Android 9.我一直在使用 Android 9 的调试板上创建系统应用程序。
The app and dpendenced JAR using ServiceManager looked build-successfully.使用 ServiceManager 的应用程序和依赖的 JAR 看起来构建成功。
But, after written the system.img and restarted,但是,写完system.img并重启后,
the device is shutdown automatically and transition to Android Recovery Screen.设备自动关闭并转换到 Android 恢复屏幕。
What do I have to do to build system apps correctly on Android 9?我必须做什么才能在 Android 9 上正确构建系统应用程序?
My app is like this.我的应用程序是这样的。
/system/priv-app/SampServiceApp/SampServiceApp.apk, /oat
/system/framework/com.android.sampservice.jar, /oat
/system/etc/permissions/com.android.sampservice.xml
almost the same as this example.几乎和这个例子一样。 (I don't want to use system_server if possible)
(如果可能,我不想使用 system_server)
https://devarea.com/aosp-creating-a-system-service/ https://devrea.com/aosp-creating-a-system-service/
but, only difference is...但是,唯一的区别是……
added "LOCAL_PRIVATE_PLATFORM_APIS" insted of "LOCAL_SDK_VERSION"在“LOCAL_SDK_VERSION”中添加了“LOCAL_PRIVATE_PLATFORM_APIS”
in Android.mk for SampServiceApp.apk (to compile & link successfully)在 Android.mk 中用于 SampServiceApp.apk(编译和链接成功)
# LOCAL_SDK_VERSION := current
LOCAL_PRIVATE_PLATFORM_APIS := true
And also, I tried to update this xml.而且,我尝试更新这个 xml。 ( https://source.android.google.cn/devices/tech/config/perms-whitelist )
( https://source.android.google.cn/devices/tech/config/perms-whitelist )
/etc/permissions/privapp-permissions-platform.xml
but, this python scripts output no entries.但是,这个 python 脚本 output 没有条目。
$ development/tools/privapp_permissions/privapp_permissions.py
↓↓ the result
<?xml version="1.0" encoding="utf-8"?>
<permissions>
</permissions>
Thank you in advance for your cooperation.预先感谢您的合作。
Oka, To build your application like system you should: To define mk file.好的,要构建类似系统的应用程序,您应该: 定义 mk 文件。 It should be something like that:
它应该是这样的:
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java) $(call all-Iaidl-files-under, app/src/main/aidl)
LOCAL_AIDL_INCLUDES := \
$(LOCAL_PATH)/app/src/main/aidl \
$(CAR_BROADCASTRADIO_SUPPORTLIB_PATH)/src
LOCAL_PACKAGE_NAME := YOUR_MODULE_NAME
LOCAL_OVERRIDES_PACKAGES := IF YOU OVERRIDE AOSP PACKAGE
LOCAL_PRIVATE_PLATFORM_APIS := true
LOCAL_CERTIFICATE := platform
LOCAL_MANIFEST_FILE := /app/src/main/AndroidManifest.xml
LOCAL_PROGUARD_ENABLED := disabled
LOCAL_DEX_PREOPT := false
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
Sure, you can use bp file instead of mk.当然,您可以使用 bp 文件代替 mk。
/etc/permissions/privapp-permissions-platform.xml
/etc/permissions/privapp-permissions-platform.xml
The file is about only permissions.该文件仅涉及权限。 Here you can define any permission that may be required for your application.
在这里,您可以定义您的应用程序可能需要的任何权限。 You can define your own manifest for your application, but don't forget to include it to build.
您可以为您的应用程序定义自己的清单,但不要忘记将其包含在构建中。
What about crash.撞车怎么办。 It is a very strange behaviour.
这是一种非常奇怪的行为。 Could you plz share dmesg and logcat?
你能分享一下 dmesg 和 logcat 吗?
I had to do two things.我必须做两件事。
Disabling pre-optimization禁用预优化
I don't know why it causes a crash.我不知道为什么它会导致崩溃。
LOCAL_DEX_PREOPT:= false LOCAL_DEX_PREOPT:= 假
Setting sepolicy设置 sepolicy
Adding rule in "public/servicemanager.te" didn't work for me.在“public/servicemanager.te”中添加规则对我不起作用。
My solution is the following.我的解决方案如下。
device/ manufacturer / device-name /sepolicy/system_app.te设备/制造商/设备名称/sepolicy/system_app.te
allow system_app my_service:service_manager add;
Other policy is as same as this examples.其他政策与本例相同。
https://devarea.com/aosp-creating-a-system-service/#.XxEndSj7SUk https://devrea.com/aosp-creating-a-system-service/#.XxEndSj7SUk
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.