mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-11-23 15:10:16 +00:00
更换定时器
Signed-off-by: Wuhongbo <wuhongbo7@h-partners.com>
This commit is contained in:
parent
b8547624eb
commit
c40d99153b
@ -44,17 +44,21 @@ IApServiceCallbacks& WifiHotspotManager::GetApCallback()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef OHOS_ARCH_LITE
|
#ifndef OHOS_ARCH_LITE
|
||||||
void WifiHotspotManager::UnloadHotspotSaTimerCallback()
|
static void UnloadHotspotSaTimerCallback()
|
||||||
{
|
{
|
||||||
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_HOTSPOT_ABILITY_ID);
|
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_HOTSPOT_ABILITY_ID);
|
||||||
StopUnloadApSaTimer();
|
WifiManager::GetInstance().GetWifiHotspotManager()->StopUnloadApSaTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WifiHotspotManager::StopUnloadApSaTimer(void)
|
void WifiHotspotManager::StopUnloadApSaTimer(void)
|
||||||
{
|
{
|
||||||
WIFI_LOGI("StopUnloadApSaTimer! unloadHotspotSaTimerId:%{public}u", unloadHotspotSaTimerId);
|
WIFI_LOGI("StopUnloadApSaTimer! unloadHotspotSaTimerId:%{public}u", unloadHotspotSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadHotspotSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadHotspotSaTimerMutex);
|
||||||
WifiTimer::GetInstance()->UnRegister(unloadHotspotSaTimerId);
|
if (unloadHotspotSaTimerId == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StopTimer(unloadHotspotSaTimerId);
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->DestroyTimer(unloadHotspotSaTimerId);
|
||||||
unloadHotspotSaTimerId = 0;
|
unloadHotspotSaTimerId = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,8 +68,12 @@ void WifiHotspotManager::StartUnloadApSaTimer(void)
|
|||||||
WIFI_LOGI("StartUnloadApSaTimer! unloadHotspotSaTimerId:%{public}u", unloadHotspotSaTimerId);
|
WIFI_LOGI("StartUnloadApSaTimer! unloadHotspotSaTimerId:%{public}u", unloadHotspotSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadHotspotSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadHotspotSaTimerMutex);
|
||||||
if (unloadHotspotSaTimerId == 0) {
|
if (unloadHotspotSaTimerId == 0) {
|
||||||
WifiTimer::TimerCallback timeoutCallback = std::bind(&WifiHotspotManager::UnloadHotspotSaTimerCallback, this);
|
std::shared_ptr<WifiSysTimer> wifiSysTimer = std::make_shared<WifiSysTimer>(false, 0, true, false);
|
||||||
WifiTimer::GetInstance()->Register(timeoutCallback, unloadHotspotSaTimerId, TIMEOUT_UNLOAD_WIFI_SA);
|
wifiSysTimer->SetCallbackInfo(UnloadHotspotSaTimerCallback);
|
||||||
|
unloadHotspotSaTimerId = MiscServices::TimeServiceClient::GetInstance()->CreateTimer(wifiSysTimer);
|
||||||
|
int64_t currentTime = MiscServices::TimeServiceClient::GetInstance()->GetWallTimeMs();
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StartTimer(unloadHotspotSaTimerId,
|
||||||
|
currentTime + TIMEOUT_UNLOAD_WIFI_SA);
|
||||||
WIFI_LOGI("RegisterUnloadHotspotSaTimer success! unloadHotspotSaTimerId:%{public}u", unloadHotspotSaTimerId);
|
WIFI_LOGI("RegisterUnloadHotspotSaTimer success! unloadHotspotSaTimerId:%{public}u", unloadHotspotSaTimerId);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -37,7 +37,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void InitApCallback(void);
|
void InitApCallback(void);
|
||||||
void UnloadHotspotSaTimerCallback();
|
|
||||||
void DealApStateChanged(ApState bState, int id = 0);
|
void DealApStateChanged(ApState bState, int id = 0);
|
||||||
void DealApGetStaJoin(const StationInfo &info, int id = 0);
|
void DealApGetStaJoin(const StationInfo &info, int id = 0);
|
||||||
void DealApGetStaLeave(const StationInfo &info, int id = 0);
|
void DealApGetStaLeave(const StationInfo &info, int id = 0);
|
||||||
|
@ -130,17 +130,21 @@ ErrCode WifiP2pManager::AutoStopP2pService()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef OHOS_ARCH_LITE
|
#ifndef OHOS_ARCH_LITE
|
||||||
void WifiP2pManager::UnloadP2PSaTimerCallback()
|
static void UnloadP2PSaTimerCallback()
|
||||||
{
|
{
|
||||||
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_P2P_ABILITY_ID);
|
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_P2P_ABILITY_ID);
|
||||||
StopUnloadP2PSaTimer();
|
WifiManager::GetInstance().GetWifiP2pManager()->StopUnloadP2PSaTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WifiP2pManager::StopUnloadP2PSaTimer(void)
|
void WifiP2pManager::StopUnloadP2PSaTimer(void)
|
||||||
{
|
{
|
||||||
WIFI_LOGI("StopUnloadP2PSaTimer! unloadP2PSaTimerId:%{public}u", unloadP2PSaTimerId);
|
WIFI_LOGI("StopUnloadP2PSaTimer! unloadP2PSaTimerId:%{public}u", unloadP2PSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadP2PSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadP2PSaTimerMutex);
|
||||||
WifiTimer::GetInstance()->UnRegister(unloadP2PSaTimerId);
|
if (unloadP2PSaTimerId == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StopTimer(unloadP2PSaTimerId);
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->DestroyTimer(unloadP2PSaTimerId);
|
||||||
unloadP2PSaTimerId = 0;
|
unloadP2PSaTimerId = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -150,8 +154,12 @@ void WifiP2pManager::StartUnloadP2PSaTimer(void)
|
|||||||
WIFI_LOGI("StartUnloadP2PSaTimer! unloadP2PSaTimerId:%{public}u", unloadP2PSaTimerId);
|
WIFI_LOGI("StartUnloadP2PSaTimer! unloadP2PSaTimerId:%{public}u", unloadP2PSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadP2PSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadP2PSaTimerMutex);
|
||||||
if (unloadP2PSaTimerId == 0) {
|
if (unloadP2PSaTimerId == 0) {
|
||||||
WifiTimer::TimerCallback timeoutCallback = std::bind(&WifiP2pManager::UnloadP2PSaTimerCallback, this);
|
std::shared_ptr<WifiSysTimer> wifiSysTimer = std::make_shared<WifiSysTimer>(false, 0, true, false);
|
||||||
WifiTimer::GetInstance()->Register(timeoutCallback, unloadP2PSaTimerId, TIMEOUT_UNLOAD_WIFI_SA);
|
wifiSysTimer->SetCallbackInfo(UnloadP2PSaTimerCallback);
|
||||||
|
unloadP2PSaTimerId = MiscServices::TimeServiceClient::GetInstance()->CreateTimer(wifiSysTimer);
|
||||||
|
int64_t currentTime = MiscServices::TimeServiceClient::GetInstance()->GetWallTimeMs();
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StartTimer(unloadP2PSaTimerId,
|
||||||
|
currentTime + TIMEOUT_UNLOAD_WIFI_SA);
|
||||||
WIFI_LOGI("StartUnloadP2PSaTimer success! unloadP2PSaTimerId:%{public}u", unloadP2PSaTimerId);
|
WIFI_LOGI("StartUnloadP2PSaTimer success! unloadP2PSaTimerId:%{public}u", unloadP2PSaTimerId);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -39,7 +39,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void InitP2pCallback(void);
|
void InitP2pCallback(void);
|
||||||
void UnloadP2PSaTimerCallback();
|
|
||||||
void DealP2pStateChanged(P2pState bState);
|
void DealP2pStateChanged(P2pState bState);
|
||||||
void DealP2pPeersChanged(const std::vector<WifiP2pDevice> &vPeers);
|
void DealP2pPeersChanged(const std::vector<WifiP2pDevice> &vPeers);
|
||||||
void DealP2pServiceChanged(const std::vector<WifiP2pServiceInfo> &vServices);
|
void DealP2pServiceChanged(const std::vector<WifiP2pServiceInfo> &vServices);
|
||||||
|
@ -44,17 +44,21 @@ IScanSerivceCallbacks& WifiScanManager::GetScanCallback()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef OHOS_ARCH_LITE
|
#ifndef OHOS_ARCH_LITE
|
||||||
void WifiScanManager::UnloadScanSaTimerCallback()
|
static void UnloadScanSaTimerCallback()
|
||||||
{
|
{
|
||||||
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_SCAN_ABILITY_ID);
|
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_SCAN_ABILITY_ID);
|
||||||
StopUnloadScanSaTimer();
|
WifiManager::GetInstance().GetWifiScanManager()->StopUnloadScanSaTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WifiScanManager::StopUnloadScanSaTimer(void)
|
void WifiScanManager::StopUnloadScanSaTimer(void)
|
||||||
{
|
{
|
||||||
WIFI_LOGI("StopUnloadScanSaTimer! unloadScanSaTimerId:%{public}u", unloadScanSaTimerId);
|
WIFI_LOGI("StopUnloadScanSaTimer! unloadScanSaTimerId:%{public}u", unloadScanSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadScanSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadScanSaTimerMutex);
|
||||||
WifiTimer::GetInstance()->UnRegister(unloadScanSaTimerId);
|
if (unloadScanSaTimerId == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StopTimer(unloadScanSaTimerId);
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->DestroyTimer(unloadScanSaTimerId);
|
||||||
unloadScanSaTimerId = 0;
|
unloadScanSaTimerId = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,8 +68,12 @@ void WifiScanManager::StartUnloadScanSaTimer(void)
|
|||||||
WIFI_LOGI("StartUnloadScanSaTimer! unloadScanSaTimerId:%{public}u", unloadScanSaTimerId);
|
WIFI_LOGI("StartUnloadScanSaTimer! unloadScanSaTimerId:%{public}u", unloadScanSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadScanSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadScanSaTimerMutex);
|
||||||
if (unloadScanSaTimerId == 0) {
|
if (unloadScanSaTimerId == 0) {
|
||||||
WifiTimer::TimerCallback timeoutCallback = std::bind(&WifiScanManager::UnloadScanSaTimerCallback, this);
|
std::shared_ptr<WifiSysTimer> wifiSysTimer = std::make_shared<WifiSysTimer>(false, 0, true, false);
|
||||||
WifiTimer::GetInstance()->Register(timeoutCallback, unloadScanSaTimerId, TIMEOUT_UNLOAD_WIFI_SA);
|
wifiSysTimer->SetCallbackInfo(UnloadScanSaTimerCallback);
|
||||||
|
unloadScanSaTimerId = MiscServices::TimeServiceClient::GetInstance()->CreateTimer(wifiSysTimer);
|
||||||
|
int64_t currentTime = MiscServices::TimeServiceClient::GetInstance()->GetWallTimeMs();
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StartTimer(unloadScanSaTimerId,
|
||||||
|
currentTime + TIMEOUT_UNLOAD_WIFI_SA);
|
||||||
WIFI_LOGI("StartUnloadScanSaTimer success! unloadScanSaTimerId:%{public}u", unloadScanSaTimerId);
|
WIFI_LOGI("StartUnloadScanSaTimer success! unloadScanSaTimerId:%{public}u", unloadScanSaTimerId);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -38,7 +38,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void InitScanCallback(void);
|
void InitScanCallback(void);
|
||||||
void UnloadScanSaTimerCallback();
|
|
||||||
void DealScanOpenRes(int instId = 0);
|
void DealScanOpenRes(int instId = 0);
|
||||||
void DealScanCloseRes(int instId = 0);
|
void DealScanCloseRes(int instId = 0);
|
||||||
void DealScanFinished(int state, int instId = 0);
|
void DealScanFinished(int state, int instId = 0);
|
||||||
|
@ -45,17 +45,21 @@ StaServiceCallback& WifiStaManager::GetStaCallback()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef OHOS_ARCH_LITE
|
#ifndef OHOS_ARCH_LITE
|
||||||
void WifiStaManager::UnloadStaSaTimerCallback()
|
static void UnloadStaSaTimerCallback()
|
||||||
{
|
{
|
||||||
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_DEVICE_ABILITY_ID);
|
WifiSaLoadManager::GetInstance().UnloadWifiSa(WIFI_DEVICE_ABILITY_ID);
|
||||||
StopUnloadStaSaTimer();
|
WifiManager::GetInstance().GetWifiStaManager()->StopUnloadStaSaTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WifiStaManager::StopUnloadStaSaTimer(void)
|
void WifiStaManager::StopUnloadStaSaTimer(void)
|
||||||
{
|
{
|
||||||
WIFI_LOGI("StopUnloadStaSaTimer! unloadStaSaTimerId:%{public}u", unloadStaSaTimerId);
|
WIFI_LOGI("StopUnloadStaSaTimer! unloadStaSaTimerId:%{public}u", unloadStaSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadStaSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadStaSaTimerMutex);
|
||||||
WifiTimer::GetInstance()->UnRegister(unloadStaSaTimerId);
|
if (unloadStaSaTimerId == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StopTimer(unloadStaSaTimerId);
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->DestroyTimer(unloadStaSaTimerId);
|
||||||
unloadStaSaTimerId = 0;
|
unloadStaSaTimerId = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -65,8 +69,12 @@ void WifiStaManager::StartUnloadStaSaTimer(void)
|
|||||||
WIFI_LOGI("StartUnloadStaSaTimer! unloadStaSaTimerId:%{public}u", unloadStaSaTimerId);
|
WIFI_LOGI("StartUnloadStaSaTimer! unloadStaSaTimerId:%{public}u", unloadStaSaTimerId);
|
||||||
std::unique_lock<std::mutex> lock(unloadStaSaTimerMutex);
|
std::unique_lock<std::mutex> lock(unloadStaSaTimerMutex);
|
||||||
if (unloadStaSaTimerId == 0) {
|
if (unloadStaSaTimerId == 0) {
|
||||||
WifiTimer::TimerCallback timeoutCallback = std::bind(&WifiStaManager::UnloadStaSaTimerCallback, this);
|
std::shared_ptr<WifiSysTimer> wifiSysTimer = std::make_shared<WifiSysTimer>(false, 0, true, false);
|
||||||
WifiTimer::GetInstance()->Register(timeoutCallback, unloadStaSaTimerId, TIMEOUT_UNLOAD_WIFI_SA);
|
wifiSysTimer->SetCallbackInfo(UnloadStaSaTimerCallback);
|
||||||
|
unloadStaSaTimerId = MiscServices::TimeServiceClient::GetInstance()->CreateTimer(wifiSysTimer);
|
||||||
|
int64_t currentTime = MiscServices::TimeServiceClient::GetInstance()->GetWallTimeMs();
|
||||||
|
MiscServices::TimeServiceClient::GetInstance()->StartTimer(unloadStaSaTimerId,
|
||||||
|
currentTime + TIMEOUT_UNLOAD_WIFI_SA);
|
||||||
WIFI_LOGI("StartUnloadStaSaTimer success! unloadStaSaTimerId:%{public}u", unloadStaSaTimerId);
|
WIFI_LOGI("StartUnloadStaSaTimer success! unloadStaSaTimerId:%{public}u", unloadStaSaTimerId);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -37,7 +37,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void InitStaCallback(void);
|
void InitStaCallback(void);
|
||||||
void ForceStopWifi(int instId = 0);
|
void ForceStopWifi(int instId = 0);
|
||||||
void UnloadStaSaTimerCallback();
|
|
||||||
void DealStaOpenRes(OperateResState state, int instId = 0);
|
void DealStaOpenRes(OperateResState state, int instId = 0);
|
||||||
void DealStaCloseRes(OperateResState state, int instId = 0);
|
void DealStaCloseRes(OperateResState state, int instId = 0);
|
||||||
void DealStaConnChanged(OperateResState state, const WifiLinkedInfo &info, int instId = 0);
|
void DealStaConnChanged(OperateResState state, const WifiLinkedInfo &info, int instId = 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user