diff options
author | Dante Russo <drusso@codeaurora.org> | 2020-01-30 19:12:40 -0800 |
---|---|---|
committer | Shinru Han <shinruhan@google.com> | 2020-02-20 12:17:56 +0800 |
commit | cd5ef1dfc22859bffaf84f2fb90fb89704406ced (patch) | |
tree | 2e827bc907cebcded0ea2c8e053539516ce5b0a1 /android | |
parent | 5b2a2ed82c174b46692a15536e6a19561e3b5f7c (diff) | |
download | gps-cd5ef1dfc22859bffaf84f2fb90fb89704406ced.tar.gz |
Only allow one extension obj of each type to be created
HAL did not expect multiple calls of GetExtensionsGnssX,
but if it happens, it causes a static callback function
in AGnss to get set to null when the first instance of
the obj gets deleted even if a second instance of AGnss
is created. This causes SUPL to fail because the static
callback function in AGnss is null and stops HAL from
being able to request SUPL into the Android Framework.
Bug: 149378039
Change-Id: Ib1ef7b06b7544e98f39b9af5295824ff6b84b398
CRs-fixed: 2614283
Test: test SUPL pass after system server restart
Diffstat (limited to 'android')
-rw-r--r-- | android/2.0/Gnss.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/android/2.0/Gnss.cpp b/android/2.0/Gnss.cpp index 6f1abf4..1b3ea1d 100644 --- a/android/2.0/Gnss.cpp +++ b/android/2.0/Gnss.cpp @@ -378,31 +378,41 @@ Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() { Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration() { ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); + if (mGnssConfig == nullptr) { + mGnssConfig = new GnssConfiguration(this); + } return mGnssConfig; } Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing() { ENTRY_LOG_CALLFLOW(); - mGnssGeofencingIface = new GnssGeofencing(); + if (mGnssGeofencingIface == nullptr) { + mGnssGeofencingIface = new GnssGeofencing(); + } return mGnssGeofencingIface; } Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching() { ENTRY_LOG_CALLFLOW(); - mGnssBatching = new GnssBatching(); + if (mGnssBatching == nullptr) { + mGnssBatching = new GnssBatching(); + } return mGnssBatching; } Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() { ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); + if (mGnssDebug == nullptr) { + mGnssDebug = new GnssDebug(this); + } return mGnssDebug; } Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() { ENTRY_LOG_CALLFLOW(); - mGnssRil = new AGnssRil(this); + if (mGnssRil == nullptr) { + mGnssRil = new AGnssRil(this); + } return mGnssRil; } @@ -589,17 +599,23 @@ Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) { Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() { ENTRY_LOG_CALLFLOW(); - mAGnssIface_2_0 = new AGnss(this); + if (mAGnssIface_2_0 == nullptr) { + mAGnssIface_2_0 = new AGnss(this); + } return mAGnssIface_2_0; } Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() { - mGnssRil = new AGnssRil(this); + if (mGnssRil == nullptr) { + mGnssRil = new AGnssRil(this); + } return mGnssRil; } Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); + if (mGnssConfig == nullptr) { + mGnssConfig = new GnssConfiguration(this); + } return mGnssConfig; } Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() { @@ -639,13 +655,17 @@ Return<bool> Gnss::injectBestLocation_2_0(const V2_0::GnssLocation& gnssLocation Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); + if (mGnssDebug == nullptr) { + mGnssDebug = new GnssDebug(this); + } return mGnssDebug; } Return<sp<V2_0::IGnssBatching>> Gnss::getExtensionGnssBatching_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssBatching = new GnssBatching(); + if (mGnssBatching == nullptr) { + mGnssBatching = new GnssBatching(); + } return mGnssBatching; } |