Encrypted share is a data security function built based on the system-level data leak prevention framework. When sharing a file, users can use this function to encrypt it. The encrypted file can be viewed only by specified Huawei accounts, preventing the file from being forwarded.
As a new standard OS-level file format with a .dlp extension, the encrypted file requires account authentication and permission control via system services before any operations can be performed on the recipient's device. Therefore, communication and chat applications need to call HarmonyOS capabilities to process encrypted files, ensuring seamless user experience.
Your application needs to adapt to the encrypted share function in two key steps to ensure that DLP files can be correctly sent and viewed:
Sending: After adaptation, your application can call system capabilities to generate and receive DLP files, allowing users to seamlessly send DLP files between system and third-party applications.
Viewing: After adaptation, your application can directly call the file preview capability to view DLP files, greatly simplifying the process for users to view DLP files without the need to manually switch to the file preview screen.
Users can share encrypted files in either of the following ways:
Method 1: A user directly selects a file and shares it to an application in encrypted form.
Method 2: A user selects a file using the picker within the application and sets encrypted share.
The user directly selects a file and shares it to the application in encrypted mode. The procedure on the device is as follows:
In system applications such as Files and Gallery, select the file to be shared in encrypted mode.
Tap the share button and then tap Encrypted share from the bottom functional area. Log in to your HUAWEI ID and then specify the users who can view the file.
Share the encrypted file to a third-party application through the system. For example, share the file to a chat application and then send it to others.
To support the user in successfully completing the preceding process, the application must meet the following requirements:
Supports sharing and sending encrypted files with the .dlp extension from the system to an application. The application does not filter .dlp files.
Ensure that the DLP file content is not damaged and the .dlp file name extension remains unchanged.
Users can view encrypted files in either of the following ways:
Method 1: View the DLP files through file preview within the application.
Method 2: Save the DLP files in the application to Files for viewing.
The procedure on the device is as follows:
To support the user in successfully completing the preceding process, the application requires the following adaptation:
Before opening a DLP file, obtain the URI of the DLP file to be opened.
Construct the want parameter.
Pass the want parameter through startAbility and use the unified opening capability of the system to open the file.
import Want from '@ohos.app.ability.Want';
import { common, wantConstant } from '@kit.AbilityKit';
@Component
struct Index {
viewDlp(dlpUri: string) {
let context = this.getUIContext()?.getHostContext() as common.UIAbilityContext;
let want: Want = {
"action": "ohos.want.action.viewData",
"uri": dlpUri, // Before opening a DLP file, obtain the URI of the DLP file to be opened.
"flags": wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, // Grant URI authorization for the opened DLP file. By default, the file is read-only.
}
try {
// Pass the want information through startAbility and call the system's unified opening capability.
context.startAbility(want);
} catch (err) {
console.error('startAbility failed');
}
}
build() {
}
} The procedure on the device is as follows:
Select a DLP file within the application.
Save the file to Files.
In Files, tap the DLP file to preview it.
To support the user in successfully completing the preceding process, the application must meet the following requirements:
The application supports downloading or saving encrypted files to Files.
The .dlp file name extension remains unchanged when an encrypted file is downloaded or saved.