我正在调查android的首次启动,并想启用bootchart,但我总是失败,以下是我所做的事情,有人可以帮助我吗?

因为bootchart服务的启动早于/ data分区挂载,所以每次bootchart都无法初始化。
内核日志中的失败消息是:bootcharting初始化失败

因此,为了确保成功启动bootchart,我更改了相关代码。并且该解决方案在Android L上可以很好地工作,但在Android L MR1上失败。
更改以下工具后,手机保持重启;禁用selinux后,请首先屏蔽徽标。

init/bootchart.c
/* called to setup bootcharting */
int   bootchart_init( void )
{
    int  ret;
    char buff[4];
    int  timeout = 0, count = 0;

    buff[0] = 0;

+    /* wait until /data mounted */
+    struct stat datadir;
+    if(stat("/data/bootchart-start", &datadir) == -1) {
+    ERROR("Bootchart, /data/bootchart-start not exists\n");
+    return -1;
+    }
    proc_read( LOG_STARTFILE, buff, sizeof(buff) );
    if (buff[0] != 0) {
        timeout = atoi(buff);
    }
init/init.c
static int bootchart_init_action(int nargs, char **args)
{
    bootchart_count = bootchart_init();
    if (bootchart_count < 0) {
        ERROR("bootcharting init failure\n");
+   queue_builtin_action(bootchart_init_action, "bootchart_init");
    } else if (bootchart_count > 0) {
        NOTICE("bootcharting started (period=%d ms)\n", bootchart_count*BOOTCHART_POLLING_MS);
    } else {
        NOTICE("bootcharting ignored\n");
    }
rootdir/init.rc
on post-fs-data
    # We chown/chmod /data again so because mount is run as root + defaults
    chown system system /data
    chmod 0771 /data
    # We restorecon /data in case the userdata partition has been reset.
    restorecon /data

+    write /data/bootchart-start 600
    # Avoid predictable entropy pool. Carry over entropy from previous boot.
    copy /data/system/entropy.dat /dev/urandom
/system/core/init/Android.mk

+ INIT_BOOTCHART :=true
ifeq ($(strip $(INIT_BOOTCHART)),true)
LOCAL_SRC_FILES += bootchart.c
LOCAL_CFLAGS    += -DBOOTCHART=1
endif

是否有人在Android L MR1上启用了引导图?您如何更改代码?
我如何修改代码以确保在/ data /分区挂载后启动bootchart初始化?

先感谢您!对我来说这很严重。

最佳答案

我可以通过以下init.rc启用bootchart进行首次启动:

on post-fs-data
    # We chown/chmod /data again so because mount is run as root + defaults
    chown system system /data
    chmod 0771 /data
    # We restorecon /data in case the userdata partition has been reset.
    restorecon /data

    # start debuggerd to make debugging early-boot crashes easier.
    start debuggerd
    start debuggerd64

    # Make sure we have the device encryption key.
    start vold
    installkey /data

    # Start bootcharting as soon as possible after the data partition is
    # mounted to collect more data.
    mkdir /data/bootchart 0755 shell shell
    # if you need to enable bootchart uncomment next line
    # Old Android
    # write /data/bootchart-start 120
    # Android > 7.0
    # write /data/bootchart/start 120
    bootchart_init

08-07 06:03