diff options
author | Ikjoon Jang <ikjn@google.com> | 2023-12-14 08:32:38 +0000 |
---|---|---|
committer | Ikjoon Jang <ikjn@google.com> | 2023-12-14 12:58:38 +0000 |
commit | e01837e90e4cd205a0a68aefee8d03f1301be3c2 (patch) | |
tree | 32f2e16e03e765029575e13e4cfd9b8d97a9ec4f | |
parent | 663a9e17d7f44c906d5f30a3ab3030c4fbefc368 (diff) | |
download | uwb-e01837e90e4cd205a0a68aefee8d03f1301be3c2.tar.gz |
config: reset configuration parameters on hal_close
Loaded configuration files should be invalidated on hal_close().
Bug: 316274283
Test: `cmd uwb disable-uwb; cmd uwb enable-uwb` and check logcat
Change-Id: Iab5a31c712d54c4374fc10e6ba1ca48b0cc2984f
-rw-r--r-- | halimpl/hal/phNxpUciHal.cc | 2 | ||||
-rw-r--r-- | halimpl/utils/phNxpConfig.cc | 19 | ||||
-rw-r--r-- | halimpl/utils/phNxpConfig.h | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/halimpl/hal/phNxpUciHal.cc b/halimpl/hal/phNxpUciHal.cc index 428030f..e66cdd2 100644 --- a/halimpl/hal/phNxpUciHal.cc +++ b/halimpl/hal/phNxpUciHal.cc @@ -1050,6 +1050,8 @@ tHAL_UWB_STATUS phNxpUciHal_close() { phNxpUciHal_cleanup_monitor(); + NxpConfig_Deinit(); + /* Return success always */ return UWBSTATUS_SUCCESS; } diff --git a/halimpl/utils/phNxpConfig.cc b/halimpl/utils/phNxpConfig.cc index 8f084c1..16bbbdf 100644 --- a/halimpl/utils/phNxpConfig.cc +++ b/halimpl/utils/phNxpConfig.cc @@ -628,6 +628,10 @@ public: } return code; } + void reset() { + m_config.reset(); + m_map.clear(); + } void dump() { ALOGD("Region mapping dump:"); for (auto &entry : m_map) { @@ -651,6 +655,7 @@ public: CascadeConfig(); void init(const char *main_config); + void deinit(); void setCountryCode(const char country_code[2]); const uwbParam* find(const char *name) const; @@ -787,6 +792,15 @@ void CascadeConfig::init(const char *main_config) } } +void CascadeConfig::deinit() +{ + mMainConfig.reset(); + mExtraConfig.clear(); + mCapsConfig.reset(); + mRegionMap.reset(); + mUciConfig.reset(); +} + void CascadeConfig::setCountryCode(const char country_code[2]) { string strCountry = mRegionMap.xlateCountryCode(country_code); @@ -873,6 +887,11 @@ extern "C" void NxpConfig_Init(void) gConfig.init(default_nxp_config_path); } +extern "C" void NxpConfig_Deinit(void) +{ + gConfig.deinit(); +} + extern "C" void NxpConfig_SetCountryCode(const char country_code[2]) { gConfig.setCountryCode(country_code); diff --git a/halimpl/utils/phNxpConfig.h b/halimpl/utils/phNxpConfig.h index 0d41ea2..74bf8b0 100644 --- a/halimpl/utils/phNxpConfig.h +++ b/halimpl/utils/phNxpConfig.h @@ -28,6 +28,7 @@ extern "C" #endif void NxpConfig_Init(void); +void NxpConfig_Deinit(void); void NxpConfig_SetCountryCode(const char country_code[2]); int NxpConfig_GetStr(const char* name, char* p_value, unsigned long len); |