mirror of
https://github.com/openharmony/base_location.git
synced 2026-08-25 12:24:02 -04:00
!531 modify agnss server
Merge pull request !531 from ruan-shaofei/master
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<std::mutex> lock(mutex_);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user