• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "query_erms_observer_stub.h"
17 
18 #include "hilog_tag_wrapper.h"
19 #include "ipc_types.h"
20 #include "iremote_object.h"
21 
22 namespace OHOS {
23 namespace AbilityRuntime {
QueryERMSObserverStub()24 QueryERMSObserverStub::QueryERMSObserverStub()
25 {}
26 
~QueryERMSObserverStub()27 QueryERMSObserverStub::~QueryERMSObserverStub()
28 {}
29 
OnQueryFinishedInner(MessageParcel & data,MessageParcel & reply)30 int QueryERMSObserverStub::OnQueryFinishedInner(MessageParcel &data, MessageParcel &reply)
31 {
32     std::string appId = data.ReadString();
33     std::string startTime = data.ReadString();
34     AtomicServiceStartupRule rule;
35     rule.isOpenAllowed = data.ReadBool();
36     rule.isEmbeddedAllowed = data.ReadBool();
37     int32_t resultCode = data.ReadInt32();
38 
39     OnQueryFinished(appId, startTime, rule, resultCode);
40     return NO_ERROR;
41 }
42 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)43 int QueryERMSObserverStub::OnRemoteRequest(
44     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
45 {
46     std::u16string descriptor = QueryERMSObserverStub::GetDescriptor();
47     std::u16string remoteDescriptor = data.ReadInterfaceToken();
48     if (descriptor != remoteDescriptor) {
49         TAG_LOGE(AAFwkTag::QUERY_ERMS, "descriptor is not equal remote");
50         return ERR_INVALID_STATE;
51     }
52 
53     if (code == static_cast<uint32_t>(IQueryERMSObserver::ON_QUERY_FINISHED)) {
54         return OnQueryFinishedInner(data, reply);
55     }
56 
57     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
58 }
59 } // namespace AbilityRuntime
60 } // namespace OHOS