目录

Security Component Overview

Security components are a set of ArkUI basic components, including the SaveButton and PasteButton components. The security components can be used as special buttons that help implement authorization upon a user tap.

Compared with dynamic permission requesting, security components allow scenario-based authorization and simplify development and user operations. The security components stand out with the following features:

  1. Minimizes the authorization by allowing the user to control when to grant the permission.

  2. Allows the authorization scenario to match the user's real intent.

  3. Reduces pop-up windows.

Security components collect only the personal data necessary for implementing business functions, serving user needs and helping develop transparent, optional, and controllable privacy-compliant applications.

Security Components

Currently, the following security components are available:

Working Mechanism

The security component solution consists of the following:

The following figure illustrates the working mechanism.

  1. After a security component is declared in .ets files, the JS engine parses the .ets files and creates the security component in the ArkUI framework.

  2. The security component registers with the security component manager service, which checks the validity of the component information.

  3. When a user taps the security component, a click event is distributed to the security component.

  4. The security component reports the click event to the security component manager service.

  5. The security component manager service calls the permission manager service to perform temporary authorization based on the component type.

  6. After the authorization is successful, the security component calls OnClick() to notify the application layer of the authorization success.

  7. The application calls the corresponding privileged operation, for example, reading pasteboard information and creating a file in the media library.

    The permission usage and authorization validity vary with the security component type. For details, see Security Components.

  8. The corresponding service calls the permission manager service or security component manager service to obtain the authorization result and return the authentication result.

Constraints

Due to the "authorization upon a user tap" feature, many restrictions are imposed on security components to prevent user privacy from being obtained by malicious applications. The security components must be clearly visible on the application UI and can be clearly identified by users to prevent authorization failures.

If the authorization fails due to invalid component style, check the device logs with the keyword "SecurityComponentCheckFail".

Logs containing the keyword can appear at any level. Avoid filtering them by level.

Possible causes include but are not limited to the following: