Search code examples
androidandroid-sourceandroid-9.0-pie

How do I integrate a system app on Android 9


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.


Solution

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

    1. Include LOCAL_PACKAGE_NAME into device/path_to_your_lunch_target.

    /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?