161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit PerformanceAnalysisKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Provides the system event logging function for applications to log the fault, statistical, security,
2561847f8eSopenharmony_ci * and user behavior events reported during running. Based on event information,
2661847f8eSopenharmony_ci * you will be able to analyze the running status of applications.
2761847f8eSopenharmony_ci *
2861847f8eSopenharmony_ci * @namespace hiSysEvent
2961847f8eSopenharmony_ci * @syscap SystemCapability.HiviewDFX.HiSysEvent
3061847f8eSopenharmony_ci * @systemapi hide for inner use
3161847f8eSopenharmony_ci * @since 9
3261847f8eSopenharmony_ci */
3361847f8eSopenharmony_cideclare namespace hiSysEvent {
3461847f8eSopenharmony_ci  /**
3561847f8eSopenharmony_ci   * Enumerate system event types.
3661847f8eSopenharmony_ci   *
3761847f8eSopenharmony_ci   * @enum {number}
3861847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
3961847f8eSopenharmony_ci   * @systemapi hide for inner use
4061847f8eSopenharmony_ci   * @since 9
4161847f8eSopenharmony_ci   */
4261847f8eSopenharmony_ci  enum EventType {
4361847f8eSopenharmony_ci    /**
4461847f8eSopenharmony_ci     * Fault event
4561847f8eSopenharmony_ci     *
4661847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
4761847f8eSopenharmony_ci     * @systemapi hide for inner use
4861847f8eSopenharmony_ci     * @since 9
4961847f8eSopenharmony_ci     */
5061847f8eSopenharmony_ci    FAULT = 1,
5161847f8eSopenharmony_ci
5261847f8eSopenharmony_ci    /**
5361847f8eSopenharmony_ci     * Statistic event
5461847f8eSopenharmony_ci     *
5561847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
5661847f8eSopenharmony_ci     * @systemapi hide for inner use
5761847f8eSopenharmony_ci     * @since 9
5861847f8eSopenharmony_ci     */
5961847f8eSopenharmony_ci    STATISTIC = 2,
6061847f8eSopenharmony_ci
6161847f8eSopenharmony_ci    /**
6261847f8eSopenharmony_ci     * Security event
6361847f8eSopenharmony_ci     *
6461847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
6561847f8eSopenharmony_ci     * @systemapi hide for inner use
6661847f8eSopenharmony_ci     * @since 9
6761847f8eSopenharmony_ci     */
6861847f8eSopenharmony_ci    SECURITY = 3,
6961847f8eSopenharmony_ci
7061847f8eSopenharmony_ci    /**
7161847f8eSopenharmony_ci     * System behavior event
7261847f8eSopenharmony_ci     *
7361847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
7461847f8eSopenharmony_ci     * @systemapi hide for inner use
7561847f8eSopenharmony_ci     * @since 9
7661847f8eSopenharmony_ci     */
7761847f8eSopenharmony_ci    BEHAVIOR = 4
7861847f8eSopenharmony_ci  }
7961847f8eSopenharmony_ci
8061847f8eSopenharmony_ci  /**
8161847f8eSopenharmony_ci   * Definition of written system event information.
8261847f8eSopenharmony_ci   *
8361847f8eSopenharmony_ci   * @interface SysEventInfo
8461847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
8561847f8eSopenharmony_ci   * @systemapi hide for inner use
8661847f8eSopenharmony_ci   * @since 9
8761847f8eSopenharmony_ci   */
8861847f8eSopenharmony_ci  interface SysEventInfo {
8961847f8eSopenharmony_ci    /**
9061847f8eSopenharmony_ci     * The domain of the event.
9161847f8eSopenharmony_ci     *
9261847f8eSopenharmony_ci     * @type { string }
9361847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
9461847f8eSopenharmony_ci     * @systemapi hide for inner use
9561847f8eSopenharmony_ci     * @since 9
9661847f8eSopenharmony_ci     */
9761847f8eSopenharmony_ci    domain: string;
9861847f8eSopenharmony_ci
9961847f8eSopenharmony_ci    /**
10061847f8eSopenharmony_ci     * The name of the event.
10161847f8eSopenharmony_ci     *
10261847f8eSopenharmony_ci     * @type { string }
10361847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
10461847f8eSopenharmony_ci     * @systemapi hide for inner use
10561847f8eSopenharmony_ci     * @since 9
10661847f8eSopenharmony_ci     */
10761847f8eSopenharmony_ci    name: string;
10861847f8eSopenharmony_ci
10961847f8eSopenharmony_ci    /**
11061847f8eSopenharmony_ci     * The type of the event.
11161847f8eSopenharmony_ci     *
11261847f8eSopenharmony_ci     * @type { EventType }
11361847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
11461847f8eSopenharmony_ci     * @systemapi hide for inner use
11561847f8eSopenharmony_ci     * @since 9
11661847f8eSopenharmony_ci     */
11761847f8eSopenharmony_ci    eventType: EventType;
11861847f8eSopenharmony_ci
11961847f8eSopenharmony_ci    /**
12061847f8eSopenharmony_ci     * The params of the event.
12161847f8eSopenharmony_ci     *
12261847f8eSopenharmony_ci     * @type { object }
12361847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
12461847f8eSopenharmony_ci     * @systemapi hide for inner use
12561847f8eSopenharmony_ci     * @since 9
12661847f8eSopenharmony_ci     */
12761847f8eSopenharmony_ci    /**
12861847f8eSopenharmony_ci     * The params of the event.
12961847f8eSopenharmony_ci     *
13061847f8eSopenharmony_ci     * @type { ?object }
13161847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
13261847f8eSopenharmony_ci     * @systemapi hide for inner use
13361847f8eSopenharmony_ci     * @since 12
13461847f8eSopenharmony_ci     */
13561847f8eSopenharmony_ci    params?: object;
13661847f8eSopenharmony_ci  }
13761847f8eSopenharmony_ci
13861847f8eSopenharmony_ci  /**
13961847f8eSopenharmony_ci   * Write system event.
14061847f8eSopenharmony_ci   *
14161847f8eSopenharmony_ci   * @param {SysEventInfo} info - system event information to be written.
14261847f8eSopenharmony_ci   * @returns {Promise<void>} - Return Promise
14361847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
14461847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
14561847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
14661847f8eSopenharmony_ci   *                         3. Parameter verification failed.
14761847f8eSopenharmony_ci   * @throws {BusinessError} 11200001 - Invalid event domain.
14861847f8eSopenharmony_ci   * @throws {BusinessError} 11200002 - Invalid event name.
14961847f8eSopenharmony_ci   * @throws {BusinessError} 11200003 - Abnormal environment.
15061847f8eSopenharmony_ci   * @throws {BusinessError} 11200004 - The event length exceeds the limit.
15161847f8eSopenharmony_ci   * @throws {BusinessError} 11200051 - Invalid event parameter.
15261847f8eSopenharmony_ci   * @throws {BusinessError} 11200052 - The size of the event parameter of the string type exceeds the limit.
15361847f8eSopenharmony_ci   * @throws {BusinessError} 11200053 - The number of event parameters exceeds the limit.
15461847f8eSopenharmony_ci   * @throws {BusinessError} 11200054 - The number of event parameters of the array type exceeds the limit.
15561847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
15661847f8eSopenharmony_ci   * @systemapi hide for inner use
15761847f8eSopenharmony_ci   * @since 9
15861847f8eSopenharmony_ci   */
15961847f8eSopenharmony_ci  function write(info: SysEventInfo): Promise<void>;
16061847f8eSopenharmony_ci
16161847f8eSopenharmony_ci  /**
16261847f8eSopenharmony_ci   * Write system event.
16361847f8eSopenharmony_ci   *
16461847f8eSopenharmony_ci   * @param {SysEventInfo} info - system event information to be written.
16561847f8eSopenharmony_ci   * @param {AsyncCallback<void>} callback - callback function.
16661847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
16761847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
16861847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
16961847f8eSopenharmony_ci   *                         3. Parameter verification failed.
17061847f8eSopenharmony_ci   * @throws {BusinessError} 11200001 - Invalid event domain.
17161847f8eSopenharmony_ci   * @throws {BusinessError} 11200002 - Invalid event name.
17261847f8eSopenharmony_ci   * @throws {BusinessError} 11200003 - Abnormal environment.
17361847f8eSopenharmony_ci   * @throws {BusinessError} 11200004 - The event length exceeds the limit.
17461847f8eSopenharmony_ci   * @throws {BusinessError} 11200051 - Invalid event parameter.
17561847f8eSopenharmony_ci   * @throws {BusinessError} 11200052 - The size of the event parameter of the string type exceeds the limit.
17661847f8eSopenharmony_ci   * @throws {BusinessError} 11200053 - The number of event parameters exceeds the limit.
17761847f8eSopenharmony_ci   * @throws {BusinessError} 11200054 - The number of event parameters of the array type exceeds the limit.
17861847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
17961847f8eSopenharmony_ci   * @systemapi hide for inner use
18061847f8eSopenharmony_ci   * @since 9
18161847f8eSopenharmony_ci   */
18261847f8eSopenharmony_ci  function write(info: SysEventInfo, callback: AsyncCallback<void>): void;
18361847f8eSopenharmony_ci
18461847f8eSopenharmony_ci  /**
18561847f8eSopenharmony_ci   * Enumerate search system event rule type.
18661847f8eSopenharmony_ci   *
18761847f8eSopenharmony_ci   * @enum {number}
18861847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
18961847f8eSopenharmony_ci   * @systemapi hide for inner use
19061847f8eSopenharmony_ci   * @since 9
19161847f8eSopenharmony_ci   */
19261847f8eSopenharmony_ci  enum RuleType {
19361847f8eSopenharmony_ci    /**
19461847f8eSopenharmony_ci     * Whole word match
19561847f8eSopenharmony_ci     *
19661847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
19761847f8eSopenharmony_ci     * @systemapi hide for inner use
19861847f8eSopenharmony_ci     * @since 9
19961847f8eSopenharmony_ci     */
20061847f8eSopenharmony_ci    WHOLE_WORD = 1,
20161847f8eSopenharmony_ci
20261847f8eSopenharmony_ci    /**
20361847f8eSopenharmony_ci     * Prefix match
20461847f8eSopenharmony_ci     *
20561847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
20661847f8eSopenharmony_ci     * @systemapi hide for inner use
20761847f8eSopenharmony_ci     * @since 9
20861847f8eSopenharmony_ci     */
20961847f8eSopenharmony_ci    PREFIX = 2,
21061847f8eSopenharmony_ci
21161847f8eSopenharmony_ci    /**
21261847f8eSopenharmony_ci     * Regular match
21361847f8eSopenharmony_ci     *
21461847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
21561847f8eSopenharmony_ci     * @systemapi hide for inner use
21661847f8eSopenharmony_ci     * @since 9
21761847f8eSopenharmony_ci     */
21861847f8eSopenharmony_ci    REGULAR = 3
21961847f8eSopenharmony_ci  }
22061847f8eSopenharmony_ci
22161847f8eSopenharmony_ci  /**
22261847f8eSopenharmony_ci   * Definition listener rule for system event information.
22361847f8eSopenharmony_ci   *
22461847f8eSopenharmony_ci   * @interface WatchRule
22561847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
22661847f8eSopenharmony_ci   * @systemapi hide for inner use
22761847f8eSopenharmony_ci   * @since 9
22861847f8eSopenharmony_ci   */
22961847f8eSopenharmony_ci  interface WatchRule {
23061847f8eSopenharmony_ci    /**
23161847f8eSopenharmony_ci     * The domain of the event.
23261847f8eSopenharmony_ci     *
23361847f8eSopenharmony_ci     * @type { string }
23461847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
23561847f8eSopenharmony_ci     * @systemapi hide for inner use
23661847f8eSopenharmony_ci     * @since 9
23761847f8eSopenharmony_ci     */
23861847f8eSopenharmony_ci    domain: string;
23961847f8eSopenharmony_ci
24061847f8eSopenharmony_ci    /**
24161847f8eSopenharmony_ci     * The name of the event.
24261847f8eSopenharmony_ci     *
24361847f8eSopenharmony_ci     * @type { string }
24461847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
24561847f8eSopenharmony_ci     * @systemapi hide for inner use
24661847f8eSopenharmony_ci     * @since 9
24761847f8eSopenharmony_ci     */
24861847f8eSopenharmony_ci    name: string;
24961847f8eSopenharmony_ci
25061847f8eSopenharmony_ci    /**
25161847f8eSopenharmony_ci     * The tag of the event.
25261847f8eSopenharmony_ci     *
25361847f8eSopenharmony_ci     * @type { string }
25461847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
25561847f8eSopenharmony_ci     * @systemapi hide for inner use
25661847f8eSopenharmony_ci     * @since 9
25761847f8eSopenharmony_ci     */
25861847f8eSopenharmony_ci    /**
25961847f8eSopenharmony_ci     * The tag of the event.
26061847f8eSopenharmony_ci     *
26161847f8eSopenharmony_ci     * @type { ?string }
26261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
26361847f8eSopenharmony_ci     * @systemapi hide for inner use
26461847f8eSopenharmony_ci     * @since 12
26561847f8eSopenharmony_ci     */
26661847f8eSopenharmony_ci    tag?: string;
26761847f8eSopenharmony_ci
26861847f8eSopenharmony_ci    /**
26961847f8eSopenharmony_ci     * The rule of match system event
27061847f8eSopenharmony_ci     *
27161847f8eSopenharmony_ci     * @type { RuleType }
27261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
27361847f8eSopenharmony_ci     * @systemapi hide for inner use
27461847f8eSopenharmony_ci     * @since 9
27561847f8eSopenharmony_ci     */
27661847f8eSopenharmony_ci    ruleType: RuleType;
27761847f8eSopenharmony_ci  }
27861847f8eSopenharmony_ci
27961847f8eSopenharmony_ci  /**
28061847f8eSopenharmony_ci   * Definition watcher for system event information.
28161847f8eSopenharmony_ci   *
28261847f8eSopenharmony_ci   * @interface Watcher
28361847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
28461847f8eSopenharmony_ci   * @systemapi hide for inner use
28561847f8eSopenharmony_ci   * @since 9
28661847f8eSopenharmony_ci   */
28761847f8eSopenharmony_ci  interface Watcher {
28861847f8eSopenharmony_ci    /**
28961847f8eSopenharmony_ci     * Rule of filter system event
29061847f8eSopenharmony_ci     *
29161847f8eSopenharmony_ci     * @type { WatchRule[] }
29261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
29361847f8eSopenharmony_ci     * @systemapi hide for inner use
29461847f8eSopenharmony_ci     * @since 9
29561847f8eSopenharmony_ci     */
29661847f8eSopenharmony_ci    rules: WatchRule[];
29761847f8eSopenharmony_ci
29861847f8eSopenharmony_ci    /**
29961847f8eSopenharmony_ci    * Receive system event.
30061847f8eSopenharmony_ci    *
30161847f8eSopenharmony_ci    * @type { function }
30261847f8eSopenharmony_ci    * @syscap SystemCapability.HiviewDFX.HiSysEvent
30361847f8eSopenharmony_ci    * @systemapi hide for inner use
30461847f8eSopenharmony_ci    * @since 9
30561847f8eSopenharmony_ci    */
30661847f8eSopenharmony_ci    onEvent: (info: SysEventInfo) => void;
30761847f8eSopenharmony_ci
30861847f8eSopenharmony_ci    /**
30961847f8eSopenharmony_ci     * Hisysevent service shutdown.
31061847f8eSopenharmony_ci     *
31161847f8eSopenharmony_ci     * @type { function }
31261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
31361847f8eSopenharmony_ci     * @systemapi hide for inner use
31461847f8eSopenharmony_ci     * @since 9
31561847f8eSopenharmony_ci     */
31661847f8eSopenharmony_ci    onServiceDied: () => void;
31761847f8eSopenharmony_ci  }
31861847f8eSopenharmony_ci
31961847f8eSopenharmony_ci  /**
32061847f8eSopenharmony_ci   * Definition arguments for query system event information.
32161847f8eSopenharmony_ci   *
32261847f8eSopenharmony_ci   * @interface QueryArg
32361847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
32461847f8eSopenharmony_ci   * @systemapi hide for inner use
32561847f8eSopenharmony_ci   * @since 9
32661847f8eSopenharmony_ci   */
32761847f8eSopenharmony_ci  interface QueryArg {
32861847f8eSopenharmony_ci    /**
32961847f8eSopenharmony_ci     * Begin time
33061847f8eSopenharmony_ci     *
33161847f8eSopenharmony_ci     * @type { number }
33261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
33361847f8eSopenharmony_ci     * @systemapi hide for inner use
33461847f8eSopenharmony_ci     * @since 9
33561847f8eSopenharmony_ci     */
33661847f8eSopenharmony_ci    beginTime: number;
33761847f8eSopenharmony_ci
33861847f8eSopenharmony_ci    /**
33961847f8eSopenharmony_ci     * End time
34061847f8eSopenharmony_ci     *
34161847f8eSopenharmony_ci     * @type { number }
34261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
34361847f8eSopenharmony_ci     * @systemapi hide for inner use
34461847f8eSopenharmony_ci     * @since 9
34561847f8eSopenharmony_ci     */
34661847f8eSopenharmony_ci    endTime: number;
34761847f8eSopenharmony_ci
34861847f8eSopenharmony_ci    /**
34961847f8eSopenharmony_ci     * Max number of receive system event
35061847f8eSopenharmony_ci     *
35161847f8eSopenharmony_ci     * @type { number }
35261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
35361847f8eSopenharmony_ci     * @systemapi hide for inner use
35461847f8eSopenharmony_ci     * @since 9
35561847f8eSopenharmony_ci     */
35661847f8eSopenharmony_ci    maxEvents: number;
35761847f8eSopenharmony_ci
35861847f8eSopenharmony_ci    /**
35961847f8eSopenharmony_ci     * Begin sequence
36061847f8eSopenharmony_ci     *
36161847f8eSopenharmony_ci     * @type { ?number }
36261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
36361847f8eSopenharmony_ci     * @systemapi hide for inner use
36461847f8eSopenharmony_ci     * @since 10
36561847f8eSopenharmony_ci     */
36661847f8eSopenharmony_ci    fromSeq?: number;
36761847f8eSopenharmony_ci
36861847f8eSopenharmony_ci    /**
36961847f8eSopenharmony_ci     * End sequence
37061847f8eSopenharmony_ci     *
37161847f8eSopenharmony_ci     * @type { ?number }
37261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
37361847f8eSopenharmony_ci     * @systemapi hide for inner use
37461847f8eSopenharmony_ci     * @since 10
37561847f8eSopenharmony_ci     */
37661847f8eSopenharmony_ci    toSeq?: number;
37761847f8eSopenharmony_ci  }
37861847f8eSopenharmony_ci
37961847f8eSopenharmony_ci  /**
38061847f8eSopenharmony_ci   * Definition event for query system event information
38161847f8eSopenharmony_ci   *
38261847f8eSopenharmony_ci   * @interface QueryRule
38361847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
38461847f8eSopenharmony_ci   * @systemapi hide for inner use
38561847f8eSopenharmony_ci   * @since 9
38661847f8eSopenharmony_ci   */
38761847f8eSopenharmony_ci  interface QueryRule {
38861847f8eSopenharmony_ci    /**
38961847f8eSopenharmony_ci     * The domain of the event
39061847f8eSopenharmony_ci     *
39161847f8eSopenharmony_ci     * @type { string }
39261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
39361847f8eSopenharmony_ci     * @systemapi hide for inner use
39461847f8eSopenharmony_ci     * @since 9
39561847f8eSopenharmony_ci     */
39661847f8eSopenharmony_ci    domain: string;
39761847f8eSopenharmony_ci
39861847f8eSopenharmony_ci    /**
39961847f8eSopenharmony_ci     * List of event name
40061847f8eSopenharmony_ci     *
40161847f8eSopenharmony_ci     * @type { string[] }
40261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
40361847f8eSopenharmony_ci     * @systemapi hide for inner use
40461847f8eSopenharmony_ci     * @since 9
40561847f8eSopenharmony_ci     */
40661847f8eSopenharmony_ci    names: string[];
40761847f8eSopenharmony_ci
40861847f8eSopenharmony_ci    /**
40961847f8eSopenharmony_ci     * Extra parameter condition of event
41061847f8eSopenharmony_ci     *
41161847f8eSopenharmony_ci     * @type { ?string }
41261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
41361847f8eSopenharmony_ci     * @systemapi hide for inner use
41461847f8eSopenharmony_ci     * @since 10
41561847f8eSopenharmony_ci     */
41661847f8eSopenharmony_ci    condition?: string;
41761847f8eSopenharmony_ci  }
41861847f8eSopenharmony_ci
41961847f8eSopenharmony_ci  /**
42061847f8eSopenharmony_ci   * Definition query result handler
42161847f8eSopenharmony_ci   *
42261847f8eSopenharmony_ci   * @interface Querier
42361847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
42461847f8eSopenharmony_ci   * @systemapi hide for inner use
42561847f8eSopenharmony_ci   * @since 9
42661847f8eSopenharmony_ci   */
42761847f8eSopenharmony_ci  interface Querier {
42861847f8eSopenharmony_ci    /**
42961847f8eSopenharmony_ci     * Handle query result, the query result will be send in several times.
43061847f8eSopenharmony_ci     *
43161847f8eSopenharmony_ci     * @type { function }
43261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
43361847f8eSopenharmony_ci     * @systemapi hide for inner use
43461847f8eSopenharmony_ci     * @since 9
43561847f8eSopenharmony_ci     */
43661847f8eSopenharmony_ci    onQuery: (infos: SysEventInfo[]) => void;
43761847f8eSopenharmony_ci
43861847f8eSopenharmony_ci    /**
43961847f8eSopenharmony_ci     * Notify querier execute query has finished.
44061847f8eSopenharmony_ci     *
44161847f8eSopenharmony_ci     * @type { function }
44261847f8eSopenharmony_ci     * @syscap SystemCapability.HiviewDFX.HiSysEvent
44361847f8eSopenharmony_ci     * @systemapi hide for inner use
44461847f8eSopenharmony_ci     * @since 9
44561847f8eSopenharmony_ci     */
44661847f8eSopenharmony_ci    onComplete: (reason: number, total: number) => void;
44761847f8eSopenharmony_ci  }
44861847f8eSopenharmony_ci
44961847f8eSopenharmony_ci  /**
45061847f8eSopenharmony_ci   * Add watcher to watch system event
45161847f8eSopenharmony_ci   *
45261847f8eSopenharmony_ci   * @permission ohos.permission.READ_DFX_SYSEVENT
45361847f8eSopenharmony_ci   * @param {Watcher} watcher watch system event
45461847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT.
45561847f8eSopenharmony_ci   * @throws {BusinessError} 202 - System API is not allowed called by Non-system application.
45661847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
45761847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
45861847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
45961847f8eSopenharmony_ci   *                         3. Parameter verification failed.
46061847f8eSopenharmony_ci   * @throws {BusinessError} 11200101 - The number of watchers exceeds the limit.
46161847f8eSopenharmony_ci   * @throws {BusinessError} 11200102 - The number of watch rules exceeds the limit.
46261847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
46361847f8eSopenharmony_ci   * @systemapi hide for inner use
46461847f8eSopenharmony_ci   * @since 9
46561847f8eSopenharmony_ci   */
46661847f8eSopenharmony_ci  function addWatcher(watcher: Watcher): void;
46761847f8eSopenharmony_ci
46861847f8eSopenharmony_ci  /**
46961847f8eSopenharmony_ci   * Remove watcher
47061847f8eSopenharmony_ci   *
47161847f8eSopenharmony_ci   * @permission ohos.permission.READ_DFX_SYSEVENT
47261847f8eSopenharmony_ci   * @param {Watcher} watcher watch system event
47361847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT.
47461847f8eSopenharmony_ci   * @throws {BusinessError} 202 - System API is not allowed called by Non-system application.
47561847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
47661847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
47761847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
47861847f8eSopenharmony_ci   *                         3. Parameter verification failed.
47961847f8eSopenharmony_ci   * @throws {BusinessError} 11200201 - The watcher does not exist.
48061847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
48161847f8eSopenharmony_ci   * @systemapi hide for inner use
48261847f8eSopenharmony_ci   * @since 9
48361847f8eSopenharmony_ci   */
48461847f8eSopenharmony_ci  function removeWatcher(watcher: Watcher): void;
48561847f8eSopenharmony_ci
48661847f8eSopenharmony_ci  /**
48761847f8eSopenharmony_ci   * Query system event
48861847f8eSopenharmony_ci   *
48961847f8eSopenharmony_ci   * @permission ohos.permission.READ_DFX_SYSEVENT
49061847f8eSopenharmony_ci   * @param {QueryArg} queryArg common arguments of query system event
49161847f8eSopenharmony_ci   * @param {QueryRule[]} rules rule of query system event
49261847f8eSopenharmony_ci   * @param {Querier} querier receive query result
49361847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT.
49461847f8eSopenharmony_ci   * @throws {BusinessError} 202 - System API is not allowed called by Non-system application.
49561847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
49661847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
49761847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
49861847f8eSopenharmony_ci   *                         3. Parameter verification failed.
49961847f8eSopenharmony_ci   * @throws {BusinessError} 11200301 - The number of query rules exceeds the limit.
50061847f8eSopenharmony_ci   * @throws {BusinessError} 11200302 - Invalid query rule.
50161847f8eSopenharmony_ci   * @throws {BusinessError} 11200303 - The number of concurrent queriers exceeds the limit.
50261847f8eSopenharmony_ci   * @throws {BusinessError} 11200304 - The query frequency exceeds the limit.
50361847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
50461847f8eSopenharmony_ci   * @systemapi hide for inner use
50561847f8eSopenharmony_ci   * @since 9
50661847f8eSopenharmony_ci   */
50761847f8eSopenharmony_ci  function query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): void;
50861847f8eSopenharmony_ci
50961847f8eSopenharmony_ci  /**
51061847f8eSopenharmony_ci   * Export system event
51161847f8eSopenharmony_ci   *
51261847f8eSopenharmony_ci   * @permission ohos.permission.READ_DFX_SYSEVENT
51361847f8eSopenharmony_ci   * @param {QueryArg} queryArg common arguments of query system event
51461847f8eSopenharmony_ci   * @param {QueryRule[]} rules rule of query system event
51561847f8eSopenharmony_ci   * @returns {number} return hiview receive task time.
51661847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT.
51761847f8eSopenharmony_ci   * @throws {BusinessError} 202 - System API is not allowed called by Non-system application.
51861847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
51961847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
52061847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
52161847f8eSopenharmony_ci   *                         3. Parameter verification failed.
52261847f8eSopenharmony_ci   * @throws {BusinessError} 11200301 - The number of query rules exceeds the limit.
52361847f8eSopenharmony_ci   * @throws {BusinessError} 11200302 - Invalid query rule.
52461847f8eSopenharmony_ci   * @throws {BusinessError} 11200304 – The query frequency exceeds the limit.
52561847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
52661847f8eSopenharmony_ci   * @systemapi hide for inner use
52761847f8eSopenharmony_ci   * @since 10
52861847f8eSopenharmony_ci   */
52961847f8eSopenharmony_ci  function exportSysEvents(queryArg: QueryArg, rules: QueryRule[]): number;
53061847f8eSopenharmony_ci
53161847f8eSopenharmony_ci  /**
53261847f8eSopenharmony_ci   * Subscribe system event
53361847f8eSopenharmony_ci   *
53461847f8eSopenharmony_ci   * @permission ohos.permission.READ_DFX_SYSEVENT
53561847f8eSopenharmony_ci   * @param {QueryRule[]} rules rule of subscribe system event
53661847f8eSopenharmony_ci   * @returns {number} return hiview receive task time.
53761847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT.
53861847f8eSopenharmony_ci   * @throws {BusinessError} 202 - System API is not allowed called by Non-system application.
53961847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
54061847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
54161847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
54261847f8eSopenharmony_ci   *                         3. Parameter verification failed.
54361847f8eSopenharmony_ci   * @throws {BusinessError} 11200301 - The number of query rules exceeds the limit.
54461847f8eSopenharmony_ci   * @throws {BusinessError} 11200302 - Invalid query rule.
54561847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
54661847f8eSopenharmony_ci   * @systemapi hide for inner use
54761847f8eSopenharmony_ci   * @since 10
54861847f8eSopenharmony_ci   */
54961847f8eSopenharmony_ci  function subscribe(rules: QueryRule[]): number;
55061847f8eSopenharmony_ci
55161847f8eSopenharmony_ci  /**
55261847f8eSopenharmony_ci   * Unsubscribe system event
55361847f8eSopenharmony_ci   *
55461847f8eSopenharmony_ci   * @permission ohos.permission.READ_DFX_SYSEVENT
55561847f8eSopenharmony_ci   * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT.
55661847f8eSopenharmony_ci   * @throws {BusinessError} 202 - System API is not allowed called by Non-system application.
55761847f8eSopenharmony_ci   * @throws {BusinessError} 401 - Parameter error. Possible causes:
55861847f8eSopenharmony_ci   *                         1. Mandatory parameters are left unspecified.
55961847f8eSopenharmony_ci   *                         2. Incorrect parameter types.
56061847f8eSopenharmony_ci   *                         3. Parameter verification failed.
56161847f8eSopenharmony_ci   * @throws {BusinessError} 11200305 – Unsubscription failed.
56261847f8eSopenharmony_ci   * @syscap SystemCapability.HiviewDFX.HiSysEvent
56361847f8eSopenharmony_ci   * @systemapi hide for inner use
56461847f8eSopenharmony_ci   * @since 10
56561847f8eSopenharmony_ci   */
56661847f8eSopenharmony_ci  function unsubscribe(): void;
56761847f8eSopenharmony_ci}
56861847f8eSopenharmony_ci
56961847f8eSopenharmony_ciexport default hiSysEvent;
570