• 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 { image } from '@ohos.multimedia.image';
22import type { Callback } from './@ohos.base';
23
24/**
25 * the moudle for metadataBinding
26 * @namespace metadataBinding
27 * @syscap SystemCapability.MultimodalAwareness.MetadataBinding
28 * @atomicservice
29 * @since 18
30 */
31declare namespace metadataBinding {
32  /**
33   * MetadataBinding provides coding capabilities
34   * @param { image.PixelMap } srcImage - Original image to be encoded
35   * @param { string } metadata - Coded metadata
36   * @returns { Promise<image.PixelMap> } encoded image
37   * @throws { BusinessError } 202 - Permission check failed. A non-system application uses the system API.
38   * @throws { BusinessError } 32100001 - Internal handling failed. File creation failed
39   * @throws { BusinessError } 32100002 - Encode process fail. Possible causes: 1. Image processing error; 2. Channel coding error
40   * @syscap SystemCapability.MultimodalAwareness.MetadataBinding
41   * @systemapi
42   * @since 18
43   */
44  function encodeImage(srcImage: image.PixelMap, metadata: string): Promise<image.PixelMap>;
45
46  /**
47   * MetadataBinding provides decode capabilities
48   * @param { image.PixelMap } encodedImage - Encoded image
49   * @returns { Promise<string> } decode result
50   * @throws { BusinessError } 202 - Permission check failed. A non-system application uses the system API.
51   * @throws { BusinessError } 32100001 - Internal handling failed. File read failed.
52   * @throws { BusinessError } 32100003 - Decode process fail. Possible causes: 1. Image is not an encoded Image; 2. Image destroyed, decoding failed
53   * @syscap SystemCapability.MultimodalAwareness.MetadataBinding
54   * @systemapi
55   * @since 18
56   */
57   function decodeImage(encodedImage: image.PixelMap): Promise<string>;
58
59  /**
60   * Obtaining the metadata of a Third-Party App
61   * @param { string } bundleName - Bundle name of a third-party application
62   * @returns { Promise<string> } third-party app callback the meta data
63   * @throws { BusinessError } 202 - Permission check failed. A non-system application uses the system API.
64   * @throws { BusinessError } 32100001 - Internal handling failed. Obtain metadata failed.
65   * @syscap SystemCapability.MultimodalAwareness.MetadataBinding
66   * @systemapi
67   * @since 18
68   */
69  function notifyMetadataBindingEvent(bundleName: string): Promise<string>;
70
71  /**
72   * set the Metadata to the screenshot app
73   * @param { string } metadata - the Metadata of a Third-Party App
74   * @throws { BusinessError } 32100001 - Internal handling failed. Set Meta data to screenshot app fail.
75   * @syscap SystemCapability.MultimodalAwareness.MetadataBinding
76   * @atomicservice
77   * @since 18
78   */
79  function submitMetadata(metadata: string): void;
80
81  /**
82   * Third-party app registration screenshot event
83   * @param { 'operationSubmitMetadata' } type - Event Type
84   * @param { string } bundleName - Bundle name of a third-party application
85   * @param { Callback<number> } callback - Call back the screenshot event
86   * @throws { BusinessError } 32100001 - Internal handling failed. Service exception.
87   * @throws { BusinessError } 32100004 - Subscribe Failed. Possible causes: 1. Abnormal system capability; 2. IPC communication abnormality;
88   * <br>3. Algorithm loading exception.
89   * @syscap SystemCapability.MultimodalAwareness.MetadataBinding
90   * @atomicservice
91   * @since 18
92   */
93  function on(type: 'operationSubmitMetadata', bundleName: string, callback: Callback<number>): void;
94
95  /**
96   * Third-party app unregistration screenshot event
97   * @param { 'operationSubmitMetadata' } type - Event Type
98   * @param { string } bundleName - Bundle name of a third-party application
99   * @param { Callback<number> } callback - Call back the screenshot event
100   * @throws { BusinessError } 32100001 - Internal handling failed. Service exception.
101   * @throws { BusinessError } 32100005 - Unsubscribe Failed. Possible causes: 1. Abnormal system capability; 2. IPC communication abnormality
102   * @syscap SystemCapability.MultimodalAwareness.MetadataBinding
103   * @atomicservice
104   * @since 18
105   */
106  function off(type: 'operationSubmitMetadata', bundleName: string, callback?: Callback<number>): void;
107}
108
109export default metadataBinding;
110