Commit bb0bb01d authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Another attempt to have a network manager, this time going simple

parent 735ab95f
......@@ -510,14 +510,14 @@ public class AndroidPlatformHelper {
setNetworkReachable(mNativePtr, false);
return;
}
Network network = mNetworkManager.getActiveNetwork(mConnectivityManager);
Log.i("[Platform Helper] Active network type is " + networkInfo.getTypeName() + ", state " + networkInfo.getState() + " / " + networkInfo.getDetailedState());
if (networkInfo.getState() == NetworkInfo.State.DISCONNECTED && networkInfo.getDetailedState() == NetworkInfo.DetailedState.BLOCKED) {
Log.w("[Platform Helper] Active network is in bad state...");
}
// Update DNS servers lists
Network network = mNetworkManager.getActiveNetwork(mConnectivityManager);
storeDnsServers(network);
int currentNetworkType = networkInfo.getType();
......
......@@ -36,20 +36,24 @@ import org.linphone.core.tools.AndroidPlatformHelper;
*/
public class NetworkManagerAbove21 implements NetworkManagerInterface {
private AndroidPlatformHelper mHelper;
private boolean mIsNetworkAvailable;
private ConnectivityManager.NetworkCallback mNetworkCallback;
public NetworkManagerAbove21(final AndroidPlatformHelper helper) {
mHelper = helper;
mIsNetworkAvailable = false;
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 21] A network is available");
mIsNetworkAvailable = true;
mHelper.updateNetworkReachability();
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 21] A network has been lost");
mIsNetworkAvailable = false;
mHelper.updateNetworkReachability();
}
......@@ -96,7 +100,7 @@ public class NetworkManagerAbove21 implements NetworkManagerInterface {
}
public boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly) {
Network[] networks = connectivityManager.getAllNetworks();
/*Network[] networks = connectivityManager.getAllNetworks();
boolean connected = false;
for (Network network : networks) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
......@@ -114,8 +118,8 @@ public class NetworkManagerAbove21 implements NetworkManagerInterface {
}
}
}
}
return connected;
}*/
return mIsNetworkAvailable;
}
public boolean hasHttpProxy(Context context, ConnectivityManager connectivityManager) {
......
......@@ -36,20 +36,24 @@ import org.linphone.core.tools.AndroidPlatformHelper;
*/
public class NetworkManagerAbove23 implements NetworkManagerInterface {
private AndroidPlatformHelper mHelper;
private boolean mIsNetworkAvailable;
private ConnectivityManager.NetworkCallback mNetworkCallback;
public NetworkManagerAbove23(final AndroidPlatformHelper helper) {
mHelper = helper;
mIsNetworkAvailable = false;
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 23] A network is available");
mIsNetworkAvailable = true;
mHelper.updateNetworkReachability();
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 23] A network has been lost");
mIsNetworkAvailable = false;
mHelper.updateNetworkReachability();
}
......@@ -101,7 +105,7 @@ public class NetworkManagerAbove23 implements NetworkManagerInterface {
}
public boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly) {
Network[] networks = connectivityManager.getAllNetworks();
/*Network[] networks = connectivityManager.getAllNetworks();
boolean connected = false;
for (Network network : networks) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
......@@ -119,8 +123,8 @@ public class NetworkManagerAbove23 implements NetworkManagerInterface {
}
}
}
}
return connected;
}*/
return mIsNetworkAvailable;
}
public boolean hasHttpProxy(Context context, ConnectivityManager connectivityManager) {
......
......@@ -39,20 +39,24 @@ import org.linphone.core.tools.AndroidPlatformHelper;
*/
public class NetworkManagerAbove24 implements NetworkManagerInterface {
private AndroidPlatformHelper mHelper;
private boolean mIsNetworkAvailable;
private ConnectivityManager.NetworkCallback mNetworkCallback;
public NetworkManagerAbove24(final AndroidPlatformHelper helper) {
mHelper = helper;
mIsNetworkAvailable = false;
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 24] A network is available");
mIsNetworkAvailable = true;
mHelper.updateNetworkReachability();
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 24] A network has been lost");
mIsNetworkAvailable = false;
mHelper.updateNetworkReachability();
}
......@@ -116,7 +120,7 @@ public class NetworkManagerAbove24 implements NetworkManagerInterface {
}
}
Network[] networks = connectivityManager.getAllNetworks();
/*Network[] networks = connectivityManager.getAllNetworks();
boolean connected = false;
for (Network network : networks) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
......@@ -135,8 +139,8 @@ public class NetworkManagerAbove24 implements NetworkManagerInterface {
}
}
}
}
return connected;
}*/
return mIsNetworkAvailable;
}
public boolean hasHttpProxy(Context context, ConnectivityManager connectivityManager) {
......
......@@ -39,20 +39,24 @@ import org.linphone.core.tools.AndroidPlatformHelper;
*/
public class NetworkManagerAbove26 implements NetworkManagerInterface {
private AndroidPlatformHelper mHelper;
private boolean mIsNetworkAvailable;
private ConnectivityManager.NetworkCallback mNetworkCallback;
public NetworkManagerAbove26(final AndroidPlatformHelper helper) {
mHelper = helper;
mIsNetworkAvailable = false;
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 26] A network is available");
mIsNetworkAvailable = true;
mHelper.updateNetworkReachability();
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 26] A network has been lost");
mIsNetworkAvailable = false;
mHelper.updateNetworkReachability();
}
......@@ -116,7 +120,7 @@ public class NetworkManagerAbove26 implements NetworkManagerInterface {
}
}
Network[] networks = connectivityManager.getAllNetworks();
/*Network[] networks = connectivityManager.getAllNetworks();
boolean connected = false;
for (Network network : networks) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
......@@ -135,8 +139,8 @@ public class NetworkManagerAbove26 implements NetworkManagerInterface {
}
}
}
}
return connected;
}*/
return mIsNetworkAvailable;
}
public boolean hasHttpProxy(Context context, ConnectivityManager connectivityManager) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment