本模块提供终端设备核心部件的正品检测服务,包括屏幕、电池和主板的一致性检测。
起始版本: 26.0.0
import { BusinessError } from "@kit.BasicServicesKit";
import { deviceDetection } from "@kit.ServiceSupportKit"; getDeviceComponentVerificationDetails(): Promise<DeviceComponentVerificationResult>
获取设备硬件一致性校验结果。使用Promise异步回调。
模型约束: 此接口仅可在Stage模型下使用。
需要权限: ohos.permission.DETECT_DEVICE
系统能力: SystemCapability.HiViewDFX.DeviceDetection
起始版本: 26.0.0
返回值:
| 类型 | 说明 |
|---|---|
| Promise<DeviceComponentVerificationResult> | Promise对象,返回硬件一致性校验结果。 |
错误码:
以下错误码的详细介绍请参见通用错误码和ArkTS API错误码。
| 错误码ID | 错误信息 |
|---|---|
| 201 | Permission verification failed. |
| 1029600001 | Insufficient memory. |
| 1029600101 | Service exception. |
| 1029600301 | Network error. |
| 1029600302 | Smart Diagnosis privacy statement not accepted. |
示例:
import { BusinessError } from "@kit.BasicServicesKit";
import { deviceDetection } from "@kit.ServiceSupportKit";
// 创建初始化结果对象
let result: deviceDetection.DeviceComponentVerificationResult = {
componentDetails: []
};
try {
// 接收一致性检测结果
result = await deviceDetection.getDeviceComponentVerificationDetails();
} catch (error) {
// 捕获异常
const err: BusinessError = error as BusinessError;
console.error('enter into getDeviceComponentVerificationDetails catch, code is: ' + err.code + ' message is: ' + err.message);
} 设备硬件一致性校验结果。
模型约束: 此接口仅可在Stage模型下使用。
系统能力: SystemCapability.HiViewDFX.DeviceDetection
起始版本: 26.0.0
| 名称 | 类型 | 只读 | 可选 | 说明 |
|---|---|---|---|---|
| componentDetails | ComponentVerificationDetail[] | 否 | 否 | 各硬件校验详情。 |
硬件校验结果详细信息。
模型约束: 此接口仅可在Stage模型下使用。
系统能力: SystemCapability.HiViewDFX.DeviceDetection
起始版本: 26.0.0
| 名称 | 类型 | 只读 | 可选 | 说明 |
|---|---|---|---|---|
| componentType | ComponentType | 否 | 否 | 硬件类型。 |
| resultType | ResultType | 否 | 否 | 校验结果。 |