目录

Security Mode of the Input Method

To protect user data, the input method module has incorporated a security mode, which includes the basic mode (BASIC) and full experience mode (FULL). In basic mode, the InputMethodExtensionAbility cannot call any system capability that may involve accessing or disclosing user privacy data. In full experience mode, there is no such restriction.

Users can switch between the basic mode and the full experience mode in Settings.

Basic Mode

  1. The InputMethodExtensionAbility process cannot start any other UIAbility or ExtensionAbility.

  2. The InputMethodExtensionAbility is controlled by the system and cannot call the APIs that may access or disclose user personal data, or transfer data out of the process. Specifically, the InputMethodExtensionAbility cannot call the APIs related to the following: network, SMS, phone, microphone, location, camera, Bluetooth, wallpaper, payment, calendar, games, speaker, Wi-Fi, pasteboard, multimedia, contacts, common events, system account, health data, map service, push service, fusion search, shared memory, distributed features, advertising device identifier, vibration, and more.

  3. The InputMethodExtensionAbility can use necessary system capabilities like IME Kit, ArkUI, windows, graphics, and screen management.

  4. The InputMethodExtensionAbility only read the shared sandbox, and can read and write the independent sandbox of InputMethodExtensionAbility. The main entry of the application can read and write the shared sandbox and its independent sandbox.

Full Experience Mode

  1. The InputMethodExtensionAbility does not have the restrictions of the basic mode. It can start UIAbility or ExtensionAbility to call the APIs for accessing user data.

  2. In full experience mode, the input method extension can read and write the shared sandbox.

How to Develop

In the onCreate lifecycle callback of InputMethodExtensionAbility, call getSecurityMode to query the security mode of the current input method app.

To ensure stable input method functions, use only the basic input capabilities in basic mode. Do not transfer data outside the InputMethodExtensionAbility by bypassing the system mechanism.

Shared Sandbox

  1. The InputMethodExtensionAbility and the application main entry each have their own sandbox and cannot access each other's sandbox.

  2. A shared sandbox is provided to facilitate data transfer and share between them. Both the input method extension and the main entry of the application can access the shared sandbox.

    Figure 1 Shared sandbox

  3. The process of configuring the shared sandbox is as follows:

    If the profile of the main entry and the dataGroupIds of the input method extension of an application contain the same data group ID, they can use the shared sandbox corresponding to the data group ID.

    To use the shared sandbox, you need to apply for a data group ID and configure it in the profile of the main entry and the dataGroupIds of InputMethodExtensionAbility of the application. The application and configuration process is as follows:

    1. Review rules:

      1. After the input method application is installed, it will be displayed in the input method list in Settings > System > Input method.

      2. In the module.json5 configuration file of the InputMethodExtensionAbility, the type field in extensionAbilities must be set to inputMethod.

    2. Application procedure:

      1. Sign in to AppGallery Connect and click Development and services.

      2. Select your target project from the project list. In the app list, select the app for which you want to apply for the shared sandbox.

      3. Go to the Project settings > Manage open capabilities page and click Request for the input method app data sharing.

      4. Provide the required information, including the app name, app ID, and developer ID, based on the template in the Request reason section. In addition, provide the required attachments by referring to the example, and click Submit.

        Return to the Manage open capabilities page. The original Request button changes to Requesting. You will receive the request result in one to three working days. Please check the service enabling request information in the interaction center for updates.

        After the request is approved, the interaction center will send you a notification, and the status will change from Requesting to Request (dimmed). You will also receive a data-group-id.

    3. After receiving the data-group-id, regenerate the app profile. The new profile contains the data-group-id you have applied for. Then, use DevEco Studio to configure the signature information for the project and add the new profile to the project.

    4. Set dataGroupIds in the module.json5 file of the InputMethodExtensionAbility to the data-group-id you have obtained.

  4. The process of using the shared sandbox is as follows:

    a. Obtain the shared sandbox path using getGroupDir in the input method extension and main entry of your app.

    The input parameter dataGroupID must be set to the data-group-id you have obtained.

    b. If the API call is successful and the shared sandbox path is returned, the data-group-id you have obtained and configured has taken effect. In this case, you can use the shared sandbox to share data between the main entry of your app and InputMethodExtensionAbility.

    In basic mode, the input method extension has only read permission on the shared sandbox and cannot write data to it. In full mode, InputMethodExtensionAbility can read and write data to the shared sandbox.