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 "completed_dispatcher.h"
17
18 namespace OHOS::AbilityRuntime::WantAgent {
CompletedDispatcher(const std::shared_ptr<PendingWant> & pendingWant,const std::shared_ptr<CompletedCallback> & callback,const std::shared_ptr<AppExecFwk::EventHandler> & handler)19 CompletedDispatcher::CompletedDispatcher(const std::shared_ptr<PendingWant> &pendingWant,
20 const std::shared_ptr<CompletedCallback> &callback, const std::shared_ptr<AppExecFwk::EventHandler> &handler)
21 : pendingWant_(pendingWant), callback_(callback), handler_(handler)
22 {}
23
Send(const int32_t resultCode)24 void CompletedDispatcher::Send(const int32_t resultCode)
25 {}
26
PerformReceive(const AAFwk::Want & want,int resultCode,const std::string & data,const AAFwk::WantParams & extras,bool serialized,bool sticky,int sendingUser)27 void CompletedDispatcher::PerformReceive(const AAFwk::Want &want, int resultCode, const std::string &data,
28 const AAFwk::WantParams &extras, bool serialized, bool sticky, int sendingUser)
29 {
30 want_ = want;
31 resultCode_ = resultCode;
32 resultData_ = data;
33 resultExtras_ = extras;
34 if (handler_ == nullptr) {
35 Run();
36 }
37 }
38
Run()39 void CompletedDispatcher::Run()
40 {
41 if (callback_ != nullptr) {
42 callback_->OnSendFinished(want_, resultCode_, resultData_, resultExtras_);
43 }
44 }
45 } // namespace OHOS::AbilityRuntime::WantAgent
46