提交 7f81a3ea 编写于 作者: L lixia7819

安全水印接口说明文档

Signed-off-by: Nlixia7819 <lixia110@huawei.com>
上级 9bdbce34
......@@ -916,6 +916,78 @@ try {
}
```
## window.on('waterMarkFlagChange')<sup>10+</sup>
on(type: 'waterMarkFlagChange', callback: Callback&lt;boolean&gt;): void
Subscribes to the watermark flag status change event.
**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
| type | string | Yes | Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark flag status change event. |
| callback | Callback&lt;boolean&gt; | Yes | Callback used to return the watermark flag status. The value **true** means that the watermark flag status is changed to enabled, and **false** means that the watermark flag status is changed to disabled.|
**Error codes**
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**Example**
```js
try {
window.on('waterMarkFlagChange', (data) => {
console.info('Succeeded in enabling the listener for watermark flag status changes. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to enable the listener for watermark flag status changes. Cause: ' + JSON.stringify(exception));
}
```
## window.off('waterMarkFlagChange')<sup>10+</sup>
off(type: 'waterMarkFlagChange', callback?: Callback&lt;boolean&gt;): void
Unsubscribes from the watermark flag status change event.
**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | -- | ------------------------------------------------------------ |
| type | string | Yes| Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark flag status change event.|
| callback | Callback&lt;boolean&gt; | No| Callback function that has been used for registering the listener. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.|
**Error codes**
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**Example**
```js
try {
window.off('waterMarkFlagChange');
} catch (exception) {
console.error('Failed to disable the listener for watermark flag status changes. Cause: ' + JSON.stringify(exception));
}
```
## window.setGestureNavigationEnabled<sup>10+</sup>
setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
......@@ -984,7 +1056,6 @@ For details about the error codes, see [Window Error Codes](../errorcodes/errorc
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300002 | This window state is abnormal. |
| 1300003 | This window manager service works abnormally. |
**Example**
......@@ -1002,6 +1073,126 @@ try {
}
```
## window.setWaterMarkImage<sup>10+</sup>
setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback&lt;void&gt;): void
Show or don't show watermark image. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------- |
| pixelMap | image.PixelMap | Yes | Watermark image.|
| enable | boolean | Yes | Whether to show watermark image. The value **true** means to show watermark image, and **false** means the opposite.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
| ID| Error Message|
| ------- | --------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**Example**
```js
import image from '@ohos.multimedia.image';
let pixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
}
};
image.createPixelMap(color, initializationOptions)
.then((pixelMap) => {
console.info('Succeeded in creating a pixelmap.');
try {
window.setWaterMarkImage(pixelMap, true, (err) => {
if(err.code) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing watermark image.');
});
} catch (exception) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
}
})
.catch((err) => {
console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`);
});
```
## window.setWaterMarkImage<sup>10+</sup>
setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise&lt;void&gt;
Show or don't show watermark image. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------- |
| enable | boolean | Yes | Whether to show watermark image. The value **true** means to show watermark image, and **false** means the opposite.|
**Return value**
| Type | Description |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [Window Error Codes](../errorcodes/errorcode-window.md).
| ID| Error Message|
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**Example**
```js
import image from '@ohos.multimedia.image';
let pixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
}
};
image.createPixelMap(color, initializationOptions)
.then((pixelMap) => {
console.info('Succeeded in creating a pixelmap.');
try {
let promise =window.setWaterMarkImage(pixelMap, true, (err) => {
if(err.code) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing watermark image.');
});
} catch (exception) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
}
})
.catch((err) => {
console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`);
});
```
## window.create<sup>(deprecated)</sup>
create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
......
......@@ -22,8 +22,12 @@
|Added|NA|Module name: ohos.screen<br>Class name: Screen<br>Method or attribute name: readonly sourceMode: ScreenSourceMode;|@ohos.screen.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback\<void>): void;|@ohos.window.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function setGestureNavigationEnabled(enable: boolean): Promise\<void>;|@ohos.window.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback\<void>): void;|@ohos.window.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise\<void>;|@ohos.window.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function on(type: 'gestureNavigationEnabledChange', callback: Callback\<boolean>): void;|@ohos.window.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function off(type: 'gestureNavigationEnabledChange', callback?: Callback\<boolean>): void;|@ohos.window.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function on(type: 'waterMarkFlagChange', callback: Callback\<boolean>): void;|@ohos.window.d.ts|
|Added|NA|Class name: window<br>Method or attribute name: function off(type: 'waterMarkFlagChange', callback?: Callback\<boolean>): void;|@ohos.window.d.ts|
|Added|NA|Module name: ohos.window<br>Class name: WindowEventType|@ohos.window.d.ts|
|Added|NA|Class name: WindowEventType<br>Method or attribute name: |@ohos.window.d.ts|
|Added|NA|Module name: ohos.window<br>Class name: WindowEventType<br>Method or attribute name: WINDOW_SHOWN = 1|@ohos.window.d.ts|
......
......@@ -916,6 +916,78 @@ try {
}
```
## window.on('waterMarkFlagChange')<sup>10+</sup>
on(type: 'waterMarkFlagChange', callback: Callback&lt;boolean&gt;): void
添加水印标志状态变化的监听。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
| type | string | 是 | 监听事件,固定为'waterMarkFlagChange',即水印标志状态变化事件。 |
| callback | Callback&lt;boolean&gt; | 是 | 回调函数。返回当前水印的启用状态。true表示水印状态变化为启用;false表示水印状态变化为禁用。 |
**错误码:**
以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**示例:**
```js
try {
window.on('waterMarkFlagChange', (data) => {
console.info('Succeeded in enabling the listener for watermark flag changes. Data: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('Failed to enable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception));
}
```
## window.off('waterMarkFlagChange')<sup>10+</sup>
off(type: 'waterMarkFlagChange', callback?: Callback&lt;boolean&gt;): void
移除水印标志状态变化的监听。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------- | -- | ------------------------------------------------------------ |
| type | string | 是 | 监听事件,固定为'waterMarkFlagChange',即水印标志状态变化事件。 |
| callback | Callback&lt;boolean&gt; | 否 | 已注册的回调函数。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有安全水印状态变化的监听。 |
**错误码:**
以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**示例:**
```js
try {
window.off('waterMarkFlagChange');
} catch (exception) {
console.error('Failed to disable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception));
}
```
## window.setGestureNavigationEnabled<sup>10+</sup>
setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
......@@ -1002,6 +1074,127 @@ try {
}
```
## window.setWaterMarkImage<sup>10+</sup>
setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback&lt;void&gt;): void
设置水印图片显示状态。使用callback异步回调。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------- |
| pixelMap | image.PixelMap | 是 | 水印图片 |
| enable | boolean | 是 | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调信息。 |
**错误码:**
以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)
| 错误码ID | 错误信息 |
| ------- | --------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**示例:**
```js
import image from '@ohos.multimedia.image';
let pixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
}
};
image.createPixelMap(color, initializationOptions)
.then((pixelMap) => {
console.info('Succeeded in creating a pixelmap.');
try {
window.setWaterMarkImage(pixelMap, true, (err) => {
if(err.code) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing watermark image.');
});
} catch (exception) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
}
})
.catch((err) => {
console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`);
});
```
## window.setWaterMarkImage<sup>10+</sup>
setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise&lt;void&gt;
设置水印图片显示状态。使用Promise异步回调。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | --------------------------- | ---- | -------------------- |
| pixelMap | image.PixelMap | 是 | 水印图片 |
| enable | boolean | 是 | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见[窗口错误码](../errorcodes/errorcode-window.md)
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1300003 | This window manager service works abnormally. |
**示例:**
```js
import image from '@ohos.multimedia.image';
let pixelMap;
let color = new ArrayBuffer(0);
let initializationOptions = {
size: {
height: 100,
width: 100
}
};
image.createPixelMap(color, initializationOptions)
.then((pixelMap) => {
console.info('Succeeded in creating a pixelmap.');
try {
let promise =window.setWaterMarkImage(pixelMap, true, (err) => {
if(err.code) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in showing watermark image.');
});
} catch (exception) {
console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
}
})
.catch((err) => {
console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`);
});
```
## window.create<sup>(deprecated)</sup>
create(id: string, type: WindowType, callback: AsyncCallback&lt;Window&gt;): void
......
......@@ -22,8 +22,12 @@
|新增|NA|模块名: ohos.screen<br>类名: Screen<br>方法 or 属性:readonly sourceMode: ScreenSourceMode;|@ohos.screen.d.ts|
|新增|NA|类名:window<br>方法or属性:function setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback\<void>): void;|@ohos.window.d.ts|
|新增|NA|类名:window<br>方法or属性:function setGestureNavigationEnabled(enable: boolean): Promise\<void>;|@ohos.window.d.ts|
|新增|NA|类名:window<br>方法or属性:function setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback\<void>): void;|@ohos.window.d.ts|
|新增|NA|类名:window<br>方法or属性:function setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise\<void>;|@ohos.window.d.ts|
|新增|NA|类名:window<br>方法or属性:function on(type: 'gestureNavigationEnabledChange', callback: Callback\<boolean>): void;|@ohos.window.d.ts|
|新增|NA|类名:window<br>方法or属性:function off(type: 'gestureNavigationEnabledChange', callback?: Callback\<boolean>): void;|@ohos.window.d.ts|
|新增|NA|类名:window<br>方法or属性:function on(type: 'waterMarkFlagChange', callback: Callback\<boolean>): void;|@ohos.window.d.ts|
|新增|NA|类名:window<br>方法or属性:function off(type: 'waterMarkFlagChange', callback?: Callback\<boolean>): void;|@ohos.window.d.ts|
|新增|NA|模块名: ohos.window<br>类名: WindowEventType|@ohos.window.d.ts|
|新增|NA|类名:WindowEventType<br>方法or属性:|@ohos.window.d.ts|
|新增|NA|模块名: ohos.window<br>类名: WindowEventType<br>方法 or 属性:WINDOW_SHOWN = 1|@ohos.window.d.ts|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册