[Hi3751V811][Android8.0]Android系统开机如何启动自己的可执行文件

平台 内核版本 安卓版本
Hi3751V811 Linux4.1 Android8.0

文章目录

    • 一、实现编译时执行对此文件的拷贝。
    • 二、添加启动动作,使Android在启动时候执行。
    • 三、挂载权限

一、实现编译时执行对此文件的拷贝。

执行文件存放路径: android/device/hisilicon/bigfish/etc/
目标地址为:/system/etc/

目录:/home/nova/hisi/android/device/hisilicon/Hi3751V811/device_copyfile.mk

#hisi start boot
PRODUCT_COPY_FILES += \
    device/hisilicon/bigfish/etc/fstab.bigfish.androido:vendor/etc/fstab.$(TARGET_BOARD_PLATFORM) \
    device/hisilicon/bigfish/etc/init.hidolphin.rc:root/init.hidolphin.rc \
    device/hisilicon/bigfish/etc/init.bigfish.rc:root/init.$(TARGET_BOARD_PLATFORM).rc \
    device/hisilicon/bigfish/etc/ueventd.bigfish.rc:root/ueventd.$(TARGET_BOARD_PLATFORM).rc

我们可以加一条

PRODUCT_COPY_FILES += \
    device/hisilicon/bigfish/etc/*.sh:/system/etc/

这样,Android在执行编译的时候就会把新增文件拷贝至相应的目标路径去了,拷贝动作已经实现。

二、添加启动动作,使Android在启动时候执行。

目录:android/device/hisilicon/bigfish/etc/init.bigfish.rc
memcserver为例:

# Add memcserver
service memcserver /vendor/bin/memcserver
    class main
    user root
    group root
    oneshot

三、挂载权限

目录:android/system/core/libcutils/fs_config.c

static const struct fs_path_config android_files[] = {
    /* clang-format off */
    { 00644, AID_SYSTEM,    AID_SYSTEM,    0, "data/app/*" },
    { 00644, AID_SYSTEM,    AID_SYSTEM,    0, "data/app-ephemeral/*" },
    { 00644, AID_SYSTEM,    AID_SYSTEM,    0, "data/app-private/*" },
    { 00644, AID_APP,       AID_APP,       0, "data/data/*" },
    { 00644, AID_MEDIA_RW,  AID_MEDIA_RW,  0, "data/media/*" },
    { 00640, AID_ROOT,      AID_SHELL,     0, "data/nativetest/tests.txt" },
    { 00640, AID_ROOT,      AID_SHELL,     0, "data/nativetest64/tests.txt" },
    ...
    { 00550, AID_ROOT,      AID_SHELL,     0, "system/etc/init.goldfish.sh" },
    { 00550, AID_ROOT,      AID_SHELL,     0, "system/etc/init.ril" },
    { 00555, AID_ROOT,      AID_ROOT,      0, "system/etc/ppp/*" },
    { 00555, AID_ROOT,      AID_ROOT,      0, "system/etc/rc.*" },
}

你可能感兴趣的:([Hi3751V811][Android8.0]Android系统开机如何启动自己的可执行文件)