目录

AntifraudPicker

This module provides APIs for apps to obtain fraudulent messages and call logs for anti-fraud purposes.

Since: 5.0.3(15)

Modules to Import

import {antifraudPicker} from '@kit.DeviceSecurityKit';

AntifraudMessageOptions

Request parameters for obtaining fraudulent messages.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Name Type Read-Only Optional Description
maxSelectNumber number No Yes Maximum number of items that can be selected. If no value is passed, the default value 50 is used. The value ranges from 1 to 50. If the value is less than 1 or greater than 50, an error message is displayed, and error code 401 is returned.

SingleAntifraudMessageInfo

Information about a fraudulent message.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Name Type Read-Only Optional Description
senderNumber string No No Mobile number of a message sender.
receivingTime number No No Timestamp when a message is received, in milliseconds.
messageContent string No No Message content, which contains a maximum of 17,152 characters.
senderName string No No Sender name.
senderPlace string No No Home area of the mobile number of a message sender.
messageType string No No Message type. 0: SMS message; 1: MMS message.
mmsSubject string No Yes Subject of an MMS message. This parameter is valid only when the message type is MMS.
mmsAttachments MmsAttachmentInfo[] No Yes MMS attachment information list. This parameter is valid only when the message type is MMS.

MmsAttachmentInfo

MMS attachment information.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Name Type Read-Only Optional Description
attachmentType number No No

MMS attachment type. The options are as follows:

-1: MMS message not downloaded

0: SMIL file

1: image

2: video

3: audio

4: contact card

5: theme

6: slide

7: text

8: location

uri string No No Attachment URI.

AntifraudMessageResult

Fraudulent messages.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Name Type Read-Only Optional Description
messageInfo SingleAntifraudMessageInfo[] No No Fraudulent message list.

SingleAntifraudCallLogInfo

Information about a fraudulent call log.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Name Type Read-Only Optional Description
callerNumber string No No Calling number.
receivingTime number No No Timestamp when a call is answered, in milliseconds.
callLogType number No No Call log type. The options are as follows: 0: incoming call; 1: outgoing call.
callerName string No No Calling party name.
callDuration number No No Call duration, in milliseconds.

AntifraudCallLogResult

Fraudulent call logs.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Name Type Read-Only Optional Description
callLogInfo SingleAntifraudCallLogInfo[] No No Fraudulent call log list.

AntifraudCallLogOptions

Request parameters for obtaining fraudulent call logs.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Name Type Read-Only Optional Description
maxSelectNumber number No Yes Maximum number of items that can be selected. If no value is passed, the default value 50 is used. The value ranges from 1 to 50. If the value is less than 1 or greater than 50, an error message is displayed, and error code 401 is returned.

selectFraudMessage

selectFraudMessage(context: common.Context, options?: AntifraudMessageOptions): Promise<AntifraudMessageResult>

Starts the fraudulent message picker and obtains the information about fraudulent messages selected by a user. This API uses a promise to return the result.

Model restriction: This API can be used only in the stage model.

Required permission: ohos.permission.USE_FRAUD_MESSAGES_PICKER

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Parameters:

Name Type Mandatory Description
context common.Context Yes App context.
options AntifraudMessageOptions No Request parameters. If no value is passed, the maximum number of items that can be selected is 50 by default.

Returns:

Type Description
Promise<AntifraudMessageResult> Promise used to return fraudulent messages.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID Error Message
201 Permission verification failed. The application does not have the permission required to call the API.
401

Parameter error.

Possible causes:

1. Mandatory parameters are left unspecified.

2. Incorrect parameter types.

3. Parameter verification failed.

1017100001 Unknown error.
1017100002 The device type is not supported.

Example:

import { antifraudPicker} from '@kit.DeviceSecurityKit';
import { BusinessError} from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { common} from '@kit.AbilityKit';

const TAG = "AntifraudPickerJsTest";

// Request the fraudulent message information and process the service.
let options: antifraudPicker.AntifraudMessageOptions = {
  maxSelectNumber: 5
};
try {
  hilog.info(0x0000, TAG, 'SelectFraudMessage begin.');
  let context = this.getUIContext().getHostContext();
  const result: antifraudPicker.AntifraudMessageResult = await antifraudPicker.selectFraudMessage(context, options);
} catch (err) {
  let e: BusinessError = err as BusinessError;
  hilog.error(0x0000, TAG, 'SelectFraudMessage failed: %{public}d %{public}s', e.code, e.message);
}

selectFraudCallLog

selectFraudCallLog(context: common.Context, options?: AntifraudCallLogOptions): Promise<AntifraudCallLogResult>

