1 /*
2 * Copyright (c) 2021 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 "status_receiver_impl.h"
17
18 #include "app_log_wrapper.h"
19
20 namespace OHOS {
21 namespace AppExecFwk {
StatusReceiverImpl()22 StatusReceiverImpl::StatusReceiverImpl()
23 {
24 APP_LOGI("create status receiver instance");
25 }
26
~StatusReceiverImpl()27 StatusReceiverImpl::~StatusReceiverImpl()
28 {
29 APP_LOGI("destroy status receiver instance");
30 }
31
OnFinished(const int32_t resultCode,const std::string & resultMsg)32 void StatusReceiverImpl::OnFinished(const int32_t resultCode, const std::string &resultMsg)
33 {
34 APP_LOGI("on finished result is %{public}d, %{public}s", resultCode, resultMsg.c_str());
35 resultMsgSignal_.set_value(resultCode);
36 }
37
OnStatusNotify(const int progress)38 void StatusReceiverImpl::OnStatusNotify(const int progress)
39 {
40 APP_LOGI("on OnStatusNotify is %{public}d", progress);
41 }
42
GetResultCode() const43 int32_t StatusReceiverImpl::GetResultCode() const
44 {
45 auto future = resultMsgSignal_.get_future();
46 future.wait();
47 int32_t resultCode = future.get();
48
49 return resultCode;
50 }
51 } // namespace AppExecFwk
52 } // namespace OHOS