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

  • 2025-06-12
  • 浏览 (5)

@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

Name Type Mandatory Description
userId number Yes User 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.

ID Error Message
201 Permission verification failed.
202 The caller is not a system application.
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.
13600001 IPC error.
13600008 No such object. Possible causes: Cannot find user key for the specified user.
13600009 User 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)

0  赞