1 /*
2 * Copyright (c) 2025 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 "sa_interceptor_stub.h"
17
18 #include "ability_manager_errors.h"
19 #include "hilog_tag_wrapper.h"
20 #include "ipc_types.h"
21 #include "iremote_object.h"
22
23 namespace OHOS {
24 namespace AbilityRuntime {
SAInterceptorStub()25 SAInterceptorStub::SAInterceptorStub() {}
26
~SAInterceptorStub()27 SAInterceptorStub::~SAInterceptorStub() {}
28
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)29 int32_t SAInterceptorStub::OnRemoteRequest(
30 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
31 {
32 TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
33 std::u16string descriptor = SAInterceptorStub::GetDescriptor();
34 std::u16string remoteDescriptor = data.ReadInterfaceToken();
35 if (descriptor != remoteDescriptor) {
36 TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid descriptor");
37 return AAFwk::ERR_SA_INTERCEPTOR_DESCRIPTOR_MISMATCH;
38 }
39
40 if (code == static_cast<uint32_t>(ISAInterceptor::SAInterceptorCmd::ON_DO_CHECK_STARTING)) {
41 return HandleOnCheckStarting(data, reply);
42 }
43 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
44 }
45
HandleOnCheckStarting(MessageParcel & data,MessageParcel & reply)46 int32_t SAInterceptorStub::HandleOnCheckStarting(MessageParcel &data, MessageParcel &reply)
47 {
48 std::string params = data.ReadString();
49 Rule rule;
50 reply.WriteInt32(OnCheckStarting(params, rule));
51
52 if (!reply.WriteParcelable(&rule)) {
53 TAG_LOGE(AAFwkTag::ABILITYMGR, "failed write rule.");
54 return AAFwk::ERR_SA_INTERCEPTOR_WRITE_RULE_FAILED;
55 }
56 return NO_ERROR;
57 }
58 } // namespace AbilityRuntime
59 } // namespace OHOS