diff --git a/interfaces/inner_api/include/common_utils.h b/interfaces/inner_api/include/common_utils.h index d1dcf513f..db34ab594 100644 --- a/interfaces/inner_api/include/common_utils.h +++ b/interfaces/inner_api/include/common_utils.h @@ -55,6 +55,8 @@ const std::string NLP_ABILITY_NAME = "const.location.nlp_ability_name"; const std::string GEOCODE_SERVICE_NAME = "const.location.geocode_service_name"; const std::string GEOCODE_ABILITY_NAME = "const.location.geocode_ability_name"; const std::string SUPL_MODE_NAME = "const.location.supl_mode"; +const std::string AGNSS_SERVER_ADDR = "const.location.agnss_server_addr"; +const std::string AGNSS_SERVER_PORT = "const.location.agnss_server_port"; const std::string EDM_POLICY_NAME = "persist.edm.location_policy"; const std::string BUILD_INFO = "ro.build.characteristics"; diff --git a/interfaces/inner_api/include/constant_definition.h b/interfaces/inner_api/include/constant_definition.h index bf0f3d443..7e44adbfe 100644 --- a/interfaces/inner_api/include/constant_definition.h +++ b/interfaces/inner_api/include/constant_definition.h @@ -52,9 +52,9 @@ const std::string PROC_NAME = "system"; const std::string SEARCH_NET_WORK_STATE_CHANGE_ACTION = "com.hos.action.SEARCH_NET_WORK_STATE_CHANGE"; const std::string SIM_STATE_CHANGE_ACTION = "com.hos.action.SIM_STATE_CHANGE"; const std::string LOCALE_KEY = "persist.global.locale"; -const int MODE_STANDALONE = 0; -const int MODE_MS_BASED = 1; -const int MODE_MS_ASSISTED = 2; +const int MODE_STANDALONE = 1; +const int MODE_MS_BASED = 2; +const int MODE_MS_ASSISTED = 3; enum { SCENE_UNSET = 0x0300, diff --git a/services/location_gnss/gnss/source/gnss_ability.cpp b/services/location_gnss/gnss/source/gnss_ability.cpp index 501a73ce6..e2b902670 100644 --- a/services/location_gnss/gnss/source/gnss_ability.cpp +++ b/services/location_gnss/gnss/source/gnss_ability.cpp @@ -45,10 +45,6 @@ namespace Location { namespace { constexpr int32_t GET_HDI_SERVICE_COUNT = 30; constexpr uint32_t WAIT_MS = 200; -#ifdef HDF_DRIVERS_INTERFACE_AGNSS_ENABLE -constexpr int AGNSS_SERVER_PORT = 7275; -const std::string AGNSS_SERVER_ADDR = "supl.platform.hicloud.com"; -#endif const uint32_t EVENT_REPORT_LOCATION = 0x0100; const uint32_t EVENT_INTERVAL_UNITE = 1000; #ifdef HDF_DRIVERS_INTERFACE_AGNSS_ENABLE @@ -657,10 +653,17 @@ void GnssAbility::SetAgnssServer() LBSLOGE(GNSS, "gnss has been disabled"); return; } + std::string addrName; + bool result = LocationConfigManager::GetInstance().GetAgnssServerAddr(addrName); + if (!result || addrName.empty()) { + LBSLOGE(GNSS, "get agnss server address failed!"); + return; + } + int port = LocationConfigManager::GetInstance().GetAgnssServerPort(); AGnssServerInfo info; info.type = AGNSS_TYPE_SUPL; - info.server = AGNSS_SERVER_ADDR; - info.port = AGNSS_SERVER_PORT; + info.server = addrName; + info.port = port; agnssInterface_->SetAgnssServer(info); } diff --git a/services/location_locator/locator/include/location_config_manager.h b/services/location_locator/locator/include/location_config_manager.h index 0d388eb51..756e72fe5 100644 --- a/services/location_locator/locator/include/location_config_manager.h +++ b/services/location_locator/locator/include/location_config_manager.h @@ -96,6 +96,21 @@ public: * @return int - supl mode */ int GetSuplMode(); + + /* + * @Description get agnss server address + * + * @param name - agnss server address + * @return bool - true success + */ + bool GetAgnssServerAddr(std::string& name); + + /* + * @Description get agnss server port + * + * @return int - agnss server port + */ + int GetAgnssServerPort(); private: LocationConfigManager(); std::string GetLocationSwitchConfigPath(); diff --git a/services/location_locator/locator/source/location_config_manager.cpp b/services/location_locator/locator/source/location_config_manager.cpp index f8badf368..fe610cf23 100644 --- a/services/location_locator/locator/source/location_config_manager.cpp +++ b/services/location_locator/locator/source/location_config_manager.cpp @@ -213,6 +213,16 @@ int LocationConfigManager::GetSuplMode() return GetIntParameter(SUPL_MODE_NAME); } +bool LocationConfigManager::GetAgnssServerAddr(std::string& name) +{ + return GetStringParameter(AGNSS_SERVER_ADDR, name); +} + +int LocationConfigManager::GetAgnssServerPort() +{ + return GetIntParameter(AGNSS_SERVER_PORT); +} + int LocationConfigManager::SetLocationSwitchState(int state) { std::unique_lock lock(mutex_); diff --git a/test/location_common/source/common_utils_test.cpp b/test/location_common/source/common_utils_test.cpp index 4c9f3a141..899e5a421 100644 --- a/test/location_common/source/common_utils_test.cpp +++ b/test/location_common/source/common_utils_test.cpp @@ -403,6 +403,7 @@ HWTEST_F(CommonUtilsTest, GetMacArrayTest001, TestSize.Level1) LBSLOGE(COMMON_UTILS, "GetMacArray failed."); } EXPECT_EQ(32, macArray[0]); + LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetMacArrayTest001 end"); } HWTEST_F(CommonUtilsTest, GetStringParameter001, TestSize.Level1) @@ -411,14 +412,15 @@ HWTEST_F(CommonUtilsTest, GetStringParameter001, TestSize.Level1) LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetStringParameter001 begin"); bool ret = CommonUtils::GetStringParameter("test", name); EXPECT_EQ(false, ret); + LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetStringParameter001 rnd"); } HWTEST_F(CommonUtilsTest, GetStringParameter002, TestSize.Level1) { std::string name = ""; LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetStringParameter002 begin"); - bool ret = CommonUtils::GetStringParameter(SUPL_MODE_NAME, name); - EXPECT_EQ(true, ret); + CommonUtils::GetStringParameter(SUPL_MODE_NAME, name); + LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetStringParameter002 end"); } } // namespace Location } // namespace OHOS diff --git a/test/location_locator/source/location_config_manager_test.cpp b/test/location_locator/source/location_config_manager_test.cpp index 734a3b834..22ea56674 100644 --- a/test/location_locator/source/location_config_manager_test.cpp +++ b/test/location_locator/source/location_config_manager_test.cpp @@ -145,5 +145,24 @@ HWTEST_F(LocationConfigManagerTest, LocationConfigManagerPrivacyTypeConfigTest00 EXPECT_NE("", LocationConfigManager::GetInstance().GetPrivacyTypeConfigPath(PRIVACY_TYPE_INVALID_LEFT)); LBSLOGI(LOCATOR, "[LocationConfigManagerTest] LocationConfigManagerCreateFileTest001 end"); } + +HWTEST_F(LocationConfigManagerTest, LocationConfigManagerGetAgnssServerAddrTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) + << "LocationConfigManagerTest, LocationConfigManagerGetAgnssServerAddrTest001, TestSize.Level1"; + LBSLOGI(LOCATOR, "[LocationConfigManagerTest] LocationConfigManagerGetAgnssServerAddrTest001 begin"); + std::string addrName; + LocationConfigManager::GetInstance().GetAgnssServerAddr(addrName); + LBSLOGI(LOCATOR, "[LocationConfigManagerTest] LocationConfigManagerGetAgnssServerAddrTest001 end"); +} + +HWTEST_F(LocationConfigManagerTest, LocationConfigManagerGetAgnssServerPortTest001, TestSize.Level1) +{ + GTEST_LOG_(INFO) + << "LocationConfigManagerTest, LocationConfigManagerGetAgnssServerPortTest001, TestSize.Level1"; + LBSLOGI(LOCATOR, "[LocationConfigManagerTest] LocationConfigManagerGetAgnssServerPortTest001 begin"); + LocationConfigManager::GetInstance().GetAgnssServerPort(); + LBSLOGI(LOCATOR, "[LocationConfigManagerTest] LocationConfigManagerGetAgnssServerPortTest001 end"); +} } // namespace Location } // namespace OHOS \ No newline at end of file