!4241 【Sample】DLPManager修复中文文件名乱码问题

Merge pull request !4241 from yuandongping/dlp-m
This commit is contained in:
openharmony_ci 2024-04-02 12:29:39 +00:00 committed by Gitee
commit 376448662f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 16 additions and 15 deletions

View File

@ -232,6 +232,7 @@ Note:If the text contains special characters, please escape them according to th
<filteritem type="filepath" name="code/SystemFeature/Security/CertificateFramework/AppScope/resources/base/media/app_icon.png" desc="Provided by code/SystemFeature/Security/CertificateFramework"/>
<filteritem type="filepath" name="code/SystemFeature/Security/CertificateFramework/screenshots/device/verify_success.jpeg" desc="Provided by code/SystemFeature/Security/CertificateFramework"/>
<filteritem type="filepath" name="code/SystemFeature/Security/CertificateFramework/screenshots/device/chain_fail.jpeg" desc="Provided by code/SystemFeature/Security/CertificateFramework"/>
<filteritem type="filepath" name="code/BasicFeature/Security/DLPManager/screenshots/device/index.jpeg" desc="Provided by code/BasicFeature/Security/DLPManager"/>
<filteritem type="filepath" name="code/SystemFeature/Security/CertificateFramework/entry/src/ohosTest/resources/base/media/icon.png" desc="Provided by code/SystemFeature/Security/CertificateFramework"/>
<filteritem type="filepath" name="code/BasicFeature/ArkTSCard/ArkTSCard/libs/ArkTSUser.hap" desc="Provided by code/BasicFeature/ArkTSCard/ArkTSCard"/>
<filteritem type="filepath" name="code/Project/HapBuild/compile-tool/tool/sign_tool/OpenHarmonyProfileDebug.pem" desc="Provided by code/Project/HapBuild"/>

View File

@ -12,9 +12,9 @@
使用说明
1.进入界面,显示原始应用沙箱目录获取原始文件打开列表。
1.进入界面,显示原始应用沙箱目录获取原始文件访问列表。
2.点击右上角的图标,可以设置沙箱保留信息。
2.点击右上角的图标,可以获取沙箱保留信息。
3.点击右下角的加号图标,可以跳转进入文件夹。

View File

