mirror of
https://github.com/openharmony/applications_dlp_manager.git
synced 2026-07-01 13:20:42 -04:00
Description:FAF接口获取相对路径和最后修改时间
Match-id-98f5d10bfab3c951272f8314713c404189b26285
This commit is contained in:
@@ -117,7 +117,7 @@ export default class MainAbility extends UIAbility {
|
||||
let linkFile = globalThis.sandbox2linkFile[key][j];
|
||||
globalThis.dlpFile = linkFile[Constants.FILE_OPEN_HISTORY_ONE];
|
||||
globalThis.dlpFd = linkFile[Constants.FILE_OPEN_HISTORY_THREE];
|
||||
globalThis.dlpFileName = globalThis.abilityWant.parameters.displayName;
|
||||
globalThis.dlpFileName = globalThis.abilityWant.parameters.fileName.name;
|
||||
globalThis.linkFileName = linkFileName;
|
||||
console.info(TAG, 'find dlp file', globalThis.dlpFileName, globalThis.dlpFd);
|
||||
resolve();
|
||||
@@ -134,7 +134,7 @@ export default class MainAbility extends UIAbility {
|
||||
async openDlpFile(): Promise<void> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
globalThis.dlpFileName = globalThis.abilityWant.parameters.displayName;
|
||||
globalThis.dlpFileName = globalThis.abilityWant.parameters.fileName.name;
|
||||
globalThis.dlpFd = getFileFd(globalThis.uri);
|
||||
console.info(TAG, 'openDLPFile', globalThis.dlpFileName, globalThis.dlpFd);
|
||||
globalThis.dlpFile = await dlpPermission.openDLPFile(globalThis.dlpFd);
|
||||
@@ -152,8 +152,12 @@ export default class MainAbility extends UIAbility {
|
||||
console.error(TAG, 'need parameters in want');
|
||||
return false;
|
||||
}
|
||||
if (globalThis.abilityWant.parameters.displayName === undefined) {
|
||||
console.error(TAG, 'need name in want.parameters.displayName');
|
||||
if (globalThis.abilityWant.parameters.fileName === undefined) {
|
||||
console.error(TAG, 'need fileName in want.parameters');
|
||||
return false;
|
||||
}
|
||||
if (globalThis.abilityWant.parameters.fileName.name === undefined) {
|
||||
console.error(TAG, 'need name in want.parameters.fileName');
|
||||
return false;
|
||||
}
|
||||
let callerToken = globalThis.abilityWant.parameters['ohos.aafwk.param.callerToken'];
|
||||
@@ -201,11 +205,11 @@ export default class MainAbility extends UIAbility {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let fileName = globalThis.abilityWant.parameters.displayName;
|
||||
let fileName = globalThis.abilityWant.parameters.fileName.name;
|
||||
let isDlpSuffix: boolean = fileName.endsWith('.dlp');
|
||||
if (!isDlpSuffix) {
|
||||
console.info(TAG, fileName, 'is not a dlp file');
|
||||
globalThis.originFileName = globalThis.abilityWant.parameters.displayName;
|
||||
globalThis.originFileName = globalThis.abilityWant.parameters.fileName.name;
|
||||
globalThis.originFd = getFileFd(globalThis.uri);
|
||||
windowStage.setUIContent(this.context, 'pages/encryptionProtection', null);
|
||||
windowStage.getMainWindow().then((win) => {
|
||||
|
||||
@@ -55,6 +55,7 @@ export default class ViewAbility extends ServiceExtensionAbility {
|
||||
fileName: string = '';
|
||||
uri: string = '';
|
||||
file = null;
|
||||
stat = null;
|
||||
uriInfo = null;
|
||||
linkUri: string = '';
|
||||
isCreated: boolean = false;
|
||||
@@ -100,11 +101,10 @@ export default class ViewAbility extends ServiceExtensionAbility {
|
||||
'linkFileName': {
|
||||
'name': this.linkFileName
|
||||
},
|
||||
'fileAssert': {
|
||||
'fileAsset': {
|
||||
'displayName': this.uriInfo.name,
|
||||
// 'relativePath': this.fileAssert.relativePath,
|
||||
// 'mediaType': this.fileAssert.mediaType,
|
||||
// 'dateModified': this.fileAssert.dateModified
|
||||
'relativePath': this.uriInfo.path,
|
||||
'dateModified': this.stat.ctime
|
||||
},
|
||||
'uri': this.linkUri,
|
||||
'dlpUri': {
|
||||
@@ -230,7 +230,8 @@ export default class ViewAbility extends ServiceExtensionAbility {
|
||||
}
|
||||
startId = Number(startId);
|
||||
hiTraceMeter.startTrace('DlpOpenFileJs', startId);
|
||||
this.fileName = <string>want.parameters.displayName;
|
||||
let obj: Object = want.parameters.fileName;
|
||||
this.fileName = (obj as any).name;
|
||||
this.uri = <string>want.uri;
|
||||
this.dlpFd = getFileFd(this.uri);
|
||||
console.debug(TAG, 'dlpFd:', this.dlpFd);
|
||||
@@ -417,6 +418,11 @@ export default class ViewAbility extends ServiceExtensionAbility {
|
||||
console.error(TAG, 'open', this.uri, 'failed', error.code, error.message);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.stat = await fs.stat(this.uriInfo.path);
|
||||
} catch (err) {
|
||||
console.log(TAG, 'stat fail', err.code, err.message);
|
||||
}
|
||||
this.startSandboxApp(startId);
|
||||
hiTraceMeter.finishTrace('DlpOpenFileJs', startId);
|
||||
}
|
||||
|
||||
@@ -769,7 +769,7 @@ struct DlpDialog {
|
||||
if (this.isDlpFile && !globalThis.requestIsFromSandBox) {
|
||||
try {
|
||||
console.info(TAG, 'closeDLPFile', this.srcFileName, this.srcFd);
|
||||
await this.dlpFile.closeDLPFile()
|
||||
await this.dlpFile.closeDLPFile();
|
||||
} catch (err) {
|
||||
console.error(TAG, 'closeDLPFile', this.srcFileName, 'failed', err.code, err.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user