This article aims to deeply explore the technical details of Huawei HarmonyOS Next system (up to API 12 as of now), and is summarized based on actual development practices.
Mainly serving as a carrier for technical sharing and exchange, it is inevitable that there may be errors and omissions. We welcome valuable opinions and questions from colleagues to make progress together.
This article is original content. Any form of reprint must indicate the source and original author.
In the era of mobile Internet, input method applications carry a large amount of personal information of users, such as passwords, credit card numbers, address books, etc. Therefore, the security of input method applications is crucial. HarmonyOS's IME Kit provides input method security mode function for developers, aiming to protect user data security and ensure the compliance of input method applications. This article will deeply explore HarmonyOS input method security mode and take you to understand how to build a safe and reliable input method application so that users can input with peace of mind.
Security mode: Basic mode and full experience mode
The HarmonyOS input method security mode includes two modes:
- Basic mode: In basic mode, input method extensions cannot call any system capabilities that may involve accessing or leaking user privacy data, such as network, SMS, phone calls, microphones, positioning, etc. This mode is suitable for scenarios with high security requirements, such as financial payments and sensitive information input.
- Full experience mode: In full experience mode, input method extensions are not subject to the relevant restrictions of basic mode and can call all system APIs, such as network, recording, Bluetooth, etc. This mode is suitable for scenarios with high requirements for user experience, such as voice input and picture input.
Main differences between the two modes:
Function | Basic mode | Full experience mode |
---|---|---|
Network access | Unavailable | Available |
Recording | Unavailable | Available |
Bluetooth | Unavailable | Available |
Reading contacts | Unavailable | Available |
Sending SMS | Unavailable | Available |
... | ... | ... |
How should developers respond?
As developers, we need to choose the appropriate mode according to the application scenario and user needs, and make corresponding development adjustments:
1. Development constraints in basic mode
In basic mode, developers need to adjust the presentation of internal functions to avoid situations where functions are unavailable. For example, if an input method application needs to use network functions to update the cloud dictionary, then in basic mode, it is necessary to consider using a local dictionary or guiding users to switch to full experience mode.
2. Open capabilities of full experience mode
In full experience mode, developers can use all system APIs to achieve a richer user experience. For example, developers can use network APIs to update the cloud dictionary, use recording APIs to implement voice input functions, and use Bluetooth APIs to implement keyboard connections.
3. How to switch security modes
Users can switch the input method security mode in the settings application. Developers can also provide security mode switching functions in the application to facilitate users to choose the appropriate mode.
Sample code: Switching security mode
import { inputMethod } from '@kit.IMEKit';
export class KeyboardController {
async switchSecurityMode() {
let securityMode = await inputMethod.getSecurityMode(); // Get the current security mode
if (securityMode === inputMethod.SecurityMode.BASIC) {
// Switch to full experience mode
await inputMethod.setSecurityMode(inputMethod.SecurityMode.FULL);
} else {
// Switch to basic mode
await inputMethod.setSecurityMode(inputMethod.SecurityMode.BASIC);
}
}
}
Significance of security mode
The introduction of input method security mode not only protects the privacy and security of users but also improves the compliance of input method applications. Developers should actively embrace security mode and choose the appropriate mode according to user needs to provide users with a safe and reliable input experience.
Summary
The HarmonyOS input method security mode provides two different security levels for us developers. We can choose the appropriate mode according to the application scenario and user needs. In basic mode, we need to adjust the function implementation to avoid situations where functions are unavailable. In full experience mode, developers can use all system APIs to achieve a richer user experience. This article introduced the overview, differences, setting methods and restrictions of the input method security mode, as well as the development key points in different modes, helping you build a safe and reliable input method application.
Top comments (0)