• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "reverse_continuation_scheduler_replica_stub.h"
16 
17 #include "hilog_wrapper.h"
18 
19 namespace OHOS {
20 namespace AppExecFwk {
ReverseContinuationSchedulerReplicaStub()21 ReverseContinuationSchedulerReplicaStub::ReverseContinuationSchedulerReplicaStub()
22 {
23     continuationFuncMap_[static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::PASS_PRIMARY)] =
24         &ReverseContinuationSchedulerReplicaStub::PassPrimaryInner;
25     continuationFuncMap_[static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::REVERSE_CONTINUATION)] =
26         &ReverseContinuationSchedulerReplicaStub::ReverseContinuationInner;
27     continuationFuncMap_[static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::NOTIFY_REVERSE_RESULT)] =
28         &ReverseContinuationSchedulerReplicaStub::NotifyReverseResultInner;
29 }
~ReverseContinuationSchedulerReplicaStub()30 ReverseContinuationSchedulerReplicaStub::~ReverseContinuationSchedulerReplicaStub()
31 {
32     continuationFuncMap_.clear();
33 }
PassPrimaryInner(MessageParcel & data,MessageParcel & reply)34 int32_t ReverseContinuationSchedulerReplicaStub::PassPrimaryInner(MessageParcel &data, MessageParcel &reply)
35 {
36     HILOG_INFO("%{public}s called begin", __func__);
37     sptr<IRemoteObject> primary = nullptr;
38     if (data.ReadBool()) {
39         primary = data.ReadRemoteObject();
40     }
41     PassPrimary(primary);
42     HILOG_INFO("%{public}s called end", __func__);
43     return NO_ERROR;
44 }
ReverseContinuationInner(MessageParcel & data,MessageParcel & reply)45 int32_t ReverseContinuationSchedulerReplicaStub::ReverseContinuationInner(MessageParcel &data, MessageParcel &reply)
46 {
47     HILOG_INFO("%{public}s called begin", __func__);
48     ReverseContinuation();
49     HILOG_INFO("%{public}s called end", __func__);
50     return NO_ERROR;
51 }
NotifyReverseResultInner(MessageParcel & data,MessageParcel & reply)52 int32_t ReverseContinuationSchedulerReplicaStub::NotifyReverseResultInner(MessageParcel &data, MessageParcel &reply)
53 {
54     HILOG_INFO("%{public}s called begin", __func__);
55     int reverseResult = data.ReadInt32();
56     NotifyReverseResult(reverseResult);
57     HILOG_INFO("%{public}s called end", __func__);
58     return NO_ERROR;
59 }
60 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)61 int ReverseContinuationSchedulerReplicaStub::OnRemoteRequest(
62     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
63 {
64     HILOG_INFO("%{public}s called begin, code = %{public}u, flags= %{public}d.", __func__, code, option.GetFlags());
65     std::u16string remoteDescriptor = data.ReadInterfaceToken();
66     if (remoteDescriptor != ReverseContinuationSchedulerReplicaStub::GetDescriptor()) {
67         HILOG_ERROR("ReverseContinuationSchedulerReplicaStub::OnRemoteRequest token is invalid");
68         return ERR_INVALID_STATE;
69     }
70 
71     auto itFunc = continuationFuncMap_.find(code);
72     if (itFunc != continuationFuncMap_.end()) {
73         auto continuationFunc = itFunc->second;
74         if (continuationFunc != nullptr) {
75             return (this->*continuationFunc)(data, reply);
76         }
77     }
78     HILOG_INFO("%{public}s called end", __func__);
79     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
80 }
81 }  // namespace AppExecFwk
82 }  // namespace OHOS