• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.file.keyManager (用户秘钥管理)(系统接口)
2
3该模块提供用户秘钥管理相关的常用功能:包括用户秘钥卸载等。
4
5> **说明:**
6>
7> - 本模块首批接口从API version 15开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> - 当前页面仅包含本模块的系统接口。
9
10## 导入模块
11
12```ts
13import { keyManager } from "@kit.CoreFileKit";
14```
15
16## keyManager.deactivateUserKey
17
18deactivateUserKey(userId: number):void
19
20用户锁屏时,同步卸载指定用户对应秘钥。**(该接口目前仅开放给锁屏应用)**
21
22**需要权限**:ohos.permission.STORAGE_MANAGER_CRYPT
23
24**系统能力**:SystemCapability.FileManagement.StorageService.Encryption
25
26**系统接口**:该接口为系统接口。
27
28**参数:**
29
30  | 参数名     | 类型   | 必填 | 说明 |
31  | ---------- | ------ | ---- | ---- |
32  | userId | number | 是   | 用户id。锁屏应用感知设备当前登录的用户,指定为该用户。|
33
34**错误码:**
35
36以下错误码的详细介绍请参见[文件管理错误码](errorcode-filemanagement.md)。
37
38| 错误码ID | 错误信息 |
39| -------- | -------- |
40| 201 | Permission verification failed. |
41| 202 | The caller is not a system application. |
42| 401 | The input parameter is invalid. Possible causes: Mandatory parameters are left unspecified; Or input parameter has type different from the type the interface requires. |
43| 13600001 | IPC error. |
44| 13600008 | No such object. Possible causes: Cannot find user key for the specified user. |
45| 13600009 | User ID out of range. Possible causes: input parameter userId < 100 or userId > 10736. |
46
47**示例:**
48
49  ```ts
50  import { keyManager } from "@kit.CoreFileKit";
51  import { BusinessError } from '@ohos.base';
52  let userId: number = 100;
53  try {
54    keyManager.deactivateUserKey(userId);
55    console.info("deactivateUserKey success");
56  } catch (err) {
57    let error: BusinessError = err as BusinessError;
58    console.error("deactivateUserKey failed with error:" + JSON.stringify(error));
59  }
60  ```