Starts the fraudulent call log picker and obtains the information about fraudulent call logs selected by a user. This API uses a promise to return the result.

Model restriction: This API can be used only in the stage model.

Required permission: ohos.permission.USE_FRAUD_CALL_LOG_PICKER

System capability: SystemCapability.Security.Antifraud

Since: 5.0.3(15)

Parameters:

Name Type Mandatory Description
context common.Context Yes App context.
options AntifraudCallLogOptions No Request parameters. If no value is passed, the maximum number of items that can be selected is 50 by default.

Returns:

Type Description
Promise<AntifraudCallLogResult> Promise used to return fraudulent call logs.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID Error Message
201 Permission verification failed. The application does not have the permission required to call the API.
401

Parameter error.

Possible causes:

1. Mandatory parameters are left unspecified.

2. Incorrect parameter types.

3. Parameter verification failed.

1017100001 Unknown error.
1017100002 The device type is not supported.

Example:

import { antifraudPicker} from '@kit.DeviceSecurityKit';
import { BusinessError} from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { common} from '@kit.AbilityKit';

const TAG = "AntifraudPickerJsTest";

// Request the fraudulent call log information and process the service.
let options: antifraudPicker.AntifraudCallLogOptions = {
  maxSelectNumber: 5
};
try {
  hilog.info(0x0000, TAG, 'SelectFraudCallLog begin.');
  let context = this.getUIContext().getHostContext();
  const result: antifraudPicker.AntifraudCallLogResult = await antifraudPicker.selectFraudCallLog(context, options);
} catch (err) {
  let e: BusinessError = err as BusinessError;
  hilog.error(0x0000, TAG, 'SelectFraudCallLog failed: %{public}d %{public}s', e.code, e.message);
}

AntifraudAppOptions

Request parameters for obtaining fraudulent apps.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.1.1(19)

Name Type Read-Only Optional Description
maxSelectNumber number No Yes Maximum number of items that can be selected. If no value is passed, the default value 50 is used. The value ranges from 1 to 50. If the value is less than 1 or greater than 50, an error message is displayed, and error code 401 is returned.

AntifraudAppResult

Fraudulent apps.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.1.1(19)

Name Type Read-Only Optional Description
appInfo SingleAntifraudAppInfo[] No No Fraudulent app list.

SingleAntifraudAppInfo

Information about a fraudulent app.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Security.Antifraud

Since: 5.1.1(19)

Name Type Read-Only Optional Description
applicationName string No No App name.
bundleName string No No App package name.
versionCode number No No App version code.
versionName string No No App version name.
installTime number No No App installation timestamp, in milliseconds.
appId string No No App ID.
label string No No App name displayed to users, for example, Clock.
installSource string No No

Installation source of the app. The options are as follows:

- pre-installed: The app is a preset app installed at initial device startup.

- ota: The app is a preset app added during system upgrade.

- recovery: This app is a preset app that is uninstalled and then restored.

- App package name: The app is installed from the specified package.

- unknown: The installation source is unknown.

selectFraudApp

selectFraudApp(context: common.Context, options?: AntifraudAppOptions): Promise<AntifraudAppResult>

Starts the fraudulent app picker and obtains the information about fraudulent apps selected by a user. This API uses a promise to return the result.

Model restriction: This API can be used only in the stage model.

Required permission: ohos.permission.USE_FRAUD_APP_PICKER

System capability: SystemCapability.Security.Antifraud

Since: 5.1.1(19)

Parameters:

Name Type Mandatory Description
context common.Context Yes App context.
options AntifraudAppOptions No Request parameters. If no value is passed, the maximum number of items that can be selected is 50 by default.

Returns:

Type Description
Promise<AntifraudAppResult> Promise used to return fraudulent apps.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID Error Message
201 Permission verification failed. The application does not have the permission required to call the API.
1017600001 Unknown error.
1017600002 The device type is not supported.
1017600003 Parameter verification failed.

Example:

import { antifraudPicker} from '@kit.DeviceSecurityKit';
import { BusinessError} from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { common} from '@kit.AbilityKit';

const TAG = "AntifraudPickerJsTest";

// Request the fraudulent app information and process the service.
let options: antifraudPicker.AntifraudAppOptions = {
  maxSelectNumber: 5
};
try {
  hilog.info(0x0000, TAG, 'SelectFraudApp begin.');
  let context = this.getUIContext().getHostContext();
  const result: antifraudPicker.AntifraudAppResult = await antifraudPicker.selectFraudApp(context, options);
} catch (err) {
  let e: BusinessError = err as BusinessError;
  hilog.error(0x0000, TAG, 'SelectFraudApp failed: %{public}d %{public}s', e.code, e.message);
}