• 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 "gnss_status_callback_taihe.h"
17 
18 #include "location_log.h"
19 #include "util.h"
20 
21 namespace OHOS {
22 namespace Location {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)23 int GnssStatusCallbackTaihe::OnRemoteRequest(
24     uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
25 {
26     LBSLOGD(GNSS_STATUS_CALLBACK, "GnssStatusCallbackTaihe::OnRemoteRequest!");
27     if (data.ReadInterfaceToken() != GetDescriptor()) {
28         LBSLOGE(GNSS_STATUS_CALLBACK, "invalid token.");
29         return -1;
30     }
31 
32     switch (code) {
33         case RECEIVE_STATUS_INFO_EVENT: {
34             std::unique_ptr<SatelliteStatus> statusInfo = SatelliteStatus::Unmarshalling(data);
35             OnStatusChange(statusInfo);
36             break;
37         }
38         default: {
39             IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40             break;
41         }
42     }
43     return 0;
44 }
45 
OnStatusChange(const std::unique_ptr<SatelliteStatus> & statusInfo)46 void GnssStatusCallbackTaihe::OnStatusChange(const std::unique_ptr<SatelliteStatus>& statusInfo)
47 {
48     LBSLOGI(LOCATING_DATA_CALLBACK, "LocatingRequiredDataCallbackTaihe::OnLocatingDataChange");
49     ::ohos::geoLocationManager::SatelliteStatusInfo satelliteStatusInfo =
50         ::ohos::geoLocationManager::SatelliteStatusInfo{};
51     Util::SatelliteStatusInfoToTaihe(satelliteStatusInfo, statusInfo);
52     if (callback_) {
53         (*callback_)(satelliteStatusInfo);
54     }
55 }
56 }  // namespace Location
57 }  // namespace OHOS
58