• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_proxy.h"
17 
18 #include "ability_manager_errors.h"
19 #include "hilog_tag_wrapper.h"
20 
21 namespace OHOS {
22 namespace AbilityRuntime {
OnCheckStarting(const std::string & params,Rule & rule)23 int32_t SAInterceptorProxy::OnCheckStarting(const std::string &params, Rule &rule)
24 {
25     MessageParcel data;
26     MessageParcel reply;
27     MessageOption option;
28     if (!data.WriteInterfaceToken(SAInterceptorProxy::GetDescriptor())) {
29         TAG_LOGE(AAFwkTag::ABILITYMGR, "SAInterceptorProxy Write interface token failed.");
30         return AAFwk::ERR_WRITE_INTERFACE_TOKEN_FAILED;
31     }
32     if (!data.WriteString(params)) {
33         TAG_LOGE(AAFwkTag::ABILITYMGR, "OnCheckStarting Write params failed");
34         return AAFwk::ERR_SA_INTERCEPTOR_WRITE_PARAMS_FAILED;
35     }
36     sptr<IRemoteObject> remote = Remote();
37     if (remote == nullptr) {
38         TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote object");
39         return AAFwk::ERR_NULL_IPC_REMOTE;
40     }
41     int result = remote->SendRequest(static_cast<int32_t>(ISAInterceptor::SAInterceptorCmd::ON_DO_CHECK_STARTING),
42         data, reply, option);
43     if (result != NO_ERROR) {
44         TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, error: %{public}d", result);
45         return AAFwk::ERR_NULL_IPC_SEND_REQUST_FAILED;
46     }
47 
48     if (!reply.ReadInt32(result)) {
49         TAG_LOGE(AAFwkTag::ABILITYMGR, "read result failed");
50         return AAFwk::ERR_SA_INTERCEPTOR_READ_PARAMS_FAILED;
51     }
52 
53     std::unique_ptr<Rule> value(reply.ReadParcelable<Rule>());
54     if (value != nullptr) {
55         rule = *value;
56     }
57     return result;
58 }
59 }  // namespace AbilityRuntime
60 }  // namespace OHOS
61