openharmony 鸿蒙 js-apis-file-keymanager-sys

2025-06-12 浏览 (1)

@ohos.file.keyManager (User Key Management) (System API)

This module provides common functions related to user key management, including user key uninstallation.

NOTE

  • The initial APIs of this module are supported since API version 15. Newly added APIs will be marked with a superscript to indicate their earliest API version.
  • This topic describes only the system APIs provided by the module.

Modules to Import

import { keyManager } from "@kit.CoreFileKit";

keyManager.deactivateUserKey

deactivateUserKey(userId: number):void

When the screen is locked, the specified user key is uninstalled synchronously. (Currently, this API is available only to lock screen applications.)

Required permission: ohos.permission.STORAGE_MANAGER_CRYPT

System capability: SystemCapability.FileManagement.StorageService.Encryption

System API: This is a system API.

Parameters

NameTypeMandatoryDescription
userIdnumberYesUser ID. This parameter specifies the user who currently logs in to the lock screen application.

Error codes

For details about the error codes, see File Management Error Codes.

IDError Message
201Permission verification failed.
202The caller is not a system application.
401The input parameter is invalid. Possible causes: Mandatory parameters are left unspecified; Or input parameter has type different from the type the interface requires.
13600001IPC error.
13600008No such object. Possible causes: Cannot find user key for the specified user.
13600009User ID out of range. Possible causes: input parameter userId < 100 or userId > 10736.

Example:

import { keyManager } from "@kit.CoreFileKit";
import { BusinessError } from '@ohos.base';
let userId: number = 100;
try {
  keyManager.deactivateUserKey(userId);
  console.info("deactivateUserKey success");
} catch (err) {
  let error: BusinessError = err as BusinessError;
  console.error("deactivateUserKey failed with error:" + JSON.stringify(error));
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Core File Kit

harmony 鸿蒙Environment

harmony 鸿蒙FileIO

harmony 鸿蒙FileShare_PolicyErrorResult

harmony 鸿蒙FileShare_PolicyInfo

harmony 鸿蒙error_code.h

harmony 鸿蒙File Management Error Codes

harmony 鸿蒙FileShare

harmony 鸿蒙FileUri

harmony 鸿蒙@ohos.application.BackupExtensionAbility (Backup and Restore Extension Capability) (System API)

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/WtJpAn