!235 [缺陷] 自由多窗模式,同时加密失败

Merge pull request !235 from 王力量/day0803_xyao_weekly
This commit is contained in:
openharmony_ci 2024-08-03 16:35:43 +00:00 committed by Gitee
commit 6e3a8dedd7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 39 additions and 21 deletions

View File

@ -2,8 +2,8 @@
"app": {
"bundleName": "com.ohos.dlpmanager",
"vendor": "example",
"versionCode": 1000102,
"versionName": "1.0.1.02",
"versionCode": 1000103,
"versionName": "1.0.1.03",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 12,

View File

@ -16,8 +16,8 @@
"app": {
"bundleName": "com.ohos.dlpmanager",
"vendor": "example",
"versionCode": 1000102,
"versionName": "1.0.1.02",
"versionCode": 1000103,
"versionName": "1.0.1.03",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 12,

View File

@ -303,7 +303,7 @@ export default class ViewAbility extends ServiceExtensionAbility {
};
try {
await this.context.startAbility(accountWant);
} catch(err) {
} catch (err) {
HiLog.info(TAG, `Failed to invoke startAbility, ${JSON.stringify(err)}`)
return;
}

View File

@ -241,6 +241,7 @@ export default class Constants {
public static SHARE_PAGES_COLUMN_HEIGHT = '100%';
public static SHARE_SET_TIMEOUT = 1500;
public static SHARE_FILE_NAME_TOO_LONG = 13900030;
public static SHARE_TEMP_SAVE_FILE_NUMBER = 20;
public static readonly ERR_CODE_NETWORK_ERROR: number = -4;
public static readonly ERR_CODE_CONNECTION_FAIL: number = -301;

View File

@ -205,28 +205,25 @@ struct encryptedSharing {
}
let parameters = this.actionWant?.parameters as Record<string, Array<string>>;
let inputUri: string = parameters['ability.params.stream'][0];
let inputFileName: string = this.getFileName(parameters);
let srcFileMsg: FileMsg = FileUtils.getSuffixFileMsgByUri(inputUri);
if (inputFileName === undefined) {
inputFileName = srcFileMsg.fileName + srcFileMsg.fileType;
};
let filePatch = decodeURIComponent(inputFileName) + '.dlp';
let inputFileName: string = this.getFileName(parameters, inputUri);
let dlpFileName = decodeURIComponent(inputFileName) + '.dlp';
let inFileFd = getFileFd(inputUri);
let srcFileSize: number = await getFileSizeByUri(inputUri);
AppStorage.setOrCreate('hiFileSize', srcFileSize);
AppStorage.setOrCreate('hiFileType', srcFileMsg.fileType);
let filePath = getContext(this).filesDir + '/' + filePatch;
let filePath = getContext(this).filesDir + `/Share/${new Date().getTime()}/`;
await fs.mkdir(filePath, true);
let newFilePath = filePath + dlpFileName;
let file: fs.File | undefined;
let filePathUri = getFileUriByPath(filePath);
let filePathUri = getFileUriByPath(newFilePath);
try {
file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
file = fs.openSync(newFilePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
await dlpPermission.generateDLPFile(inFileFd, file.fd, this.dlpProperty);
this.showToast($r('app.string.Share_File_Encrypted_Success'));
let dstFileSize: number = await getFileSizeByUri(filePathUri);
AppStorage.setOrCreate('hiPolicySizeEnc', dstFileSize);
AppStorage.setOrCreate('hiCode', 201);
sendDlpFileCreateProperties(dlpPermission.AccountType.CLOUD_ACCOUNT); // 201: DLP_2C_FILE_CREATE_EVENT
this.backToPages(filePathUri, filePatch);
this.backToPages(filePathUri, dlpFileName);
HiLog.info(TAG, `beginToGenerateDLPFile success`);
} catch (err) {
HiLog.error(TAG, `open temp failed: ${JSON.stringify(err)}`);
@ -246,12 +243,17 @@ struct encryptedSharing {
}
}
getFileName(parameters: Record<string, Array<string>>): string {
getFileName(parameters: Record<string, Array<string>>, inputUri: string): string {
let abilityPickerRecords = parameters['ability.picker.records'];
let srcFileMsg: FileMsg = FileUtils.getSuffixFileMsgByUri(inputUri);
AppStorage.setOrCreate('hiFileType', srcFileMsg.fileType);
let res: string = '';
Object.keys(abilityPickerRecords).forEach(key => {
res = abilityPickerRecords[key][0]?.['4'];
});
if (res === undefined) {
res = srcFileMsg.fileName + srcFileMsg.fileType;
};
return res;
}
@ -441,14 +443,29 @@ struct encryptedSharing {
}
}
clearHistoryDLPFile() {
let pathDir = getContext(this).filesDir + '/Share';
fs.listFile(pathDir).then((filenames: Array<string>) => {
HiLog.info(TAG, `listFile succeed`);
let filenamesLists = filenames.sort((a, b) => Number(a) - Number(b));
if (filenamesLists.length > Constants.SHARE_TEMP_SAVE_FILE_NUMBER) {
let deleteArray = filenamesLists.slice(0, filenamesLists.length - Constants.SHARE_TEMP_SAVE_FILE_NUMBER);
deleteArray.forEach((item) => {
fs.rmdirSync(pathDir + `/${item}`);
})
}
}).catch ((err: BusinessError) => {
HiLog.error(TAG, `list file failed with error message: ${JSON.stringify(err)}`);
});
}
aboutToAppear() {
HiLog.info(TAG, `aboutToAppear enter: ${this.showUIExtensionForAccountLogin}`);
this.getAccountInfo();
AppStorage.setOrCreate('hiAccountType', dlpPermission.AccountType.CLOUD_ACCOUNT);
sendDlpManagerAccountLogin(-1);
this.checkContacts();
let pathDir = getContext(this).filesDir;
fs.rmdirSync(pathDir);
this.clearHistoryDLPFile();
this.getUIContext().setKeyboardAvoidMode(1);
this.subscribeLanguageChange();
let str = this.getExternalResourceString(Constants.DLP_CREDMGR_BUNDLE_NAME, 'entry', 'add_users_hint');

View File

@ -25,7 +25,7 @@
"description": "$string:MainAbility_desc",
"icon": "$media:app_icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:app_icon",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"excludeFromMissions": true,
"exported": true,

View File

@ -39,7 +39,7 @@
"description": "$string:MainAbility_desc",
"icon": "$media:app_icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:app_icon",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"excludeFromMissions": true,
"exported": true,