鸿蒙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;
}
相关推荐
ldsweet9 小时前
《HarmonyOS技术精讲-Basic Services Kit》上传下载进阶:多任务并发与后台长时任务
华为·harmonyos
qizayaoshuap11 小时前
# [特殊字符] 宠物模拟器 — 鸿蒙ArkTS完整技术解析(最终篇)
华为·harmonyos·宠物
不言鹅喻11 小时前
HarmonyOS ArkTS 实战:实现一个校园自动售货机库存与补货记录应用
华为·harmonyos
世人万千丶12 小时前
鸿蒙Flutter TextStyle样式配置
学习·flutter·harmonyos·鸿蒙
不肥嘟嘟右卫门15 小时前
鸿蒙原生ArkTS布局方式之LazyForEach懒加载布局深度解析
华为·harmonyos
程序员黑豆16 小时前
鸿蒙开发入门:以 Text 组件为例,掌握内置组件用法
前端·harmonyos
xd18557855516 小时前
道歉话术生成:基于鸿蒙生态的智能情感沟通助手
人工智能·华为·harmonyos·鸿蒙
程序员黑豆17 小时前
鸿蒙应用开发之模拟器安装与使用教程
前端·harmonyos
SameX18 小时前
HarmonyOS 用 relationalStore 做本地数据库的完整实战 —— 一个真实项目的 5 个决策
harmonyos
绝世番茄19 小时前
鸿蒙原生 ArkTS 布局方式之 Button+Shake 抖动按钮实战全解
华为·harmonyos·鸿蒙