diff options
author | qctecmdr Service <qctecmdr@qualcomm.com> | 2019-03-22 17:36:07 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2019-03-22 17:36:07 -0700 |
commit | 01869b4004179870db2160ed41283dce7fbbdcde (patch) | |
tree | 706e104a74ab46130f83e92bab20d891a58e591c /android | |
parent | 52c9486628ae714bd9e9948503ef4f2e70df683f (diff) | |
parent | b046241ec2fdc9a48e99face1794046488a8cabe (diff) | |
download | gps-01869b4004179870db2160ed41283dce7fbbdcde.tar.gz |
Merge "Improved Location NI Privacy"
Diffstat (limited to 'android')
-rw-r--r-- | android/2.0/Gnss.cpp | 9 | ||||
-rw-r--r-- | android/2.0/Gnss.h | 2 | ||||
-rw-r--r-- | android/2.0/GnssConfiguration.cpp | 47 | ||||
-rw-r--r-- | android/visibility_control/1.0/GnssVisibilityControl.cpp | 77 | ||||
-rw-r--r-- | android/visibility_control/1.0/GnssVisibilityControl.h | 13 |
5 files changed, 111 insertions, 37 deletions
diff --git a/android/2.0/Gnss.cpp b/android/2.0/Gnss.cpp index 0c9519f..4033147 100644 --- a/android/2.0/Gnss.cpp +++ b/android/2.0/Gnss.cpp @@ -38,6 +38,8 @@ namespace gnss { namespace V2_0 { namespace implementation { +using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl; + static std::string getVersionString() { static std::string version; if (!version.empty()) @@ -239,6 +241,10 @@ Return<bool> Gnss::updateConfiguration(GnssConfig& gnssConfig) { mPendingConfig.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT; mPendingConfig.blacklistedSvIds = gnssConfig.blacklistedSvIds; } + if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT) { + mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT; + mPendingConfig.emergencyExtensionSeconds = gnssConfig.emergencyExtensionSeconds; + } } return true; } @@ -483,8 +489,9 @@ Return<sp<::android::hardware::gnss::measurement_corrections::V1_0::IMeasurement } Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>> Gnss::getExtensionVisibilityControl() { + ENTRY_LOG_CALLFLOW(); if (mVisibCtrl == nullptr) { - mVisibCtrl = new GnssVisibilityControl(); + mVisibCtrl = new GnssVisibilityControl(this); } return mVisibCtrl; } diff --git a/android/2.0/Gnss.h b/android/2.0/Gnss.h index b0a4f91..dfae2a3 100644 --- a/android/2.0/Gnss.h +++ b/android/2.0/Gnss.h @@ -55,7 +55,6 @@ using ::android::hardware::gnss::V1_0::GnssLocation; using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections; using ::android::hardware::gnss::measurement_corrections::V1_0::implementation::MeasurementCorrections; using ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl; -using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl; struct Gnss : public IGnss { Gnss(); @@ -131,7 +130,6 @@ struct Gnss : public IGnss { getExtensionVisibilityControl() override; - // These methods are not part of the IGnss base class. GnssAPIClient* getApi(); Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb); diff --git a/android/2.0/GnssConfiguration.cpp b/android/2.0/GnssConfiguration.cpp index 93a843a..eb98be1 100644 --- a/android/2.0/GnssConfiguration.cpp +++ b/android/2.0/GnssConfiguration.cpp @@ -175,35 +175,9 @@ Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) } Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) { - if (mGnss == nullptr) { - LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__); - return false; - } - - GnssConfig config; - memset(&config, 0, sizeof(GnssConfig)); - config.size = sizeof(GnssConfig); - config.flags = GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT; - switch (lock) { - case 0: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE; - break; - case 1: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO; - break; - case 2: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_NI; - break; - case 3: - config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO_AND_NI; - break; - default: - LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock); - return false; - break; - } - - return mGnss->updateConfiguration(config); + /* we no longer set GPS lock here, there is + visibility control for this */ + return true; } Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) { @@ -308,8 +282,19 @@ bool GnssConfiguration::setBlacklistedSource( // Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow. Return<bool> GnssConfiguration::setEsExtensionSec(uint32_t emergencyExtensionSeconds) { - //TODO emergencyExtensionSeconds is not supporded in GnssConfig yet - return false; + ENTRY_LOG_CALLFLOW(); + if (mGnss == nullptr) { + LOC_LOGe("mGnss is nullptr"); + return false; + } + + GnssConfig config; + memset(&config, 0, sizeof(GnssConfig)); + config.size = sizeof(GnssConfig); + config.flags = GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT; + config.emergencyExtensionSeconds = emergencyExtensionSeconds; + + return mGnss->updateConfiguration(config); } } // namespace implementation diff --git a/android/visibility_control/1.0/GnssVisibilityControl.cpp b/android/visibility_control/1.0/GnssVisibilityControl.cpp index 5608050..82e465c 100644 --- a/android/visibility_control/1.0/GnssVisibilityControl.cpp +++ b/android/visibility_control/1.0/GnssVisibilityControl.cpp @@ -48,11 +48,72 @@ using ::android::hardware::Return; using ::android::hardware::Void; using ::android::sp; -GnssVisibilityControl::GnssVisibilityControl() {} -GnssVisibilityControl::~GnssVisibilityControl() {} +static GnssVisibilityControl* spGnssVisibilityControl = nullptr; + +static void convertGnssNfwNotification(GnssNfwNotification& in, + IGnssVisibilityControlCallback::NfwNotification& out); + +GnssVisibilityControl::GnssVisibilityControl(Gnss* gnss) : mGnss(gnss) { + spGnssVisibilityControl = this; +} +GnssVisibilityControl::~GnssVisibilityControl() { + spGnssVisibilityControl = nullptr; +} + +void GnssVisibilityControl::nfwStatusCb(GnssNfwNotification notification) { + if (nullptr != spGnssVisibilityControl) { + spGnssVisibilityControl->statusCb(notification); + } +} + +static void convertGnssNfwNotification(GnssNfwNotification& in, + IGnssVisibilityControlCallback::NfwNotification& out) +{ + memset(&out, 0, sizeof(IGnssVisibilityControlCallback::NfwNotification)); + out.proxyAppPackageName = in.proxyAppPackageName; + out.protocolStack = (IGnssVisibilityControlCallback::NfwProtocolStack)in.protocolStack; + out.otherProtocolStackName = in.otherProtocolStackName; + out.requestor = (IGnssVisibilityControlCallback::NfwRequestor)in.requestor; + out.requestorId = in.requestorId; + out.responseType = (IGnssVisibilityControlCallback::NfwResponseType)in.responseType; + out.inEmergencyMode = in.inEmergencyMode; + out.isCachedLocation = in.isCachedLocation; +} + +void GnssVisibilityControl::statusCb(GnssNfwNotification notification) { + + if (mGnssVisibilityControlCbIface != nullptr) { + IGnssVisibilityControlCallback::NfwNotification nfwNotification; + + // Convert from one structure to another + convertGnssNfwNotification(notification, nfwNotification); + + auto r = mGnssVisibilityControlCbIface->nfwNotifyCb(nfwNotification); + if (!r.isOk()) { + LOC_LOGw("Error invoking NFW status cb %s", r.description().c_str()); + } + } else { + LOC_LOGw("setCallback has not been called yet"); + } +} // Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl follow. Return<bool> GnssVisibilityControl::enableNfwLocationAccess(const hidl_vec<::android::hardware::hidl_string>& proxyApps) { + + if (nullptr == mGnss || nullptr == mGnss->getGnssInterface()) { + LOC_LOGe("Null GNSS interface"); + return false; + } + + /* If the vector is empty we need to disable all NFW clients + If there is at least one app in the vector we need to enable + all NFW clients */ + if (0 == proxyApps.size()) { + mGnss->getGnssInterface()->enableNfwLocationAccess(false); + } else { + mGnss->getGnssInterface()->enableNfwLocationAccess(true); + } + return true; } /** @@ -61,6 +122,18 @@ Return<bool> GnssVisibilityControl::enableNfwLocationAccess(const hidl_vec<::and * @param callback Handle to IGnssVisibilityControlCallback interface. */ Return<bool> GnssVisibilityControl::setCallback(const ::android::sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControlCallback>& callback) { + + if (nullptr == mGnss || nullptr == mGnss->getGnssInterface()) { + LOC_LOGe("Null GNSS interface"); + return false; + } + mGnssVisibilityControlCbIface = callback; + + NfwCbInfo cbInfo = {}; + cbInfo.visibilityControlCb = (void*)nfwStatusCb; + + mGnss->getGnssInterface()->nfwInit(cbInfo); + return true; } diff --git a/android/visibility_control/1.0/GnssVisibilityControl.h b/android/visibility_control/1.0/GnssVisibilityControl.h index 3023347..4eaea51 100644 --- a/android/visibility_control/1.0/GnssVisibilityControl.h +++ b/android/visibility_control/1.0/GnssVisibilityControl.h @@ -34,7 +34,9 @@ #include <hidl/MQDescriptor.h> #include <hidl/Status.h> +#include <gps_extended_c.h> #include <location_interface.h> +#include "Gnss.h" namespace android { namespace hardware { @@ -50,9 +52,10 @@ using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::sp; +using ::android::hardware::gnss::V2_0::implementation::Gnss; struct GnssVisibilityControl : public IGnssVisibilityControl { - GnssVisibilityControl(); + GnssVisibilityControl(Gnss* gnss); ~GnssVisibilityControl(); // Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl follow. @@ -64,6 +67,14 @@ struct GnssVisibilityControl : public IGnssVisibilityControl { */ Return<bool> setCallback(const ::android::sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControlCallback>& callback) override; + void statusCb(GnssNfwNotification notification); + + /* Data call setup callback passed down to GNSS HAL implementation */ + static void nfwStatusCb(GnssNfwNotification notification); + +private: + Gnss* mGnss = nullptr; + sp<IGnssVisibilityControlCallback> mGnssVisibilityControlCbIface = nullptr; }; |