mirror of
https://gitee.com/openharmony/filemanagement_user_file_service
synced 2024-11-23 15:29:42 +00:00
fix:log
Signed-off-by: zhouoaoteng <zhouaoteng@huawei.com>
This commit is contained in:
parent
450d367422
commit
4411492111
@ -572,8 +572,8 @@ static int ReadFileFilterResults(MessageParcel &reply, SharedMemoryInfo &memInfo
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FileAccessExtProxy::ListFile(const FileInfo &fileInfo, const int64_t offset, const FileFilter &filter,
|
int FileAccessExtProxy::ListFile(const FileInfo &fileInfo, const int64_t offset,
|
||||||
SharedMemoryInfo &memInfo)
|
const FileFilter &filter, SharedMemoryInfo &memInfo)
|
||||||
{
|
{
|
||||||
UserAccessTracer trace;
|
UserAccessTracer trace;
|
||||||
trace.Start("ListFile");
|
trace.Start("ListFile");
|
||||||
|
@ -21,7 +21,7 @@ const PhotoViewMIMETypes = {
|
|||||||
VIDEO_TYPE: 'video/*',
|
VIDEO_TYPE: 'video/*',
|
||||||
IMAGE_VIDEO_TYPE: '*/*',
|
IMAGE_VIDEO_TYPE: '*/*',
|
||||||
INVALID_TYPE: ''
|
INVALID_TYPE: ''
|
||||||
}
|
};
|
||||||
|
|
||||||
const DocumentSelectMode = {
|
const DocumentSelectMode = {
|
||||||
FILE: 0,
|
FILE: 0,
|
||||||
@ -50,7 +50,7 @@ const ErrCode = {
|
|||||||
RESULT_ERROR: 13900042,
|
RESULT_ERROR: 13900042,
|
||||||
NAME_TOO_LONG: 13900030,
|
NAME_TOO_LONG: 13900030,
|
||||||
CONTEXT_NO_EXIST: 16000011,
|
CONTEXT_NO_EXIST: 16000011,
|
||||||
}
|
};
|
||||||
|
|
||||||
const ERRCODE_MAP = new Map([
|
const ERRCODE_MAP = new Map([
|
||||||
[ErrCode.INVALID_ARGS, 'Invalid argument'],
|
[ErrCode.INVALID_ARGS, 'Invalid argument'],
|
||||||
@ -70,7 +70,7 @@ const ACTION = {
|
|||||||
SELECT_ACTION_MODAL: 'ohos.want.action.OPEN_FILE_SERVICE',
|
SELECT_ACTION_MODAL: 'ohos.want.action.OPEN_FILE_SERVICE',
|
||||||
SAVE_ACTION: 'ohos.want.action.CREATE_FILE',
|
SAVE_ACTION: 'ohos.want.action.CREATE_FILE',
|
||||||
SAVE_ACTION_MODAL: 'ohos.want.action.CREATE_FILE_SERVICE',
|
SAVE_ACTION_MODAL: 'ohos.want.action.CREATE_FILE_SERVICE',
|
||||||
}
|
};
|
||||||
|
|
||||||
const CREATE_FILE_NAME_LENGTH_LIMIT = 256;
|
const CREATE_FILE_NAME_LENGTH_LIMIT = 256;
|
||||||
const ARGS_ZERO = 0;
|
const ARGS_ZERO = 0;
|
||||||
@ -78,6 +78,7 @@ const ARGS_ONE = 1;
|
|||||||
const ARGS_TWO = 2;
|
const ARGS_TWO = 2;
|
||||||
const RESULT_CODE_ERROR = -1;
|
const RESULT_CODE_ERROR = -1;
|
||||||
const RESULT_CODE_OK = 0;
|
const RESULT_CODE_OK = 0;
|
||||||
|
const FILENAME_LENGTH = 3;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* UTF-8字符编码数值对应的存储长度:
|
* UTF-8字符编码数值对应的存储长度:
|
||||||
@ -109,7 +110,6 @@ function strSizeUTF8(str) {
|
|||||||
|
|
||||||
function checkArguments(args) {
|
function checkArguments(args) {
|
||||||
let checkArgumentsResult = undefined;
|
let checkArgumentsResult = undefined;
|
||||||
|
|
||||||
if (args.length === ARGS_TWO && typeof args[ARGS_ONE] !== 'function') {
|
if (args.length === ARGS_TWO && typeof args[ARGS_ONE] !== 'function') {
|
||||||
checkArgumentsResult = getErr(ErrCode.INVALID_ARGS);
|
checkArgumentsResult = getErr(ErrCode.INVALID_ARGS);
|
||||||
}
|
}
|
||||||
@ -122,7 +122,10 @@ function checkArguments(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option.newFileNames !== undefined && option.newFileNames.length > 0) {
|
if (option.newFileNames === undefined || option.newFileNames.length <= 0) {
|
||||||
|
return checkArgumentsResult;
|
||||||
|
}
|
||||||
|
|
||||||
for (let i = 0; i < option.newFileNames.length; i++) {
|
for (let i = 0; i < option.newFileNames.length; i++) {
|
||||||
let value = option.newFileNames[i];
|
let value = option.newFileNames[i];
|
||||||
if (strSizeUTF8(value) >= CREATE_FILE_NAME_LENGTH_LIMIT) {
|
if (strSizeUTF8(value) >= CREATE_FILE_NAME_LENGTH_LIMIT) {
|
||||||
@ -131,7 +134,6 @@ function checkArguments(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return checkArgumentsResult;
|
return checkArgumentsResult;
|
||||||
}
|
}
|
||||||
@ -165,6 +167,32 @@ function parsePhotoPickerSelectOption(args) {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function anonymousPathArray(geturi) {
|
||||||
|
let anonymousPathArrays = [];
|
||||||
|
let anonymousPath = '';
|
||||||
|
if (geturi === undefined) {
|
||||||
|
return anonymousPathArrays;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < geturi.length; ++i) {
|
||||||
|
let lastSlashIndex = geturi[i].lastIndexOf('/');
|
||||||
|
if (lastSlashIndex === -1) {
|
||||||
|
anonymousPathArrays.push(geturi[i]);
|
||||||
|
} else {
|
||||||
|
let dirPath = geturi[i].substring(0, lastSlashIndex + 1);
|
||||||
|
let fileName = geturi[i].substring(lastSlashIndex + 1);
|
||||||
|
if (fileName.length <= 0) {
|
||||||
|
anonymousPath = '******';
|
||||||
|
} else {
|
||||||
|
let lastLetter = fileName.slice(-1);
|
||||||
|
let maskedName = '******' + lastLetter;
|
||||||
|
anonymousPath = dirPath + maskedName;
|
||||||
|
}
|
||||||
|
anonymousPathArrays.push(anonymousPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return anonymousPathArrays;
|
||||||
|
}
|
||||||
|
|
||||||
function getPhotoPickerSelectResult(args) {
|
function getPhotoPickerSelectResult(args) {
|
||||||
let selectResult = {
|
let selectResult = {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
@ -227,7 +255,7 @@ async function photoPickerSelect(...args) {
|
|||||||
} else {
|
} else {
|
||||||
reject(photoSelectResult.error);
|
reject(photoSelectResult.error);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[picker] photo select error: ' + error);
|
console.error('[picker] photo select error: ' + error);
|
||||||
}
|
}
|
||||||
@ -303,7 +331,9 @@ function getDocumentPickerSelectResult(args) {
|
|||||||
selectResult.data = [];
|
selectResult.data = [];
|
||||||
selectResult.error = args.resultCode;
|
selectResult.error = args.resultCode;
|
||||||
}
|
}
|
||||||
console.log('[picker] document select selectResult: ' + JSON.stringify(selectResult));
|
|
||||||
|
console.log('[picker] document select selectResult: : errorcode is = ' + selectResult.error +
|
||||||
|
', selecturi is = ' + anonymousPathArray(selectResult.data));
|
||||||
return selectResult;
|
return selectResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +370,6 @@ async function documentPickerSelect(...args) {
|
|||||||
} catch (paramError) {
|
} catch (paramError) {
|
||||||
console.error('[picker] DocumentSelect paramError: ' + JSON.stringify(paramError));
|
console.error('[picker] DocumentSelect paramError: ' + JSON.stringify(paramError));
|
||||||
}
|
}
|
||||||
console.log('[picker] DocumentSelect result: ' + JSON.stringify(documentSelectResult));
|
|
||||||
selectResult = getDocumentPickerSelectResult(documentSelectResult);
|
selectResult = getDocumentPickerSelectResult(documentSelectResult);
|
||||||
return sendResult(args, selectResult);
|
return sendResult(args, selectResult);
|
||||||
}
|
}
|
||||||
@ -394,12 +423,17 @@ function getAudioPickerSelectResult(args) {
|
|||||||
if (args.uriArr) {
|
if (args.uriArr) {
|
||||||
selectResult.data = args.uriArr;
|
selectResult.data = args.uriArr;
|
||||||
selectResult.error = args.resultCode;
|
selectResult.error = args.resultCode;
|
||||||
|
} else {
|
||||||
|
selectResult.data = [];
|
||||||
|
selectResult.error = args.resultCode;
|
||||||
}
|
}
|
||||||
} else if (args.resultCode === RESULT_CODE_ERROR) {
|
} else if (args.resultCode === RESULT_CODE_ERROR) {
|
||||||
selectResult.data = [];
|
selectResult.data = [];
|
||||||
selectResult.error = args.resultCode;
|
selectResult.error = args.resultCode;
|
||||||
}
|
}
|
||||||
console.log('[picker] getAudioPickerSelectResult selectResult: ' + JSON.stringify(selectResult));
|
|
||||||
|
console.log('[picker] getAudioPickerSelectResult selectResult: errorcode is = ' + selectResult.error +
|
||||||
|
', selecturi is = ' + anonymousPathArray(selectResult.data));
|
||||||
return selectResult;
|
return selectResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +461,9 @@ function getDocumentPickerSaveResult(args) {
|
|||||||
saveResult.data = [];
|
saveResult.data = [];
|
||||||
saveResult.error = args.resultCode;
|
saveResult.error = args.resultCode;
|
||||||
}
|
}
|
||||||
console.log('[picker] getDocumentPickerSaveResult saveResult: ' + JSON.stringify(saveResult));
|
|
||||||
|
console.log('[picker] getDocumentPickerSaveResult saveResult: errorcode is = ' + saveResult.error +
|
||||||
|
', selecturi is = ' + anonymousPathArray(saveResult.data) + ', usersavesuffix = ' + saveResult.suffix);
|
||||||
return saveResult;
|
return saveResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +527,6 @@ async function documentPickerSave(...args) {
|
|||||||
documentSaveResult = await modalPicker(args, documentSaveContext, documentSaveConfig);
|
documentSaveResult = await modalPicker(args, documentSaveContext, documentSaveConfig);
|
||||||
saveResult = getDocumentPickerSaveResult(documentSaveResult);
|
saveResult = getDocumentPickerSaveResult(documentSaveResult);
|
||||||
this.suffixIndex = saveResult.suffix;
|
this.suffixIndex = saveResult.suffix;
|
||||||
console.log('[picker] download save result: ' + JSON.stringify(saveResult));
|
|
||||||
return sendResult(args, saveResult);
|
return sendResult(args, saveResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,6 +537,7 @@ function getSelectedSuffixIndex() {
|
|||||||
console.log('[picker] Get Selected Suffix Index end: ' + index);
|
console.log('[picker] Get Selected Suffix Index end: ' + index);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendResult(args, result) {
|
async function sendResult(args, result) {
|
||||||
try {
|
try {
|
||||||
if (result === undefined) {
|
if (result === undefined) {
|
||||||
@ -641,4 +677,4 @@ export default {
|
|||||||
PhotoViewPicker : PhotoViewPicker,
|
PhotoViewPicker : PhotoViewPicker,
|
||||||
DocumentViewPicker: DocumentViewPicker,
|
DocumentViewPicker: DocumentViewPicker,
|
||||||
AudioViewPicker : AudioViewPicker,
|
AudioViewPicker : AudioViewPicker,
|
||||||
}
|
};
|
||||||
|
@ -46,8 +46,7 @@ void ModalUICallback::OnError(int32_t code, const std::string& name, const std::
|
|||||||
|
|
||||||
void ModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want &result)
|
void ModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want &result)
|
||||||
{
|
{
|
||||||
HILOG_INFO("modal picker: OnResultForModal enter. resultCode is %{public}d, %{public}s",
|
HILOG_INFO("modal picker: OnResultForModal enter. resultCode is %{public}d,", resultCode);
|
||||||
resultCode, result.ToString().c_str());
|
|
||||||
pickerCallBack_->resultCode = resultCode;
|
pickerCallBack_->resultCode = resultCode;
|
||||||
pickerCallBack_->want = result;
|
pickerCallBack_->want = result;
|
||||||
pickerCallBack_->ready = true;
|
pickerCallBack_->ready = true;
|
||||||
|
@ -106,8 +106,7 @@ static napi_value MakeResultWithPickerCallBack(napi_env env, std::shared_ptr<Pic
|
|||||||
napi_create_object(env, &result);
|
napi_create_object(env, &result);
|
||||||
|
|
||||||
const int32_t resCode = pickerCallBack->resultCode;
|
const int32_t resCode = pickerCallBack->resultCode;
|
||||||
HILOG_INFO("modal picker: resCode is %{public}d. want is %{public}s.",
|
HILOG_INFO("modal picker: resCode is %{public}d.", resCode);
|
||||||
resCode, pickerCallBack->want.ToString().c_str());
|
|
||||||
napi_value resultCode = nullptr;
|
napi_value resultCode = nullptr;
|
||||||
napi_create_int32(env, resCode, &resultCode);
|
napi_create_int32(env, resCode, &resultCode);
|
||||||
status = napi_set_named_property(env, result, "resultCode", resultCode);
|
status = napi_set_named_property(env, result, "resultCode", resultCode);
|
||||||
|
Loading…
Reference in New Issue
Block a user