@ -82,7 +82,7 @@ struct DlpPage {
async getDlpPermission(): Promise<void> {
dlpPermission.getDLPPermissionInfo().then( ( data: dlpPermission.DLPPermissionInfo ) => {
Logger.info( TAG , 'getDLPPermissionInfo, result: ' + JSON.stringify( data ) );
promptAction.showToast( { message : 'permission' + JSON.stringify( data ) , duration : 2000 } );
promptAction.showToast( { message : 'permission' + decodeURIComponent(JSON.stringify(data)) , duration : 2000 } );
} ).catch( ( err: BusinessError ) => {
Logger.info( TAG , 'getDLPPermissionInfo: ' + JSON.stringify( err ) );
} );
@ -99,7 +99,7 @@ struct DlpPage {
let msg = 'isDlpFile:' + true + ';inSandbox:' + this.inSandbox;
dlpPermission.getDLPPermissionInfo().then( ( data: dlpPermission.DLPPermissionInfo ) => {
Logger.info( TAG , 'getDLPPermissionInfo, result: ' + JSON.stringify( data ) );
promptAction.showToast( { message : msg + ' permission' + JSON.stringify( data ) , duration : 2000 } );
promptAction.showToast( { message : msg + ' permission' + decodeURIComponent(JSON.stringify(data)) , duration : 2000 } );
} ).catch( ( err: BusinessError ) => {
Logger.info( TAG , 'getDLPPermissionInfo: ' + JSON.stringify( err ) );
} );
@ -174,7 +174,7 @@ struct DlpPage {
try {
let res = dlpPermission.getOriginalFileName( fileName ); // 获取原始文件名
Logger.info( TAG , 'OriginalFileName:' + res );
promptAction.showToast( { message : 'OriginalFileName:' + res , duration : 2000 } );
promptAction.showToast( { message : 'OriginalFileName:' + decodeURIComponent(res) , duration : 2000 } );
} catch( err ) {
Logger.error( TAG , 'getOriginalFileNameFunc error:' + (err as BusinessError).code + (err as BusinessError).message );
}
@ -227,7 +227,7 @@ struct DlpPage {
Logger.info( TAG , "funcAbilityWant:" + JSON.stringify( wantInfo ) );
this.dlpLinkUri = wantInfo.uri as string;
this.dlpUri = (wantInfo.parameters?.dlpUri as DLPUriObj).name;
this.dlpName = (wantInfo.parameters?.fileAsset as DLPNameObj).displayName;
this.dlpName = decodeURIComponent((wantInfo.parameters?.fileAsset as DLPNameObj).displayName);
this.dlpLinkName = (wantInfo.parameters?.linkFileName as DLPLinkNameObj).name;
this.dlpContent = this.mediaFileUri.readFileContent( this.dlpLinkUri );

View File

@ -58,7 +58,7 @@ struct FilePage {
scroller: Scroller = new Scroller();
getFileInfo(): void {
this.myFileName = (router.getParams() as myParams).fileName;
this.myFileName = decodeURIComponent((router.getParams() as myParams).fileName);
this.myPath = (router.getParams() as myParams).myPath;
this.myUri = (router.getParams() as myParams).myUri;
this.fd = (router.getParams() as myParams).fd;
@ -91,7 +91,7 @@ struct FilePage {
async getDLPFile(): Promise<void> {
try {
let info: Array<dlpPermission.AccessedDLPFileInfo> = await dlpPermission.getDLPFileAccessRecords();
promptAction.showToast( { message : 'getDLPFile:' + JSON.stringify( info ) , duration : 2000 } );
promptAction.showToast( { message : 'getDLPFile:' + decodeURIComponent(JSON.stringify(info)) , duration : 2000 } );
Logger.info( TAG , 'getDLPFile:' , JSON.stringify( info ) );
} catch( err ) {
Logger.error( TAG , 'getDLPFileAccessRecords error:' + (err as BusinessError).code + (err as BusinessError).message );
@ -105,7 +105,7 @@ struct FilePage {
try {
let res: Array<dlpPermission.RetentionSandboxInfo> = await dlpPermission.getRetentionSandboxList(); // 获取沙箱保留列表
Logger.info( TAG , 'res' , JSON.stringify( res ) );
promptAction.showToast( { message : 'getSandboxList:' + JSON.stringify( res ) , duration : 2000 } );
promptAction.showToast( { message : 'getSandboxList:' + decodeURIComponent(JSON.stringify(res)) , duration : 2000 } );
} catch( err ) {
Logger.error( TAG , 'getRetentionSandboxList error:' + (err as BusinessError).code + (err as BusinessError).message ); // 失败报错
}
@ -116,7 +116,7 @@ struct FilePage {
async getDlpPermission(): Promise<void> {
dlpPermission.getDLPPermissionInfo().then( ( data: dlpPermission.DLPPermissionInfo ) => {
Logger.info( TAG , 'getDLPPermissionInfo, result: ' + JSON.stringify( data ) );
promptAction.showToast( { message : 'permission' + JSON.stringify( data ) , duration : 2000 } );
promptAction.showToast( { message : 'permission' + decodeURIComponent(JSON.stringify(data)) , duration : 2000 } );
} ).catch( ( err: BusinessError ) => {
Logger.info( TAG , 'getDLPPermissionInfo: ' + JSON.stringify( err ) );
} );
@ -131,7 +131,7 @@ struct FilePage {
Logger.info( TAG , 'isDlpFile:' + this.isDLPFile );
this.inSandbox = await dlpPermission.isInSandbox();
let msg = 'isDlpFile:' + this.isDLPFile + ';inSandbox:' + this.inSandbox;
promptAction.showToast( { message : msg , duration : 2000 } );
promptAction.showToast( { message : decodeURIComponent(msg) , duration : 2000 } );
this.getDLPSupported( fileSuffix );
} catch( err ) {
Logger.error( TAG , 'isDLPFile error:' + (err as BusinessError).code + (err as BusinessError).message );

View File

@ -217,7 +217,7 @@ export struct Index {
async getDLPFile(): Promise<void> {
try {
let info: Array<dlpPermission.AccessedDLPFileInfo> = await dlpPermission.getDLPFileAccessRecords(); // 获取DLP访问列表
promptAction.showToast( { message : "getDLPFile" + JSON.stringify( info ) , duration : 2000 } );
promptAction.showToast( { message : "getDLPFile" + decodeURIComponent(JSON.stringify(info)) , duration : 2000 } );
Logger.info( TAG , 'getDLPFile:' , JSON.stringify( info ) );
} catch( err ) {
Logger.error( TAG , 'getDLPFileAccessRecords error:' + (err as BusinessError).code + (err as BusinessError).message );
@ -253,7 +253,7 @@ export struct Index {
try {
let res: Array<dlpPermission.RetentionSandboxInfo> = await dlpPermission.getRetentionSandboxList(); // 获取沙箱保留列表
Logger.info( TAG , 'getRetentionSandboxList:' + JSON.stringify( res ) );
promptAction.showToast( { message : 'getRetentionSandboxList:' + JSON.stringify( res ) , duration : 2000 } );
promptAction.showToast( { message : 'getRetentionSandboxList:' + decodeURIComponent(JSON.stringify(res)) , duration : 2000 } );
} catch( err ) {
Logger.error( TAG , 'getRetentionSandboxList error:' + (err as BusinessError).code + (err as BusinessError).message );
}
@ -298,7 +298,7 @@ export struct Index {
try {
dlpPermission.on( 'openDLPFile' , ( info: dlpPermission.AccessedDLPFileInfo ) => {
Logger.info( TAG , 'openDlpFile event:' + info.uri + info.lastOpenTime );
promptAction.showToast( { message : 'openDlpFile event:' + info.uri + info.lastOpenTime , duration : 2000 } );
promptAction.showToast( { message : 'openDlpFile event:' + decodeURIComponent(info.uri) + info.lastOpenTime , duration : 2000 } );
} );
} catch( err ) {
Logger.error( TAG , 'onOpenDLPFile error:' + (err as BusinessError).code + (err as BusinessError).message );
@ -351,7 +351,7 @@ export struct Index {
try {
await accountAbility.setOsAccountDistributedInfo( info );
Logger.info( TAG , "login success;info:" + JSON.stringify( info ) )
promptAction.showToast( { message : "login success;info:" + JSON.stringify( info ) , duration : 2000 } )
promptAction.showToast( { message : "login success;info:" + decodeURIComponent(JSON.stringify(info)) , duration : 2000 } )
} catch( err ) {
Logger.error( TAG , "setOsAccountDistributedInfo LOGIN failed" + err.code + err.message );
return

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 25 KiB