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

More logs in Android platform helper to help debug connectivity issues

parent 77ed22ee
......@@ -461,6 +461,7 @@ public class AndroidPlatformHelper {
} else if (connected) {
if (mWifiOnly) {
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
Log.i("[Platform Helper] Network available through WiFi, network is reachable");
setNetworkReachable(mNativePtr, true);
} else {
Log.i("[Platform Helper] Wifi-only mode, setting network not reachable");
......@@ -468,11 +469,12 @@ public class AndroidPlatformHelper {
}
} else {
int curtype = networkInfo.getType();
Log.i("[Platform Helper] Network type is " + networkInfo.getTypeName());
if (curtype != mLastNetworkType || mUsingHttpProxy != usingHttpProxyBefore) {
if ((curtype != mLastNetworkType && mLastNetworkType != -1) || mUsingHttpProxy != usingHttpProxyBefore) {
//if kind of network has changed, we need to notify network_reachable(false) to make sure all current connections are destroyed.
//they will be re-created during setNetworkReachable(true).
Log.i("[Platform Helper] Connectivity has changed.");
Log.i("[Platform Helper] Connectivity has changed, disable/enable network to force re-creating connections.");
setNetworkReachable(mNativePtr, false);
}
setNetworkReachable(mNativePtr, true);
......@@ -483,7 +485,7 @@ public class AndroidPlatformHelper {
public synchronized void setDozeModeEnabled(boolean b) {
dozeModeEnabled = b;
Log.i("[Platform Helper] Doze state is " + dozeModeEnabled);
Log.i("[Platform Helper] Doze mode enabled: " + dozeModeEnabled);
}
private synchronized void startNetworkMonitoring() {
......
......@@ -41,6 +41,7 @@ public class DozeReceiver extends android.content.BroadcastReceiver {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
boolean dozeM = pm.isDeviceIdleMode();
Log.i("[Platform Helper] Doze mode enabled: " + dozeM);
if (mHelper != null) {
mHelper.setDozeModeEnabled(dozeM);
mHelper.postNetworkUpdateRunner();
......
......@@ -40,6 +40,7 @@ public class NetworkManager extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
Boolean lNoConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
Log.i("[Platform Helper] Network connectivity disabled: " + lNoConnectivity);
if (mHelper != null) {
mHelper.postNetworkUpdateRunner();
}
......
......@@ -40,11 +40,13 @@ public class NetworkManagerAbove21 {
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
Log.i("[Platform Helper] Network is available");
helper.postNetworkUpdateRunner();
}
@Override
public void onLost(Network network) {
Log.i("[Platform Helper] Network is lost");
helper.postNetworkUpdateRunner();
}
};
......
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