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 "entity_recognition_observer_proxy.h"
17 #include "errors.h"
18 #include "message_option.h"
19 #include "message_parcel.h"
20 #include "pasteboard_hilog.h"
21 #include "pasteboard_serv_ipc_interface_code.h"
22
23 using namespace OHOS::Security::PasteboardServ;
24 namespace OHOS {
25 namespace MiscServices {
EntityRecognitionObserverProxy(const sptr<IRemoteObject> & object)26 EntityRecognitionObserverProxy::EntityRecognitionObserverProxy(const sptr<IRemoteObject> &object)
27 : IRemoteProxy<IEntityRecognitionObserver>(object)
28 {
29 }
30
OnRecognitionEvent(EntityType entityType,std::string & entity)31 void EntityRecognitionObserverProxy::OnRecognitionEvent(EntityType entityType, std::string &entity)
32 {
33 MessageParcel data;
34 MessageParcel reply;
35 MessageOption option;
36 PASTEBOARD_CHECK_AND_RETURN_LOGE(
37 data.WriteInterfaceToken(GetDescriptor()), PASTEBOARD_MODULE_SERVICE, "write descriptor failed!");
38 PASTEBOARD_CHECK_AND_RETURN_LOGE(data.WriteString(entity), PASTEBOARD_MODULE_SERVICE, "Write entity failed");
39 uint32_t type = static_cast<uint32_t>(entityType);
40 PASTEBOARD_CHECK_AND_RETURN_LOGE(data.WriteUint32(type), PASTEBOARD_MODULE_SERVICE, "Write type failed");
41 int32_t ret =
42 Remote()->SendRequest(static_cast<int>(EntityObserverInterfaceCode::ON_RECOGNITION_EVENT), data, reply, option);
43 PASTEBOARD_CHECK_AND_RETURN_LOGE(
44 ret == ERR_OK, PASTEBOARD_MODULE_SERVICE, "SendRequest is failed, error code: %{public}d", ret);
45 return;
46 }
47 } // namespace MiscServices
48 } // namespace OHOS
49