From c703a7bfe0d327f37a1b86ac4659f742558fedf8 Mon Sep 17 00:00:00 2001 From: chensihan Date: Mon, 31 Mar 2025 15:48:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9session=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=20Signed-off-by:=20chensihan=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/js/backup/session_backup_n_exporter.cpp | 6 +++--- .../backup/session_incremental_backup_n_exporter.cpp | 6 +++--- .../kits/js/backup/session_restore_n_exporter.cpp | 6 +++--- .../backup_sa/src/module_external/bms_adapter.cpp | 11 +++++------ utils/src/b_jsonutil/b_jsonutil.cpp | 12 +++--------- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/interfaces/kits/js/backup/session_backup_n_exporter.cpp b/interfaces/kits/js/backup/session_backup_n_exporter.cpp index ee0c14adc..f331a15f3 100644 --- a/interfaces/kits/js/backup/session_backup_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_backup_n_exporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -379,8 +379,8 @@ napi_value SessionBackupNExporter::Constructor(napi_env env, napi_callback_info .onProcess = bind(OnProcess, backupEntity->callbacks, placeholders::_1, placeholders::_2), .onBackupSizeReport = bind(OnBackupSizeReport, backupEntity->callbacks, placeholders::_1)}, errMsg, errCode); if (!backupEntity->session) { - std::tuple errInfo = - std::make_tuple(errCode, BError::GetBackupMsgByErrno(errCode) + ", " + errMsg); + std::tuple errInfo = (errCode == BError(BError::Codes::SA_SESSION_CONFLICT)) ? + std::make_tuple(errCode, errMsg) : std::make_tuple(errCode, BError::GetBackupMsgByErrno(errCode)); ErrParam errorParam = [ errInfo ]() { return errInfo;}; NError(errorParam).ThrowErr(env); return nullptr; diff --git a/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp b/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp index d3a84c628..5d61b6db4 100644 --- a/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_incremental_backup_n_exporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -382,8 +382,8 @@ napi_value SessionIncrementalBackupNExporter::Constructor(napi_env env, napi_cal .onProcess = bind(OnProcess, backupEntity->callbacks, placeholders::_1, placeholders::_2), .onBackupSizeReport = bind(OnBackupSizeReport, backupEntity->callbacks, placeholders::_1)}, errMsg, errCode); if (!backupEntity->session) { - std::tuple errInfo = - std::make_tuple(errCode, BError::GetBackupMsgByErrno(errCode) + ", " + errMsg); + std::tuple errInfo = (errCode == BError(BError::Codes::SA_SESSION_CONFLICT)) ? + std::make_tuple(errCode, errMsg) : std::make_tuple(errCode, BError::GetBackupMsgByErrno(errCode)); ErrParam errorParam = [ errInfo ]() { return errInfo;}; NError(errorParam).ThrowErr(env); return nullptr; diff --git a/interfaces/kits/js/backup/session_restore_n_exporter.cpp b/interfaces/kits/js/backup/session_restore_n_exporter.cpp index 23df85f3d..bb507b410 100644 --- a/interfaces/kits/js/backup/session_restore_n_exporter.cpp +++ b/interfaces/kits/js/backup/session_restore_n_exporter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -469,8 +469,8 @@ napi_value SessionRestoreNExporter::Constructor(napi_env env, napi_callback_info .onBackupServiceDied = bind(OnBackupServiceDied, restoreEntity->callbacks), .onProcess = bind(OnProcess, restoreEntity->callbacks, placeholders::_1, placeholders::_2)}, errMsg, errCode); if (!restoreEntity->sessionSheet) { - std::tuple errInfo = - std::make_tuple(errCode, BError::GetBackupMsgByErrno(errCode) + ", " + errMsg); + std::tuple errInfo = (errCode == BError(BError::Codes::SA_SESSION_CONFLICT)) ? + std::make_tuple(errCode, errMsg) : std::make_tuple(errCode, BError::GetBackupMsgByErrno(errCode)); ErrParam errorParam = [ errInfo ]() { return errInfo;}; NError(errorParam).ThrowErr(env); return nullptr; diff --git a/services/backup_sa/src/module_external/bms_adapter.cpp b/services/backup_sa/src/module_external/bms_adapter.cpp index 12a70dd62..bf1a73223 100644 --- a/services/backup_sa/src/module_external/bms_adapter.cpp +++ b/services/backup_sa/src/module_external/bms_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -34,6 +34,7 @@ #include "module_ipc/service.h" #include "module_ipc/svc_session_manager.h" #include "module_sched/sched_scheduler.h" +#include "parameters.h" #include "status_receiver_host.h" #include "system_ability_definition.h" #include "if_system_ability_manager.h" @@ -47,6 +48,7 @@ const string HMOS_HAP_CODE_PATH = "1"; const string LINUX_HAP_CODE_PATH = "2"; const string MEDIA_LIBRARY_HAP = "com.ohos.medialibrary.medialibrarydata"; const string EXTERNAL_FILE_HAP = "com.ohos.UserFile.ExternalFileManager"; +const string APP_GALLERY_BUNDLE_NAME = "const.appgallery.shaderowner.bundlename"; const int E_ERR = -1; const vector dataDir = {"app", "local", "distributed", "database", "cache"}; } // namespace @@ -152,11 +154,8 @@ vector BundleMgrAdapter::GetBundleInfos(const vecto string BundleMgrAdapter::GetAppGalleryBundleName() { - auto bms = GetBundleManager(); - - string bundleName = ""; - auto ret = bms->QueryAppGalleryBundleName(bundleName); - if (!ret) { + string bundleName = OHOS::system::GetParameter(APP_GALLERY_BUNDLE_NAME, ""); + if (bundleName.empty()) { HILOGI("Get App Gallery BundleName fail!"); } else { HILOGI("App Gallery BundleName: %{public}s", bundleName.c_str()); diff --git a/utils/src/b_jsonutil/b_jsonutil.cpp b/utils/src/b_jsonutil/b_jsonutil.cpp index bc3bebd9b..cdd7a085d 100644 --- a/utils/src/b_jsonutil/b_jsonutil.cpp +++ b/utils/src/b_jsonutil/b_jsonutil.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -468,23 +468,17 @@ std::string BJsonUtil::BuildInitSessionErrInfo(int32_t userId, std::string calle HILOGE("Failed to create cJSON object info, update errMsg failed"); return ""; } - cJSON *sessionInfoArray = cJSON_CreateArray(); - if (sessionInfoArray == nullptr) { - HILOGE("Failed to create cJSON array sessionInfoArray, update errMsg failed"); - cJSON_Delete(info); - return ""; - } - cJSON_AddItemToObject(info, "sessionInfo", sessionInfoArray); cJSON *sessionInfoObject = cJSON_CreateObject(); if (sessionInfoObject == nullptr) { HILOGE("Failed to create cJSON object sessionInfoObject, update errMsg failed"); cJSON_Delete(info); return ""; } - cJSON_AddItemToArray(sessionInfoArray, sessionInfoObject); + cJSON_AddStringToObject(sessionInfoObject, "error", "Session Conflict"); cJSON_AddStringToObject(sessionInfoObject, "userId", to_string(userId).c_str()); cJSON_AddStringToObject(sessionInfoObject, "name", callerName.c_str()); cJSON_AddStringToObject(sessionInfoObject, "activeTime", activeTime.c_str()); + cJSON_AddItemToObject(info, "sessionInfo", sessionInfoObject); char *jsonStr = cJSON_Print(info); if (jsonStr == nullptr) { HILOGE("update errMsg failed"); -- Gitee