!798 开关缓存问题优化

Merge pull request !798 from liuxinbing/master
This commit is contained in:
openharmony_ci 2024-08-03 12:23:44 +00:00 committed by Gitee
commit 3a83a6b14a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 137 additions and 140 deletions

View File

@ -64,7 +64,8 @@ std::shared_ptr<DataShare::DataShareHelper> LocationDataRdbHelper::CreateDataSha
LBSLOGE(LOCATOR_STANDARD, "%{public}s: remoteObject is nullptr, reInitialize", __func__);
Initialize();
}
return DataShare::DataShareHelper::Creator(remoteObj_, LOCATION_DATA_URI);
return DataShare::DataShareHelper::Creator(remoteObj_,
LocationDataRdbManager::GetLocationDataUri("location_enable"));
}
void LocationDataRdbHelper::ReleaseDataShareHelper(std::shared_ptr<DataShare::DataShareHelper>& dataShareHelper)

View File

@ -24,7 +24,6 @@ const int DEFAULT_USERID = 100;
const int DEFAULT_SWITCHMODE = 2;
const int UNKNOW_ERROR = -1;
const int MAX_SIZE = 100;
const char* LOCATION_SWITCH_MODE = "persist.location.switch_mode";
std::mutex LocationDataRdbManager::mutex_;
const std::string LOCATION_ENHANCE_STATUS = "location_enhance_status";
@ -54,21 +53,27 @@ std::string LocationDataRdbManager::GetLocationDataSecureUri(std::string key)
int LocationDataRdbManager::QuerySwitchState()
{
int32_t state = DISABLED;
Uri locationDataEnableUri(LOCATION_DATA_URI);
int32_t state = DEFAULT_STATE;
int res = LocationDataRdbManager::GetSwitchMode();
if (res == DISABLED || res == ENABLED) {
return res;
}
Uri locationDataEnableUri(GetLocationDataUri("location_enable"));
LocationErrCode errCode = LocationDataRdbHelper::GetInstance()->
GetValue(locationDataEnableUri, LOCATION_DATA_COLUMN_ENABLE, state);
if (errCode != ERRCODE_SUCCESS) {
LBSLOGE(COMMON_UTILS, "%{public}s: query state failed, errcode = %{public}d", __func__, errCode);
return DEFAULT_STATE;
}
SetSwitchMode(state);
if (res == DEFAULT_STATE && state != DEFAULT_STATE) {
LocationDataRdbManager::SetSwitchStateToSyspara(state);
}
return state;
}
LocationErrCode LocationDataRdbManager::SetSwitchState(int modeValue)
LocationErrCode LocationDataRdbManager::SetSwitchStateToDb(int modeValue)
{
Uri locationDataEnableUri(LOCATION_DATA_URI);
Uri locationDataEnableUri(GetLocationDataUri("location_enable"));
return LocationDataRdbHelper::GetInstance()->
SetValue(locationDataEnableUri, LOCATION_DATA_COLUMN_ENABLE, modeValue);
}
@ -120,7 +125,7 @@ int LocationDataRdbManager::GetSwitchMode()
return std::stoi(value);
}
bool LocationDataRdbManager::SetSwitchMode(int value)
bool LocationDataRdbManager::SetSwitchStateToSyspara(int value)
{
char valueArray[MAX_SIZE] = {0};
(void)sprintf_s(valueArray, sizeof(valueArray), "%d", value);
@ -133,6 +138,23 @@ bool LocationDataRdbManager::SetSwitchMode(int value)
return true;
}
void LocationDataRdbManager::SyncSwitchStatus()
{
int state = DEFAULT_STATE;
Uri locationDataEnableUri(GetLocationDataUri("location_enable"));
LocationErrCode errCode = LocationDataRdbHelper::GetInstance()->
GetValue(locationDataEnableUri, LOCATION_DATA_COLUMN_ENABLE, state);
if (errCode != ERRCODE_SUCCESS) {
LBSLOGE(COMMON_UTILS, "%{public}s: query state failed, errcode = %{public}d", __func__, errCode);
}
int cacheState = LocationDataRdbManager::GetSwitchMode();
if (cacheState == DEFAULT_STATE && state != DEFAULT_STATE) {
LocationDataRdbManager::SetSwitchStateToSyspara(state);
} else if (cacheState != DEFAULT_STATE && state != cacheState) {
LocationDataRdbManager::SetSwitchStateToDb(cacheState);
}
}
bool LocationDataRdbManager::ClearSwitchMode()
{
char valueArray[MAX_SIZE] = {0};

View File

@ -20,14 +20,10 @@
#include "switch_callback_proxy.h"
#include "constant_definition.h"
#include "location_data_rdb_helper.h"
#include "location_data_rdb_manager.h"
#include "location_log.h"
#include "common_hisysevent.h"
#include "if_system_ability_manager.h"
#include "system_ability_definition.h"
#include "iservice_registry.h"
#include "location_data_rdb_observer.h"
#include "location_data_rdb_manager.h"
#include "parameter.h"
namespace OHOS {
namespace Location {
LocationDataManager* LocationDataManager::GetInstance()
@ -38,18 +34,6 @@ LocationDataManager* LocationDataManager::GetInstance()
LocationDataManager::LocationDataManager()
{
sptr<ISystemAbilityManager> sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (sam == nullptr) {
LBSLOGE(LOCATOR_STANDARD, "%{public}s: get samgr failed.", __func__);
return;
}
if (saStatusListener_ == nullptr) {
saStatusListener_ = sptr<DataShareSystemAbilityListener>(new DataShareSystemAbilityListener());
}
int32_t result = sam->SubscribeSystemAbility(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID, saStatusListener_);
if (result != ERR_OK) {
LBSLOGE(LOCATOR, "%{public}s SubcribeSystemAbility result is %{public}d!", __func__, result);
}
}
LocationDataManager::~LocationDataManager()
@ -89,6 +73,9 @@ LocationErrCode LocationDataManager::RegisterSwitchCallback(const sptr<IRemoteOb
switchCallbacks_.push_back(switchCallback);
LBSLOGD(LOCATOR, "after uid:%{public}d register, switch callback size:%{public}s",
uid, std::to_string(switchCallbacks_.size()).c_str());
if (switchCallbacks_.size() == 1) {
RegisterLocationSwitchObserver();
}
return ERRCODE_SUCCESS;
}
@ -129,13 +116,6 @@ LocationErrCode LocationDataManager::UnregisterSwitchCallback(const sptr<IRemote
return ERRCODE_SUCCESS;
}
void LocationDataManager::SetCachedSwitchState(int state)
{
std::unique_lock<std::mutex> lock(switchStateMutex_);
isStateCached_ = true;
cachedSwitchState_ = state;
}
bool LocationDataManager::IsSwitchStateReg()
{
std::unique_lock<std::mutex> lock(mutex_);
@ -147,38 +127,31 @@ void LocationDataManager::ResetIsObserverReg()
isObserverReg_ = false;
}
void LocationDataManager::RegisterDatashareObserver()
void LocationDataManager::RegisterLocationSwitchObserver()
{
auto locationDataRdbHelper = LocationDataRdbHelper::GetInstance();
auto dataRdbObserver = sptr<LocationDataRdbObserver>(new (std::nothrow) LocationDataRdbObserver());
if (locationDataRdbHelper == nullptr || dataRdbObserver == nullptr) {
return;
}
if (!isObserverReg_) {
Uri locationDataEnableUri(LOCATION_DATA_URI);
locationDataRdbHelper->RegisterDataObserver(locationDataEnableUri, dataRdbObserver);
isObserverReg_ = true;
}
}
auto eventCallback = [](const char *key, const char *value, void *context) {
int32_t state = DEFAULT_STATE;
state = LocationDataRdbManager::QuerySwitchState();
auto manager = LocationDataManager::GetInstance();
if (manager == nullptr) {
LBSLOGE(LOCATOR, "SubscribeLocaleConfigEvent LocationDataRdbManager is nullptr");
return;
}
if (state == DEFAULT_STATE) {
LBSLOGE(COUNTRY_CODE, "LOCATION_SWITCH_MODE changed. state %{public}d. do not report", state);
return;
}
bool switch_state = (state == ENABLED);
LBSLOGI(COUNTRY_CODE, "LOCATION_SWITCH_MODE changed. switch_state %{public}d", switch_state);
manager->ReportSwitchState(switch_state);
};
void DataShareSystemAbilityListener::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
{
LBSLOGI(LOCATOR_STANDARD, "%{public}s enter", __func__);
auto locationDataManager = LocationDataManager::GetInstance();
if (locationDataManager == nullptr) {
int ret = WatchParameter(LOCATION_SWITCH_MODE, eventCallback, nullptr);
if (ret != SUCCESS) {
LBSLOGE(LOCATOR, "WatchParameter fail");
return;
}
locationDataManager->RegisterDatashareObserver();
}
void DataShareSystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
{
LBSLOGI(LOCATOR_STANDARD, "%{public}s enter", __func__);
auto locationDataManager = LocationDataManager::GetInstance();
if (locationDataManager == nullptr) {
return;
}
locationDataManager->ResetIsObserverReg();
return;
}
} // namespace Location
} // namespace OHOS

View File

@ -50,9 +50,8 @@ void LocationDataRdbObserver::HandleSwitchStateChanged()
return;
}
int32_t state = DISABLED;
int32_t state = DEFAULT_STATE;
state = LocationDataRdbManager::QuerySwitchState();
locationDataManager->SetCachedSwitchState(state);
locationDataManager->ReportSwitchState(state);
}
} // namespace Location

