Merged
hicollie docs #135272
aefaefwAdd on Mar 23
hicollie docs #135272
Merged
Merged fromaefaefw/docsmasterintoopenharmony/docsmaster
Total: 8 files changed+255-21
| @@ -91,6 +91,7 @@ | |||
| 91 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.memory=${eventInfo.params['memory']}`); | 91 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.memory=${eventInfo.params['memory']}`); |
| 92 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.external_log=${JSON.stringify(eventInfo.params['external_log'])}`); | 92 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.external_log=${JSON.stringify(eventInfo.params['external_log'])}`); |
| 93 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.log_over_limit=${eventInfo.params['log_over_limit']}`); | 93 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.log_over_limit=${eventInfo.params['log_over_limit']}`); |
| 94 | + hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.external_callback_log=${eventInfo.params['external_callback_log']}`); | ||
| 94 | } | 95 | } |
| 95 | } | 96 | } |
| 96 | } | 97 | } |
| @@ -213,6 +214,7 @@ | |||
| 213 | HiAppEvent eventInfo.params.memory={"pss":0,"rss":150748,"sys_avail_mem":5387264,"sys_free_mem":218902,"sys_total_mem":11679236,"vss":38306936} | 214 | HiAppEvent eventInfo.params.memory={"pss":0,"rss":150748,"sys_avail_mem":5387264,"sys_free_mem":218902,"sys_total_mem":11679236,"vss":38306936} |
| 214 | HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/APP_HICOLLIE_1754914811140_20317.log"] | 215 | HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/APP_HICOLLIE_1754914811140_20317.log"] |
| 215 | HiAppEvent eventInfo.params.log_over_limit=false | 216 | HiAppEvent eventInfo.params.log_over_limit=false |
| 217 | + HiAppEvent eventInfo.params.external_callback_log=THREAD_BLOCK_3S:log3s THREAD_BLOCK_6S:log6s | ||
| 216 | ``` | 218 | ``` |
| 217 | 219 | ||
| 218 | ### 移除事件观察者 | 220 | ### 移除事件观察者 |
| @@ -121,6 +121,7 @@ | |||
| 121 | auto memory = writer.write(params["memory"]); | 121 | auto memory = writer.write(params["memory"]); |
| 122 | auto externalLog = writer.write(params["external_log"]); | 122 | auto externalLog = writer.write(params["external_log"]); |
| 123 | auto logOverLimit = params["log_over_limit"].asBool(); | 123 | auto logOverLimit = params["log_over_limit"].asBool(); |
| 124 | + auto externalCallbackLog = params["external_callback_log"].asString(); | ||
| 124 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); | 125 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); |
| 125 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); | 126 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); |
| 126 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", | 127 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", |
| @@ -135,6 +136,7 @@ | |||
| 135 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.memory=%{public}s", memory.c_str()); | 136 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.memory=%{public}s", memory.c_str()); |
| 136 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", externalLog.c_str()); | 137 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", externalLog.c_str()); |
| 137 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); | 138 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); |
| 139 | + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_callback_log=%{public}s", externalCallbackLog.c_str()); | ||
| 138 | } | 140 | } |
| 139 | } | 141 | } |
| 140 | } | 142 | } |
| @@ -212,6 +214,7 @@ | |||
| 212 | auto memory = writer.write(eventInfo["memory"]); | 214 | auto memory = writer.write(eventInfo["memory"]); |
| 213 | auto externalLog = writer.write(eventInfo["external_log"]); | 215 | auto externalLog = writer.write(eventInfo["external_log"]); |
| 214 | auto logOverLimit = eventInfo["log_over_limit"].asBool(); | 216 | auto logOverLimit = eventInfo["log_over_limit"].asBool(); |
| 217 | + auto externalCallbackLog = params["external_callback_log"].asString(); | ||
| 215 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); | 218 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); |
| 216 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); | 219 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); |
| 217 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", | 220 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", |
| @@ -228,6 +231,7 @@ | |||
| 228 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", | 231 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", |
| 229 | externalLog.c_str()); | 232 | externalLog.c_str()); |
| 230 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); | 233 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); |
| 234 | + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_callback_log=%{public}s", externalCallbackLog.c_str()); | ||
| 231 | } | 235 | } |
| 232 | } | 236 | } |
| 233 | } | 237 | } |
| @@ -406,6 +410,7 @@ | |||
| 406 | HiAppEvent eventInfo.params.memory={"pss":0,"rss":124668,"sys_avail_mem":2220032,"sys_free_mem":526680,"sys_total_mem":11692576,"vss":4238700} | 410 | HiAppEvent eventInfo.params.memory={"pss":0,"rss":124668,"sys_avail_mem":2220032,"sys_free_mem":526680,"sys_total_mem":11692576,"vss":4238700} |
| 407 | HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/APP_HICOLLIE_1740993644458_26215.log"] | 411 | HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/APP_HICOLLIE_1740993644458_26215.log"] |
| 408 | HiAppEvent eventInfo.params.log_over_limit=0 | 412 | HiAppEvent eventInfo.params.log_over_limit=0 |
| 413 | + HiAppEvent eventInfo.params.external_callback_log=THREAD_BLOCK_3S:log3s THREAD_BLOCK_6S:log6s | ||
| 409 | ``` | 414 | ``` |
| 410 | 415 | ||
| 411 | ### 移除并销毁事件观察者 | 416 | ### 移除并销毁事件观察者 |
| @@ -46,6 +46,7 @@ | |||
| 46 | | memory | object | 内存信息,详见memory属性。 | | 46 | | memory | object | 内存信息,详见memory属性。 | |
| 47 | | external_log | string[] | 故障日志文件路径。**为避免目录空间超限(限制参考log_over_limit),导致新生成的日志文件写入失败,日志文件处理完后请及时删除。** | | 47 | | external_log | string[] | 故障日志文件路径。**为避免目录空间超限(限制参考log_over_limit),导致新生成的日志文件写入失败,日志文件处理完后请及时删除。** | |
| 48 | | log_over_limit | boolean | 生成的故障日志文件与已存在的日志文件总大小是否超过5M上限。true表示超过上限,日志写入失败;false表示未超过上限。 | | 48 | | log_over_limit | boolean | 生成的故障日志文件与已存在的日志文件总大小是否超过5M上限。true表示超过上限,日志写入失败;false表示未超过上限。 | |
| 49 | +| external_callback_log | string | 自定义回调日志信息,可通过[OH_HiCollie_SetFreezeCallback](../reference/apis-performance-analysis-kit/capi-hicollie-h.md#oh_hicollie_setfreezecallback)写入。<br>**说明**:从API version 24开始支持。 | | ||
| 49 | 50 | ||
| 50 | ### exception字段说明 | 51 | ### exception字段说明 |
| 51 | 52 | ||
| @@ -120,6 +120,8 @@ | |||
| 120 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.test_data=${eventInfo.params['test_data']}`); | 120 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.test_data=${eventInfo.params['test_data']}`); |
| 121 | // 开发者可以获取到应用冻屏事件的故障进程存活时间 | 121 | // 开发者可以获取到应用冻屏事件的故障进程存活时间 |
| 122 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.process_life_time=${eventInfo.params['process_life_time']}`); | 122 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.process_life_time=${eventInfo.params['process_life_time']}`); |
| 123 | + // 开发者可以获取到应用冻屏事件的回调日志信息 | ||
| 124 | + hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.external_callback_log=${eventInfo.params['external_callback_log']}`); | ||
| 123 | // 开发者可以获取到应用冻屏事件的页面切换日志 | 125 | // 开发者可以获取到应用冻屏事件的页面切换日志 |
| 124 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.page_switch_log=${JSON.stringify(eventInfo.params['page_switch_log'])}`); | 126 | hilog.info(0x0000, 'testTag', `HiAppEvent eventInfo.params.page_switch_log=${JSON.stringify(eventInfo.params['page_switch_log'])}`); |
| 125 | } | 127 | } |
| @@ -172,6 +174,7 @@ | |||
| 172 | HiAppEvent eventInfo.params.log_over_limit=false | 174 | HiAppEvent eventInfo.params.log_over_limit=false |
| 173 | HiAppEvent eventInfo.params.test_data=100 | 175 | HiAppEvent eventInfo.params.test_data=100 |
| 174 | HiAppEvent eventInfo.params.process_life_time=18 | 176 | HiAppEvent eventInfo.params.process_life_time=18 |
| 177 | + HiAppEvent eventInfo.params.external_callback_log=THREAD_BLOCK_3S:log3s THREAD_BLOCK_6S:log6s | ||
| 175 | ``` | 178 | ``` |
| 176 | 179 | ||
| 177 | 2. 若应用无法启动或长时间未启动,开发者可以参考[使用FaultLogExtensionAbility订阅事件](./fault-log-extension-app-events-arkts.md)回调重写的函数,进行延迟上报。 | 180 | 2. 若应用无法启动或长时间未启动,开发者可以参考[使用FaultLogExtensionAbility订阅事件](./fault-log-extension-app-events-arkts.md)回调重写的函数,进行延迟上报。 |
| @@ -110,6 +110,7 @@ | |||
| 110 | auto memory = writer.write(params["memory"]); | 110 | auto memory = writer.write(params["memory"]); |
| 111 | auto externalLog = writer.write(params["external_log"]); | 111 | auto externalLog = writer.write(params["external_log"]); |
| 112 | auto logOverLimit = params["log_over_limit"].asBool(); | 112 | auto logOverLimit = params["log_over_limit"].asBool(); |
| 113 | + auto externalCallbackLog = params["external_callback_log"].asString(); | ||
| 113 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); | 114 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); |
| 114 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); | 115 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); |
| 115 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", bundleVersion.c_str()); | 116 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", bundleVersion.c_str()); |
| @@ -128,6 +129,7 @@ | |||
| 128 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.memory=%{public}s", memory.c_str()); | 129 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.memory=%{public}s", memory.c_str()); |
| 129 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", externalLog.c_str()); | 130 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", externalLog.c_str()); |
| 130 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); | 131 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); |
| 132 | + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_callback_log=%{public}s", externalCallbackLog.c_str()); | ||
| 131 | } | 133 | } |
| 132 | } | 134 | } |
| 133 | } | 135 | } |
| @@ -186,10 +188,11 @@ | |||
| 186 | auto handleSize6s = eventInfo["event_handler_size_6s"].asString(); | 188 | auto handleSize6s = eventInfo["event_handler_size_6s"].asString(); |
| 187 | auto peerBindSize = eventInfo["peer_binder"].size(); | 189 | auto peerBindSize = eventInfo["peer_binder"].size(); |
| 188 | auto threadSize = eventInfo["threads"].size(); | 190 | auto threadSize = eventInfo["threads"].size(); |
| 189 | - auto memory = writer.write(eventInfo["memory"]); | 191 | + auto memory = writer.write(eventInfo["memory"]); |
| 190 | auto externalLog = writer.write(eventInfo["external_log"]); | 192 | auto externalLog = writer.write(eventInfo["external_log"]); |
| 191 | auto logOverLimit = eventInfo["log_over_limit"].asBool(); | 193 | auto logOverLimit = eventInfo["log_over_limit"].asBool(); |
| 192 | auto process_life_time = eventInfo["process_life_time"].asString(); | 194 | auto process_life_time = eventInfo["process_life_time"].asString(); |
| 195 | + auto externalCallbackLog = params["external_callback_log"].asString(); | ||
| 193 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); | 196 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.time=%{public}lld", time); |
| 194 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); | 197 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.foreground=%{public}d", foreground); |
| 195 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", bundleVersion.c_str()); | 198 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.bundle_version=%{public}s", bundleVersion.c_str()); |
| @@ -209,6 +212,7 @@ | |||
| 209 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", externalLog.c_str()); | 212 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_log=%{public}s", externalLog.c_str()); |
| 210 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); | 213 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.log_over_limit=%{public}d", logOverLimit); |
| 211 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.process_life_time=%{public}s", process_life_time.c_str()); | 214 | OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.process_life_time=%{public}s", process_life_time.c_str()); |
| 215 | + OH_LOG_INFO(LogType::LOG_APP, "HiAppEvent eventInfo.params.external_callback_log=%{public}s", externalCallbackLog.c_str()); | ||
| 212 | } | 216 | } |
| 213 | } | 217 | } |
| 214 | } | 218 | } |
| @@ -308,6 +312,7 @@ | |||
| 308 | HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/APP_FREEZE_1502049185239_1587.log"] | 312 | HiAppEvent eventInfo.params.external_log=["/data/storage/el2/log/hiappevent/APP_FREEZE_1502049185239_1587.log"] |
| 309 | HiAppEvent eventInfo.params.log_over_limit=0 | 313 | HiAppEvent eventInfo.params.log_over_limit=0 |
| 310 | HiAppEvent eventInfo.params.process_life_time=18 | 314 | HiAppEvent eventInfo.params.process_life_time=18 |
| 315 | + HiAppEvent eventInfo.params.external_callback_log=THREAD_BLOCK_3S:log3s THREAD_BLOCK_6S:log6s | ||
| 311 | ``` | 316 | ``` |
| 312 | 317 | ||
| 313 | 2. 若应用无法启动或长时间未启动,开发者可以参考[使用FaultLogExtensionAbility订阅事件](./fault-log-extension-app-events-arkts.md)回调重写的函数,进行延迟上报。 | 318 | 2. 若应用无法启动或长时间未启动,开发者可以参考[使用FaultLogExtensionAbility订阅事件](./fault-log-extension-app-events-arkts.md)回调重写的函数,进行延迟上报。 |
| @@ -89,6 +89,7 @@ hiAppEvent.configEventPolicy(policy).then(() => { | |||
| 89 | | external_log<sup>12+</sup> | string[] | 故障日志文件路径。**为避免目录空间超限(参考log_over_limit),导致新生成的日志文件写入失败,日志文件处理完后请及时删除。** | | 89 | | external_log<sup>12+</sup> | string[] | 故障日志文件路径。**为避免目录空间超限(参考log_over_limit),导致新生成的日志文件写入失败,日志文件处理完后请及时删除。** | |
| 90 | | log_over_limit<sup>12+</sup> | boolean | 生成的故障日志文件与已存在的日志文件总大小是否超过5M上限。true表示超过上限,日志写入失败;false表示未超过上限。 | | 90 | | log_over_limit<sup>12+</sup> | boolean | 生成的故障日志文件与已存在的日志文件总大小是否超过5M上限。true表示超过上限,日志写入失败;false表示未超过上限。 | |
| 91 | | process_life_time | number | 故障进程存活时间。<br>**说明**:从API 22开始支持。 | | 91 | | process_life_time | number | 故障进程存活时间。<br>**说明**:从API 22开始支持。 | |
| 92 | +| external_callback_log | string | 自定义回调日志信息,可通过[OH_HiCollie_SetFreezeCallback](../reference/apis-performance-analysis-kit/capi-hicollie-h.md#oh_hicollie_setfreezecallback)写入。<br>**说明**:从API version 24开始支持。 | | ||
| 92 | | page_switch_log | string | 页面切换日志路径,日志介绍详见通用日志。<br>**说明**:从API version 24开始支持。 | | 93 | | page_switch_log | string | 页面切换日志路径,日志介绍详见通用日志。<br>**说明**:从API version 24开始支持。 | |
| 93 | 94 | ||
| 94 | ### exception字段说明 | 95 | ### exception字段说明 |
| @@ -19,6 +19,8 @@ | |||
| 19 | | OH_HiCollie_Init_JankDetection | 注册应用业务线程卡顿检测的回调函数。<br/>线程卡顿监控功能需要开发者实现两个卡顿检测回调函数,分别放在业务线程处理事件的前后。作为插桩函数,监控业务线程处理事件执行情况。<br/>**说明**:在非主线程使用该接口。 | | 19 | | OH_HiCollie_Init_JankDetection | 注册应用业务线程卡顿检测的回调函数。<br/>线程卡顿监控功能需要开发者实现两个卡顿检测回调函数,分别放在业务线程处理事件的前后。作为插桩函数,监控业务线程处理事件执行情况。<br/>**说明**:在非主线程使用该接口。 | |
| 20 | | OH_HiCollie_Report | 上报应用业务线程卡死事件,生成卡死故障日志,辅助定位应用卡死问题。<br/>先调用OH_HiCollie_Init_StuckDetection或OH_HiCollie_Init_StuckDetectionWithTimeout接口,初始化检测的task。<br/>如果task任务超时,结合业务逻辑,调用OH_HiCollie_Report接口上报卡死事件。<br/>**说明**:<br/>- 在非主线程使用该接口。<br/>- 该接口仅对[release版本应用](performance-analysis-kit-terminology.md#release版本应用)生效,对[debug版本应用](performance-analysis-kit-terminology.md#debug版本应用)不生效。 | | 20 | | OH_HiCollie_Report | 上报应用业务线程卡死事件,生成卡死故障日志,辅助定位应用卡死问题。<br/>先调用OH_HiCollie_Init_StuckDetection或OH_HiCollie_Init_StuckDetectionWithTimeout接口,初始化检测的task。<br/>如果task任务超时,结合业务逻辑,调用OH_HiCollie_Report接口上报卡死事件。<br/>**说明**:<br/>- 在非主线程使用该接口。<br/>- 该接口仅对[release版本应用](performance-analysis-kit-terminology.md#release版本应用)生效,对[debug版本应用](performance-analysis-kit-terminology.md#debug版本应用)不生效。 | |
| 21 | | OH_HiCollie_ReportInputBlock | 上报应用输入无响应事件,生成卡死故障日志,辅助定位应用卡死问题。如果在PC或平板设备上,还会弹窗提示用户继续等待或关闭应用,其他设备不会弹窗。建议如下两种方式使用该接口。<br/>方式一(推荐):配合OH_HiCollie_Report、OH_HiCollie_Init_StuckDetection或OH_HiCollie_Init_StuckDetectionWithTimeout接口使用,业务线程通过上述接口周期性检测自身卡死情况,当满足业务线程卡死且有输入事件(如屏幕点击、鼠标点击、键盘输入等)条件时再调用OH_HiCollie_ReportInputBlock接口。<br/>方式二:业务线程不通过OH_HiCollie_Report、OH_HiCollie_Init_StuckDetection或OH_HiCollie_Init_StuckDetectionWithTimeout接口也能检测自身卡死情况,则应用结合业务线程卡死情况和输入事件再调用OH_HiCollie_ReportInputBlock接口。<br/>**说明**:<br/>- 该接口可以在主线程使用,比如输入事件需要先经过主线程再封装传递给业务线程处理,业务线程卡死时维护一个状态标志位,主线程结合业务线程的卡死状态标志位和输入事件再调用该接口。<br/>- 该接口仅对[release版本应用](performance-analysis-kit-terminology.md#release版本应用)生效,对[debug版本应用](performance-analysis-kit-terminology.md#debug版本应用)不生效。<br/>- 从API version 24开始,支持该接口。 | | 21 | | OH_HiCollie_ReportInputBlock | 上报应用输入无响应事件,生成卡死故障日志,辅助定位应用卡死问题。如果在PC或平板设备上,还会弹窗提示用户继续等待或关闭应用,其他设备不会弹窗。建议如下两种方式使用该接口。<br/>方式一(推荐):配合OH_HiCollie_Report、OH_HiCollie_Init_StuckDetection或OH_HiCollie_Init_StuckDetectionWithTimeout接口使用,业务线程通过上述接口周期性检测自身卡死情况,当满足业务线程卡死且有输入事件(如屏幕点击、鼠标点击、键盘输入等)条件时再调用OH_HiCollie_ReportInputBlock接口。<br/>方式二:业务线程不通过OH_HiCollie_Report、OH_HiCollie_Init_StuckDetection或OH_HiCollie_Init_StuckDetectionWithTimeout接口也能检测自身卡死情况,则应用结合业务线程卡死情况和输入事件再调用OH_HiCollie_ReportInputBlock接口。<br/>**说明**:<br/>- 该接口可以在主线程使用,比如输入事件需要先经过主线程再封装传递给业务线程处理,业务线程卡死时维护一个状态标志位,主线程结合业务线程的卡死状态标志位和输入事件再调用该接口。<br/>- 该接口仅对[release版本应用](performance-analysis-kit-terminology.md#release版本应用)生效,对[debug版本应用](performance-analysis-kit-terminology.md#debug版本应用)不生效。<br/>- 从API version 24开始,支持该接口。 | |
| 22 | +| OH_HiCollie_SetFreezeCallback | 将冻屏回调设置进系统,系统将在冻屏事件发生时回调此函数。<br/>**说明**:从API version 24开始,支持该接口。 | | ||
| 23 | +| OH_HiCollie_AssociateProcessReport | 主动报告一个进程的冻屏事件。此时会生成[应用执行超时事件](hiappevent-watcher-apphicollie-events.md)事件。<br/>**说明**:从API version 24开始,支持该接口。 | | ||
| 22 | 24 | ||
| 23 | API接口的具体使用说明(参数使用限制、具体取值范围等)请参考[HiCollie](../reference/apis-performance-analysis-kit/capi-hicollie-h.md)。 | 25 | API接口的具体使用说明(参数使用限制、具体取值范围等)请参考[HiCollie](../reference/apis-performance-analysis-kit/capi-hicollie-h.md)。 |
| 24 | 26 | ||
| @@ -70,7 +72,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 70 | 72 | ||
| 71 | 3. 编辑“napi_init.cpp”文件,导入依赖的文件,定义LOG_TAG,下述代码步骤用于模拟卡死卡顿场景,具体使用请结合业务需要。示例代码如下: | 73 | 3. 编辑“napi_init.cpp”文件,导入依赖的文件,定义LOG_TAG,下述代码步骤用于模拟卡死卡顿场景,具体使用请结合业务需要。示例代码如下: |
| 72 | 74 | ||
| 73 | - (1)**应用线程卡顿检测**:OH_HiCollie_Init_JankDetection,示例代码如下: | 75 | + - 从API version 12开始,支持**应用线程卡顿检测**:OH_HiCollie_Init_JankDetection,示例代码如下: |
| 74 | 76 | ||
| 75 | ```c++ | 77 | ```c++ |
| 76 | #include <thread> | 78 | #include <thread> |
| @@ -169,7 +171,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 169 | } | 171 | } |
| 170 | ``` | 172 | ``` |
| 171 | 173 | ||
| 172 | - (2)**应用线程卡死检测**: OH_HiCollie_Init_StuckDetection, 示例代码如下: | 174 | + - 从API version 12开始,支持**应用线程卡死检测**: OH_HiCollie_Init_StuckDetection, 示例代码如下: |
| 173 | 175 | ||
| 174 | ```c++ | 176 | ```c++ |
| 175 | #include "napi/native_api.h" | 177 | #include "napi/native_api.h" |
| @@ -272,7 +274,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 272 | } | 274 | } |
| 273 | ``` | 275 | ``` |
| 274 | 276 | ||
| 275 | - (3)**应用线程卡死检测,自定义检测时间**:OH_HiCollie_Init_StuckDetectionWithTimeout,示例代码如下: | 277 | + - 从API version 18开始,支持**应用线程卡死检测,自定义检测时间**:OH_HiCollie_Init_StuckDetectionWithTimeout,示例代码如下: |
| 276 | 278 | ||
| 277 | ```c++ | 279 | ```c++ |
| 278 | #include "napi/native_api.h" | 280 | #include "napi/native_api.h" |
| @@ -374,7 +376,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 374 | } | 376 | } |
| 375 | ``` | 377 | ``` |
| 376 | 378 | ||
| 377 | - (4)**应用线程卡死检测,应用主动上报输入无响应故障**:OH_HiCollie_ReportInputBlock,示例代码如下: | 379 | + - 从API version 24开始,支持**应用线程卡死检测,应用主动上报输入无响应故障**:OH_HiCollie_ReportInputBlock,示例代码如下: |
| 378 | 380 | ||
| 379 | ```c++ | 381 | ```c++ |
| 380 | #include "napi/native_api.h" | 382 | #include "napi/native_api.h" |
| @@ -488,34 +490,112 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 488 | } | 490 | } |
| 489 | ``` | 491 | ``` |
| 490 | 492 | ||
| 493 | + - 从API version 24开始,支持**应用线程卡死检测,三方框架生成自定义日志**:OH_HiCollie_SetFreezeCallback、OH_HiCollie_AssociateProcessReport,示例代码如下: | ||
| 494 | + | ||
| 495 | + ```c++ | ||
| 496 | + #include "napi/native_api.h" | ||
| 497 | + #include "hilog/log.h" | ||
| 498 | + #include "hicollie/hicollie.h" | ||
| 499 | + #include <thread> | ||
| 500 | + #include <string> | ||
| 501 | + #include <unistd.h> | ||
| 502 | + | ||
| 503 | + #undef LOG_TAG | ||
| 504 | + #define LOG_TAG "StruckTest" | ||
| 505 | + | ||
| 506 | + static size_t UserCall(OH_HiCollie_Freeze_Type type, void* buffer, size_t size) | ||
| 507 | + { | ||
| 508 | + std::string source("Freeze is happened"); | ||
| 509 | + if (type == OH_THREAD_BLOCK_3S) { | ||
| 510 | + source += ":block 3s"; | ||
| 511 | + } else if (type == OH_THREAD_BLOCK_6S) { | ||
| 512 | + source += ":block 6s"; | ||
| 513 | + } else { | ||
| 514 | + source += ":other block"; | ||
| 515 | + } | ||
| 516 | + char* buffer1 = (char*)buffer; | ||
| 517 | + int needed = snprintf(buffer1, size, "UserCallback%s", source.c_str()); | ||
| 518 | + return needed; | ||
| 519 | + } | ||
| 520 | + | ||
| 521 | + static napi_value TestHiCollieSetFreezeCallback(napi_env env, napi_callback_info info) | ||
| 522 | + { | ||
| 523 | + // 设置用户回调 | ||
| 524 | + OH_HiCollie_SetFreezeCallback(UserCall); | ||
| 525 | + return 0; | ||
| 526 | + } | ||
| 527 | + | ||
| 528 | + static napi_value TestHiCollieAssociateProcessReport(napi_env env, napi_callback_info info) | ||
| 529 | + { | ||
| 530 | + // 上报BUSINESS_THREAD_BLOCK_3S事件 | ||
| 531 | + OH_HiCollie_AssociateProcessReport(false); | ||
| 532 | + sleep(3); | ||
| 533 | + // 上报BUSINESS_THREAD_BLOCK_6S事件 | ||
| 534 | + OH_HiCollie_AssociateProcessReport(true); | ||
| 535 | + return 0; | ||
| 536 | + } | ||
| 537 | + | ||
| 538 | + EXTERN_C_START | ||
| 539 | + static napi_value Init(napi_env env, napi_value exports) | ||
| 540 | + { | ||
| 541 | + napi_property_descriptor desc[] = { | ||
| 542 | + { "testHiCollieSetFreezeCallback", nullptr, TestHiCollieSetFreezeCallback, nullptr, nullptr, nullptr, napi_default, nullptr }, | ||
| 543 | + { "testHiCollieAssociateProcessReport", nullptr, TestHiCollieAssociateProcessReport, nullptr, nullptr, nullptr, napi_default, nullptr } | ||
| 544 | + }; | ||
| 545 | + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); | ||
| 546 | + return exports; | ||
| 547 | + } | ||
| 548 | + EXTERN_C_END | ||
| 549 | + | ||
| 550 | + static napi_module demoModule = { | ||
| 551 | + .nm_version = 1, | ||
| 552 | + .nm_flags = 0, | ||
| 553 | + .nm_filename = nullptr, | ||
| 554 | + .nm_register_func = Init, | ||
| 555 | + .nm_modname = "entry", | ||
| 556 | + .nm_priv = ((void*)0), | ||
| 557 | + .reserved = { 0 }, | ||
| 558 | + }; | ||
| 559 | + | ||
| 560 | + extern "C" __attribute__((constructor)) void RegisterEntryModule(void) | ||
| 561 | + { | ||
| 562 | + napi_module_register(&demoModule); | ||
| 563 | + } | ||
| 564 | + ``` | ||
| 491 | 565 | ||
| 492 | 4. 将TestHiCollieNdk注册为ArkTS接口。 | 566 | 4. 将TestHiCollieNdk注册为ArkTS接口。 |
| 493 | 567 | ||
| 494 | - (1)OH_HiCollie_Init_JankDetection示例,编辑“index.d.ts”文件,定义ArkTS接口: | 568 | + - OH_HiCollie_Init_JankDetection示例,编辑“index.d.ts”文件,定义ArkTS接口: |
| 495 | 569 | ||
| 496 | - ```typescript | 570 | + ```ts |
| 497 | export const testHiCollieJankNdk: () => void; | 571 | export const testHiCollieJankNdk: () => void; |
| 498 | ``` | 572 | ``` |
| 499 | 573 | ||
| 500 | - (2)OH_HiCollie_Init_StuckDetection示例,编辑“index.d.ts”文件,定义ArkTS接口: | 574 | + - OH_HiCollie_Init_StuckDetection示例,编辑“index.d.ts”文件,定义ArkTS接口: |
| 501 | 575 | ||
| 502 | - ```typescript | 576 | + ```ts |
| 503 | export const testHiCollieStuckNdk: () => void; | 577 | export const testHiCollieStuckNdk: () => void; |
| 504 | ``` | 578 | ``` |
| 505 | 579 | ||
| 506 | - (3)OH_HiCollie_Init_StuckDetectionWithTimeout示例,编辑“index.d.ts”文件,定义ArkTS接口: | 580 | + - OH_HiCollie_Init_StuckDetectionWithTimeout示例,编辑“index.d.ts”文件,定义ArkTS接口: |
| 507 | 581 | ||
| 508 | - ```typescript | 582 | + ```ts |
| 509 | export const testHiCollieStuckWithTimeoutNdk: () => void; | 583 | export const testHiCollieStuckWithTimeoutNdk: () => void; |
| 510 | ``` | 584 | ``` |
| 511 | 585 | ||
| 512 | - (4)OH_HiCollie_ReportInputBlock示例,编辑“index.d.ts”文件,定义ArkTS接口: | 586 | + - OH_HiCollie_ReportInputBlock示例,编辑“index.d.ts”文件,定义ArkTS接口: |
| 513 | 587 | ||
| 514 | - ```typescript | 588 | + ```ts |
| 515 | export const testHiCollieStuckNdk: () => void; | 589 | export const testHiCollieStuckNdk: () => void; |
| 516 | export const testHiCollieInputBlock: () => void; | 590 | export const testHiCollieInputBlock: () => void; |
| 517 | ``` | 591 | ``` |
| 518 | 592 | ||
| 593 | + - OH_HiCollie_SetFreezeCallbac、OH_HiCollie_AssociateProcessReport示例,编辑“index.d.ts”文件,定义ArkTS接口: | ||
| 594 | + | ||
| 595 | + ```ts | ||
| 596 | + export const testHiCollieSetFreezeCallback: () => void; | ||
| 597 | + export const testHiCollieAssociateProcessReport: () => void; | ||
| 598 | + ``` | ||
| 519 | 5. 编辑“Index.ets”文件: | 599 | 5. 编辑“Index.ets”文件: |
| 520 | 600 | ||
| 521 | ```ts | 601 | ```ts |
| @@ -538,7 +618,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 538 | } | 618 | } |
| 539 | ``` | 619 | ``` |
| 540 | 620 | ||
| 541 | - (1)添加点击事件,触发OH_HiCollie_Init_JankDetection方法。 | 621 | + - 添加点击事件,触发OH_HiCollie_Init_JankDetection方法。 |
| 542 | 622 | ||
| 543 | ```ts | 623 | ```ts |
| 544 | Column() { | 624 | Column() { |
| @@ -552,7 +632,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 552 | } | 632 | } |
| 553 | ``` | 633 | ``` |
| 554 | 634 | ||
| 555 | - (2)添加点击事件,触发OH_HiCollie_Init_StuckDetection方法。 | 635 | + - 添加点击事件,触发OH_HiCollie_Init_StuckDetection方法。 |
| 556 | 636 | ||
| 557 | ```ts | 637 | ```ts |
| 558 | Column() { | 638 | Column() { |
| @@ -566,7 +646,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 566 | } | 646 | } |
| 567 | ``` | 647 | ``` |
| 568 | 648 | ||
| 569 | - (3)添加点击事件,触发OH_HiCollie_Init_StuckDetectionWithTimeout方法。 | 649 | + - 添加点击事件,触发OH_HiCollie_Init_StuckDetectionWithTimeout方法。 |
| 570 | 650 | ||
| 571 | ```ts | 651 | ```ts |
| 572 | Column() { | 652 | Column() { |
| @@ -580,7 +660,7 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 580 | } | 660 | } |
| 581 | ``` | 661 | ``` |
| 582 | 662 | ||
| 583 | - (4)添加点击事件,触发OH_HiCollie_Init_StuckDetectionWithTimeout方法和OH_HiCollie_ReportInputBlock方法。 | 663 | + - 添加点击事件,触发OH_HiCollie_Init_StuckDetectionWithTimeout方法和OH_HiCollie_ReportInputBlock方法。 |
| 584 | 664 | ||
| 585 | ```ts | 665 | ```ts |
| 586 | Column() { | 666 | Column() { |
| @@ -600,23 +680,47 @@ API接口的具体使用说明(参数使用限制、具体取值范围等) | |||
| 600 | .onClick(testNapi.testHiCollieInputBlock); | 680 | .onClick(testNapi.testHiCollieInputBlock); |
| 601 | } | 681 | } |
| 602 | ``` | 682 | ``` |
| 683 | + - 添加点击事件,触发OH_HiCollie_SetFreezeCallback方法和OH_HiCollie_AssociateProcessReport方法。 | ||
| 684 | + | ||
| 685 | + ```ts | ||
| 686 | + Column() { | ||
| 687 | + Button("testHiCollieSetFreezeCallback", { stateEffect:true, type: ButtonType.Capsule}) | ||
| 688 | + .width('75%') | ||
| 689 | + .height(50) | ||
| 690 | + .margin(15) | ||
| 691 | + .fontSize(20) | ||
| 692 | + .fontWeight(FontWeight.Bold) | ||
| 693 | + .onClick(testNapi.testHiCollieSetFreezeCallback); | ||
| 694 | + Button("testHiCollieAssociateProcessReport", { stateEffect:true, type: ButtonType.Capsule}) | ||
| 695 | + .width('75%') | ||
| 696 | + .height(50) | ||
| 697 | + .margin(15) | ||
| 698 | + .fontSize(20) | ||
| 699 | + .fontWeight(FontWeight.Bold) | ||
| 700 | + .onClick(testNapi.testHiCollieAssociateProcessReport); | ||
| 701 | + } | ||
| 702 | + ``` | ||
| 603 | 703 | ||
| 604 | 6. 点击DevEco Studio界面中的运行按钮,运行应用工程。 | 704 | 6. 点击DevEco Studio界面中的运行按钮,运行应用工程。 |
| 605 | 705 | ||
| 606 | 7. 在DevEco Studio的底部,切换到“Log”窗口,过滤自定义的LOG_TAG。 | 706 | 7. 在DevEco Studio的底部,切换到“Log”窗口,过滤自定义的LOG_TAG。 |
| 607 | 707 | ||
| 608 | - (1)点击“testHiCollieJankNdk”按钮。 | 708 | + - 点击“testHiCollieJankNdk”按钮。 |
| 609 | 709 | ||
| 610 | 此时窗口将显示通过OH_HiCollie_Init_JankDetection接口获取的应用业务线程采样栈的超时信息。可以通过订阅hiappevent获取对应的事件,参见[订阅主线程超时事件](hiappevent-watcher-mainthreadjank-events-arkts.md)。 | 710 | 此时窗口将显示通过OH_HiCollie_Init_JankDetection接口获取的应用业务线程采样栈的超时信息。可以通过订阅hiappevent获取对应的事件,参见[订阅主线程超时事件](hiappevent-watcher-mainthreadjank-events-arkts.md)。 |
| 611 | 711 | ||
| 612 | - (2)点击“testHiCollieStuckNdk”按钮。 | 712 | + - 点击“testHiCollieStuckNdk”按钮。 |
| 613 | 713 | ||
| 614 | 此时窗口将显示通过OH_HiCollie_Init_StuckDetection接口,初始化卡死检测回调函数。可以根据实际业务场景,自行定义卡死检测函数。 | 714 | 此时窗口将显示通过OH_HiCollie_Init_StuckDetection接口,初始化卡死检测回调函数。可以根据实际业务场景,自行定义卡死检测函数。 |
| 615 | 715 | ||
| 616 | - (3)点击“testHiCollieStuckWithTimeoutNdk”按钮。 | 716 | + - 点击“testHiCollieStuckWithTimeoutNdk”按钮。 |
| 617 | 717 | ||
| 618 | 此时窗口将显示通过OH_HiCollie_Init_StuckDetectionWithTimeout接口,初始化卡死检测回调函数。可以根据实际业务场景,自行定义卡死检测函数,及卡死检测时间。 | 718 | 此时窗口将显示通过OH_HiCollie_Init_StuckDetectionWithTimeout接口,初始化卡死检测回调函数。可以根据实际业务场景,自行定义卡死检测函数,及卡死检测时间。 |
| 619 | 719 | ||
| 620 | - (4)先点击“testHiCollieStuckNdk”按钮,再持续点击“testHiCollieInputBlock”按钮。 | 720 | + - 先点击“testHiCollieStuckNdk”按钮,再持续点击“testHiCollieInputBlock”按钮。 |
| 621 | 721 | ||
| 622 | 此时窗口将显示通过OH_HiCollie_Init_StuckDetection接口,初始化卡死检测回调函数。在PC或平板设备上前6秒时间内点击“testHiCollieInputBlock”按钮没有弹窗,后续点击该按钮会有弹窗。可以根据实际业务场景,自行定义卡死检测函数或输入事件判断的条件。 | 722 | 此时窗口将显示通过OH_HiCollie_Init_StuckDetection接口,初始化卡死检测回调函数。在PC或平板设备上前6秒时间内点击“testHiCollieInputBlock”按钮没有弹窗,后续点击该按钮会有弹窗。可以根据实际业务场景,自行定义卡死检测函数或输入事件判断的条件。 |
| 723 | + | ||
| 724 | + - 先点击“testHiCollieSetFreezeCallback”按钮,再点击“testHiCollieAssociateProcessReport”按钮。 | ||
| 725 | + | ||
| 726 | + 此时窗口将显示通过OH_HiCollie_SetFreezeCallback接口,设置自定义日志函数,再通过OH_HiCollie_AssociateProcessReport接口上报线程超时事件,随后生成[APP_HICOLLIE](hiappevent-watcher-apphicollie-events.md)事件,其中包含回调日志字段。 | ||
| @@ -36,6 +36,7 @@ HiCollie模块对外提供检测业务线程卡死、卡顿,以及上报卡死 | |||
| 36 | | -- | -- | -- | | 36 | | -- | -- | -- | |
| 37 | | [HiCollie_ErrorCode](#hicollie_errorcode) | HiCollie_ErrorCode | 错误码定义。 | | 37 | | [HiCollie_ErrorCode](#hicollie_errorcode) | HiCollie_ErrorCode | 错误码定义。 | |
| 38 | | [HiCollie_Flag](#hicollie_flag) | HiCollie_Flag | 定义函数执行超时时发生的动作。 | | 38 | | [HiCollie_Flag](#hicollie_flag) | HiCollie_Flag | 定义函数执行超时时发生的动作。 | |
| 39 | +| [OH_HiCollie_Freeze_Type](#oh_hicollie_freeze_type) | OH_HiCollie_Freeze_Type | 定义FreezeCallback返回的冻屏类型。 | | ||
| 39 | 40 | ||
| 40 | ### 函数 | 41 | ### 函数 |
| 41 | 42 | ||
| @@ -52,6 +53,9 @@ HiCollie模块对外提供检测业务线程卡死、卡顿,以及上报卡死 | |||
| 52 | | [typedef void (\*OH_HiCollie_Callback)(void*)](#oh_hicollie_callback) | OH_HiCollie_Callback | 当用户调用[OH_HiCollie_SetTimer](capi-hicollie-h.md#oh_hicollie_settimer)后,未在其自定义的任务超时时间阈值内调用[OH_HiCollie_CancelTimer](capi-hicollie-h.md#oh_hicollie_canceltimer),回调函数将被执行。 | | 53 | | [typedef void (\*OH_HiCollie_Callback)(void*)](#oh_hicollie_callback) | OH_HiCollie_Callback | 当用户调用[OH_HiCollie_SetTimer](capi-hicollie-h.md#oh_hicollie_settimer)后,未在其自定义的任务超时时间阈值内调用[OH_HiCollie_CancelTimer](capi-hicollie-h.md#oh_hicollie_canceltimer),回调函数将被执行。 | |
| 53 | | [HiCollie_ErrorCode OH_HiCollie_SetTimer(HiCollie_SetTimerParam param, int *id)](#oh_hicollie_settimer) | - | 注册定时器,用于检测函数或代码块执行是否超过自定义时间。<br> 结合OH_HiCollie_CancelTimer接口配套使用,应在调用耗时的函数之前使用。 | | 54 | | [HiCollie_ErrorCode OH_HiCollie_SetTimer(HiCollie_SetTimerParam param, int *id)](#oh_hicollie_settimer) | - | 注册定时器,用于检测函数或代码块执行是否超过自定义时间。<br> 结合OH_HiCollie_CancelTimer接口配套使用,应在调用耗时的函数之前使用。 | |
| 54 | | [void OH_HiCollie_CancelTimer(int id)](#oh_hicollie_canceltimer) | - | 取消定时器。<br> 结合OH_HiCollie_SetTimer接口配套使用,执行函数或代码块后使用,OH_HiCollie_CancelTimer通过id将该任务取消;<br> 若未在自定义时间内取消,则执行回调函数,在特定自定义超时动作下,生成故障日志。 | | 55 | | [void OH_HiCollie_CancelTimer(int id)](#oh_hicollie_canceltimer) | - | 取消定时器。<br> 结合OH_HiCollie_SetTimer接口配套使用,执行函数或代码块后使用,OH_HiCollie_CancelTimer通过id将该任务取消;<br> 若未在自定义时间内取消,则执行回调函数,在特定自定义超时动作下,生成故障日志。 | |
| 56 | +| [typedef size_t (\*OH_HiCollie_FreezeCallback)(OH_HiCollie_Freeze_Type type, void* buffer, size_t size)](#oh_hicollie_freezecallback) | OH_HiCollie_FreezeCallback | 冻屏事件使用的回调。 | | ||
| 57 | +| [void* OH_HiCollie_SetFreezeCallback(OH_HiCollie_FreezeCallback callback)](#oh_hicollie_setfreezecallback) | - | 将冻屏回调设置进系统,系统将在冻屏事件发生时回调此函数。 | | ||
| 58 | +| [HiCollie_ErrorCode OH_HiCollie_AssociateProcessReport(bool isFreezeEvent)](#oh_hicollie_associateprocessreport) | - | 报告一个进程的冻屏事件,此时会生成APP_HICOLLIE类型HiAppEvent事件。 | | ||
| 55 | 59 | ||
| 56 | ## 枚举类型说明 | 60 | ## 枚举类型说明 |
| 57 | 61 | ||
| @@ -77,6 +81,7 @@ enum HiCollie_ErrorCode | |||
| 77 | | HICOLLIE_INVALID_TIMEOUT_VALUE = 29800004 | 无效的函数执行超时时间阈值。<br>**起始版本:** 18 | | 81 | | HICOLLIE_INVALID_TIMEOUT_VALUE = 29800004 | 无效的函数执行超时时间阈值。<br>**起始版本:** 18 | |
| 78 | | HICOLLIE_WRONG_PROCESS_CONTEXT = 29800005 | 函数执行超时检测接入进程错误。<br>**起始版本:** 18 | | 82 | | HICOLLIE_WRONG_PROCESS_CONTEXT = 29800005 | 函数执行超时检测接入进程错误。<br>**起始版本:** 18 | |
| 79 | | HICOLLIE_WRONG_TIMER_ID_OUTPUT_PARAM = 29800006 | 用于保存返回的计时器id的指针不应为NULL。<br>**起始版本:** 18 | | 83 | | HICOLLIE_WRONG_TIMER_ID_OUTPUT_PARAM = 29800006 | 用于保存返回的计时器id的指针不应为NULL。<br>**起始版本:** 18 | |
| 84 | +| OH_HICOLLIE_REACH_REPORT_LIMIT = 29800007 | 上报频率超过限制。<br>**起始版本:** 24 | | ||
| 80 | 85 | ||
| 81 | ### HiCollie_Flag | 86 | ### HiCollie_Flag |
| 82 | 87 | ||
| @@ -97,6 +102,29 @@ enum HiCollie_Flag | |||
| 97 | | HICOLLIE_FLAG_LOG = (1 << 0) | 生成日志。 | | 102 | | HICOLLIE_FLAG_LOG = (1 << 0) | 生成日志。 | |
| 98 | | HICOLLIE_FLAG_RECOVERY = (1 << 1) | 执行恢复动作。 | | 103 | | HICOLLIE_FLAG_RECOVERY = (1 << 1) | 执行恢复动作。 | |
| 99 | 104 | ||
| 105 | +### OH_HiCollie_Freeze_Type | ||
| 106 | + | ||
| 107 | +```c | ||
| 108 | +enum OH_HiCollie_Freeze_Type | ||
| 109 | +``` | ||
| 110 | + | ||
| 111 | +**描述** | ||
| 112 | + | ||
| 113 | +定义FreezeCallback返回的冻屏类型。 | ||
| 114 | + | ||
| 115 | +**起始版本:** 24 | ||
| 116 | + | ||
| 117 | +| 枚举项 | 描述 | | ||
| 118 | +| -- | -- | | ||
| 119 | +| OH_THREAD_BLOCK_3S | 主线程超时一个周期。<br>**起始版本:** 24 | | ||
一个周期:这个是规范表述吗?开发者是否容易理解? ![]() ![]() | |||
| 120 | +| OH_THREAD_BLOCK_6S | 主线程超时两个周期。<br>**起始版本:** 24 | | ||
| 121 | +| OH_LIFECYCLE_HALF_TIMEOUT | Ability生命周期超时一个周期。<br>**起始版本:** 24 | | ||
| 122 | +| OH_LIFECYCLE_TIMEOUT | Ability生命周期超时两个周期。<br>**起始版本:** 24 | | ||
| 123 | +| OH_APP_INPUT_BLOCK | 输入事件超时。<br>**起始版本:** 24 | | ||
| 124 | +| OH_BUSINESS_THREAD_BLOCK_3S | 通过[OH_HiCollie_Report](capi-hicollie-h.md#oh_hicollie_report)上报3S冻屏事件。<br>**起始版本:** 24 | | ||
| 125 | +| OH_BUSINESS_THREAD_BLOCK_6S | 通过[OH_HiCollie_Report](capi-hicollie-h.md#oh_hicollie_report)上报6S冻屏事件。<br>**起始版本:** 24 | | ||
| 126 | +| OH_BUSINESS_INPUT_BLOCK | 通过[OH_HiCollie_ReportInputBlock](capi-hicollie-h.md#oh_hicollie_reportinputblock)上报冻屏事件。<br>**起始版本:** 24 | | ||
| 127 | + | ||
| 100 | 128 | ||
| 101 | ## 函数说明 | 129 | ## 函数说明 |
| 102 | 130 | ||
| @@ -342,4 +370,89 @@ void OH_HiCollie_CancelTimer(int id) | |||
| 342 | | -- | -- | | 370 | | -- | -- | |
| 343 | | int id | 执行[OH_HiCollie_SetTimer](capi-hicollie-h.md#oh_hicollie_settimer)函数后更新的计时器id。 | | 371 | | int id | 执行[OH_HiCollie_SetTimer](capi-hicollie-h.md#oh_hicollie_settimer)函数后更新的计时器id。 | |
| 344 | 372 | ||
| 373 | +### OH_HiCollie_FreezeCallback() | ||
| 345 | 374 | ||
| 375 | +```c | ||
| 376 | +typedef size_t (*OH_HiCollie_FreezeCallback)(OH_HiCollie_Freeze_Type type, void* buffer, size_t size) | ||
| 377 | +``` | ||
| 378 | + | ||
| 379 | +**描述** | ||
| 380 | + | ||
| 381 | +冻屏事件使用的回调[OH_HiCollie_SetFreezeCallback](capi-hicollie-h.md#oh_hicollie_setfreezecallback)。 | ||
| 382 | + | ||
| 383 | +**起始版本:** 24 | ||
| 384 | + | ||
| 385 | +**参数:** | ||
| 386 | + | ||
| 387 | +| 参数项 | 描述 | | ||
| 388 | +| -- | -- | | ||
| 389 | +| OH_HiCollie_Freeze_Type type | 冻屏事件类型。 | | ||
| 390 | +| void\* buffer | 系统提供log buffer,其中的内容将被迁移到APP_FREEZE或APP_HICOLLIE事件当中。 | | ||
| 391 | +| size_t size | 可以使用的缓冲区大小,最大值为64KB。 如果超过上限,可能导致应用crash。| | ||
| 392 | + | ||
| 393 | +**返回:** | ||
| 394 | + | ||
| 395 | +| 类型 | 说明 | | ||
| 396 | +| -- | -- | | ||
| 397 | +| size_t | 已使用的缓冲区大小,单位字节。| | ||
| 398 | + | ||
| 399 | +> **注意:** | ||
| 400 | +> | ||
| 401 | +> 返回值超过64KB时,日志内容可能为空。 | ||
| 402 | + | ||
| 403 | +### OH_HiCollie_SetFreezeCallback() | ||
| 404 | + | ||
| 405 | +```c | ||
| 406 | +void* OH_HiCollie_SetFreezeCallback(OH_HiCollie_FreezeCallback callback) | ||
| 407 | +``` | ||
| 408 | + | ||
| 409 | +**描述** | ||
| 410 | + | ||
| 411 | +将冻屏回调设置进系统,系统将在冻屏事件发生时回调此函数。 | ||
| 412 | + | ||
| 413 | +**起始版本:** 24 | ||
| 414 | + | ||
| 415 | +**参数:** | ||
| 416 | + | ||
| 417 | +| 参数项 | 描述 | | ||
| 418 | +| -- | -- | | ||
| 419 | +| [OH_HiCollie_FreezeCallback](capi-hicollie-h.md#oh_hicollie_freezecallback) callback | 回调函数。 | | ||
| 420 | + | ||
| 421 | +**返回:** | ||
| 422 | + | ||
| 423 | +| 类型 | 说明 | | ||
| 424 | +| -- | -- | | ||
| 425 | +| void* | 本进程内上次传入的回调函数。| | ||
| 426 | + | ||
| 427 | +### OH_HiCollie_AssociateProcessReport() | ||
| 428 | + | ||
| 429 | +```c | ||
| 430 | +HiCollie_ErrorCode OH_HiCollie_AssociateProcessReport(bool isFreezeEvent) | ||
| 431 | +``` | ||
| 432 | + | ||
| 433 | +**描述** | ||
| 434 | + | ||
| 435 | +报告一个进程的冻屏事件,此时会生成APP_HICOLLIE类型HiAppEvent事件。 | ||
| 436 | + | ||
| 437 | +**起始版本:** 24 | ||
| 438 | + | ||
| 439 | +**参数:** | ||
| 440 | + | ||
| 441 | +| 参数项 | 描述 | | ||
| 442 | +| -- | -- | | ||
| 443 | +| bool isFreezeEvent | 上报事件类型。true:上报6S冻屏事件。false:上报3S冻屏事件。 | | ||
| 444 | + | ||
| 445 | + | ||
| 446 | +> **说明:** | ||
| 447 | +> | ||
| 448 | +> BUSINESS_THREAD_BLOCK_3S、BUSINESS_THREAD_BLOCK_6S等同于BUSSINESS_THREAD_BLOCK_3S、BUSSINESS_THREAD_BLOCK_6S。 | ||
这个是针对什么的说明???与上下内容没有直接的逻辑关联 ![]() ![]() | |||
| 449 | + | ||
| 450 | +**返回:** | ||
| 451 | + | ||
| 452 | +| 类型 | 说明 | | ||
| 453 | +| -- | -- | | ||
| 454 | +| [HiCollie_ErrorCode](capi-hicollie-h.md#hicollie_errorcode) | HICOLLIE_SUCCESS:0 - 成功。<br> OH_HICOLLIE_REACH_REPORT_LIMIT:29800007 - 上报频率过高。 | | ||
| 455 | + | ||
| 456 | +> **说明:** | ||
| 457 | +> | ||
| 458 | +> 1分钟内最多上报1次。 | ||
这个是不是放在返回值中??不需要单独说明? ![]() ![]() | |||


示例代码是不是都采用了sample同源 请全量排查