Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (c) 2017, The Linux Foundation. All rights reserved.
      3  * Not a Contribution
      4  */
      5 /*
      6  * Copyright (C) 2016 The Android Open Source Project
      7  *
      8  * Licensed under the Apache License, Version 2.0 (the "License");
      9  * you may not use this file except in compliance with the License.
     10  * You may obtain a copy of the License at
     11  *
     12  *      http://www.apache.org/licenses/LICENSE-2.0
     13  *
     14  * Unless required by applicable law or agreed to in writing, software
     15  * distributed under the License is distributed on an "AS IS" BASIS,
     16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     17  * See the License for the specific language governing permissions and
     18  * limitations under the License.
     19  */
     20 
     21 #ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
     22 #define ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
     23 
     24 #include <AGnss.h>
     25 #include <AGnssRil.h>
     26 #include <GnssBatching.h>
     27 #include <GnssConfiguration.h>
     28 #include <GnssGeofencing.h>
     29 #include <GnssMeasurement.h>
     30 #include <GnssNi.h>
     31 #include <GnssDebug.h>
     32 
     33 #include <android/hardware/gnss/1.0/IGnss.h>
     34 #include <hidl/Status.h>
     35 
     36 #include <GnssAPIClient.h>
     37 #include <location_interface.h>
     38 
     39 namespace android {
     40 namespace hardware {
     41 namespace gnss {
     42 namespace V1_0 {
     43 namespace implementation {
     44 
     45 using ::android::hardware::Return;
     46 using ::android::hardware::Void;
     47 using ::android::hardware::hidl_vec;
     48 using ::android::hardware::hidl_string;
     49 using ::android::sp;
     50 
     51 struct Gnss : public IGnss {
     52     Gnss();
     53     ~Gnss();
     54 
     55     // registerAsService will call interfaceChain to determine the version of service
     56     /* comment this out until we know really how to manipulate hidl version
     57     using interfaceChain_cb = std::function<
     58         void(const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& descriptors)>;
     59     virtual ::android::hardware::Return<void> interfaceChain(interfaceChain_cb _hidl_cb) override {
     60         _hidl_cb({
     61                 "android.hardware.gnss (at) 1.1::IGnss",
     62                 ::android::hidl::base::V1_0::IBase::descriptor,
     63                 });
     64         return ::android::hardware::Void();
     65     }
     66     */
     67 
     68     /*
     69      * Methods from ::android::hardware::gnss::V1_0::IGnss follow.
     70      * These declarations were generated from Gnss.hal.
     71      */
     72     Return<bool> setCallback(const sp<IGnssCallback>& callback)  override;
     73     Return<bool> start()  override;
     74     Return<bool> stop()  override;
     75     Return<void> cleanup()  override;
     76     Return<bool> injectLocation(double latitudeDegrees,
     77                                 double longitudeDegrees,
     78                                 float accuracyMeters)  override;
     79     Return<bool> injectTime(int64_t timeMs,
     80                             int64_t timeReferenceMs,
     81                             int32_t uncertaintyMs) override;
     82     Return<void> deleteAidingData(IGnss::GnssAidingData aidingDataFlags)  override;
     83     Return<bool> setPositionMode(IGnss::GnssPositionMode mode,
     84                                  IGnss::GnssPositionRecurrence recurrence,
     85                                  uint32_t minIntervalMs,
     86                                  uint32_t preferredAccuracyMeters,
     87                                  uint32_t preferredTimeMs)  override;
     88     Return<sp<IAGnss>> getExtensionAGnss() override;
     89     Return<sp<IGnssNi>> getExtensionGnssNi() override;
     90     Return<sp<IGnssMeasurement>> getExtensionGnssMeasurement() override;
     91     Return<sp<IGnssConfiguration>> getExtensionGnssConfiguration() override;
     92     Return<sp<IGnssGeofencing>> getExtensionGnssGeofencing() override;
     93     Return<sp<IGnssBatching>> getExtensionGnssBatching() override;
     94 
     95     Return<sp<IAGnssRil>> getExtensionAGnssRil() override;
     96 
     97     inline Return<sp<IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
     98         return nullptr;
     99     }
    100 
    101     inline Return<sp<IGnssXtra>> getExtensionXtra() override {
    102         return nullptr;
    103     }
    104 
    105     Return<sp<IGnssDebug>> getExtensionGnssDebug() override;
    106 
    107     // These methods are not part of the IGnss base class.
    108     GnssAPIClient* getApi();
    109     Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
    110     Return<bool> updateConfiguration(GnssConfig& gnssConfig);
    111     GnssInterface* getGnssInterface();
    112 
    113  private:
    114     struct GnssDeathRecipient : hidl_death_recipient {
    115         GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
    116         }
    117         ~GnssDeathRecipient() = default;
    118         virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
    119         sp<Gnss> mGnss;
    120     };
    121 
    122  private:
    123     sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
    124 
    125     sp<AGnss> mAGnssIface = nullptr;
    126     sp<GnssNi> mGnssNi = nullptr;
    127     sp<GnssMeasurement> mGnssMeasurement = nullptr;
    128     sp<GnssConfiguration> mGnssConfig = nullptr;
    129     sp<GnssGeofencing> mGnssGeofencingIface = nullptr;
    130     sp<GnssBatching> mGnssBatching = nullptr;
    131     sp<IGnssDebug> mGnssDebug = nullptr;
    132     sp<AGnssRil> mGnssRil = nullptr;
    133 
    134     GnssAPIClient* mApi = nullptr;
    135     sp<IGnssCallback> mGnssCbIface = nullptr;
    136     sp<IGnssNiCallback> mGnssNiCbIface = nullptr;
    137     GnssConfig mPendingConfig;
    138     GnssInterface* mGnssInterface = nullptr;
    139 };
    140 
    141 extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
    142 
    143 }  // namespace implementation
    144 }  // namespace V1_0
    145 }  // namespace gnss
    146 }  // namespace hardware
    147 }  // namespace android
    148 
    149 #endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
    150