1 /*
2 * Copyright (C) 2022 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 "nmea_message_callback_proxy.h"
17
18 #include "string_ex.h"
19
20 #include "message_parcel.h"
21 #include "message_option.h"
22
23 #include "location_log.h"
24
25 namespace OHOS {
26 namespace Location {
NmeaMessageCallbackProxy(const sptr<IRemoteObject> & impl)27 NmeaMessageCallbackProxy::NmeaMessageCallbackProxy(const sptr<IRemoteObject> &impl)
28 : IRemoteProxy<INmeaMessageCallback>(impl)
29 {
30 }
31
OnMessageChange(int64_t timestamp,const std::string msg)32 void NmeaMessageCallbackProxy::OnMessageChange(int64_t timestamp, const std::string msg)
33 {
34 MessageParcel data;
35 MessageParcel reply;
36 if (!data.WriteInterfaceToken(GetDescriptor())) {
37 return;
38 }
39 data.WriteInt64(timestamp);
40 data.WriteString16(Str8ToStr16(msg));
41 MessageOption option = { MessageOption::TF_ASYNC };
42 int error = Remote()->SendRequest(RECEIVE_NMEA_MESSAGE_EVENT, data, reply, option);
43 if (error != ERR_OK) {
44 LBSLOGI(NMEA_MESSAGE_CALLBACK,
45 "NmeaMessageCallbackProxy::OnStatusChange Transact ErrCode = %{public}d", error);
46 }
47 }
48 } // namespace Location
49 } // namespace OHOS