View File

@ -69,17 +69,17 @@ LocatorImpl::~LocatorImpl()
bool LocatorImpl::IsLocationEnabled()
{
int32_t state = DISABLED;
int res = LocationDataRdbManager::GetSwitchMode();
if (res == DISABLED || res == ENABLED) {
return (res == ENABLED);
LBSLOGD(LOCATION_NAPI, "IsLocationEnabled");
if (!LocationSaLoadManager::InitLocationSa(LOCATION_LOCATOR_SA_ID)) {
return ERRCODE_SERVICE_UNAVAILABLE;
}
auto locationDataRdbHelper =
LocationDataRdbHelper::GetInstance();
if (locationDataRdbHelper == nullptr) {
sptr<LocatorProxy> proxy = GetProxy();
if (proxy == nullptr) {
LBSLOGE(LOCATOR_STANDARD, "%{public}s get proxy failed.", __func__);
return false;
}
state = LocationDataRdbManager::QuerySwitchState();
int32_t state = DEFAULT_STATE;
state = proxy->GetSwitchState();
return (state == ENABLED);
}
@ -113,11 +113,8 @@ void LocatorImpl::EnableAbility(bool enable)
return;
}
LocationErrCode errCode = proxy->EnableAbilityV9(enable);
// cache the value
if (errCode == ERRCODE_SUCCESS) {
if (locationDataManager_ != nullptr) {
locationDataManager_->SetCachedSwitchState(enable ? ENABLED : DISABLED);
}
if (errorCode != ERRCODE_SUCCESS) {
LBSLOGE(LOCATOR_STANDARD, "%{public}s EnableAbilityV9 failed. %{public}d", __func__, errCode);
}
}
@ -578,18 +575,19 @@ bool LocatorImpl::SetReverseGeocodingMockInfo(std::vector<std::shared_ptr<Geocod
LocationErrCode LocatorImpl::IsLocationEnabledV9(bool &isEnabled)
{
LBSLOGD(LOCATOR_STANDARD, "LocatorImpl::IsLocationEnabledV9()");
int32_t state = DISABLED;
int res = LocationDataRdbManager::GetSwitchMode();
if (res == DISABLED || res == ENABLED) {
isEnabled = (res == ENABLED);
return ERRCODE_SUCCESS;
if (!LocationSaLoadManager::InitLocationSa(LOCATION_LOCATOR_SA_ID)) {
return ERRCODE_SERVICE_UNAVAILABLE;
}
auto locationDataRdbHelper =
LocationDataRdbHelper::GetInstance();
if (locationDataRdbHelper == nullptr) {
return ERRCODE_NOT_SUPPORTED;
sptr<LocatorProxy> proxy = GetProxy();
if (proxy == nullptr) {
LBSLOGE(LOCATOR_STANDARD, "%{public}s get proxy failed.", __func__);
return ERRCODE_SERVICE_UNAVAILABLE;
}
int32_t state = DEFAULT_STATE;
state = proxy->GetSwitchState();
if (state == DEFAULT_STATE) {
return ERRCODE_SERVICE_UNAVAILABLE;
}
state = LocationDataRdbManager::QuerySwitchState();
isEnabled = (state == ENABLED);
return ERRCODE_SUCCESS;
}
@ -629,12 +627,6 @@ LocationErrCode LocatorImpl::EnableAbilityV9(bool enable)
return ERRCODE_SERVICE_UNAVAILABLE;
}
LocationErrCode errCode = proxy->EnableAbilityV9(enable);
// cache the value
if (errCode == ERRCODE_SUCCESS) {
if (locationDataManager_ != nullptr) {
locationDataManager_->SetCachedSwitchState(enable ? ENABLED : DISABLED);
}
}
return errCode;
}

View File

@ -51,6 +51,7 @@ constexpr const char* FEATURE_SWITCH_PROP = "ro.config.locator_background";
constexpr const char* TIME_INTERVAL_PROP = "ro.config.locator_background.timeInterval";
constexpr const char* PROC_NAME = "system";
constexpr const char* LOCALE_KEY = "persist.global.locale";
constexpr const char* LOCATION_SWITCH_MODE = "persist.location.switch_mode";
const int MODE_STANDALONE = 1;
const int MODE_MS_BASED = 2;
const int MODE_MS_ASSISTED = 3;

View File

@ -22,15 +22,9 @@
#include "constant_definition.h"
#include "i_switch_callback.h"
#include "common_utils.h"
#include "system_ability_status_change_stub.h"
namespace OHOS {
namespace Location {
class DataShareSystemAbilityListener : public SystemAbilityStatusChangeStub {
public:
void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
};
class LocationDataManager {
public:
LocationDataManager();
@ -38,21 +32,16 @@ public:
LocationErrCode ReportSwitchState(bool isEnabled);
LocationErrCode RegisterSwitchCallback(const sptr<IRemoteObject>& callback, pid_t uid);
LocationErrCode UnregisterSwitchCallback(const sptr<IRemoteObject>& callback);
void SetCachedSwitchState(int32_t state);
bool IsSwitchStateReg();
void ResetIsObserverReg();
void RegisterDatashareObserver();
void RegisterLocationSwitchObserver();
static LocationDataManager* GetInstance();
private:
std::mutex mutex_;
std::mutex switchStateMutex_;
std::vector<sptr<ISwitchCallback>> switchCallbacks_;
int32_t cachedSwitchState_ = DISABLED;
bool isStateCached_ = false;
bool isObserverReg_ = false;
sptr<ISystemAbilityStatusChange> saStatusListener_ =
sptr<DataShareSystemAbilityListener>(new DataShareSystemAbilityListener());
};
} // namespace Location
} // namespace OHOS

View File

@ -25,21 +25,20 @@ namespace OHOS {
namespace Location {
const std::string LOCATION_DATA_COLUMN_ENABLE = "location_switch_enable";
const std::string LOCATION_WORKING_STATE = "location_working_state";
const std::string LOCATION_DATA_URI =
"datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=location_enable";
class LocationDataRdbManager {
public:
static std::string GetLocationDataUri(std::string key);
static int QuerySwitchState();
static LocationErrCode SetSwitchState(int modeValue);
static LocationErrCode SetSwitchStateToDb(int modeValue);
static bool SetLocationWorkingState(int32_t state);
static bool GetLocationWorkingState(int32_t& state);
static int GetSwitchMode();
static bool SetSwitchMode(int value);
static bool SetSwitchStateToSyspara(int value);
static bool ClearSwitchMode();
static std::string GetLocationDataSecureUri(std::string key);
static bool SetLocationEnhanceStatus(int32_t state);
static bool GetLocationEnhanceStatus(int32_t& state);
static void SyncSwitchStatus();
private:
static std::mutex mutex_;
};

View File

@ -78,6 +78,7 @@ ohos_shared_library("lbsservice_locator") {
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"init:libbeget_proxy",
"ipc:ipc_single",
"os_account:os_account_innerkits",
"safwk:system_ability_fwk",

View File

@ -51,6 +51,7 @@ public:
explicit LocatorHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner);
~LocatorHandler() override;
void InitLocatorHandlerEventMap();
void ConstructDbHandleMap();
void ConstructGeocodeHandleMap();
private:
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) override;
@ -78,6 +79,7 @@ private:
void InitMonitorManagerEvent(const AppExecFwk::InnerEvent::Pointer& event);
void IsStandByEvent(const AppExecFwk::InnerEvent::Pointer& event);
void SetLocationWorkingStateEvent(const AppExecFwk::InnerEvent::Pointer& event);
void SetSwitchStateToDbEvent(const AppExecFwk::InnerEvent::Pointer& event);
LocatorEventHandleMap locatorHandlerEventMap_;
};
@ -199,6 +201,7 @@ public:
#ifdef FEATURE_GEOCODE_SUPPORT
LocationErrCode SendGeoRequest(int type, MessageParcel &data, MessageParcel &reply);
#endif
void ReportDataToResSched(std::string state);
private:
bool Init();
@ -214,7 +217,6 @@ private:
bool IsCacheVaildScenario(const sptr<RequestConfig>& requestConfig);
bool IsSingleRequest(const sptr<RequestConfig>& requestConfig);
void SendSwitchState(const int state);
void ReportDataToResSched(std::string state);
bool CheckIsReportPermitted(AppIdentity &identity);
bool registerToAbility_ = false;

View File

@ -59,6 +59,7 @@
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "geo_convert_request.h"
#include "parameter.h"
namespace OHOS {
namespace Location {
@ -88,6 +89,7 @@ const uint32_t EVENT_INIT_MSDP_MONITOR_MANAGER = 0x0020;
const uint32_t EVENT_IS_STAND_BY = 0x0021;
const uint32_t EVENT_SET_LOCATION_WORKING_STATE = 0x0022;
const uint32_t EVENT_SEND_GEOREQUEST = 0x0023;
const uint32_t EVENT_SET_SWITCH_STATE_TO_DB = 0x0024;
const uint32_t RETRY_INTERVAL_UNITE = 1000;
const uint32_t RETRY_INTERVAL_OF_INIT_REQUEST_MANAGER = 5 * RETRY_INTERVAL_UNITE;
@ -431,38 +433,23 @@ LocationErrCode LocatorAbility::EnableAbility(bool isEnabled)
LBSLOGI(LOCATOR, "EnableAbility %{public}d", isEnabled);
int modeValue = isEnabled ? 1 : 0;
int currentSwitchState = LocationDataRdbManager::QuerySwitchState();
if (modeValue == currentSwitchState) {
if (modeValue == currentSwitchState && currentSwitchState != DEFAULT_STATE) {
LBSLOGD(LOCATOR, "no need to set location ability, enable:%{public}d", modeValue);
return ERRCODE_SUCCESS;
}
if (LocationDataRdbManager::SetSwitchState(modeValue) != ERRCODE_SUCCESS) {
LBSLOGE(LOCATOR, "%{public}s: can not set state to db", __func__);
return ERRCODE_SERVICE_UNAVAILABLE;
// update param
LocationDataRdbManager::SetSwitchStateToSyspara(isEnabled ? ENABLED : DISABLED);
AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::
Get(EVENT_SET_SWITCH_STATE_TO_DB, modeValue);
if (locatorHandler_ != nullptr && locatorHandler_->SendEvent(event)) {
LBSLOGD(LOCATOR, "%{public}s: EVENT_SET_SWITCH_STATE_TO_DB Send Success", __func__);
}
if (currentSwitchState != DEFAULT_STATE) {
// update param
LocationDataRdbManager::SetSwitchMode(isEnabled ? ENABLED : DISABLED);
}
UpdateSaAbility();
ApplyRequests(0);
std::string state = isEnabled ? "enable" : "disable";
ReportDataToResSched(state);
WriteLocationSwitchStateEvent(state);
return ERRCODE_SUCCESS;
}
LocationErrCode LocatorAbility::GetSwitchState(int& state)
{
int res = LocationDataRdbManager::GetSwitchMode();
if (res == DISABLED || res == ENABLED) {
state = res;
return ERRCODE_SUCCESS;
}
state = LocationDataRdbManager::QuerySwitchState();
if (res == DEFAULT_STATE && state != DEFAULT_STATE) {
// update param
LocationDataRdbManager::SetSwitchMode(state);
}
return ERRCODE_SUCCESS;
}
@ -1796,8 +1783,7 @@ void LocatorHandler::InitLocatorHandlerEventMap()
[this](const AppExecFwk::InnerEvent::Pointer& event) { InitMonitorManagerEvent(event); };
locatorHandlerEventMap_[EVENT_IS_STAND_BY] =
[this](const AppExecFwk::InnerEvent::Pointer& event) { IsStandByEvent(event); };
locatorHandlerEventMap_[EVENT_SET_LOCATION_WORKING_STATE] =
[this](const AppExecFwk::InnerEvent::Pointer& event) { SetLocationWorkingStateEvent(event); };
ConstructDbHandleMap();
ConstructGeocodeHandleMap();
}
@ -1807,6 +1793,14 @@ void LocatorHandler::ConstructGeocodeHandleMap()
[this](const AppExecFwk::InnerEvent::Pointer& event) { SendGeoRequestEvent(event); };
}
void LocatorHandler::ConstructDbHandleMap()
{
locatorHandlerEventMap_[EVENT_SET_LOCATION_WORKING_STATE] =
[this](const AppExecFwk::InnerEvent::Pointer& event) { SetLocationWorkingStateEvent(event); };
locatorHandlerEventMap_[EVENT_SET_SWITCH_STATE_TO_DB] =
[this](const AppExecFwk::InnerEvent::Pointer& event) { SetSwitchStateToDbEvent(event); };
}
void LocatorHandler::GetCachedLocationSuccess(const AppExecFwk::InnerEvent::Pointer& event)
{
auto workRecordStatistic = WorkRecordStatistic::GetInstance();
@ -2026,10 +2020,16 @@ void LocatorHandler::ReportLocationErrorEvent(const AppExecFwk::InnerEvent::Poin
void LocatorHandler::SyncSwitchStatus(const AppExecFwk::InnerEvent::Pointer& event)
{
int state = LocationDataRdbManager::QuerySwitchState();
int cacheState = LocationDataRdbManager::GetSwitchMode();
if (state != DEFAULT_STATE && state != cacheState) {
LocationDataRdbManager::SetSwitchMode(state);
LocationDataRdbManager::SyncSwitchStatus();
auto eventCallback = [](const char *key, const char *value, void *context) {
LocationDataRdbManager::SyncSwitchStatus();
};
int ret = WatchParameter(LOCATION_SWITCH_MODE, eventCallback, nullptr);
if (ret != SUCCESS) {
LBSLOGE(LOCATOR, "WatchParameter fail");
return;
}
}
@ -2118,6 +2118,24 @@ void LocatorHandler::SetLocationWorkingStateEvent(const AppExecFwk::InnerEvent::
}
}
void LocatorHandler::SetSwitchStateToDbEvent(const AppExecFwk::InnerEvent::Pointer& event)
{
int modeValue = event->GetParam();
if (LocationDataRdbManager::SetSwitchStateToDb(modeValue) != ERRCODE_SUCCESS) {
LBSLOGE(LOCATOR, "%{public}s: can not set state to db", __func__);
return;
}
auto locatorAbility = LocatorAbility::GetInstance();
if (locatorAbility != nullptr) {
locatorAbility->UpdateSaAbility();
locatorAbility->ApplyRequests(0);
bool isEnabled = (modeValue == ENABLED);
std::string state = isEnabled ? "enable" : "disable";
locatorAbility->ReportDataToResSched(state);
WriteLocationSwitchStateEvent(state);
}
}
LocatorCallbackDeathRecipient::LocatorCallbackDeathRecipient(int32_t tokenId)
{
tokenId_ = tokenId;

View File

@ -191,7 +191,7 @@ HWTEST_F(LocatorSkeletonTest, PreStartLocating, TestSize.Level1)
identity.SetTokenId(tokenId);
identity.SetFirstTokenId(0);
identity.SetBundleName("bundleName");
LocationDataRdbManager::SetSwitchState(ENABLED);
LocationDataRdbManager::SetSwitchStateToDb(ENABLED);
locatorAbilityStub->PreStartLocating(data, reply, identity);
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartLocating end");
}
@ -236,7 +236,7 @@ HWTEST_F(LocatorSkeletonTest, PreGetCacheLocation, TestSize.Level1)
identity.SetTokenId(tokenId);
identity.SetFirstTokenId(0);
identity.SetBundleName("bundleName");
LocationDataRdbManager::SetSwitchState(ENABLED);
LocationDataRdbManager::SetSwitchStateToDb(ENABLED);
auto result = locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
EXPECT_EQ(ERRCODE_SUCCESS, result);
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCacheLocation end");
@ -989,7 +989,7 @@ HWTEST_F(LocatorSkeletonTest, PreRegisterLocationError, TestSize.Level1)
identity.SetTokenId(tokenId);
identity.SetFirstTokenId(0);
identity.SetBundleName("bundleName");
LocationDataRdbManager::SetSwitchState(ENABLED);
LocationDataRdbManager::SetSwitchStateToDb(ENABLED);
locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocationError end");
}