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 #pragma once
18 
19 #include <android/hardware/gnss/BnGnssCallback.h>
20 #include <utility>
21 #include "GnssCallbackEventQueue.h"
22 
23 /* Callback class for data & Event. */
24 class GnssCallbackAidl : public android::hardware::gnss::BnGnssCallback {
25   public:
GnssCallbackAidl()26     GnssCallbackAidl()
27         : capabilities_cbq_("capabilities"),
28           signal_type_capabilities_cbq_("signal_type_capabilities"),
29           info_cbq_("system_info"),
30           location_cbq_("location"),
31           sv_info_list_cbq_("sv_info"),
32           sv_info_list_timestamps_millis_cbq_("sv_info_timestamps"),
33           nmea_cbq_("nmea"){};
~GnssCallbackAidl()34     ~GnssCallbackAidl(){};
35 
36     android::binder::Status gnssSetCapabilitiesCb(const int capabilities) override;
37     android::binder::Status gnssSetSignalTypeCapabilitiesCb(
38             const std::vector<android::hardware::gnss::GnssSignalType>& signalTypes) override;
39     android::binder::Status gnssStatusCb(const GnssStatusValue status) override;
40     android::binder::Status gnssSvStatusCb(const std::vector<GnssSvInfo>& svInfoList) override;
41     android::binder::Status gnssLocationCb(
42             const android::hardware::gnss::GnssLocation& location) override;
43     android::binder::Status gnssNmeaCb(const int64_t timestamp, const std::string& nmea) override;
44     android::binder::Status gnssAcquireWakelockCb() override;
45     android::binder::Status gnssReleaseWakelockCb() override;
46     android::binder::Status gnssSetSystemInfoCb(const GnssSystemInfo& info) override;
47     android::binder::Status gnssRequestTimeCb() override;
48     android::binder::Status gnssRequestLocationCb(const bool independentFromGnss,
49                                                   const bool isUserEmergency) override;
50 
51     int last_capabilities_;
52     std::vector<android::hardware::gnss::GnssSignalType> last_signal_type_capabilities;
53     android::hardware::gnss::IGnssCallback::GnssSystemInfo last_info_;
54     android::hardware::gnss::GnssLocation last_location_;
55 
56     android::hardware::gnss::common::GnssCallbackEventQueue<int> capabilities_cbq_;
57     android::hardware::gnss::common::GnssCallbackEventQueue<
58             std::vector<android::hardware::gnss::GnssSignalType>>
59             signal_type_capabilities_cbq_;
60     android::hardware::gnss::common::GnssCallbackEventQueue<
61             android::hardware::gnss::IGnssCallback::GnssSystemInfo>
62             info_cbq_;
63     android::hardware::gnss::common::GnssCallbackEventQueue<android::hardware::gnss::GnssLocation>
64             location_cbq_;
65     android::hardware::gnss::common::GnssCallbackEventQueue<
66             std::vector<android::hardware::gnss::IGnssCallback::GnssSvInfo>>
67             sv_info_list_cbq_;
68     android::hardware::gnss::common::GnssCallbackEventQueue<long>
69             sv_info_list_timestamps_millis_cbq_;
70     android::hardware::gnss::common::GnssCallbackEventQueue<std::pair<int64_t, std::string>>
71             nmea_cbq_;
72 };