1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define LOG_TAG "GnssCallbackAidl"
18
19 #include "GnssCallbackAidl.h"
20 #include <log/log.h>
21 #include <utils/SystemClock.h>
22
23 using android::binder::Status;
24 using android::hardware::gnss::GnssLocation;
25 using GnssSvInfo = android::hardware::gnss::IGnssCallback::GnssSvInfo;
26 using GnssSystemInfo = android::hardware::gnss::IGnssCallback::GnssSystemInfo;
27 using GnssSignalType = android::hardware::gnss::GnssSignalType;
28
gnssSetCapabilitiesCb(const int capabilities)29 Status GnssCallbackAidl::gnssSetCapabilitiesCb(const int capabilities) {
30 ALOGI("Capabilities received %#08x", capabilities);
31 capabilities_cbq_.store(capabilities);
32 return Status::ok();
33 }
34
gnssSetSignalTypeCapabilitiesCb(const std::vector<GnssSignalType> & signalTypes)35 Status GnssCallbackAidl::gnssSetSignalTypeCapabilitiesCb(
36 const std::vector<GnssSignalType>& signalTypes) {
37 ALOGI("SignalTypeCapabilities received");
38 std::ostringstream ss;
39 for (auto& signalType : signalTypes) {
40 ss << "[constellation=" << (int)signalType.constellation
41 << ", carrierFrequencyHz=" << signalType.carrierFrequencyHz
42 << ", codeType=" << signalType.codeType << "], ";
43 }
44 ALOGI("%s", ss.str().c_str());
45 signal_type_capabilities_cbq_.store(signalTypes);
46 return Status::ok();
47 }
48
gnssStatusCb(const GnssStatusValue)49 Status GnssCallbackAidl::gnssStatusCb(const GnssStatusValue /* status */) {
50 ALOGI("gnssStatusCb");
51 return Status::ok();
52 }
53
gnssSvStatusCb(const std::vector<GnssSvInfo> & svInfoList)54 Status GnssCallbackAidl::gnssSvStatusCb(const std::vector<GnssSvInfo>& svInfoList) {
55 ALOGI("gnssSvStatusCb. Size = %d", (int)svInfoList.size());
56 sv_info_list_cbq_.store(svInfoList);
57 sv_info_list_timestamps_millis_cbq_.store(::android::elapsedRealtime());
58 return Status::ok();
59 }
60
gnssLocationCb(const GnssLocation & location)61 Status GnssCallbackAidl::gnssLocationCb(const GnssLocation& location) {
62 ALOGI("Location received");
63 location_cbq_.store(location);
64 return Status::ok();
65 }
66
gnssNmeaCb(const int64_t timestamp,const std::string & nmea)67 Status GnssCallbackAidl::gnssNmeaCb(const int64_t timestamp, const std::string& nmea) {
68 nmea_cbq_.store(std::make_pair(timestamp, nmea));
69 return Status::ok();
70 }
71
gnssAcquireWakelockCb()72 Status GnssCallbackAidl::gnssAcquireWakelockCb() {
73 return Status::ok();
74 }
75
gnssReleaseWakelockCb()76 Status GnssCallbackAidl::gnssReleaseWakelockCb() {
77 return Status::ok();
78 }
79
gnssSetSystemInfoCb(const GnssSystemInfo & info)80 Status GnssCallbackAidl::gnssSetSystemInfoCb(const GnssSystemInfo& info) {
81 ALOGI("gnssSetSystemInfoCb, year=%d, name=%s", info.yearOfHw, info.name.c_str());
82 info_cbq_.store(info);
83 return Status::ok();
84 }
85
gnssRequestTimeCb()86 Status GnssCallbackAidl::gnssRequestTimeCb() {
87 return Status::ok();
88 }
89
gnssRequestLocationCb(const bool,const bool)90 Status GnssCallbackAidl::gnssRequestLocationCb(const bool /* independentFromGnss */,
91 const bool /* isUserEmergency */) {
92 return Status::ok();
93 }
94