鸿蒙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;
}
相关推荐
网络工程师俱乐部2 小时前
TCP连接重置,到底是怎么回事?
网络·网络协议·tcp/ip·华为·网络工程师·华为认证·交换机
髩獹朲小怪兽2 小时前
鸿蒙next 文字转语音
华为·harmonyos
二流小码农3 小时前
鸿蒙开发:两个重磅更新,鸿蒙版微信要来了!
android·ios·harmonyos
一起努力学习吧!5 小时前
【华为】基于华为交换机的VLAN配置与不同VLAN间通信实现
网络·华为
吹白7 小时前
【已解决】HarmonyOS NEXT / DevEco Studio项目错误:ArkTS:ERROR Failed to execute es2abc
华为·harmonyos·arkts·鸿蒙·鸿蒙系统·arkui·鸿蒙开发
东林知识库7 小时前
鸿蒙NEXT开发-沉浸式导航和键盘避让模式(基于最新api12稳定版)
华为·harmonyos
一起努力学习吧!8 小时前
【华为】ACL访问控制列表
网络·华为
小白小白从不日白9 小时前
鸿蒙--下拉刷新+上拉加载
华为·harmonyos
lqj_本人10 小时前
flutter鸿蒙版本通过底部导航栏的实现熟悉架构及语法
flutter·华为·harmonyos