[630][adas] 修复处于PING状态时,无法停止PING问题
This commit is contained in:
@@ -155,7 +155,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartFindIP() {
|
||||
public void onStartFindAddress() {
|
||||
updateConnectStatus(AdasConstants.IpcConnectionStatus.SEARCH_ADDRESS);
|
||||
}
|
||||
|
||||
@@ -165,11 +165,8 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopFindIP(boolean isCall) {
|
||||
pingAddressHelper = null;
|
||||
if (isCall) {
|
||||
updateConnectStatus(AdasConstants.IpcConnectionStatus.DISCONNECTED);
|
||||
}
|
||||
public void onStopFindAddress() {
|
||||
stopPingAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +175,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
* @param ip 返回可用IP 当为null时表示无可用IP
|
||||
*/
|
||||
@Override
|
||||
public void onAvailableIP(String ip) {
|
||||
public void onAvailableAddress(String ip) {
|
||||
if (TextUtils.isEmpty(ip)) {
|
||||
updateConnectStatus(AdasConstants.IpcConnectionStatus.NOT_FOUND_ADDRESS);
|
||||
} else {
|
||||
@@ -342,9 +339,9 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
pingAddressHelper.setReconnectCount(adasOptions.getReconnectCount());
|
||||
}
|
||||
|
||||
private void stopPingAddress(boolean isCall) {
|
||||
private void stopPingAddress() {
|
||||
if (pingAddressHelper != null) {
|
||||
pingAddressHelper.stop(isCall);
|
||||
pingAddressHelper.stop();
|
||||
pingAddressHelper = null;
|
||||
}
|
||||
}
|
||||
@@ -701,7 +698,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
|
||||
public void disconnect(boolean isCertificationFailed) {
|
||||
stopPingAddress(true);
|
||||
stopPingAddress();
|
||||
isInitConfigure.set(false);
|
||||
if (!adasOptions.isPassenger()) {
|
||||
if (mSocket != null)
|
||||
@@ -815,11 +812,10 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
*/
|
||||
private boolean connectFinish() {
|
||||
AdasConstants.IpcConnectionStatus status = getIpcConnectionStatus();
|
||||
CupidLogUtils.log(TAG, "连接状态=" + status + " 是否正在重连=" + mSocket.isReconnection());
|
||||
if (status == AdasConstants.IpcConnectionStatus.DISCONNECTED) {
|
||||
return true;
|
||||
} else {
|
||||
if (mSocket != null && mSocket.isReconnection()) {
|
||||
if ((mSocket != null && mSocket.isReconnection()) || (pingAddressHelper != null && pingAddressHelper.isNeedReconnect())) {
|
||||
return false;
|
||||
} else {
|
||||
return status == AdasConstants.IpcConnectionStatus.CONNECT_EXCEPTION ||
|
||||
@@ -847,6 +843,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
* @param args 状态描述
|
||||
*/
|
||||
private void callConnectStatus(AdasConstants.IpcConnectionStatus status, @Nullable Object... args) {
|
||||
CupidLogUtils.log(TAG, "连接状态=" + status + " 是否正在重连=" + mSocket.isReconnection());
|
||||
String reason = null;
|
||||
if (status == AdasConstants.IpcConnectionStatus.CONNECTED) { //连接成功
|
||||
if (args != null && args.length > 1) {
|
||||
@@ -883,7 +880,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
usedSsmSource = AdasConstants.SsmSource.SSM_UNKNOWN;
|
||||
receivedAckManager.stop();
|
||||
if (connectFinish()) {
|
||||
stopPingAddress(false);
|
||||
stopPingAddress();
|
||||
}
|
||||
if (args != null && args.length > 0) {
|
||||
reason = String.valueOf(args[0]);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PingAddressHelper {
|
||||
/**
|
||||
* 开始查找可用IP
|
||||
*/
|
||||
void onStartFindIP();
|
||||
void onStartFindAddress();
|
||||
|
||||
/**
|
||||
* 非法地址
|
||||
@@ -47,14 +47,14 @@ public class PingAddressHelper {
|
||||
/**
|
||||
* 主动停止
|
||||
*/
|
||||
void onStopFindIP(boolean isCall);
|
||||
void onStopFindAddress();
|
||||
|
||||
/**
|
||||
* 轮询结果可连通的IP
|
||||
*
|
||||
* @param ip 返回可用IP 当为null时表示无可用IP
|
||||
*/
|
||||
void onAvailableIP(String ip);
|
||||
void onAvailableAddress(String ip);
|
||||
}
|
||||
|
||||
public PingAddressHelper(@NonNull IPingAddressListener listener) {
|
||||
@@ -78,7 +78,7 @@ public class PingAddressHelper {
|
||||
return isEm;
|
||||
}
|
||||
|
||||
private boolean isNeedReconnect() {
|
||||
public boolean isNeedReconnect() {
|
||||
if (reconnectCount == -1) {
|
||||
return false;
|
||||
} else if (reconnectCount == 0) {
|
||||
@@ -88,14 +88,14 @@ public class PingAddressHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(boolean isCall) {
|
||||
public void stop() {
|
||||
if (retryTimer != null) {
|
||||
retryTimer.cancel();
|
||||
retryTimer = null;
|
||||
}
|
||||
isCallListener.set(true);
|
||||
if (!interrupted()) {
|
||||
listener.onStopFindIP(isCall);
|
||||
listener.onStopFindAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class PingAddressHelper {
|
||||
listener.onIllegalAddress();
|
||||
} else {
|
||||
currentCount++;
|
||||
listener.onStartFindIP();
|
||||
listener.onStartFindAddress();
|
||||
if (retryTimer != null) {
|
||||
retryTimer.cancel();
|
||||
retryTimer = null;
|
||||
@@ -130,7 +130,7 @@ public class PingAddressHelper {
|
||||
if (isAvailable) {
|
||||
if (!isCallListener.get() && !Thread.currentThread().isInterrupted()) {
|
||||
isCallListener.set(true);
|
||||
listener.onAvailableIP(temp);
|
||||
listener.onAvailableAddress(temp);
|
||||
CupidLogUtils.i(TAG, "可用IP=" + temp);
|
||||
interrupted();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class PingAddressHelper {
|
||||
if (queryCount == unavailableCount.incrementAndGet()) {
|
||||
if (!isCallListener.get()) {
|
||||
isCallListener.set(true);
|
||||
listener.onAvailableIP(null);
|
||||
listener.onAvailableAddress(null);
|
||||
CupidLogUtils.i(TAG, "所有IP均不可用");
|
||||
if (isNeedReconnect()) {
|
||||
//当配置中的所有IP都ping不通时,需要继续ping
|
||||
@@ -168,7 +168,7 @@ public class PingAddressHelper {
|
||||
}, 4 * 1000L);//延时
|
||||
}
|
||||
} else {
|
||||
stop(false);
|
||||
stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user