安全审计相关具体可参考安全审计实现。import { securityAudit } from '@kit.DeviceSecurityKit'; import { BusinessError} from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; const TAG = "SecurityAuditAuditJsTest"; const callback = (event: securityAudit.AuditEvent) => { hilog.info(0x0000, TAG, '%{public}s', 'Security_SecurityAudit_JsApi_Func eventId= ' + event.eventId); hilog.info(0x0000, TAG, '%{public}s', 'Security_SecurityAudit_JsApi_Func version= ' + event.version); hilog.info(0x0000, TAG, '%{public}s', 'Security_SecurityAudit_JsApi_Func content= ' + event.content); hilog.info(0x0000, TAG, '%{public}s', 'Security_SecurityAudit_JsApi_Func timestamp= ' + event.timestamp); hilog.info(0x0000, TAG, '%{public}s', 'Security_SecurityAudit_JsApi_Func userId= ' + event.userId); hilog.info(0x0000, TAG, '%{public}s', 'Security_SecurityAudit_JsApi_Func deviceId= ' + event.deviceId); }; let auditEventInfo: securityAudit.AuditEventInfo = { eventId: 0x810800800 }; try { hilog.info(0x0000, TAG, 'on begin.'); securityAudit.on('auditEventOccur', auditEventInfo, callback); hilog.info(0x0000, TAG, 'Succeeded in on.'); } catch (err) { let e: BusinessError = err as BusinessError; hilog.error(0x0000, TAG, 'on failed: %{public}d %{public}s', e.code, e.message); }
安全审计相关具体可参考安全审计实现。