1 /*
2 * Copyright (c) 2022 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 "app_log_tag_wrapper.h"
17 #include "service_center_status_callback.h"
18
19 namespace OHOS {
20 namespace AppExecFwk {
ServiceCenterStatusCallback(const std::weak_ptr<BundleConnectAbilityMgr> & server)21 ServiceCenterStatusCallback::ServiceCenterStatusCallback(const std::weak_ptr<BundleConnectAbilityMgr> &server)
22 : server_(server)
23 {
24 LOG_I(BMS_TAG_DEFAULT, "ServiceCenterStatusCallback");
25 }
26
OnInstallFinished(std::string installResult)27 int32_t ServiceCenterStatusCallback::OnInstallFinished(std::string installResult)
28 {
29 LOG_I(BMS_TAG_DEFAULT, "OnInstallFinished");
30 auto server = server_.lock();
31 if (server == nullptr) {
32 LOG_E(BMS_TAG_DEFAULT, "pointer is nullptr");
33 return ERR_INVALID_VALUE;
34 }
35 server->OnServiceCenterCall(installResult);
36 return ERR_OK;
37 }
38
OnDelayedHeartbeat(std::string installResult)39 int32_t ServiceCenterStatusCallback::OnDelayedHeartbeat(std::string installResult)
40 {
41 LOG_I(BMS_TAG_DEFAULT, "OnDelayedHeartbeat");
42 auto server = server_.lock();
43 if (server == nullptr) {
44 LOG_E(BMS_TAG_DEFAULT, "pointer is nullptr");
45 return ERR_INVALID_VALUE;
46 }
47 server->OnDelayedHeartbeat(installResult);
48 return ERR_OK;
49 }
50
OnServiceCenterReceived(std::string installResultStr)51 int32_t ServiceCenterStatusCallback::OnServiceCenterReceived(std::string installResultStr)
52 {
53 LOG_I(BMS_TAG_DEFAULT, "OnDelayedHeartbeat");
54 auto server = server_.lock();
55 if (server == nullptr) {
56 LOG_E(BMS_TAG_DEFAULT, "pointer is nullptr");
57 return ERR_INVALID_VALUE;
58 }
59 server->OnServiceCenterReceived(installResultStr);
60 return ERR_OK;
61 }
62 } // namespace AppExecFwk
63 } // namespace OHOS
64