Search code examples
androidembedded-linuxandroid-source

How to run System Android App on system user


I am Working on Android System app, that means I signed it with the platform key and I pushed it into "/system/priv-app", but when I check it with "adb shell ps" I found the user is "u0_a40" not "system"

Who can explain me what happen and what can I do to run the app with the system user?


Solution

  • The AndroidManifest.xml needs to specify that your app is supposed to run as system user:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
              package="com.example.mysystemapp"
              android:sharedUserId="android.uid.system"
              coreApp="true">
    

    For completeness sake, if you want to compile your system app as part of the AOSP build process via an Android.mk file, you need to put this in the Android.mk:

    LOCAL_PRIVILEGED_MODULE := true
    LOCAL_CERTIFICATE := platform
    

    This ensures that the app ends up in /system/priv-app and is signed by the platform key.