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_stub.h"
17 #include "appexecfwk_errors.h"
18 #include "hilog_tag_wrapper.h"
19 #include "ipc_types.h"
20 #include "iremote_object.h"
21
22 namespace OHOS {
23 namespace AAFwk {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)24 int HiddenStartObserverStub::OnRemoteRequest(
25 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
26 {
27 std::u16string descriptor = HiddenStartObserverStub::GetDescriptor();
28 std::u16string remoteDescriptor = data.ReadInterfaceToken();
29 if (descriptor != remoteDescriptor) {
30 TAG_LOGE(AAFwkTag::ABILITYMGR, "local descriptor is not equal to remote.");
31 return ERR_INVALID_STATE;
32 }
33
34 if (static_cast<Message>(code) == Message::TRANSACT_ON_IS_HIDDEN_START) {
35 return HandleIsHiddenStart(data, reply);
36 }
37 TAG_LOGW(AAFwkTag::ABILITYMGR, "HiddenStartObserverStub::OnRemoteRequest, default case, need check");
38 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
39 }
40
HandleIsHiddenStart(MessageParcel & data,MessageParcel & reply)41 int32_t HiddenStartObserverStub::HandleIsHiddenStart(MessageParcel &data, MessageParcel &reply)
42 {
43 int32_t pid = data.ReadInt32();
44 bool result = IsHiddenStart(pid);
45 reply.WriteBool(result);
46 return NO_ERROR;
47 }
48 } // namespace AAFwk
49 } // namespace OHOS