Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 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 | |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 17 | #define LOG_TAG "GnssCallbackAidl" |
| 18 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 19 | #include "GnssCallbackAidl.h" |
| 20 | #include <log/log.h> |
Zhanghao | d32f378 | 2023-03-21 05:41:55 +0000 | [diff] [blame] | 21 | #include <utils/SystemClock.h> |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 22 | |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 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; |
Yu-Han Yang | d237744 | 2022-10-12 23:54:51 +0000 | [diff] [blame] | 27 | using GnssSignalType = android::hardware::gnss::GnssSignalType; |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 28 | |
| 29 | Status GnssCallbackAidl::gnssSetCapabilitiesCb(const int capabilities) { |
| 30 | ALOGI("Capabilities received %#08x", capabilities); |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 31 | capabilities_cbq_.store(capabilities); |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 32 | return Status::ok(); |
| 33 | } |
| 34 | |
Yu-Han Yang | d237744 | 2022-10-12 23:54:51 +0000 | [diff] [blame] | 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 | |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 49 | Status GnssCallbackAidl::gnssStatusCb(const GnssStatusValue /* status */) { |
Yu-Han Yang | 19a32b6 | 2022-04-27 09:57:01 -0700 | [diff] [blame] | 50 | ALOGI("gnssStatusCb"); |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 51 | return Status::ok(); |
| 52 | } |
| 53 | |
| 54 | Status GnssCallbackAidl::gnssSvStatusCb(const std::vector<GnssSvInfo>& svInfoList) { |
| 55 | ALOGI("gnssSvStatusCb. Size = %d", (int)svInfoList.size()); |
| 56 | sv_info_list_cbq_.store(svInfoList); |
Zhanghao | d32f378 | 2023-03-21 05:41:55 +0000 | [diff] [blame] | 57 | sv_info_list_timestamps_millis_cbq_.store(::android::elapsedRealtime()); |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 58 | return Status::ok(); |
| 59 | } |
| 60 | |
| 61 | Status GnssCallbackAidl::gnssLocationCb(const GnssLocation& location) { |
| 62 | ALOGI("Location received"); |
| 63 | location_cbq_.store(location); |
| 64 | return Status::ok(); |
| 65 | } |
| 66 | |
Yu-Han Yang | 19a32b6 | 2022-04-27 09:57:01 -0700 | [diff] [blame] | 67 | Status GnssCallbackAidl::gnssNmeaCb(const int64_t timestamp, const std::string& nmea) { |
| 68 | nmea_cbq_.store(std::make_pair(timestamp, nmea)); |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 69 | return Status::ok(); |
| 70 | } |
| 71 | |
| 72 | Status GnssCallbackAidl::gnssAcquireWakelockCb() { |
| 73 | return Status::ok(); |
| 74 | } |
| 75 | |
| 76 | Status GnssCallbackAidl::gnssReleaseWakelockCb() { |
| 77 | return Status::ok(); |
| 78 | } |
| 79 | |
| 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 | |
| 86 | Status GnssCallbackAidl::gnssRequestTimeCb() { |
| 87 | return Status::ok(); |
| 88 | } |
| 89 | |
| 90 | Status GnssCallbackAidl::gnssRequestLocationCb(const bool /* independentFromGnss */, |
| 91 | const bool /* isUserEmergency */) { |
| 92 | return Status::ok(); |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 93 | } |