• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 action or motion.
25 *
26 * @namespace motion
27 * @syscap SystemCapability.MultimodalAwareness.Motion
28 * @since 15
29 */
30
31declare namespace motion {
32  /**
33   * Enum for operating hand status.
34   *
35   * @enum { number } OperatingHandStatus
36   * @syscap SystemCapability.MultimodalAwareness.Motion
37   * @since 15
38   */
39  export enum OperatingHandStatus {
40    /**
41     * indicates nothing has been detected.
42     *
43     * @syscap SystemCapability.MultimodalAwareness.Motion
44     * @since 15
45     */
46    UNKNOWN_STATUS = 0,
47    /**
48     * indicates the operating hand is left hand.
49     *
50     * @syscap SystemCapability.MultimodalAwareness.Motion
51     * @since 15
52     */
53    LEFT_HAND_OPERATED = 1,
54    /**
55     * indicates the operating hand is right hand.
56     *
57     * @syscap SystemCapability.MultimodalAwareness.Motion
58     * @since 15
59     */
60    RIGHT_HAND_OPERATED = 2
61  }
62
63  /**
64   * Enum for holding hand status
65   *
66   * @enum { number } HoldingHandStatus
67   * @syscap SystemCapability.MultimodalAwareness.Motion
68   * @since 20
69   */
70  export enum HoldingHandStatus {
71    /**
72     * indicates no holding has been detected.
73     *
74     * @syscap SystemCapability.MultimodalAwareness.Motion
75     * @since 20
76     */
77    NOT_HELD = 0,
78    /**
79     * indicates holding with the left hand.
80     *
81     * @syscap SystemCapability.MultimodalAwareness.Motion
82     * @since 20
83     */
84    LEFT_HAND_HELD = 1,
85    /**
86     * indicates holding with the right hand.
87     *
88     * @syscap SystemCapability.MultimodalAwareness.Motion
89     * @since 20
90     */
91    RIGHT_HAND_HELD = 2,
92    /**
93     * indicates holding with both hands.
94     *
95     * @syscap SystemCapability.MultimodalAwareness.Motion
96     * @since 20
97     */
98    BOTH_HANDS_HELD = 3,
99    /**
100     * indicates nothing has been detected.
101     *
102     * @syscap SystemCapability.MultimodalAwareness.Motion
103     * @since 20
104     */
105    UNKNOWN_STATUS = 16
106  }
107
108  /**
109   * Subscribe to detect the operating hand changed event.
110   * @permission ohos.permission.ACTIVITY_MOTION or ohos.permission.DETECT_GESTURE
111   * @param { 'operatingHandChanged' } type - Indicates the event type.
112   * @param { Callback<OperatingHandStatus> } callback - Indicates the callback for getting the event data.
113   * @throws { BusinessError } 201 - Permission denied. An attempt was made to subscribe operatingHandChanged
114   * <br> event forbidden by permission: ohos.permission.ACTIVITY_MOTION or ohos.permission.DETECT_GESTURE.
115   * @throws { BusinessError } 401 - Parameter error. Parameter verification failed.
116   * @throws { BusinessError } 801 - Capability not supported. Function can not work correctly due to limited
117   * <br> device capabilities.
118   * @throws { BusinessError } 31500001 - Service exception. Possible causes: 1. A system error, such as null pointer, container-related exception;
119   * <br>2. N-API invocation exception, invalid N-API status.
120   * @throws { BusinessError } 31500002 - Subscription failed. Possible causes: 1. Callback registration failure;
121   * <br>2. Failed to bind native object to js wrapper; 3. N-API invocation exception, invalid N-API status; 4. IPC request exception.
122   * @syscap SystemCapability.MultimodalAwareness.Motion
123   * @since arkts{ '1.1':'15','1.2':'20'}
124   * @arkts 1.1&1.2
125   */
126  function on(type: 'operatingHandChanged', callback: Callback<OperatingHandStatus>): void;
127
128  /**
129   * Unsubscribe from the operating hand changed event.
130   * @permission ohos.permission.ACTIVITY_MOTION or ohos.permission.DETECT_GESTURE
131   * @param { 'operatingHandChanged' } type - Indicates the event type.
132   * @param { Callback<OperatingHandStatus> } callback - Indicates the callback for getting the event data.
133   * @throws { BusinessError } 201 - Permission denied. An attempt was made to unsubscribe operatingHandChanged
134   * <br> event forbidden by permission: ohos.permission.ACTIVITY_MOTION or ohos.permission.DETECT_GESTURE.
135   * @throws { BusinessError } 401 - Parameter error. Parameter verification failed.
136   * @throws { BusinessError } 801 - Capability not supported. Function can not work correctly due to limited
137   * <br> device capabilities.
138   * @throws { BusinessError } 31500001 - Service exception. Possible causes: 1. A system error, such as null pointer, container-related exception;
139   * <br>2. N-API invocation exception, invalid N-API status.
140   * @throws { BusinessError } 31500003 - Unsubscription failed. Possible causes: 1. Callback failure;
141   * <br>2. N-API invocation exception, invalid N-API status; 3. IPC request exception.
142   * @syscap SystemCapability.MultimodalAwareness.Motion
143   * @since arkts{ '1.1':'15','1.2':'20'}
144   * @arkts 1.1&1.2
145   */
146  function off(type: 'operatingHandChanged', callback?: Callback<OperatingHandStatus>): void;
147
148  /**
149   * Get the recent operating hand status.
150   * @permission ohos.permission.ACTIVITY_MOTION or ohos.permission.DETECT_GESTURE
151   * @returns { OperatingHandStatus } The result of operating hand status.
152   * @throws { BusinessError } 201 - Permission denied. An attempt was made to get the recent operating hand
153   * <br> status forbidden by permission: ohos.permission.ACTIVITY_MOTION or ohos.permission.DETECT_GESTURE.
154   * @throws { BusinessError } 801 - Capability not supported. Function can not work correctly due to limited
155   * <br> device capabilities.
156   * @throws { BusinessError } 31500001 - Service exception. Possible causes: 1. A system error, such as null pointer, container-related exception;
157   * <br>2. N-API invocation exception, invalid N-API status.
158   * @syscap SystemCapability.MultimodalAwareness.Motion
159   * @since arkts{ '1.1':'15','1.2':'20'}
160   * @arkts 1.1&1.2
161   */
162  function getRecentOperatingHandStatus(): OperatingHandStatus;
163
164  /**
165   * Subscribe the holding hand change event.
166   * @permission ohos.permission.DETECT_GESTURE
167   * @param { 'holdingHandChanged' } type - Indicates the event type.
168   * @param { Callback<HoldingHandStatus> } callback - Indicates the callback for getting the event data.
169   * @throws { BusinessError } 201 - Permission denied. An attempt was made to subscribe holdingHandChanged
170   * <br> event forbidden by permission: ohos.permission.DETECT_GESTURE.
171   * @throws { BusinessError } 801 - Capability not supported. Function can not work correctly due to limited
172   * <br> device capabilities.
173   * @throws { BusinessError } 31500001 - Service exception. Possible causes: 1. A system error, such as null pointer, container-related exception;
174   * <br>2. N-API invocation exception, invalid N-API status.
175   * @throws { BusinessError } 31500002 - Subscription failed. Possible causes: 1. Callback registration failure;
176   * <br>2. Failed to bind native object to js wrapper; 3. N-API invocation exception, invalid N-API status; 4. IPC request exception.
177   * @syscap SystemCapability.MultimodalAwareness.Motion
178   * @since 20
179   * @arkts 1.1&1.2
180   */
181  function on(type: 'holdingHandChanged', callback: Callback<HoldingHandStatus>): void;
182
183  /**
184   * Unsubscribe from the holding hand changed event.
185   * @permission ohos.permission.DETECT_GESTURE
186   * @param { 'holdingHandChanged' } type - Indicates the event type.
187   * @param { Callback<HoldingHandStatus> } callback - Indicates the callback for getting the event data.
188   * @throws { BusinessError } 201 - Permission denied. An attempt was made to unsubscribe holdingHandChanged
189   * <br> event forbidden by permission: ohos.permission.DETECT_GESTURE.
190   * @throws { BusinessError } 801 - Capability not supported. Function can not work correctly due to limited
191   * <br> device capabilities.
192   * @throws { BusinessError } 31500001 - Service exception. Possible causes: 1. A system error, such as null pointer, container-related exception;
193   * <br>2. N-API invocation exception, invalid N-API status.
194   * @throws { BusinessError } 31500003 - Unsubscription failed. Possible causes: 1. Callback failure;
195   * <br>2. N-API invocation exception, invalid N-API status; 3. IPC request exception.
196   * @syscap SystemCapability.MultimodalAwareness.Motion
197   * @since 20
198   * @arkts 1.1&1.2
199   */
200  function off(type: 'holdingHandChanged', callback?: Callback<HoldingHandStatus>): void;
201}
202export default motion;
203