mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-27 10:50:41 +00:00
fix Self-control mechanism transtype 9
Signed-off-by: wang_mingxu <wangmingxu9@huawei.com>
This commit is contained in:
parent
7ce6cd1463
commit
2674344b43
@ -40,8 +40,10 @@ typedef struct {
|
||||
uint32_t activeHml;
|
||||
int32_t passiveHml;
|
||||
int32_t rawHml;
|
||||
int32_t powerPid;
|
||||
bool isDisableLowPower;
|
||||
bool isDifferentPid;
|
||||
bool isChangedPid;
|
||||
LaneTransType transType;
|
||||
} PowerControlInfo;
|
||||
|
||||
@ -132,7 +134,7 @@ void LaneAddP2pAddress(const char *networkId, const char *ipAddr, uint16_t port)
|
||||
|
||||
void LaneAddP2pAddressByIp(const char *ipAddr, uint16_t port);
|
||||
void LaneUpdateP2pAddressByIp(const char *ipAddr, const char *networkId);
|
||||
void DetectEnableWifiDirectApply(PowerControlInfo powerInfo);
|
||||
void DetectEnableWifiDirectApply(PowerControlInfo *powerInfo);
|
||||
void DetectDisableWifiDirectApply(void);
|
||||
|
||||
int32_t FindLaneResourceByLinkAddr(const LaneLinkInfo *info, LaneResource *resource);
|
||||
|
@ -268,6 +268,9 @@ static void SetLanePowerStatus(bool status)
|
||||
static void HandleDetectWifiDirectApply(PowerControlInfo *powerInfo, WifiDirectLinkInfo *wifiDirectInfo)
|
||||
{
|
||||
if (powerInfo->isDisableLowPower) {
|
||||
if (powerInfo->transType == LANE_T_BYTE || powerInfo->transType == LANE_T_MSG) {
|
||||
powerInfo->isChangedPid = true;
|
||||
}
|
||||
DisablePowerControl(wifiDirectInfo);
|
||||
SetLanePowerStatus(false);
|
||||
} else if ((powerInfo->activeHml >= 1) && (powerInfo->passiveHml == 0) && (powerInfo->rawHml == 0)
|
||||
@ -281,6 +284,8 @@ static void HandleDetectWifiDirectApply(PowerControlInfo *powerInfo, WifiDirect
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "enable fail, ret=%{public}d", ret);
|
||||
SetLanePowerStatus(false);
|
||||
} else {
|
||||
powerInfo->isChangedPid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,7 +332,7 @@ void DetectDisableWifiDirectApply(void)
|
||||
HandleDetectWifiDirectApply(&powerInfo, &wifiDirectInfo);
|
||||
}
|
||||
|
||||
void DetectEnableWifiDirectApply(PowerControlInfo powerInfo)
|
||||
void DetectEnableWifiDirectApply(PowerControlInfo *powerInfo)
|
||||
{
|
||||
WifiDirectLinkInfo wifiDirectInfo;
|
||||
(void)memset_s(&wifiDirectInfo, sizeof(wifiDirectInfo), 0, sizeof(wifiDirectInfo));
|
||||
@ -341,10 +346,10 @@ void DetectEnableWifiDirectApply(PowerControlInfo powerInfo)
|
||||
LNN_LOGI(LNN_LANE, "link.type=%{public}d, link.bw=%{public}d", item->link.type, item->link.linkInfo.p2p.bw);
|
||||
if (item->link.type == LANE_HML) {
|
||||
if (item->clientRef > 0) {
|
||||
powerInfo.activeHml += item->clientRef;
|
||||
powerInfo->activeHml++;
|
||||
}
|
||||
if (item->isServerSide) {
|
||||
powerInfo.passiveHml++;
|
||||
powerInfo->passiveHml++;
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo, item->link.linkInfo.p2p.bw);
|
||||
}
|
||||
if (item->link.linkInfo.p2p.bw == LANE_BW_160M || item->link.linkInfo.p2p.bw == LANE_BW_80P80M) {
|
||||
@ -352,20 +357,25 @@ void DetectEnableWifiDirectApply(PowerControlInfo powerInfo)
|
||||
}
|
||||
}
|
||||
if (item->link.type == LANE_HML_RAW) {
|
||||
powerInfo.rawHml++;
|
||||
powerInfo->rawHml++;
|
||||
}
|
||||
}
|
||||
if (powerInfo.isDifferentPid == false && powerInfo.activeHml > ISHARE_SESSION_NUM) {
|
||||
if (powerInfo.isDifferentPid == true && g_enabledLowPower) {
|
||||
powerInfo.isDisableLowPower = true;
|
||||
}
|
||||
if ((powerInfo.isDifferentPid == true || powerInfo.passiveHml > 0 ||
|
||||
powerInfo.rawHml > 0) && g_enabledLowPower) {
|
||||
if (powerInfo->isDifferentPid == true && !g_enabledLowPower) {
|
||||
powerInfo->isDisableLowPower = false;
|
||||
}
|
||||
if (powerInfo->isDifferentPid == false && !g_enabledLowPower && powerInfo->activeHml > 1) {
|
||||
powerInfo->isDisableLowPower = true;
|
||||
}
|
||||
if ((powerInfo.passiveHml > 0 || powerInfo.rawHml > 0) && g_enabledLowPower) {
|
||||
powerInfo.isDisableLowPower = true;
|
||||
}
|
||||
LaneUnlock();
|
||||
LNN_LOGI(LNN_LANE, "activeHml=%{public}d, passiveHml=%{public}d, rawHml=%{public}d, isDisableLowPower=%{public}d",
|
||||
powerInfo.activeHml, powerInfo.passiveHml, powerInfo.rawHml, powerInfo.isDisableLowPower);
|
||||
HandleDetectWifiDirectApply(&powerInfo, &wifiDirectInfo);
|
||||
powerInfo->activeHml, powerInfo->passiveHml, powerInfo->rawHml, powerInfo->isDisableLowPower);
|
||||
HandleDetectWifiDirectApply(powerInfo, &wifiDirectInfo);
|
||||
}
|
||||
|
||||
static int32_t CreateNewLaneResource(const LaneLinkInfo *linkInfo, uint64_t laneId, bool isServerSide)
|
||||
|
@ -134,6 +134,16 @@ static void Unlock(void)
|
||||
(void)SoftBusMutexUnlock(&g_transLaneMutex);
|
||||
}
|
||||
|
||||
static void SetPowerPidStatus(int32_t powerPid)
|
||||
{
|
||||
if (Lock() != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get lock fail");
|
||||
return;
|
||||
}
|
||||
g_powerPid = powerPid;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
static int32_t LnnLanePostMsgToHandler(int32_t msgType, uint64_t param1, uint64_t param2,
|
||||
void *obj, uint64_t delayMillis)
|
||||
{
|
||||
@ -829,6 +839,7 @@ static int32_t FreeLaneLink(uint32_t laneReqId, uint64_t laneId)
|
||||
}
|
||||
LNN_LOGE(LNN_LANE, "get networkId fail");
|
||||
}
|
||||
SetPowerPidStatus(0);
|
||||
return DestroyLink(networkId, laneReqId, resourceItem.link.type);
|
||||
}
|
||||
|
||||
@ -1351,12 +1362,15 @@ void ProcessPowerControlInfoByLaneReqId(const LaneLinkType linkType, uint32_t la
|
||||
} else {
|
||||
powerInfo.isDifferentPid = true;
|
||||
}
|
||||
g_powerPid = item->allocInfo.pid;
|
||||
powerInfo.powerPid = item->allocInfo.pid;
|
||||
}
|
||||
}
|
||||
Unlock();
|
||||
if (linkType == LANE_HML && IsPowerControlEnabled()) {
|
||||
DetectEnableWifiDirectApply(powerInfo);
|
||||
DetectEnableWifiDirectApply(&powerInfo);
|
||||
}
|
||||
if (powerInfo.isChangedPid == true) {
|
||||
SetPowerPidStatus(powerInfo.powerPid)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ int32_t CheckLaneResourceNumByLinkType(const char *peerUdid, LaneLinkType type,
|
||||
return GetTransLaneIf()->CheckLaneResourceNumByLinkType(peerUdid, type, laneNum);
|
||||
}
|
||||
|
||||
void DetectEnableWifiDirectApply(PowerControlInfo powerInfo)
|
||||
void DetectEnableWifiDirectApply(PowerControlInfo *powerInfo)
|
||||
{
|
||||
return GetTransLaneIf()->DetectEnableWifiDirectApply(powerInfo);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
virtual int32_t LaneCapCheck(const char *networkId, LaneLinkType linkType) = 0;
|
||||
virtual int32_t GetErrCodeOfLink(const char *networkId, LaneLinkType linkType) = 0;
|
||||
virtual int32_t CheckLaneResourceNumByLinkType(const char *peerUdid, LaneLinkType type, int32_t *laneNum) = 0;
|
||||
virtual void DetectEnableWifiDirectApply(PowerControlInfo powerInfo) = 0;
|
||||
virtual void DetectEnableWifiDirectApply(PowerControlInfo *powerInfo) = 0;
|
||||
};
|
||||
|
||||
class TransLaneDepsInterfaceMock : public TransLaneDepsInterface {
|
||||
@ -80,7 +80,7 @@ public:
|
||||
MOCK_METHOD2(LaneCapCheck, int32_t (const char *networkId, LaneLinkType linkType));
|
||||
MOCK_METHOD2(GetErrCodeOfLink, int32_t (const char *networkId, LaneLinkType linkType));
|
||||
MOCK_METHOD3(CheckLaneResourceNumByLinkType, int32_t (const char *peerUdid, LaneLinkType type, int32_t *laneNum));
|
||||
MOCK_METHOD1(DetectEnableWifiDirectApply, void (PowerControlInfo powerInfo));
|
||||
MOCK_METHOD1(DetectEnableWifiDirectApply, void (PowerControlInfo *powerInfo));
|
||||
|
||||
static int32_t ActionOfLaneLinkSuccess(const LinkRequest *reqInfo, uint32_t reqId, const LaneLinkCb *cb);
|
||||
static int32_t ActionOfLaneLinkFail(const LinkRequest *reqInfo, uint32_t reqId, const LaneLinkCb *cb);
|
||||
|
Loading…
Reference in New Issue
Block a user