Add development system App to Android11.0 system

Add development system App to Android11.0 system

Development system App

This article describes adding and developing system Apps in Android 11. Subsequent functions such as OTA upgrades and settings to start Apps at startup will be implemented here.

Create your own App project directory and files

App application projects can be placed in /vendor/vendor name/App project name, eg: /vendor/yjz/demo;

  1. The demo project and source code files can be manually created directly in this directory, or you can use studio to create and generate demo application projects. After copying the demo project files to this directory, I used studio to create and copy them.
    Note: For application projects created by studio, you only need to copy the app directory and its files.

  2. Add the Android.bp file of the application, path: /vendor/yjz/demo/Android.bp;
    Note: If the androidx package or third-party package is used in the application, you can Refer to the reference settings of static_libs in /packages/apps/Settings/Android.bp;


android_app {
    
    
    name: "demo",

    srcs: ["app/src/main/java/**/*.java"],

    resource_dirs: ["app/src/main/res"],

    manifest: "app/src/main/AndroidManifest.xml",

    privileged: true,

    platform_apis: true,

    certificate: "platform",

    libs: [
        "framework",
    ],

    static_libs: [
        "androidx.annotation_annotation",
    ],
}

  1. AndroidManifest.xml file, please note that the following attributes must be added and modify the file path: /vendor/yjz/demo/app/src/main/AndroidManifest.xml.

    android:sharedUserId="android.uid.system"
    coreApp="true" //Take app as core app

    android:directBootAware="true"
    android:persistent="true" //System applications start automatically after booting

 
 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.yjz.demo"
    coreApp="true"
    android:sharedUserId="android.uid.system">

    <application
        android:name=".DemoApplication"
        android:allowBackup="false"
        android:directBootAware="true"
        android:defaultToDeviceProtectedStorage="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:persistent="true"
        android:supportsRtl="true"
        android:theme="@style/DemoNoActionBarTheme"
        tools:targetApi="31">

    </application>

</manifest>

  1. Add a demo project to compile with the system and modify the file path: /device/rockchip/rk356x/device.mk.
 //********省略代码******

PRODUCT_PACKAGES += demo

  1. Recompile the firmware and flash the machine, enter the device with adb shell, ps -ef |grep com.yjz.demo, and check the added applications;

Guess you like

Origin blog.csdn.net/yjz_0314/article/details/133012926