鸿蒙OS投票机制

(基于openharmony5.0)

投票机制

param get | grep ohos.boot.time
投票机制参数图

只有当所有的投票完成,开机动画才会退出,整理需要投票的系统应用(三方应用不参与投票)如下图所示:

以进程foundation为例:

foundation\systemabilitymgr\safwk\etc\profile\foundation.cfg

复制代码
"bootevents": [
    "bootevent.wms.fullscreen.ready",
    "bootevent.appfwk.ready",
    "bootevent.lockscreen.ready",
    "bootevent.wms.ready"
],

可以看到foundation进程有4个投票事件,会在相应的时机,代码中调用SystemWriteParam()方法进行投票。如果有需要投票的地方没有投,会导致开机动画不会退出,开机动画退出会检测bootevent.boot.completed事件。

base\startup\init\services\modules\bootevent\bootevent.c

复制代码
#define BOOT_EVENT_BOOT_COMPLETED "bootevent.boot.completed"

...

static int BootEventParaFireByName(const char *paramName)
{
    BOOT_EVENT_PARAM_ITEM *found = NULL;

    char *bootEventValue = strrchr(paramName, '.');
    INIT_CHECK(bootEventValue != NULL, return 0);
    bootEventValue[0] = '\0';

    WriteBooteventSysParam(paramName);

    found = (BOOT_EVENT_PARAM_ITEM *)OH_ListFind(&bootEventList, (void *)paramName, BootEventParaListCompareProc);
    if (found == NULL) {
        return 0;
    }

    // Already fired
    if (found->timestamp[BOOTEVENT_READY].tv_sec > 0) {
        return 0;
    }
    INIT_CHECK_RETURN_VALUE(clock_gettime(CLOCK_MONOTONIC,
        &(found->timestamp[BOOTEVENT_READY])) == 0, 0);

    g_bootEventNum--;
    SetServiceBooteventHookMgr(NULL, paramName, 2); // 2: bootevent service has ready
    // Check if all boot event params are fired
    if (g_bootEventNum > 0) {
        return 0;
    }
    // All parameters are fired, set boot completed now ...
    INIT_LOGI("All boot events are fired, boot complete now ...");
    //所有投票事件都已经完成
    SystemWriteParam(BOOT_EVENT_BOOT_COMPLETED, "true");
    SaveServiceBootEvent();
    // report complete event
    ReportSysEvent();
    BootCompleteClearAll();
#ifndef STARTUP_INIT_TEST
    HookMgrExecute(GetBootStageHookMgr(), INIT_BOOT_COMPLETE, NULL, NULL);
#endif
    RemoveCmdExecutor("bootevent", -1);
    return 1;
}
相关推荐
刘大猫.12 小时前
华为昇腾芯片将为DeepSeek-V4推理,通往国产算力自由
华为·ai·大模型·算力·deepseek·deepseek-v4·昇腾芯片
Lanren的编程日记17 小时前
Flutter鸿蒙应用开发:数据加密功能实现实战,全方位保护用户隐私数据
flutter·华为·harmonyos
想你依然心痛18 小时前
HarmonyOS 6健康应用实战:基于悬浮导航与沉浸光感的“光影律动“智能健身系统
华为·harmonyos·悬浮导航·沉浸光感
酣大智18 小时前
Win11 24H2 eNSP中AR报错40,解决方法
网络·华为
ICT系统集成阿祥18 小时前
黄金秘籍解决华为防火墙最困难的故障
网络·华为·php
酣大智19 小时前
eNSP中AR报错40,重新安装
网络·华为
weitingfu20 小时前
AI 游戏,为什么更适合鸿蒙?
人工智能·游戏·华为·ai·harmonyos
木斯佳20 小时前
鸿蒙开发入门指南:鸿蒙canvas实操——快速掌握自定义图表组件
harmonyos·自定义图表
光锥智能20 小时前
华为MateBook 14 鸿蒙版发布,体验全面升维
华为·harmonyos
UnicornDev21 小时前
【HarmonyOS 6】练习记录页面 UI 设计
ui·华为·harmonyos·arkts·鸿蒙