• 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 "hidden_start_observer_proxy.h"
17 
18 #include "hilog_tag_wrapper.h"
19 #include "ipc_types.h"
20 
21 
22 namespace OHOS {
23 namespace AAFwk {
HiddenStartObserverProxy(const sptr<IRemoteObject> & impl)24 HiddenStartObserverProxy::HiddenStartObserverProxy(
25     const sptr<IRemoteObject> &impl) : IRemoteProxy<IHiddenStartObserver>(impl)
26 {}
27 
WriteInterfaceToken(MessageParcel & data)28 bool HiddenStartObserverProxy::WriteInterfaceToken(MessageParcel &data)
29 {
30     if (!data.WriteInterfaceToken(HiddenStartObserverProxy::GetDescriptor())) {
31         TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed");
32         return false;
33     }
34     return true;
35 }
36 
IsHiddenStart(int32_t pid)37 bool HiddenStartObserverProxy::IsHiddenStart(int32_t pid)
38 {
39     MessageParcel data;
40     MessageParcel reply;
41     MessageOption option(MessageOption::TF_SYNC);
42     if (!WriteInterfaceToken(data)) {
43         TAG_LOGE(AAFwkTag::ABILITYMGR, "WriteInterfaceToken failed");
44         return false;
45     }
46     data.WriteInt32(pid);
47     int32_t ret = SendTransactCmd(
48         static_cast<uint32_t>(IHiddenStartObserver::Message::TRANSACT_ON_IS_HIDDEN_START),
49         data, reply, option);
50     if (ret != NO_ERROR) {
51         TAG_LOGW(AAFwkTag::ABILITYMGR, "SendRequest is failed, error code: %{public}d.", ret);
52         return false;
53     }
54     return reply.ReadBool();
55 }
56 
SendTransactCmd(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)57 int32_t HiddenStartObserverProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
58     MessageParcel &reply, MessageOption &option)
59 {
60     sptr<IRemoteObject> remote = Remote();
61     if (remote == nullptr) {
62         TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote is nullptr.");
63         return ERR_NULL_OBJECT;
64     }
65 
66     return remote->SendRequest(code, data, reply, option);
67 }
68 } // namespace AAFwk
69 } // namespace OHOS