1 /*
2  * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "module_notify/notify_work_service.h"
17 
18 #include "common_event_data.h"
19 #include "common_event_manager.h"
20 #include "common_event_support.h"
21 #include "filemgmt_libhilog.h"
22 #include "int_wrapper.h"
23 #include "string_wrapper.h"
24 #include "want.h"
25 #include "want_params.h"
26 
27 namespace OHOS::FileManagement::Backup {
NotifyWorkService()28 NotifyWorkService::NotifyWorkService() {}
~NotifyWorkService()29 NotifyWorkService::~NotifyWorkService() {}
30 
NotifyBundleDetail(BJsonUtil::BundleDetailInfo bundleDetailInfo)31 bool NotifyWorkService::NotifyBundleDetail(BJsonUtil::BundleDetailInfo bundleDetailInfo)
32 {
33     AAFwk::Want want;
34     std::string bundleName = bundleDetailInfo.bundleName;
35     std::string bundleDetail = bundleDetailInfo.detail;
36     HILOGI("Start publish event, bundleName is: %{public}s, detail:%{public}s", bundleName.c_str(),
37         bundleDetail.c_str());
38     want.SetBundle(bundleName);
39     want.SetParam("bundleName", bundleName);
40     want.SetParam("userId", bundleDetailInfo.userId);
41     want.SetParam("index", bundleDetailInfo.bundleIndex);
42     want.SetParam("detail", bundleDetail);
43     want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_RESTORE_START);
44     EventFwk::CommonEventData commonData {want};
45     HILOGI("End publish event, bundleName is: %{public}s", bundleName.c_str());
46     return EventFwk::CommonEventManager::PublishCommonEvent(commonData);
47 }
48 }