fix sync bug

Signed-off-by: dinghao <dinghao47@huawei.com>
This commit is contained in:
dinghao 2024-04-09 22:29:41 +08:00
parent 551e763300
commit a1cde3ece8
18 changed files with 207 additions and 132 deletions

View File

@ -51,10 +51,7 @@
"bounds_checking_function"
]
},
"adapted_system_type": [
"small",
"standard"
],
"adapted_system_type": [ "small", "standard"],
"rom": "1024KB",
"ram": "1024KB",
"build": {

View File

@ -130,8 +130,8 @@ public:
/**
* @brief Called do restore.
*/
virtual ErrCode OnRestore(std::function<void(const std::string)> callbackEx,
std::function<void()> callback);
virtual ErrCode OnRestore(std::function<void()> callback, std::function<void(const std::string)> callbackEx,
std::function<void()> callbackExAppDone);
/**
* @brief Called do restore.
@ -168,9 +168,9 @@ public:
bool RestoreDataReady();
/**
* @brief Called Notification containing extended information
* @brief Called Extention to notify
*/
virtual ErrCode CallExtNotify(std::string result);
virtual ErrCode CallExtRestore(std::string result);
public:
ExtBackup() = default;

View File

@ -58,9 +58,21 @@ struct CallbackInfo {
CallbackInfo(std::function<void()> callbackIn) : callback(callbackIn) {}
};
struct CallbackInfoBackup {
std::function<void(const std::string)> callbackParam;
CallbackInfoBackup(std::function<void(const std::string)> param)
: callbackParam(param)
{
}
};
struct CallbackInfoEx {
std::function<void(const std::string)> callbackParam;
CallbackInfoEx(std::function<void(const std::string)> callbackIn) : callbackParam(callbackIn) {}
std::function<void()> callbackAppDone;
CallbackInfoEx(std::function<void(const std::string)> param, std::function<void()> appDone)
: callbackParam(param), callbackAppDone(appDone)
{
}
};
class ExtBackupJs : public ExtBackup {
@ -100,8 +112,8 @@ public:
* @param callbackEx The callbackEx.
* @param callback The callBack.
*/
ErrCode OnRestore(std::function<void(const std::string)> callbackEx,
std::function<void()> callback) override;
ErrCode OnRestore(std::function<void()> callback,std::function<void(const std::string)> callbackEx,
std::function<void()> callbackExAppDone) override;
/**
* @brief Call the app's OnRestore.
@ -121,7 +133,7 @@ public:
*
* @param result The result.
*/
ErrCode CallExtNotify(std::string result) override;
ErrCode CallExtRestore(std::string result) override;
public:
explicit ExtBackupJs(AbilityRuntime::JsRuntime &jsRuntime) : jsRuntime_(jsRuntime) {}
@ -147,6 +159,7 @@ private:
AbilityRuntime::JsRuntime &jsRuntime_;
std::unique_ptr<NativeReference> jsObj_;
std::shared_ptr<CallbackInfoBackup> callbackInfoBackup_;
std::shared_ptr<CallbackInfoEx> callbackInfoEx_;
std::shared_ptr<CallbackInfo> callbackInfo_;
std::condition_variable callJsCon_;

View File

@ -155,7 +155,26 @@ private:
*
* @param errCode
*/
std::function<void(const std::string)> GetCallbackExFun(wptr<BackupExtExtension> obj);
std::function<void(const std::string)> RestoreResultCallbackEx(wptr<BackupExtExtension> obj);
/**
* @brief get callbackEx for execute onRestore with string param
*
* @param errCode
*/
std::function<void(const std::string)> IncrementalRestoreResultCallbackEx(wptr<BackupExtExtension> obj);
/**
* @brief get callbackEx for execute onRestore
*
* @param errCode
*/
std::function<void()> IncrementalAppDoneCallbackEx(wptr<BackupExtExtension> obj);
/**
* @brief get callbackEx for execute appDone
*/
std::function<void()> AppDoneCallbackEx(wptr<BackupExtExtension> obj);
private:
std::shared_mutex lock_;
std::shared_ptr<ExtBackup> extension_;

View File

@ -250,8 +250,8 @@ ErrCode ExtBackup::OnBackup(function<void()> callback)
return ERR_OK;
}
ErrCode ExtBackup::OnRestore(std::function<void(const std::string)> callbackEx,
function<void()> callback)
ErrCode ExtBackup::OnRestore(function<void()> callback, std::function<void(const std::string)> callbackEx,
std::function<void()> callbackExAppDone)
{
HILOGI("BackupExtensionAbility(base) OnRestore with Ex.");
return ERR_OK;
@ -269,9 +269,9 @@ ErrCode ExtBackup::GetBackupInfo(function<void(std::string)> callback)
return ERR_OK;
}
ErrCode ExtBackup::CallExtNotify(std::string result)
ErrCode ExtBackup::CallExtRestore(std::string result)
{
HILOGI("BackupExtensionAbility(base) CallExtNotify.");
HILOGI("BackupExtensionAbility(base) CallExtRestore.");
return ERR_OK;
}

View File

@ -190,6 +190,33 @@ static bool CallPromiseEx(AbilityRuntime::JsRuntime &jsRuntime, napi_value resul
return true;
}
static bool CallPromiseEx(AbilityRuntime::JsRuntime &jsRuntime, napi_value result,
CallbackInfoBackup *callbackInfoBackup)
{
AbilityRuntime::HandleScope handleScope(jsRuntime);
auto env = jsRuntime.GetNapiEnv();
napi_value method = nullptr;
if (napi_get_named_property(env, result, "then", &method) != napi_ok) {
HILOGI("CallPromise, Failed to get method then");
return false;
}
bool isCallable = false;
if (napi_is_callable(env, method, &isCallable) != napi_ok) {
HILOGI("CallPromise, Failed to check method then is callable");
return false;
}
if (!isCallable) {
HILOGI("CallPromise, property then is not callable.");
return false;
}
napi_value ret;
napi_create_function(env, "promiseCallbackEx", strlen("promiseCallbackEx"), PromiseCallbackEx, callbackInfoBackup,
&ret);
napi_value argv[1] = {ret};
napi_call_function(env, result, method, 1, argv, nullptr);
return true;
}
void ExtBackupJs::Init(const shared_ptr<AppExecFwk::AbilityLocalRecord> &record,
const shared_ptr<AppExecFwk::OHOSApplication> &application,
shared_ptr<AppExecFwk::AbilityHandler> &handler,
@ -336,15 +363,15 @@ ErrCode ExtBackupJs::OnBackup(function<void()> callback)
return errCode;
}
ErrCode ExtBackupJs::OnRestore(std::function<void(const std::string)> callbackEx,
function<void()> callback)
ErrCode ExtBackupJs::OnRestore(function<void()> callback, std::function<void(const std::string)> callbackEx,
std::function<void()> callbackExAppDone)
{
HILOGI("BackupExtensionAbility(JS) OnRestore.");
BExcepUltils::BAssert(jsObj_, BError::Codes::EXT_BROKEN_FRAMEWORK,
"The app does not provide the onRestore interface.");
needCallOnRestore_.store(false);
callbackInfo_ = std::make_shared<CallbackInfo>(callback);
callbackInfoEx_ = std::make_shared<CallbackInfoEx>(callbackEx);
callbackInfoEx_ = std::make_shared<CallbackInfoEx>(callbackEx, callbackExAppDone);
auto envir = jsRuntime_.GetNapiEnv();
napi_value value = jsObj_.get()->GetNapiValue();
if (value == nullptr) {
@ -389,12 +416,10 @@ ErrCode ExtBackupJs::OnRestore(function<void()> callback)
ErrCode ExtBackupJs::CallJSRestoreEx(napi_env env, napi_value val)
{
bool isExist;
napi_has_named_property(env, val, "onRestoreEx", &isExist);
if (!isExist) {
HILOGI("Js method onRestoreEx is not exist");
return CallJSRestore(env, val);
napi_status status = napi_has_named_property(env, val, "onRestoreEx", &isExist);
if (status != napi_ok) {
HILOGI("Js method onRestoreEx status err");
}
HILOGI("Js method onRestoreEx is exist");
auto retParser = [jsRuntime {&jsRuntime_}, callbackInfoEx {callbackInfoEx_}](napi_env envir, napi_value result) ->
bool {
if (!CheckPromise(envir, result)) {
@ -412,8 +437,10 @@ ErrCode ExtBackupJs::CallJSRestoreEx(napi_env env, napi_value val)
HILOGE("Call onRestoreEx error");
return errCode;
}
HILOGI("Call Js method lock");
if (!needCallOnRestore_.load()) {
if (callbackInfoEx_) {
callbackInfoEx_->callbackAppDone();
}
HILOGI("Call Js method onRestoreEx done");
return ERR_OK;
}
@ -423,10 +450,13 @@ ErrCode ExtBackupJs::CallJSRestoreEx(napi_env env, napi_value val)
ErrCode ExtBackupJs::CallJSRestore(napi_env env, napi_value val)
{
bool isExist;
napi_has_named_property(env, val, "onRestore", &isExist);
napi_status status = napi_has_named_property(env, val, "onRestore", &isExist);
if (status != napi_ok) {
HILOGI("Js method onRestore status err");
}
if (!isExist) {
HILOGI("Js method onRestore is not exist");
return ErrCode(isExist);
return ErrCode(BError::Codes::EXT_METHOD_NOT_EXIST);
}
HILOGI("Js method onRestore is exist");
auto retParser = [jsRuntime {&jsRuntime_}, callbackInfo {callbackInfo_}](napi_env env, napi_value result) -> bool {
@ -451,8 +481,8 @@ ErrCode ExtBackupJs::GetBackupInfo(std::function<void(const std::string)> callba
HILOGI("BackupExtensionAbility(JS) GetBackupInfo begin.");
BExcepUltils::BAssert(jsObj_, BError::Codes::EXT_BROKEN_FRAMEWORK,
"The app does not provide the GetBackupInfo interface.");
callbackInfoEx_ = std::make_shared<CallbackInfoEx>(callback);
auto retParser = [jsRuntime {&jsRuntime_}, callBackInfo {callbackInfoEx_}](napi_env env,
callbackInfoBackup_ = std::make_shared<CallbackInfoBackup>(callback);
auto retParser = [jsRuntime {&jsRuntime_}, callBackInfo {callbackInfoBackup_}](napi_env env,
napi_value result) -> bool {
if (!CheckPromise(env, result)) {
size_t strLen = 0;
@ -601,16 +631,15 @@ std::function<bool(napi_env env, std::vector<napi_value> &argv)> ExtBackupJs::Pa
return onRestoreFun;
}
ErrCode ExtBackupJs::CallExtNotify(std::string result)
ErrCode ExtBackupJs::CallExtRestore(std::string result)
{
HILOGI("Start CallExtNotify, result is: %{public}s", result.c_str());
HILOGI("Start CallExtRestore, result is: %{public}s", result.c_str());
if (result.size() == 0) {
needCallOnRestore_.store(true);
} else {
needCallOnRestore_.store(false);
}
callJsCon_.notify_one();
HILOGI("End CallExtNotify");
HILOGI("End CallExtRestore");
return ERR_OK;
}
} // namespace OHOS::FileManagement::Backup

View File

@ -1027,7 +1027,6 @@ void BackupExtExtension::AsyncTaskRestoreForUpgrade()
HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__);
auto task = [obj {wptr<BackupExtExtension>(this)}]() {
auto ptr = obj.promote();
auto callBackupEx = ptr->GetCallbackExFun(obj);
auto callBackup = [obj]() {
auto extensionPtr = obj.promote();
BExcepUltils::BAssert(extensionPtr, BError::Codes::EXT_BROKEN_FRAMEWORK,
@ -1035,12 +1034,20 @@ void BackupExtExtension::AsyncTaskRestoreForUpgrade()
extensionPtr->AppDone(BError(BError::Codes::OK));
extensionPtr->DoClear();
};
auto callBackupEx = ptr->RestoreResultCallbackEx(obj);
auto callBackupExAppDone = ptr->AppDoneCallbackEx(obj);
try {
BExcepUltils::BAssert(ptr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
BExcepUltils::BAssert(ptr->extension_, BError::Codes::EXT_INVAL_ARG,
"extension handle have been already released");
ptr->extension_->OnRestore(callBackupEx, callBackup);
ErrCode err = ptr->extension_->OnRestore(callBackup, callBackupEx, callBackupExAppDone);
if (err != ErrCode(BError::Codes::EXT_METHOD_NOT_EXIST)) {
HILOGI("OnRestore result EXT_METHOD_NOT_EXIST");
return;
}
ptr->AppDone(err);
ptr->DoClear();
} catch (const BError &e) {
ptr->AppDone(e.GetCode());
} catch (const exception &e) {
@ -1070,33 +1077,26 @@ void BackupExtExtension::AsyncTaskIncrementalRestoreForUpgrade()
{
auto task = [obj {wptr<BackupExtExtension>(this)}]() {
auto ptr = obj.promote();
auto callBackupEx = [obj](const std::string restoreRetInfo) {
HILOGI("begin call restoreEx");
auto extensionPtr = obj.promote();
BExcepUltils::BAssert(extensionPtr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
extensionPtr->extension_->CallExtNotify(restoreRetInfo);
if (restoreRetInfo.size()) {
extensionPtr->AppResultReport(restoreRetInfo, BackupRestoreScenario::INCREMENTAL_RESTORE);
}
extensionPtr->AppDone(BError(BError::Codes::OK));
extensionPtr->DoClear();
};
auto callBackup = [obj]() {
HILOGI("begin call restore");
auto extensionPtr = obj.promote();
BExcepUltils::BAssert(extensionPtr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
extensionPtr->AppIncrementalDone(BError(BError::Codes::OK));
// 清空恢复目录
extensionPtr->DoClear();
};
auto callBackupEx = ptr->IncrementalRestoreResultCallbackEx(obj);
auto callBackupExAppDone = ptr->IncrementalAppDoneCallbackEx(obj);
try {
BExcepUltils::BAssert(ptr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
BExcepUltils::BAssert(ptr->extension_, BError::Codes::EXT_INVAL_ARG,
"extension handle have been already released");
ptr->extension_->OnRestore(callBackupEx, callBackup);
ErrCode err = ptr->extension_->OnRestore(callBackup, callBackupEx, callBackupExAppDone);
if (err == ErrCode(BError::Codes::EXT_METHOD_NOT_EXIST)) {
ptr->AppIncrementalDone(err);
ptr->DoClear();
}
} catch (const BError &e) {
ptr->AppIncrementalDone(e.GetCode());
} catch (const exception &e) {
@ -1615,24 +1615,57 @@ ErrCode BackupExtExtension::GetBackupInfo(std::string &result)
return ERR_OK;
}
std::function<void(std::string)> BackupExtExtension::GetCallbackExFun(wptr<BackupExtExtension> obj)
std::function<void(std::string)> BackupExtExtension::RestoreResultCallbackEx(wptr<BackupExtExtension> obj)
{
HILOGI("Begin get callbackEx");
return [obj](const std::string restoreRetInfo) {
auto extensionPtr = obj.promote();
BExcepUltils::BAssert(extensionPtr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
extensionPtr->extension_->CallExtNotify(restoreRetInfo);
extensionPtr->extension_->CallExtRestore(restoreRetInfo);
if (restoreRetInfo.size()) {
if (extensionPtr->extension_->WasFromSpecialVersion() && extensionPtr->extension_->RestoreDataReady()) {
extensionPtr->AppResultReport(restoreRetInfo,
BackupRestoreScenario::INCREMENTAL_RESTORE);
} else {
extensionPtr->AppResultReport(restoreRetInfo, BackupRestoreScenario::FULL_RESTORE);
}
extensionPtr->AppResultReport(restoreRetInfo, BackupRestoreScenario::FULL_RESTORE);
}
};
}
std::function<void()> BackupExtExtension::AppDoneCallbackEx(wptr<BackupExtExtension> obj)
{
HILOGI("Begin get callback for appDone");
return [obj]() {
HILOGI("begin call callBackupExAppDone");
auto extensionPtr = obj.promote();
BExcepUltils::BAssert(extensionPtr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
extensionPtr->AppDone(BError(BError::Codes::OK));
extensionPtr->DoClear();
};
}
std::function<void(std::string)> BackupExtExtension::IncrementalRestoreResultCallbackEx(wptr<BackupExtExtension> obj)
{
HILOGI("Begin get callback for onRestore");
return [obj](const std::string restoreRetInfo) {
HILOGI("begin call restoreEx");
auto extensionPtr = obj.promote();
BExcepUltils::BAssert(extensionPtr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
extensionPtr->extension_->CallExtRestore(restoreRetInfo);
if (restoreRetInfo.size()) {
extensionPtr->AppResultReport(restoreRetInfo, BackupRestoreScenario::INCREMENTAL_RESTORE);
}
};
}
std::function<void()> BackupExtExtension::IncrementalAppDoneCallbackEx(wptr<BackupExtExtension> obj)
{
return [obj]() {
HILOGI("begin call callBackupExAppDone for restore");
auto extensionPtr = obj.promote();
BExcepUltils::BAssert(extensionPtr, BError::Codes::EXT_BROKEN_FRAMEWORK,
"Ext extension handle have been already released");
extensionPtr->AppIncrementalDone(BError(BError::Codes::OK));
extensionPtr->DoClear();
};
}
} // namespace OHOS::FileManagement::Backup

View File

@ -414,7 +414,7 @@ int TarFile::WriteAll(const vector<uint8_t> &buf, size_t len)
{
size_t count = 0;
while (count < len) {
auto i = fwrite(&buf[0] + count, sizeof(uint8_t), len - count, currentTarFile_);
auto i = fwrite(&buf[0] + count, sizeof(char), len - count, currentTarFile_);
if (i < 1) {
HILOGE("Failed to fwrite tar file, err = %{public}d", errno);
return count;

View File

@ -103,7 +103,6 @@ ohos_shared_library("fileuri_native") {
"samgr:samgr_proxy",
]
innerapi_tags = [ "platformsdk" ]
part_name = "app_file_service"
subsystem_name = "filemanagement"
}

View File

@ -371,11 +371,11 @@ napi_value SessionRestoreNExporter::Constructor(napi_env env, napi_callback_info
napi_value SessionRestoreNExporter::AppendBundles(napi_env env, napi_callback_info cbinfo)
{
HILOGI("called SessionRestore::AppendBundles begin");
int32_t fd = BConstants::INVALID_FD_NUM;
int32_t fd_restore = BConstants::INVALID_FD_NUM;
std::vector<std::string> bundleNames;
std::vector<std::string> bundleInfos;
NFuncArg funcArg(env, cbinfo);
if (!VerifyParamSuccess(funcArg, fd, bundleNames, bundleInfos, env)) {
if (!VerifyParamSuccess(funcArg, fd_restore, bundleNames, bundleInfos, env)) {
return nullptr;
}
auto restoreEntity = NClass::GetEntityOf<RestoreEntity>(env, funcArg.GetThisVar());
@ -384,7 +384,7 @@ napi_value SessionRestoreNExporter::AppendBundles(napi_env env, napi_callback_in
NError(BError(BError::Codes::SDK_INVAL_ARG, "Failed to get RestoreSession entity.").GetCode()).ThrowErr(env);
return nullptr;
}
auto cbExec = [entity {restoreEntity}, fd {fd}, bundles {bundleNames}, infos {bundleInfos}]() -> NError {
auto cbExec = [entity {restoreEntity}, fd {fd_restore}, bundles {bundleNames}, infos {bundleInfos}]() -> NError {
if (!(entity && (entity->sessionWhole || entity->sessionSheet))) {
return NError(BError(BError::Codes::SDK_INVAL_ARG, "restore session is nullptr").GetCode());
}

View File

@ -21,7 +21,6 @@
#include "b_jsonutil/b_jsonutil.h"
#include "b_json/b_json_entity_caps.h"
#include "b_resources/b_constants.h"
#include "i_service_reverse.h"
#include "iremote_stub.h"
#include "module_sched/sched_scheduler.h"

View File

@ -424,30 +424,19 @@ void Service::SetCurrentSessProperties(std::vector<BJsonEntityCaps::BundleInfo>
session_->SetBundleVersionName(restoreInfo.name, restoreInfo.versionName);
session_->SetBundleDataSize(restoreInfo.name, restoreInfo.spaceOccupied);
session_->SetBackupExtName(restoreInfo.name, restoreInfo.extensionName);
if (bundleNameDetailMap.empty()) {
continue;
}
NotifyBundleInfos(bundleNameDetailMap, restoreInfo, restoreType);
}
HILOGI("End");
}
void Service::NotifyBundleInfos(std::map<std::string, BJsonUtil::BundleDetailInfo> &bundleNameDetailMap,
BJsonEntityCaps::BundleInfo restoreInfo, RestoreTypeEnum restoreType)
{
if (restoreType == TypeRestoreTypeEnum::RESTORE_DATA_READDY ||
SpeicalVersion(restoreInfo.versionName, restoreInfo.versionCode)) {
auto iter = bundleNameDetailMap.find(restoreInfo.name);
if (iter != bundleNameDetailMap.end()) {
BJsonUtil::BundleDetailInfo bundleDetailInfo = iter->second;
if (bundleDetailInfo.type == COMMON_EVENT_TYPE) {
DelayedSingleton<NotifyWorkService>::GetInstance()->NotifyBundleDetail(bundleDetailInfo);
bool notifyRet =
DelayedSingleton<NotifyWorkService>::GetInstance()->NotifyBundleDetail(bundleDetailInfo);
HILOGI("Publish event end, notify result is:%{public}d", notifyRet);
}
}
}
HILOGI("End");
}
ErrCode Service::AppendBundlesBackupSession(const vector<BundleName> &bundleNames)
{
HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__);
@ -498,7 +487,7 @@ ErrCode Service::PublishFile(const BFileInfo &fileInfo)
{
HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__);
try {
HILOGD("Begin");
HILOGI("Begin");
VerifyCaller(IServiceReverse::Scenario::RESTORE);
auto backUpConnection = session_->GetExtConnection(fileInfo.owner);

View File

@ -275,7 +275,6 @@ int32_t ServiceStub::CmdAppendBundlesDetailsRestoreSession(MessageParcel &data,
if (!data.ReadInt32(userId)) {
return BError(BError::Codes::SA_INVAL_ARG, "Failed to receive userId");
}
int res = AppendBundlesRestoreSession(move(fd), bundleNames, detailInfos, restoreType, userId);
if (!reply.WriteInt32(res)) {
return BError(BError::Codes::SA_BROKEN_IPC, string("Failed to send the result ") + to_string(res));

View File

@ -28,7 +28,7 @@ using namespace std;
UniqueFd SvcExtensionProxy::GetFileHandle(const string &fileName)
{
HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__);
HILOGD("Start");
HILOGI("Start");
BExcepUltils::BAssert(Remote(), BError::Codes::SDK_INVAL_ARG, "Remote is nullptr");
MessageParcel data;
data.WriteInterfaceToken(GetDescriptor());

View File

@ -42,8 +42,7 @@ bool NotifyWorkService::NotifyBundleDetail(BJsonUtil::BundleDetailInfo bundleDet
want.SetParam("detail", bundleDetailInfo.detail);
want.SetAction(EVENT_NAME);
EventFwk::CommonEventData commonData {want};
bool publishRet = EventFwk::CommonEventManager::PublishCommonEvent(commonData);
HILOGI("End publish event, bundleName is: %{public}s", bundleName.c_str());
return publishRet;
return EventFwk::CommonEventManager::PublishCommonEvent(commonData);
}
}

View File

@ -1257,6 +1257,50 @@ HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_OnBunleFileReady_0200, tes
}
GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_OnBunleFileReady_0200";
}
/**
* @tc.number: SUB_backup_sa_session_SetSessionUserId_0100
* @tc.name: SUB_backup_sa_session_SetSessionUserId_0100
* @tc.desc: SetSessionUserId
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: I8ZIMJ
*/
HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_SetSessionUserId_0100, testing::ext::TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_backup_sa_session_SetSessionUserId_0100";
try {
int32_t userId = 1;
sessionManagerPtr_->SetSessionUserId(userId);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SetSessionUserId.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_backup_sa_session_SetSessionUserId_0100";
}
/**
* @tc.number: SUB_backup_sa_session_GetSessionUserId_0100
* @tc.name: SUB_backup_sa_session_GetSessionUserId_0100
* @tc.desc: GetSessionUserId
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: I8ZIMJ
*/
HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_GetSessionUserId_0100, testing::ext::TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_backup_sa_session_GetSessionUserId_0100";
try {
sessionManagerPtr_->GetSessionUserId();
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by GetSessionUserId.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_backup_sa_session_GetSessionUserId_0100";
}
/**
* @tc.number: SUB_backup_sa_session_GetBundleRestoreType_0100
* @tc.name: SUB_backup_sa_session_GetBundleRestoreType_0100
@ -1517,7 +1561,6 @@ HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_IsOnOnStartSched_0102, tes
GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_IsOnOnStartSched_0102";
}
/**
* @tc.number: SUB_backup_sa_session_SetBundleDataSize_0100
* @tc.name: SUB_backup_sa_session_SetBundleDataSize_0100
@ -1561,47 +1604,4 @@ HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_SetBundleDataSize_0101, te
}
GTEST_LOG_(INFO) << "SvcSessionManagerTest-end SUB_backup_sa_session_SetBundleDataSize_0101";
}
/**
* @tc.number: SUB_backup_sa_session_SetSessionUserId_0100
* @tc.name: SUB_backup_sa_session_SetSessionUserId_0100
* @tc.desc: SetSessionUserId
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: I8ZIMJ
*/
HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_SetSessionUserId_0100, testing::ext::TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_backup_sa_session_SetSessionUserId_0100";
try {
int32_t userId = 1;
sessionManagerPtr_->SetSessionUserId(userId);
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by SetSessionUserId.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_backup_sa_session_SetSessionUserId_0100";
}
/**
* @tc.number: SUB_backup_sa_session_GetSessionUserId_0100
* @tc.name: SUB_backup_sa_session_GetSessionUserId_0100
* @tc.desc: GetSessionUserId
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: I8ZIMJ
*/
HWTEST_F(SvcSessionManagerTest, SUB_backup_sa_session_GetSessionUserId_0100, testing::ext::TestSize.Level1)
{
GTEST_LOG_(INFO) << "ServiceTest-begin SUB_backup_sa_session_GetSessionUserId_0100";
try {
sessionManagerPtr_->GetSessionUserId();
} catch (...) {
EXPECT_TRUE(false);
GTEST_LOG_(INFO) << "ServiceTest-an exception occurred by GetSessionUserId.";
}
GTEST_LOG_(INFO) << "ServiceTest-end SUB_backup_sa_session_GetSessionUserId_0100";
}
} // namespace OHOS::FileManagement::Backup

View File

@ -86,6 +86,7 @@ public:
EXT_ABILITY_TIMEOUT = 0x5005,
EXT_FORBID_BACKUP_RESTORE = 0x5006,
EXT_BACKUP_PACKET_ERROR = 0x5007,
EXT_METHOD_NOT_EXIST = 0x5008,
};
enum BackupErrorCode {

View File

@ -76,10 +76,8 @@ std::map<std::string, BJsonUtil::BundleDetailInfo> BJsonUtil::BuildBundleInfos(
bundleDetailInfo.bundleIndex = index;
bundleNamesOnly.emplace_back(bundleNameSplit);
}
if (i < bundleInfos.size()) {
std::string bundleInfo = bundleInfos[i];
ParseBundleInfoJson(bundleInfo, bundleDetailInfo);
}
std::string bundleInfo = bundleInfos[i];
ParseBundleInfoJson(bundleInfo, bundleDetailInfo);
bundleDetailInfos.emplace_back(bundleDetailInfo);
bundleNameDetailMap[bundleDetailInfo.bundleName] = bundleDetailInfo;
}