openharmony 鸿蒙 asset-as-user-sys

2025-06-12 浏览 (1)

Performing Asset Operations in Specified User Space (for System Applications Only)

For a singleton application that provides system-wide management functionalities, all users share an instance, which isolates data of different users. You need to specify the user space to which the operated asset belongs when:

  1. The singleton application needs to store, access, and destroy assets for multiple active users.
  2. The singleton application needs to store an asset that is accessible after the device is first unlocked or accessible when the device is unlocked.

To implement isolation and access control of the assets for singleton applications, ASSET provides a set of APIs for asset operations with the user space specified. These APIs are available only for system applications.

Constraints

The caller must have the ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS permission.

For details about how to request the permission, see Requesting Permissions for system_basic Applications.

Available APIs

The following table describes the APIs.

APIDescriptionAPI with User Space Not Specified
addAsUserAdds an asset to the specified user space. This API uses a promise to return the result.add
removeAsUserRemoves one or more assets from the specified user space. This API uses a promise to return the result.remove
updateAsUserUpdates an asset in the specified user space. This API uses a promise to return the result.update
preQueryAsUserPerforms preprocessing for the asset query in the specified user space. This API is used when user authentication is required for the access to the asset. This API must be used with queryAsUser and postQueryAsUser together. This API uses a promise to return the result.preQuery
queryAsUserQueries one or more assets in the specified user space. If user authentication is required before accessing the asset, call preQueryAsUser before this API and call postQueryAsUser after this API. This API uses a promise to return the result.query if user authentication is required before the asset is accessed.
query if the asset can be accessed without user authentication.
postQueryAsUserPerforms postprocessing for the asset query in the specified user space. This API is used when user authentication is required for the access to the asset. This API must be used with preQueryAsUser together. This API uses a promise to return the result.postQuery

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Asset Store Kit (Asset Store Service)

harmony 鸿蒙Adding an Asset (ArkTS)

harmony 鸿蒙Managing Assets in a Group

harmony 鸿蒙Querying an Asset with User Authentication (ArkTS)

harmony 鸿蒙Querying Assets (ArkTS)

harmony 鸿蒙Removing Assets (ArkTS)

harmony 鸿蒙Updating an Asset (ArkTS)

harmony 鸿蒙Adding an Asset (C/C++)

harmony 鸿蒙Managing Assets in a Group

harmony 鸿蒙Querying Assets (C/C++)

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