From cd5ef1dfc22859bffaf84f2fb90fb89704406ced Mon Sep 17 00:00:00 2001 From: Dante Russo Date: Thu, 30 Jan 2020 19:12:40 -0800 Subject: 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 --- android/2.0/Gnss.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 file 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> Gnss::getExtensionGnssMeasurement() { Return> Gnss::getExtensionGnssConfiguration() { ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); + if (mGnssConfig == nullptr) { + mGnssConfig = new GnssConfiguration(this); + } return mGnssConfig; } Return> Gnss::getExtensionGnssGeofencing() { ENTRY_LOG_CALLFLOW(); - mGnssGeofencingIface = new GnssGeofencing(); + if (mGnssGeofencingIface == nullptr) { + mGnssGeofencingIface = new GnssGeofencing(); + } return mGnssGeofencingIface; } Return> Gnss::getExtensionGnssBatching() { ENTRY_LOG_CALLFLOW(); - mGnssBatching = new GnssBatching(); + if (mGnssBatching == nullptr) { + mGnssBatching = new GnssBatching(); + } return mGnssBatching; } Return> Gnss::getExtensionGnssDebug() { ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); + if (mGnssDebug == nullptr) { + mGnssDebug = new GnssDebug(this); + } return mGnssDebug; } Return> Gnss::getExtensionAGnssRil() { ENTRY_LOG_CALLFLOW(); - mGnssRil = new AGnssRil(this); + if (mGnssRil == nullptr) { + mGnssRil = new AGnssRil(this); + } return mGnssRil; } @@ -589,17 +599,23 @@ Return Gnss::setCallback_2_0(const sp& callback) { Return> 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> Gnss::getExtensionAGnssRil_2_0() { - mGnssRil = new AGnssRil(this); + if (mGnssRil == nullptr) { + mGnssRil = new AGnssRil(this); + } return mGnssRil; } Return> Gnss::getExtensionGnssConfiguration_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssConfig = new GnssConfiguration(this); + if (mGnssConfig == nullptr) { + mGnssConfig = new GnssConfiguration(this); + } return mGnssConfig; } Return> Gnss::getExtensionGnssMeasurement_2_0() { @@ -639,13 +655,17 @@ Return Gnss::injectBestLocation_2_0(const V2_0::GnssLocation& gnssLocation Return> Gnss::getExtensionGnssDebug_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssDebug = new GnssDebug(this); + if (mGnssDebug == nullptr) { + mGnssDebug = new GnssDebug(this); + } return mGnssDebug; } Return> Gnss::getExtensionGnssBatching_2_0() { ENTRY_LOG_CALLFLOW(); - mGnssBatching = new GnssBatching(); + if (mGnssBatching == nullptr) { + mGnssBatching = new GnssBatching(); + } return mGnssBatching; } -- cgit v1.2.3