Commit 77983fe5 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

More changes regarding android network manager

parent 74099680
......@@ -87,7 +87,6 @@ private:
jmethodID mGetNativeLibraryDirId = nullptr;
jmethodID mSetNativeVideoWindowId = nullptr;
jmethodID mSetNativePreviewVideoWindowId = nullptr;
jmethodID mUpdateNetworkReachabilityId = nullptr;
jmethodID mOnLinphoneCoreStartId = nullptr;
jmethodID mOnLinphoneCoreStopId = nullptr;
jmethodID mOnWifiOnlyEnabledId = nullptr;
......@@ -141,7 +140,6 @@ AndroidPlatformHelpers::AndroidPlatformHelpers (std::shared_ptr<LinphonePrivate:
mGetNativeLibraryDirId = getMethodId(env, klass, "getNativeLibraryDir", "()Ljava/lang/String;");
mSetNativeVideoWindowId = getMethodId(env, klass, "setVideoRenderingView", "(Ljava/lang/Object;)V");
mSetNativePreviewVideoWindowId = getMethodId(env, klass, "setVideoPreviewView", "(Ljava/lang/Object;)V");
mUpdateNetworkReachabilityId = getMethodId(env, klass, "updateNetworkReachability", "()V");
mOnLinphoneCoreStartId = getMethodId(env, klass, "onLinphoneCoreStart", "(Z)V");
mOnLinphoneCoreStopId = getMethodId(env, klass, "onLinphoneCoreStop", "()V");
mOnWifiOnlyEnabledId = getMethodId(env, klass, "onWifiOnlyEnabled", "(Z)V");
......
......@@ -90,11 +90,11 @@ public class AndroidPlatformHelper {
private boolean mUsingHttpProxy;
private NetworkManagerInterface mNetworkManager;
private Handler mMainHandler;
private Runnable mNetworkUpdateRunner;
private boolean mMonitoringEnabled;
private boolean mIsInInteractiveMode;
private InteractivityReceiver mInteractivityReceiver;
private IntentFilter mInteractivityIntentFilter;
private String[] mDnsServers;
private native void setNativePreviewWindowId(long nativePtr, Object view);
private native void setNativeVideoWindowId(long nativePtr, Object view);
......@@ -107,20 +107,13 @@ public class AndroidPlatformHelper {
mNativePtr = nativePtr;
mContext = (Context) ctx_obj;
mWifiOnly = wifiOnly;
mDnsServers = null;
mResources = mContext.getResources();
mMainHandler = new Handler(mContext.getMainLooper());
MediastreamerAndroidContext.setContext(mContext);
Log.i("[Platform Helper] Created");
mMainHandler = new Handler(mContext.getMainLooper());
mNetworkUpdateRunner = new Runnable() {
@Override
public void run() {
synchronized(AndroidPlatformHelper.this) {
updateNetworkReachability();
}
}
};
WifiManager wifiMgr = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mConnectivityManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
......@@ -167,7 +160,7 @@ public class AndroidPlatformHelper {
public synchronized void onWifiOnlyEnabled(boolean enabled) {
mWifiOnly = enabled;
postNetworkUpdateRunner();
updateNetworkReachability(null);
}
public synchronized Object getPowerManager() {
......@@ -175,24 +168,13 @@ public class AndroidPlatformHelper {
}
public synchronized String[] getDnsServers() {
if (mConnectivityManager == null || Build.VERSION.SDK_INT < Version.API23_MARSHMALLOW_60)
return null;
if (mConnectivityManager.getActiveNetwork() == null
|| mConnectivityManager.getLinkProperties(mConnectivityManager.getActiveNetwork()) == null)
return null;
int i = 0;
List<InetAddress> inetServers = null;
inetServers = mConnectivityManager.getLinkProperties(mConnectivityManager.getActiveNetwork()).getDnsServers();
String[] servers = new String[inetServers.size()];
for (InetAddress address : inetServers) {
servers[i++] = address.getHostAddress();
String dnsList = "";
for (String dns : mDnsServers) {
dnsList += dns;
dnsList += ", ";
}
Log.i("[Platform Helper] getDnsServers() returning");
return servers;
Log.i("[Platform Helper] getDnsServers() returning " + dnsList);
return mDnsServers;
}
public String getDataPath() {
......@@ -430,10 +412,6 @@ public class AndroidPlatformHelper {
}
}
public synchronized void postNetworkUpdateRunner() {
mMainHandler.post(mNetworkUpdateRunner);
}
public synchronized Handler getHandler() {
return mMainHandler;
}
......@@ -459,19 +437,49 @@ public class AndroidPlatformHelper {
}
}
public synchronized void updateNetworkReachability() {
private synchronized void storeDnsServers(Network activeNetwork) {
mDnsServers = null;
if (activeNetwork == null || mConnectivityManager.getLinkProperties(activeNetwork) == null) {
Log.e("[Platform Helper] Active network is null or we can't get it's link properties");
return;
}
int i = 0;
List<InetAddress> inetServers = null;
inetServers = mConnectivityManager.getLinkProperties(activeNetwork).getDnsServers();
String[] servers = new String[inetServers.size()];
for (InetAddress address : inetServers) {
String host = address.getHostAddress();
servers[i++] = host;
Log.i("[Platform Helper] Adding " + host + " to DNS servers list");
}
mDnsServers = servers;
}
public synchronized void updateNetworkReachability(Network activeNetwork) {
if (mNativePtr == 0) {
Log.w("[Platform Helper] Native pointer has been reset, stopping there");
return;
}
if (mDozeModeEnabled) {
Log.i("[Platform Helper] Device in idle mode: shutting down network");
setNetworkReachable(mNativePtr, false);
return;
}
NetworkInfo activeNetworkInfo = activeNetwork == null ? null : mConnectivityManager.getNetworkInfo(activeNetwork);
if (activeNetworkInfo != null) {
Log.i("[Platform Helper] Notified network state " + activeNetworkInfo.getState() + " / " + activeNetworkInfo.getDetailedState() + ", isAvailable() " + activeNetworkInfo.isAvailable());
}
boolean connected = mNetworkManager.isCurrentlyConnected(mContext, mConnectivityManager, mWifiOnly);
if (!connected) {
Log.i("[Platform Helper] No connectivity: setting network unreachable");
setNetworkReachable(mNativePtr, false);
} else if (mDozeModeEnabled) {
Log.i("[Platform Helper] Device in idle mode: shutting down network");
setNetworkReachable(mNativePtr, false);
} else {
if (mNetworkManager.hasHttpProxy(mContext, mConnectivityManager)) {
String host = mNetworkManager.getProxyHost(mContext, mConnectivityManager);
......@@ -492,21 +500,38 @@ public class AndroidPlatformHelper {
}
Log.i("[Platform Helper] Network should be reachable");
NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
NetworkInfo networkInfo = mNetworkManager.getActiveNetworkInfo(mConnectivityManager);
if (networkInfo == null) {
Log.e("[Platform Helper] getActiveNetworkInfo() returned null !");
setNetworkReachable(mNativePtr, false);
return;
}
Network network = mNetworkManager.getActiveNetwork(mConnectivityManager);
Log.i("[Platform Helper] Active network type is " + networkInfo.getTypeName());
if (!networkInfo.isAvailable()) {
Log.e("[Platform Helper] getActiveNetwork() isn't available !");
setNetworkReachable(mNativePtr, false);
return;
Log.i("[Platform Helper] Active network 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, try to use the one notified by the system");
if (activeNetwork != null) {
if (activeNetworkInfo.isAvailable() && !(activeNetworkInfo.getState() == NetworkInfo.State.DISCONNECTED && activeNetworkInfo.getDetailedState() == NetworkInfo.DetailedState.BLOCKED)) {
Log.i("[Platform Helper] Using notified network instead");
networkInfo = activeNetworkInfo;
network = activeNetwork;
} else {
Log.e("[Platform Helper] Notified network seems in bad state as well, set reachability to false");
setNetworkReachable(mNativePtr, false);
return;
}
} else {
Log.e("[Platform Helper] No network was passed to this updateNetworkReachability call, set reachability to false");
setNetworkReachable(mNativePtr, false);
return;
}
}
Log.i("[Platform Helper] Active network state " + networkInfo.getState() + " / " + networkInfo.getDetailedState());
// Update DNS servers lists
storeDnsServers(network);
int currentNetworkType = networkInfo.getType();
if (mLastNetworkType != -1 && mLastNetworkType != currentNetworkType) {
Log.i("[Platform Helper] Network type has changed (last one was " + networkTypeToString(mLastNetworkType) + "), disable network reachability first");
......@@ -535,8 +560,10 @@ public class AndroidPlatformHelper {
mNetworkManager = new NetworkManager(this);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
mNetworkManager = new NetworkManager(this);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
mNetworkManager = new NetworkManagerAbove21(this);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
mNetworkManager = new NetworkManagerAbove23(this);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
mNetworkManager = new NetworkManagerAbove24(this);
} else {
......@@ -559,7 +586,7 @@ public class AndroidPlatformHelper {
Log.i("[Platform Helper] Registering interactivity receiver");
mContext.registerReceiver(mInteractivityReceiver, mInteractivityIntentFilter);
updateNetworkReachability();
updateNetworkReachability(null);
}
private synchronized void stopNetworkMonitoring() {
......
......@@ -44,7 +44,7 @@ public class DozeReceiver extends android.content.BroadcastReceiver {
Log.i("[Platform Helper] Doze mode enabled: " + dozeM);
if (mHelper != null) {
mHelper.setDozeModeEnabled(dozeM);
mHelper.postNetworkUpdateRunner();
mHelper.updateNetworkReachability(null);
}
}
}
......
......@@ -46,7 +46,7 @@ public class NetworkManager extends BroadcastReceiver implements NetworkManagerI
mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Log.i("[Platform Helper] [Network Manager] Broadcast receiver called");
if (mHelper != null) {
mHelper.postNetworkUpdateRunner();
mHelper.updateNetworkReachability(null);
}
}
......@@ -59,13 +59,21 @@ public class NetworkManager extends BroadcastReceiver implements NetworkManagerI
context.unregisterReceiver(this);
}
public NetworkInfo getActiveNetworkInfo(ConnectivityManager connectivityManager) {
return connectivityManager.getActiveNetworkInfo();
}
public Network getActiveNetwork(ConnectivityManager connectivityManager) {
return null;
}
public boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly) {
NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo();
boolean connected = false;
for (NetworkInfo networkInfo : networkInfos) {
Log.i("[Platform Helper] [Network Manager] Found network type: " + networkInfo.getTypeName() + ", isAvailable() = " + networkInfo.isAvailable() + ", isConnected() = " + networkInfo.isConnected());
if (networkInfo.isAvailable()) {
Log.i("[Platform Helper] [Network Manager] Network is available");
Log.i("[Platform Helper] [Network Manager] Network is available, state is " + networkInfo.getState() + " / " + networkInfo.getDetailedState());
if (networkInfo.getType() != ConnectivityManager.TYPE_WIFI && wifiOnly) {
Log.i("[Platform Helper] [Network Manager] Wifi only mode enabled, skipping");
} else {
......
......@@ -44,18 +44,19 @@ public class NetworkManagerAbove21 implements NetworkManagerInterface {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 21] A network is available");
mHelper.postNetworkUpdateRunner();
mHelper.updateNetworkReachability(network);
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 21] A network has been lost");
mHelper.postNetworkUpdateRunner();
mHelper.updateNetworkReachability(null);
}
@Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
Log.i("[Platform Helper] [Network Manager 21] onCapabilitiesChanged " + network.toString() + ", " + networkCapabilities.toString());
mHelper.updateNetworkReachability(network);
}
@Override
......@@ -86,6 +87,14 @@ public class NetworkManagerAbove21 implements NetworkManagerInterface {
connectivityManager.unregisterNetworkCallback(mNetworkCallback);
}
public NetworkInfo getActiveNetworkInfo(ConnectivityManager connectivityManager) {
return connectivityManager.getActiveNetworkInfo();
}
public Network getActiveNetwork(ConnectivityManager connectivityManager) {
return null;
}
public boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly) {
Network[] networks = connectivityManager.getAllNetworks();
boolean connected = false;
......@@ -93,7 +102,7 @@ public class NetworkManagerAbove21 implements NetworkManagerInterface {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
Log.i("[Platform Helper] [Network Manager 21] Found network type: " + networkInfo.getTypeName() + ", isAvailable() = " + networkInfo.isAvailable() + ", isConnected() = " + networkInfo.isConnected());
if (networkInfo.isAvailable()) {
Log.i("[Platform Helper] [Network Manager 21] Network is available");
Log.i("[Platform Helper] [Network Manager 21] Network is available, state is " + networkInfo.getState() + " / " + networkInfo.getDetailedState());
if (networkInfo.getType() != ConnectivityManager.TYPE_WIFI && wifiOnly) {
Log.i("[Platform Helper] [Network Manager 21] Wifi only mode enabled, skipping");
} else {
......
/*
NetworkManagerAbove23.java
Copyright (C) 2019 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.linphone.core.tools;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.os.Build;
import org.linphone.core.tools.AndroidPlatformHelper;
/**
* Intercept network state changes and update linphone core.
*/
public class NetworkManagerAbove23 implements NetworkManagerInterface {
private AndroidPlatformHelper mHelper;
private ConnectivityManager.NetworkCallback mNetworkCallback;
public NetworkManagerAbove23(final AndroidPlatformHelper helper) {
mHelper = helper;
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 23] A network is available");
mHelper.updateNetworkReachability(network);
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 23] A network has been lost");
mHelper.updateNetworkReachability(null);
}
@Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
Log.i("[Platform Helper] [Network Manager 23] onCapabilitiesChanged " + network.toString() + ", " + networkCapabilities.toString());
mHelper.updateNetworkReachability(network);
}
@Override
public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
Log.i("[Platform Helper] [Network Manager 23] onLinkPropertiesChanged " + network.toString() + ", " + linkProperties.toString());
}
@Override
public void onLosing(Network network, int maxMsToLive) {
Log.i("[Platform Helper] [Network Manager 23] onLosing " + network.toString());
}
@Override
public void onUnavailable() {
Log.i("[Platform Helper] [Network Manager 23] onUnavailable");
}
};
}
public void registerNetworkCallbacks(Context context, ConnectivityManager connectivityManager) {
connectivityManager.registerNetworkCallback(
new NetworkRequest.Builder().build(),
mNetworkCallback
);
}
public void unregisterNetworkCallbacks(Context context, ConnectivityManager connectivityManager) {
connectivityManager.unregisterNetworkCallback(mNetworkCallback);
}
public NetworkInfo getActiveNetworkInfo(ConnectivityManager connectivityManager) {
Network network = connectivityManager.getActiveNetwork();
if (network != null) {
return connectivityManager.getNetworkInfo(network);
}
Log.i("[Platform Helper] [Network Manager 23] getActiveNetwork() returned null, using getActiveNetworkInfo() instead");
return connectivityManager.getActiveNetworkInfo();
}
public Network getActiveNetwork(ConnectivityManager connectivityManager) {
return connectivityManager.getActiveNetwork();
}
public boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly) {
Network[] networks = connectivityManager.getAllNetworks();
boolean connected = false;
for (Network network : networks) {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
Log.i("[Platform Helper] [Network Manager 23] Found network type: " + networkInfo.getTypeName() + ", isAvailable() = " + networkInfo.isAvailable() + ", isConnected() = " + networkInfo.isConnected());
if (networkInfo.isAvailable()) {
Log.i("[Platform Helper] [Network Manager 23] Network is available, state is " + networkInfo.getState() + " / " + networkInfo.getDetailedState());
if (networkInfo.getType() != ConnectivityManager.TYPE_WIFI && wifiOnly) {
Log.i("[Platform Helper] [Network Manager 23] Wifi only mode enabled, skipping");
} else {
NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network);
if (capabilities != null) {
Log.i("[Platform Helper] [Network Manager 23] Network capabilities are " + capabilities.toString());
connected = capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
&& capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
}
}
}
}
return connected;
}
public boolean hasHttpProxy(Context context, ConnectivityManager connectivityManager) {
return false;
}
public String getProxyHost(Context context, ConnectivityManager connectivityManager) {
return null;
}
public int getProxyPort(Context context, ConnectivityManager connectivityManager) {
return 0;
}
}
......@@ -47,19 +47,19 @@ public class NetworkManagerAbove24 implements NetworkManagerInterface {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 24] A network is available");
mHelper.postNetworkUpdateRunner();
mHelper.updateNetworkReachability(network);
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 24] A network has been lost");
mHelper.postNetworkUpdateRunner();
mHelper.updateNetworkReachability(null);
}
@Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
Log.i("[Platform Helper] [Network Manager 24] onCapabilitiesChanged " + network.toString() + ", " + networkCapabilities.toString());
mHelper.postNetworkUpdateRunner();
mHelper.updateNetworkReachability(network);
}
@Override
......@@ -91,6 +91,19 @@ public class NetworkManagerAbove24 implements NetworkManagerInterface {
connectivityManager.unregisterNetworkCallback(mNetworkCallback);
}
public NetworkInfo getActiveNetworkInfo(ConnectivityManager connectivityManager) {
Network network = connectivityManager.getActiveNetwork();
if (network != null) {
return connectivityManager.getNetworkInfo(network);
}
Log.i("[Platform Helper] [Network Manager 24] getActiveNetwork() returned null, using getActiveNetworkInfo() instead");
return connectivityManager.getActiveNetworkInfo();
}
public Network getActiveNetwork(ConnectivityManager connectivityManager) {
return connectivityManager.getActiveNetwork();
}
public boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly) {
int restrictBackgroundStatus = connectivityManager.getRestrictBackgroundStatus();
if (restrictBackgroundStatus == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED) {
......@@ -98,7 +111,7 @@ public class NetworkManagerAbove24 implements NetworkManagerInterface {
// In this state, application should not try to use the network while running on background, because it would be denied.
Log.w("[Platform Helper] [Network Manager 24] Device is restricting metered network activity while application is running on background");
if (mHelper.isInBackground()) {
Log.w("[Platform Helper] [Network Manager 26] Device is in background, returning false");
Log.w("[Platform Helper] [Network Manager 24] Device is in background, returning false");
return false;
}
}
......@@ -109,7 +122,7 @@ public class NetworkManagerAbove24 implements NetworkManagerInterface {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
Log.i("[Platform Helper] [Network Manager 24] Found network type: " + networkInfo.getTypeName() + ", isAvailable() = " + networkInfo.isAvailable() + ", isConnected() = " + networkInfo.isConnected());
if (networkInfo.isAvailable()) {
Log.i("[Platform Helper] [Network Manager 24] Network is available");
Log.i("[Platform Helper] [Network Manager 24] Network is available, state is " + networkInfo.getState() + " / " + networkInfo.getDetailedState());
if (networkInfo.getType() != ConnectivityManager.TYPE_WIFI && wifiOnly) {
Log.i("[Platform Helper] [Network Manager 24] Wifi only mode enabled, skipping");
} else {
......
......@@ -47,19 +47,19 @@ public class NetworkManagerAbove26 implements NetworkManagerInterface {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] [Network Manager 26] A network is available");
mHelper.updateNetworkReachability();
mHelper.updateNetworkReachability(network);
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] [Network Manager 26] A network has been lost");
mHelper.updateNetworkReachability();
mHelper.updateNetworkReachability(null);
}
@Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
Log.i("[Platform Helper] [Network Manager 26] onCapabilitiesChanged " + network.toString() + ", " + networkCapabilities.toString());
mHelper.updateNetworkReachability();
mHelper.updateNetworkReachability(network);
}
@Override
......@@ -91,6 +91,19 @@ public class NetworkManagerAbove26 implements NetworkManagerInterface {
connectivityManager.unregisterNetworkCallback(mNetworkCallback);
}
public NetworkInfo getActiveNetworkInfo(ConnectivityManager connectivityManager) {
Network network = connectivityManager.getActiveNetwork();
if (network != null) {
return connectivityManager.getNetworkInfo(network);
}
Log.i("[Platform Helper] [Network Manager 26] getActiveNetwork() returned null, using getActiveNetworkInfo() instead");
return connectivityManager.getActiveNetworkInfo();
}
public Network getActiveNetwork(ConnectivityManager connectivityManager) {
return connectivityManager.getActiveNetwork();
}
public boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly) {
int restrictBackgroundStatus = connectivityManager.getRestrictBackgroundStatus();
if (restrictBackgroundStatus == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED) {
......@@ -109,7 +122,7 @@ public class NetworkManagerAbove26 implements NetworkManagerInterface {
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
Log.i("[Platform Helper] [Network Manager 26] Found network type: " + networkInfo.getTypeName() + ", isAvailable() = " + networkInfo.isAvailable() + ", isConnected() = " + networkInfo.isConnected());
if (networkInfo.isAvailable()) {
Log.i("[Platform Helper] [Network Manager 26] Network is available");
Log.i("[Platform Helper] [Network Manager 26] Network is available, state is " + networkInfo.getState() + " / " + networkInfo.getDetailedState());
if (networkInfo.getType() != ConnectivityManager.TYPE_WIFI && wifiOnly) {
Log.i("[Platform Helper] [Network Manager 26] Wifi only mode enabled, skipping");
} else {
......
......@@ -21,6 +21,8 @@ package org.linphone.core.tools;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
public interface NetworkManagerInterface {
void registerNetworkCallbacks(Context context, ConnectivityManager connectivityManager);
......@@ -29,6 +31,10 @@ public interface NetworkManagerInterface {
boolean isCurrentlyConnected(Context context, ConnectivityManager connectivityManager, boolean wifiOnly);
NetworkInfo getActiveNetworkInfo(ConnectivityManager connectivityManager);
Network getActiveNetwork(ConnectivityManager connectivityManager);
boolean hasHttpProxy(Context context, ConnectivityManager connectivityManager);
String getProxyHost(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