Reputation: 3
I've been creating a system app on a debug board used Android 9.
The app and dpendenced JAR using ServiceManager looked build-successfully.
But, after written the system.img and restarted,
the device is shutdown automatically and transition to Android Recovery Screen.
What do I have to do to build system apps correctly on 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)
https://devarea.com/aosp-creating-a-system-service/
but, only difference is ...
added "LOCAL_PRIVATE_PLATFORM_APIS" insted of "LOCAL_SDK_VERSION"
in Android.mk for SampServiceApp.apk
(to compile & link successfully)
# LOCAL_SDK_VERSION := current
LOCAL_PRIVATE_PLATFORM_APIS := true
And also, I tried to update this xml. (https://source.android.google.cn/devices/tech/config/perms-whitelist)
/etc/permissions/privapp-permissions-platform.xml
but, this python scripts output no entries.
$ 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.
Upvotes: 0
Views: 2256
Reputation: 3
I had to do two things.
Disabling pre-optimization
I don't know why it causes a crash.
LOCAL_DEX_PREOPT := false
Setting sepolicy
Adding rule in "public/servicemanager.te" didn't work for me.
My solution is the following.
device/manufacturer/device-name/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
Upvotes: 0
Reputation: 94
Oka, To build your application like system you should: To define mk file. 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.
/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?
Upvotes: 1