• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"),
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit MultimodalAwarenessKit
19 */
20
21import type { Callback } from './@ohos.base';
22
23/**
24 * This module provides the capability to subscribe to report the user status.
25 *
26 * @namespace userStatus
27 * @syscap SystemCapability.MultimodalAwareness.UserStatus
28 * @since 20
29 */
30declare namespace userStatus {
31  /**
32   * Represents the classification result of the user based on age group,
33   * including the detected category (e.g., child or adult) and the confidence score.
34   *
35   * @interface UserClassification
36   * @syscap SystemCapability.MultimodalAwareness.UserStatus
37   * @since 20
38   */
39  export interface UserClassification {
40    /**
41     * ageGroup
42     *
43     * @type  { ?UserAgeGroup }
44     * @syscap SystemCapability.MultimodalAwareness.UserStatus
45     * @since 20
46     */
47    ageGroup?: UserAgeGroup;
48
49    /**
50     * confidence for the detected ageGroup
51     *
52     * @type  { ?float }
53     * @syscap SystemCapability.MultimodalAwareness.UserStatus
54     * @since 20
55     */
56    confidence?: float;
57  }
58
59  /**
60   * Represents the user's age group (e.g., child, adult).
61   *
62   * @enum { number } UserAgeGroup
63   * @syscap SystemCapability.MultimodalAwareness.UserStatus
64   * @since 20
65   */
66  export enum UserAgeGroup {
67    /**
68     * Indicates that the operator is not a child.
69     *
70     * @syscap SystemCapability.MultimodalAwareness.UserStatus
71     * @since 20
72     */
73    OTHERS = 0,
74
75    /**
76     * Indicates that the operator is a child.
77     *
78     * @syscap SystemCapability.MultimodalAwareness.UserStatus
79     * @since 20
80     */
81    CHILD = 1
82  }
83
84  /**
85   * Subscribe to age group detection feature.
86   * @param { 'userAgeGroupDetected' } type - Indicates the event type.
87   * @param { Callback<UserClassification> } callback - Indicates the callback for getting the event data.
88   * @throws { BusinessError } 801 - Capability not supported. Function can not work correctly due to limited
89   * <br> device capabilities.
90   * @throws { BusinessError } 33900001 - Service exception. Possible causes:
91   * <br>1. System error, such as a null pointer and container-related exception.
92   * <br>2. Node-API invocation exception, such as invalid Node-API status.
93   * @throws { BusinessError } 33900002 - Subscription failed. Possible causes:
94   * <br>1. Callback registration failed.
95   * <br>2. Failed to bind the native object to the JS wrapper.
96   * <br>3. Node-API invocation exception, such as invalid Node-API status.
97   * <br>4. IPC request exception.
98   * @syscap SystemCapability.MultimodalAwareness.UserStatus
99   * @since 20
100   * @arkts 1.1&1.2
101   */
102  function on(type: 'userAgeGroupDetected', callback: Callback<UserClassification>): void;
103
104  /**
105   * Unsubscribe to age group detection feature.
106   * @param { 'userAgeGroupDetected' } type - Indicates the event type.
107   * @param { Callback<UserClassification> } [callback] - Indicates the callback for getting the event data.
108   * @throws { BusinessError } 801 - Capability not supported. Function can not work correctly due to limited
109   * <br> device capabilities.
110   * @throws { BusinessError } 33900001 - Service exception. Possible causes:
111   * <br>1. System error, such as a null pointer and container-related exception.
112   * <br>2. Node-API invocation exception, such as invalid Node-API status.
113   * @throws { BusinessError } 33900003 - Unsubscription failed. Possible causes:
114   * <br>1. Callback failure.
115   * <br>2. Node-API invocation exception, such as invalid Node-API status.
116   * <br>3. IPC request exception.
117   * @syscap SystemCapability.MultimodalAwareness.UserStatus
118   * @since 20
119   * @arkts 1.1&1.2
120   */
121  function off(type: 'userAgeGroupDetected', callback?: Callback<UserClassification>): void;
122}
123export default userStatus;