简体   繁体   English

如何在 Android 9 上集成系统应用程序

[英]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。

  1. Include LOCAL_PACKAGE_NAME into device/path_to_your_lunch_target.将 LOCAL_PACKAGE_NAME 包含在 device/path_to_your_lunch_target 中。

/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.我必须做两件事。

  1. Disabling pre-optimization禁用预优化
    I don't know why it causes a crash.我不知道为什么它会导致崩溃。

    LOCAL_DEX_PREOPT:= false LOCAL_DEX_PREOPT:= 假

  2. 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.

相关问题 如何将推荐系统集成到Android应用中? - How to integrate a recommendation system into an Android app? 如何在 Android 应用程序中集成 python 库? - How do I integrate python library in Android app? 如何将inMobi广告提供商与PhoneGap应用程序(适用于Android)集成? - How do I integrate inMobi ad providers with a PhoneGap App (for android)? 如何使用android studio将统一的android应用集成到现有应用中? - How do I integrate a unity android app into an existing app using android studio? 如何检查应用程序是否为 Android 中的非系统应用程序? - How do I check if an app is a non-system app in Android? Android开发:如何在其中集成线程? - Android Development: How do I integrate threads in this? Android:如何集成whatsapp调用 - Android : How do I integrate whatsapp calling 如何将标签集成到Android偏好设置中 - How do I integrate tabs into android preference 我有一个现有的 Django Webapp,如何制作 rest API 以将 webapp 与 ZC31B323617ECCECA84 集成 - I have an existing Django Webapp, how do I make a rest API to integrate the webapp with an android app? 如何使用 adb 恢复以前删除的 android 系统应用程序? - How do I restore previously removed android system app with adb?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM