Signed-off-by: 李文龙 <liwenlong22@huawei.com>
This commit is contained in:
李文龙 2024-10-31 14:28:39 +08:00
parent 56fd05458d
commit a20a6327e6
17 changed files with 0 additions and 269 deletions

View File

@ -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",

View File

@ -24,7 +24,6 @@
"*ExecuteHookWhenAddWorkRecord*";
"*LOCATOR_SA_LOCATION_PERMISSION_CHECK*";
"*ExecuteHookWhenCheckAppForCacheTime*";
"*WorkRecordStatistic*";
local:
*;
};

View File

@ -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> WorkRecordStatistic::instance_ = nullptr;
std::mutex WorkRecordStatistic::workRecordStatisticMutex_;
const uint32_t WORKING_STATE = 1;
const uint32_t NO_WORKING_STATE = 0;
std::shared_ptr<WorkRecordStatistic> WorkRecordStatistic::GetInstance()
{
if (instance_ == nullptr) {
std::unique_lock<std::mutex> lock(workRecordStatisticMutex_);
if (instance_ == nullptr) {
std::shared_ptr<WorkRecordStatistic> workRecordStatistic = std::make_shared<WorkRecordStatistic>();
instance_ = workRecordStatistic;
}
}
return instance_;
}
void WorkRecordStatistic::DestroyInstance()
{
std::unique_lock<std::mutex> lock(workRecordStatisticMutex_);
if (instance_ != nullptr) {
instance_ = nullptr;
}
}
bool WorkRecordStatistic::Update(std::string name, int requestNum)
{
std::unique_lock<std::mutex> 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

View File

@ -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 <mutex>
#include <string>
#include <map>
namespace OHOS {
namespace Location {
class WorkRecordStatistic {
public:
static std::shared_ptr<WorkRecordStatistic> GetInstance();
static void DestroyInstance();
bool Update(std::string name, int requestNum);
private:
bool UpdateLocationWorkingState();
std::map<std::string, int> workRecordStatisticMap_;
static std::shared_ptr<WorkRecordStatistic> instance_;
int location_working_state_ = 0;
std::mutex mutex_;
static std::mutex workRecordStatisticMutex_;
};
} // namespace Location
} // namespace OHOS
#endif // WORK_RECORD_STATISTIC_H

View File

@ -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<CoordinateSystemType>& coordinateSystemTypes);
LocationErrCode SendNetworkLocation(const std::unique_ptr<Location>& location);
#endif
void UpdateLastLocationRequestNum();
void SyncStillMovementState(bool stillState);
void SyncIdleState(bool stillState);
#ifdef FEATURE_GEOCODE_SUPPORT

View File

@ -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<Request>& 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<CoordinateSystemType>& 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<AppIdentity> identity = event->GetSharedObject<AppIdentity>();
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<int>(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<AppIdentity> identity = event->GetSharedObject<AppIdentity>();
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<int>(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();

View File

@ -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()

View File

@ -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<CoordinateSystemType> coordinateSystemTypes;
proxy->QuerySupportCoordinateSystemType(coordinateSystemTypes);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES));
WorkRecordStatistic::DestroyInstance();
return true;
}
#endif // FEATURE_GNSS_SUPPORT

View File

@ -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<uint32_t>(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<uint32_t>(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

View File

@ -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<NetworkAbility>(new (std::nothrow) NetworkAbility());
ability->OnRemoteRequest(static_cast<uint32_t>(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<NetworkAbility>(new (std::nothrow) NetworkAbility());
ability->OnRemoteRequest(static_cast<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(NetworkInterfaceCode::DISABLE_LOCATION_MOCK),
requestParcel, reply, option);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES));
WorkRecordStatistic::DestroyInstance();
return true;
}
#endif

View File

@ -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

View File

@ -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<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(PassiveInterfaceCode::SET_MOCKED_LOCATIONS),
requestParcel, reply, option);
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIMES));
WorkRecordStatistic::DestroyInstance();
return true;
}
#endif

View File

@ -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

View File

@ -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)

View File

@ -19,7 +19,6 @@
#include <gtest/gtest.h>
#include "work_record.h"
#include "work_record_statistic.h"
namespace OHOS {
namespace Location {

View File

@ -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

View File

@ -535,8 +535,6 @@ HWTEST_F(LocatorAbilityTest, LocatorAbilityUpdateLastLocationRequestNum001, Test
LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateLastLocationRequestNum001 begin");
auto locatorAbility =
sptr<LocatorAbility>(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");
}