diff --git a/frameworks/location_common/common/BUILD.gn b/frameworks/location_common/common/BUILD.gn index 1b43cfa6..1b96e044 100644 --- a/frameworks/location_common/common/BUILD.gn +++ b/frameworks/location_common/common/BUILD.gn @@ -33,7 +33,6 @@ local_base_sources = [ "$LOCATION_COMMON_DIR/source/request.cpp", "$LOCATION_COMMON_DIR/source/sa_load_with_statistic.cpp", "$LOCATION_COMMON_DIR/source/ui_extension_ability_connection.cpp", - "$LOCATION_COMMON_DIR/source/work_record_statistic.cpp", "$LOCATION_ROOT_DIR/frameworks/base_module/source/location.cpp", "$LOCATION_ROOT_DIR/frameworks/base_module/source/request_config.cpp", "$LOCATION_ROOT_DIR/frameworks/base_module/source/satellite_status.cpp", diff --git a/frameworks/location_common/common/liblbsservice_common_version_script.txt b/frameworks/location_common/common/liblbsservice_common_version_script.txt index 2d7ddc05..e1290688 100644 --- a/frameworks/location_common/common/liblbsservice_common_version_script.txt +++ b/frameworks/location_common/common/liblbsservice_common_version_script.txt @@ -24,7 +24,6 @@ "*ExecuteHookWhenAddWorkRecord*"; "*LOCATOR_SA_LOCATION_PERMISSION_CHECK*"; "*ExecuteHookWhenCheckAppForCacheTime*"; - "*WorkRecordStatistic*"; local: *; }; \ No newline at end of file diff --git a/frameworks/location_common/common/source/work_record_statistic.cpp b/frameworks/location_common/common/source/work_record_statistic.cpp deleted file mode 100644 index 5384c2c4..00000000 --- a/frameworks/location_common/common/source/work_record_statistic.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "work_record_statistic.h" -#include "common_utils.h" -#include "location_data_rdb_manager.h" - -namespace OHOS { -namespace Location { -std::shared_ptr WorkRecordStatistic::instance_ = nullptr; -std::mutex WorkRecordStatistic::workRecordStatisticMutex_; - -const uint32_t WORKING_STATE = 1; -const uint32_t NO_WORKING_STATE = 0; - -std::shared_ptr WorkRecordStatistic::GetInstance() -{ - if (instance_ == nullptr) { - std::unique_lock lock(workRecordStatisticMutex_); - if (instance_ == nullptr) { - std::shared_ptr workRecordStatistic = std::make_shared(); - instance_ = workRecordStatistic; - } - } - return instance_; -} - -void WorkRecordStatistic::DestroyInstance() -{ - std::unique_lock lock(workRecordStatisticMutex_); - if (instance_ != nullptr) { - instance_ = nullptr; - } -} - -bool WorkRecordStatistic::Update(std::string name, int requestNum) -{ - std::unique_lock lock(mutex_); - if (name == "CacheLocation") { - workRecordStatisticMap_[name] = workRecordStatisticMap_[name] += requestNum; - } else { - workRecordStatisticMap_[name] = requestNum; - } - if (!UpdateLocationWorkingState()) { - return false; - } - return true; -} - -bool WorkRecordStatistic::UpdateLocationWorkingState() -{ - int requestNum = 0; - for (const auto& pair : workRecordStatisticMap_) { - requestNum += pair.second; - } - - if (requestNum == 1 && location_working_state_ != WORKING_STATE) { - if (!LocationDataRdbManager::SetLocationWorkingState(WORKING_STATE)) { - return false; - } - location_working_state_ = WORKING_STATE; - } else if (requestNum == 0 && location_working_state_ != NO_WORKING_STATE) { - if (!LocationDataRdbManager::SetLocationWorkingState(NO_WORKING_STATE)) { - return false; - } - location_working_state_ = NO_WORKING_STATE; - } - return true; -} -} // namespace Location -} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/include/work_record_statistic.h b/interfaces/inner_api/include/work_record_statistic.h deleted file mode 100644 index 645b1e23..00000000 --- a/interfaces/inner_api/include/work_record_statistic.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WORK_RECORD_STATISTIC_H -#define WORK_RECORD_STATISTIC_H - -#include -#include -#include - -namespace OHOS { -namespace Location { -class WorkRecordStatistic { -public: - static std::shared_ptr GetInstance(); - static void DestroyInstance(); - bool Update(std::string name, int requestNum); -private: - bool UpdateLocationWorkingState(); - std::map workRecordStatisticMap_; - static std::shared_ptr instance_; - int location_working_state_ = 0; - std::mutex mutex_; - static std::mutex workRecordStatisticMutex_; -}; -} // namespace Location -} // namespace OHOS -#endif // WORK_RECORD_STATISTIC_H diff --git a/services/location_locator/locator/include/locator_ability.h b/services/location_locator/locator/include/locator_ability.h index 23e94a45..d259ad31 100644 --- a/services/location_locator/locator/include/locator_ability.h +++ b/services/location_locator/locator/include/locator_ability.h @@ -61,7 +61,6 @@ private: void RetryRegisterActionEvent(const AppExecFwk::InnerEvent::Pointer& event); void ReportLocationMessageEvent(const AppExecFwk::InnerEvent::Pointer& event); void SendSwitchStateToHifenceEvent(const AppExecFwk::InnerEvent::Pointer& event); - void UpdateLastLocationRequestNum(const AppExecFwk::InnerEvent::Pointer& event); void UnloadSaEvent(const AppExecFwk::InnerEvent::Pointer& event); void StartLocatingEvent(const AppExecFwk::InnerEvent::Pointer& event); void StopLocatingEvent(const AppExecFwk::InnerEvent::Pointer& event); @@ -203,7 +202,6 @@ public: std::vector& coordinateSystemTypes); LocationErrCode SendNetworkLocation(const std::unique_ptr& location); #endif - void UpdateLastLocationRequestNum(); void SyncStillMovementState(bool stillState); void SyncIdleState(bool stillState); #ifdef FEATURE_GEOCODE_SUPPORT diff --git a/services/location_locator/locator/source/locator_ability.cpp b/services/location_locator/locator/source/locator_ability.cpp index 97ee0a14..a31afc14 100644 --- a/services/location_locator/locator/source/locator_ability.cpp +++ b/services/location_locator/locator/source/locator_ability.cpp @@ -49,7 +49,6 @@ #include "passive_ability_proxy.h" #endif #include "permission_status_change_cb.h" -#include "work_record_statistic.h" #include "permission_manager.h" #ifdef RES_SCHED_SUPPROT #include "res_type.h" @@ -75,7 +74,6 @@ const uint32_t EVENT_REPORT_LOCATION_MESSAGE = 0x0005; const uint32_t EVENT_SEND_SWITCHSTATE_TO_HIFENCE = 0x0006; const uint32_t EVENT_START_LOCATING = 0x0007; const uint32_t EVENT_STOP_LOCATING = 0x0008; -const uint32_t EVENT_UPDATE_LASTLOCATION_REQUESTNUM = 0x0009; const uint32_t EVENT_UNLOAD_SA = 0x0010; const uint32_t EVENT_GET_CACHED_LOCATION_SUCCESS = 0x0014; const uint32_t EVENT_GET_CACHED_LOCATION_FAILED = 0x0015; @@ -1020,10 +1018,6 @@ bool LocatorAbility::NeedReportCacheLocation(const std::shared_ptr& req if (cacheLocation == nullptr) { return false; } - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - if (!workRecordStatistic->Update("CacheLocation", 1)) { - LBSLOGE(LOCATOR, "%{public}s line:%{public}d workRecordStatistic::Update failed", __func__, __LINE__); - } if (IsSingleRequest(request->GetRequestConfig())) { return ReportSingleCacheLocation(request, callback, cacheLocation); } else { @@ -1058,10 +1052,6 @@ bool LocatorAbility::ReportSingleCacheLocation( if (requestManager_->IsNeedStopUsingPermission(request->GetPid())) { PrivacyKit::StopUsingPermission(request->GetTokenId(), ACCESS_APPROXIMATELY_LOCATION, request->GetPid()); } - if (locatorHandler_ != nullptr && - locatorHandler_->SendHighPriorityEvent(EVENT_UPDATE_LASTLOCATION_REQUESTNUM, 0, 1)) { - LBSLOGD(LOCATOR, "%{public}s: EVENT_UPDATE_LASTLOCATION_REQUESTNUM Send Success", __func__); - } return true; } @@ -1479,14 +1469,6 @@ void LocatorAbility::ReportDataToResSched(std::string state) #endif } -void LocatorAbility::UpdateLastLocationRequestNum() -{ - if (locatorHandler_ != nullptr && - locatorHandler_->SendHighPriorityEvent(EVENT_UPDATE_LASTLOCATION_REQUESTNUM, 0, RETRY_INTERVAL_UNITE)) { - LBSLOGD(LOCATOR, "%{public}s: EVENT_UPDATE_LASTLOCATION_REQUESTNUM Send Success", __func__); - } -} - #ifdef FEATURE_GNSS_SUPPORT LocationErrCode LocatorAbility::QuerySupportCoordinateSystemType( std::vector& coordinateSystemTypes) @@ -1812,8 +1794,6 @@ void LocatorHandler::InitLocatorHandlerEventMap() [this](const AppExecFwk::InnerEvent::Pointer& event) { StartLocatingEvent(event); }; locatorHandlerEventMap_[EVENT_STOP_LOCATING] = [this](const AppExecFwk::InnerEvent::Pointer& event) { StopLocatingEvent(event); }; - locatorHandlerEventMap_[EVENT_UPDATE_LASTLOCATION_REQUESTNUM] = - [this](const AppExecFwk::InnerEvent::Pointer& event) { UpdateLastLocationRequestNum(event); }; locatorHandlerEventMap_[EVENT_UNLOAD_SA] = [this](const AppExecFwk::InnerEvent::Pointer& event) { UnloadSaEvent(event); }; locatorHandlerEventMap_[EVENT_GET_CACHED_LOCATION_SUCCESS] = @@ -1862,10 +1842,6 @@ void LocatorHandler::ConstructDbHandleMap() void LocatorHandler::GetCachedLocationSuccess(const AppExecFwk::InnerEvent::Pointer& event) { - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - if (!workRecordStatistic->Update("CacheLocation", 1)) { - LBSLOGE(LOCATOR, "%{public}s line:%{public}d workRecordStatistic::Update failed", __func__, __LINE__); - } std::shared_ptr identity = event->GetSharedObject(); int64_t tokenId = identity->GetTokenId(); OHOS::Security::AccessToken::PermUsedTypeEnum type = @@ -1873,7 +1849,6 @@ void LocatorHandler::GetCachedLocationSuccess(const AppExecFwk::InnerEvent::Poin auto locatorAbility = LocatorAbility::GetInstance(); int ret; if (locatorAbility != nullptr) { - locatorAbility->UpdateLastLocationRequestNum(); ret = locatorAbility->UpdatePermissionUsedRecord(tokenId, ACCESS_APPROXIMATELY_LOCATION, static_cast(type), 1, 0); LBSLOGD(LOCATOR, "UpdatePermissionUsedRecord, ret=%{public}d", ret); @@ -1888,10 +1863,6 @@ void LocatorHandler::GetCachedLocationSuccess(const AppExecFwk::InnerEvent::Poin void LocatorHandler::GetCachedLocationFailed(const AppExecFwk::InnerEvent::Pointer& event) { - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - if (!workRecordStatistic->Update("CacheLocation", 1)) { - LBSLOGE(LOCATOR, "%{public}s line:%{public}d workRecordStatistic::Update failed", __func__, __LINE__); - } std::shared_ptr identity = event->GetSharedObject(); int64_t tokenId = identity->GetTokenId(); OHOS::Security::AccessToken::PermUsedTypeEnum type = @@ -1899,7 +1870,6 @@ void LocatorHandler::GetCachedLocationFailed(const AppExecFwk::InnerEvent::Point auto locatorAbility = LocatorAbility::GetInstance(); int ret; if (locatorAbility != nullptr) { - locatorAbility->UpdateLastLocationRequestNum(); ret = locatorAbility->UpdatePermissionUsedRecord(tokenId, ACCESS_APPROXIMATELY_LOCATION, static_cast(type), 0, 1); LBSLOGD(LOCATOR, "UpdatePermissionUsedRecord, ret=%{public}d", ret); @@ -2017,14 +1987,6 @@ void LocatorHandler::StopLocatingEvent(const AppExecFwk::InnerEvent::Pointer& ev } } -void LocatorHandler::UpdateLastLocationRequestNum(const AppExecFwk::InnerEvent::Pointer& event) -{ - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - if (!workRecordStatistic->Update("CacheLocation", -1)) { - LBSLOGE(LOCATOR, "%{public}s line:%{public}d workRecordStatistic::Update failed", __func__, __LINE__); - } -} - void LocatorHandler::UnloadSaEvent(const AppExecFwk::InnerEvent::Pointer& event) { auto locationSaLoadManager = LocationSaLoadManager::GetInstance(); diff --git a/services/location_locator/locator/source/subability_common.cpp b/services/location_locator/locator/source/subability_common.cpp index c53a6a43..33228975 100644 --- a/services/location_locator/locator/source/subability_common.cpp +++ b/services/location_locator/locator/source/subability_common.cpp @@ -23,7 +23,6 @@ #include "common_utils.h" #include "locationhub_ipc_interface_code.h" -#include "work_record_statistic.h" #include "app_identity.h" namespace OHOS { @@ -79,10 +78,6 @@ void SubAbility::HandleRefrashRequirements() HandleLocalRequest(*newRecord_); lastRecord_->Clear(); lastRecord_->Set(*newRecord_); - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - if (!workRecordStatistic->Update(name_, GetRequestNum())) { - LBSLOGE(label_, "workRecordStatistic::Update failed"); - } } int SubAbility::GetRequestNum() diff --git a/test/fuzztest/locator/gnss_fuzzer/gnss_fuzzer.cpp b/test/fuzztest/locator/gnss_fuzzer/gnss_fuzzer.cpp index 4727ed41..3e3dd8a7 100644 --- a/test/fuzztest/locator/gnss_fuzzer/gnss_fuzzer.cpp +++ b/test/fuzztest/locator/gnss_fuzzer/gnss_fuzzer.cpp @@ -34,7 +34,6 @@ #include "subability_common.h" #include "work_record.h" #include "geofence_request.h" -#include "work_record_statistic.h" #include "if_system_ability_manager.h" #include "system_ability_definition.h" #include "iservice_registry.h" @@ -81,7 +80,6 @@ namespace OHOS { std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); proxy->UnregisterNmeaMessageCallback(nmeaCallbackHost); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -129,7 +127,6 @@ namespace OHOS { std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); proxy->SetMocked(data[index++], locations); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -157,7 +154,6 @@ namespace OHOS { std::vector coordinateSystemTypes; proxy->QuerySupportCoordinateSystemType(coordinateSystemTypes); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } #endif // FEATURE_GNSS_SUPPORT diff --git a/test/fuzztest/locator/gnssability_fuzzer/gnssability_fuzzer.cpp b/test/fuzztest/locator/gnssability_fuzzer/gnssability_fuzzer.cpp index 9ecd2582..fbc54ca6 100644 --- a/test/fuzztest/locator/gnssability_fuzzer/gnssability_fuzzer.cpp +++ b/test/fuzztest/locator/gnssability_fuzzer/gnssability_fuzzer.cpp @@ -30,7 +30,6 @@ #include "gnss_ability.h" #endif #include "permission_manager.h" -#include "work_record_statistic.h" namespace OHOS { using namespace OHOS::Location; @@ -97,7 +96,6 @@ bool GnssAbility001FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(GnssInterfaceCode::SET_MOCKED_LOCATIONS), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -115,7 +113,6 @@ bool GnssAbility002FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -133,7 +130,6 @@ bool GnssAbility003FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -151,7 +147,6 @@ bool GnssAbility004FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -169,7 +164,6 @@ bool GnssAbility005FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -187,7 +181,6 @@ bool GnssAbility006FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -204,7 +197,6 @@ bool GnssAbility007FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(GnssInterfaceCode::REG_NMEA), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -222,7 +214,6 @@ bool GnssAbility008FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -240,7 +231,6 @@ bool GnssAbility009FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -258,7 +248,6 @@ bool GnssAbility010FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -276,7 +265,6 @@ bool GnssAbility011FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -294,7 +282,6 @@ bool GnssAbility012FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -312,7 +299,6 @@ bool GnssAbility013FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -330,7 +316,6 @@ bool GnssAbility014FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -348,7 +333,6 @@ bool GnssAbility015FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -366,7 +350,6 @@ bool GnssAbility016FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -384,7 +367,6 @@ bool GnssAbility017FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -402,7 +384,6 @@ bool GnssAbility018FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -420,7 +401,6 @@ bool GnssAbility019FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -438,7 +418,6 @@ bool GnssAbility020FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -456,7 +435,6 @@ bool GnssAbility021FuzzTest(const char* data, size_t size) requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } #endif diff --git a/test/fuzztest/locator/networkability_fuzzer/networkability_fuzzer.cpp b/test/fuzztest/locator/networkability_fuzzer/networkability_fuzzer.cpp index 1998a593..588fea42 100644 --- a/test/fuzztest/locator/networkability_fuzzer/networkability_fuzzer.cpp +++ b/test/fuzztest/locator/networkability_fuzzer/networkability_fuzzer.cpp @@ -30,7 +30,6 @@ #include "network_ability.h" #endif #include "permission_manager.h" -#include "work_record_statistic.h" namespace OHOS { @@ -98,7 +97,6 @@ bool NetworkAbility001FuzzTest(const char* data, size_t size) auto ability = sptr(new (std::nothrow) NetworkAbility()); ability->OnRemoteRequest(static_cast(NetworkInterfaceCode::SEND_LOCATION_REQUEST), requestParcel, reply, option); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -114,7 +112,6 @@ bool NetworkAbility002FuzzTest(const char* data, size_t size) auto ability = sptr(new (std::nothrow) NetworkAbility()); ability->OnRemoteRequest(static_cast(NetworkInterfaceCode::SET_MOCKED_LOCATIONS), requestParcel, reply, option); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -131,7 +128,6 @@ bool NetworkAbility003FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(NetworkInterfaceCode::SELF_REQUEST), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -148,7 +144,6 @@ bool NetworkAbility004FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(NetworkInterfaceCode::SET_ENABLE), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -165,7 +160,6 @@ bool NetworkAbility005FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(NetworkInterfaceCode::ENABLE_LOCATION_MOCK), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -182,7 +176,6 @@ bool NetworkAbility006FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(NetworkInterfaceCode::DISABLE_LOCATION_MOCK), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } #endif diff --git a/test/fuzztest/locator/networkabilityproxy_fuzzer/networkabilityproxy_fuzzer.cpp b/test/fuzztest/locator/networkabilityproxy_fuzzer/networkabilityproxy_fuzzer.cpp index d3c915ec..853ef9dd 100644 --- a/test/fuzztest/locator/networkabilityproxy_fuzzer/networkabilityproxy_fuzzer.cpp +++ b/test/fuzztest/locator/networkabilityproxy_fuzzer/networkabilityproxy_fuzzer.cpp @@ -31,7 +31,6 @@ #include "network_ability_proxy.h" #endif #include "permission_manager.h" -#include "work_record_statistic.h" namespace OHOS { using namespace OHOS::Location; @@ -76,7 +75,6 @@ bool NetworkAbilityProxy001FuzzTest(const uint8_t* data, size_t size) proxy->DisableMock(); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); proxy->SetMocked(data[index++], locations); - WorkRecordStatistic::DestroyInstance(); return true; } #endif diff --git a/test/fuzztest/locator/passiveability_fuzzer/passiveability_fuzzer.cpp b/test/fuzztest/locator/passiveability_fuzzer/passiveability_fuzzer.cpp index 8760be50..523acdb9 100644 --- a/test/fuzztest/locator/passiveability_fuzzer/passiveability_fuzzer.cpp +++ b/test/fuzztest/locator/passiveability_fuzzer/passiveability_fuzzer.cpp @@ -30,7 +30,6 @@ #include "passive_ability.h" #endif #include "permission_manager.h" -#include "work_record_statistic.h" namespace OHOS { using namespace OHOS::Location; @@ -99,7 +98,6 @@ bool PassiveAbility001FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(PassiveInterfaceCode::SEND_LOCATION_REQUEST), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -117,7 +115,6 @@ bool PassiveAbility002FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(PassiveInterfaceCode::SET_ENABLE), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -135,7 +132,6 @@ bool PassiveAbility003FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(PassiveInterfaceCode::ENABLE_LOCATION_MOCK), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -153,7 +149,6 @@ bool PassiveAbility004FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(PassiveInterfaceCode::DISABLE_LOCATION_MOCK), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } @@ -171,7 +166,6 @@ bool PassiveAbility005FuzzTest(const char* data, size_t size) ability->OnRemoteRequest(static_cast(PassiveInterfaceCode::SET_MOCKED_LOCATIONS), requestParcel, reply, option); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); - WorkRecordStatistic::DestroyInstance(); return true; } #endif diff --git a/test/fuzztest/locator/passiveabilityproxy_fuzzer/passiveabilityproxy_fuzzer.cpp b/test/fuzztest/locator/passiveabilityproxy_fuzzer/passiveabilityproxy_fuzzer.cpp index e4a5f7e4..55cdaf03 100644 --- a/test/fuzztest/locator/passiveabilityproxy_fuzzer/passiveabilityproxy_fuzzer.cpp +++ b/test/fuzztest/locator/passiveabilityproxy_fuzzer/passiveabilityproxy_fuzzer.cpp @@ -31,7 +31,6 @@ #include "passive_ability_proxy.h" #endif #include "permission_manager.h" -#include "work_record_statistic.h" namespace OHOS { using namespace OHOS::Location; @@ -77,7 +76,6 @@ bool PassiveAbility001FuzzTest(const uint8_t* data, size_t size) proxy->DisableMock(); std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES)); proxy->SetMocked(data[index++], locations); - WorkRecordStatistic::DestroyInstance(); return true; } #endif diff --git a/test/location_common/source/location_common_test.cpp b/test/location_common/source/location_common_test.cpp index 03420ade..bee70ab2 100644 --- a/test/location_common/source/location_common_test.cpp +++ b/test/location_common/source/location_common_test.cpp @@ -56,7 +56,6 @@ #endif #include "hook_utils.h" #include "hookmgr.h" -#include "work_record_statistic.h" #include "permission_manager.h" using namespace testing::ext; @@ -812,16 +811,6 @@ HWTEST_F(LocationCommonTest, HookUtils002, TestSize.Level1) LBSLOGI(LOCATOR, "[LocationCommonTest] HookUtils002 end"); } -HWTEST_F(LocationCommonTest, WorkRecordStatistic001, TestSize.Level1) -{ - GTEST_LOG_(INFO) - << "LocationCommonTest, WorkRecordStatistic001, TestSize.Level1"; - LBSLOGI(LOCATOR, "[LocationCommonTest] WorkRecordStatistic001 begin"); - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - workRecordStatistic->Update("network", 1); - LBSLOGI(LOCATOR, "[LocationCommonTest] WorkRecordStatistic001 end"); -} - HWTEST_F(LocationCommonTest, Request001, TestSize.Level1) { GTEST_LOG_(INFO) diff --git a/test/location_locator/include/work_record_test.h b/test/location_locator/include/work_record_test.h index e0e02583..d870de45 100644 --- a/test/location_locator/include/work_record_test.h +++ b/test/location_locator/include/work_record_test.h @@ -19,7 +19,6 @@ #include #include "work_record.h" -#include "work_record_statistic.h" namespace OHOS { namespace Location { diff --git a/test/location_locator/source/work_record_test.cpp b/test/location_locator/source/work_record_test.cpp index 1347d230..d2fe2238 100644 --- a/test/location_locator/source/work_record_test.cpp +++ b/test/location_locator/source/work_record_test.cpp @@ -300,46 +300,5 @@ HWTEST_F(WorkRecordTest, GetTimeInterval001, TestSize.Level1) EXPECT_EQ("", workrecord->GetUuid(-1)); LBSLOGI(LOCATOR, "[WorkRecordTest] GetTimeInterval001 end"); } - -HWTEST_F(WorkRecordTest, WorkRecordStatistic001, TestSize.Level1) -{ - GTEST_LOG_(INFO) - << "WorkRecordTest, WorkRecordStatistic001, TestSize.Level1"; - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic001 begin"); - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - workRecordStatistic->Update("network", 1); - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic001 end"); -} - -HWTEST_F(WorkRecordTest, WorkRecordStatistic002, TestSize.Level1) -{ - GTEST_LOG_(INFO) - << "WorkRecordTest, WorkRecordStatistic002, TestSize.Level1"; - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic002 begin"); - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - workRecordStatistic->Update("network", 0); - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic002 end"); -} - -HWTEST_F(WorkRecordTest, WorkRecordStatistic003, TestSize.Level1) -{ - GTEST_LOG_(INFO) - << "WorkRecordTest, WorkRecordStatistic003, TestSize.Level1"; - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic003 begin"); - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - workRecordStatistic->DestroyInstance(); - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic003 end"); -} - -HWTEST_F(WorkRecordTest, WorkRecordStatistic004, TestSize.Level1) -{ - GTEST_LOG_(INFO) - << "WorkRecordTest, WorkRecordStatistic004, TestSize.Level1"; - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic004 begin"); - auto workRecordStatistic = WorkRecordStatistic::GetInstance(); - workRecordStatistic->location_working_state_ = WORKING_STATE; - workRecordStatistic->UpdateLocationWorkingState(); - LBSLOGI(LOCATOR, "[WorkRecordTest] WorkRecordStatistic004 end"); -} } // namespace Location } // namespace OHOS \ No newline at end of file diff --git a/test/location_manager/source/locator_ability_test.cpp b/test/location_manager/source/locator_ability_test.cpp index aef97a80..20563fde 100644 --- a/test/location_manager/source/locator_ability_test.cpp +++ b/test/location_manager/source/locator_ability_test.cpp @@ -535,8 +535,6 @@ HWTEST_F(LocatorAbilityTest, LocatorAbilityUpdateLastLocationRequestNum001, Test LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateLastLocationRequestNum001 begin"); auto locatorAbility = sptr(new (std::nothrow) LocatorAbility()); - locatorAbility->UpdateLastLocationRequestNum(); - locatorAbility->UpdateLastLocationRequestNum(); locatorAbility->locatorHandler_->TaskCancelAndWait(); LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateLastLocationRequestNum001 end"); } @@ -771,7 +769,6 @@ HWTEST_F(LocatorAbilityTest, LocatorHandlerUpdateLastLocationRequestNum001, Test int state = 1; AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state); - locatorHandler->UpdateLastLocationRequestNum(event); LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateLastLocationRequestNum001 end"); }