do not crash on mystery last second null IP addresses, closes #1434
java.lang.IllegalArgumentException: Could not parse [null/24] at org.apache.commons.net.util.SubnetUtils.calculate(SubnetUtils.java:275) at org.apache.commons.net.util.SubnetUtils.<init>(SubnetUtils.java:51) at org.fdroid.fdroid.net.WifiStateChangeService.setIpInfoFromNetworkInterface(WifiStateChangeService.java:261) at org.fdroid.fdroid.net.WifiStateChangeService.access$100(WifiStateChangeService.java:50) at org.fdroid.fdroid.net.WifiStateChangeService$WifiInfoThread.run(WifiStateChangeService.java:132)
This commit is contained in:
parent
5295b6f0d1
commit
edb9fcd044
@ -14,6 +14,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.apache.commons.net.util.SubnetUtils;
|
import org.apache.commons.net.util.SubnetUtils;
|
||||||
|
import org.fdroid.fdroid.BuildConfig;
|
||||||
import org.fdroid.fdroid.FDroidApp;
|
import org.fdroid.fdroid.FDroidApp;
|
||||||
import org.fdroid.fdroid.Preferences;
|
import org.fdroid.fdroid.Preferences;
|
||||||
import org.fdroid.fdroid.UpdateService;
|
import org.fdroid.fdroid.UpdateService;
|
||||||
@ -266,11 +267,17 @@ public class WifiStateChangeService extends IntentService {
|
|||||||
// java.lang.IllegalArgumentException: Value [64] not in range [0,32]
|
// java.lang.IllegalArgumentException: Value [64] not in range [0,32]
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (inetAddress.equals(address.getAddress()) && !TextUtils.isEmpty(FDroidApp.ipAddressString)) {
|
try {
|
||||||
String cidr = String.format(Locale.ENGLISH, "%s/%d",
|
String cidr = String.format(Locale.ENGLISH, "%s/%d",
|
||||||
FDroidApp.ipAddressString, networkPrefixLength);
|
FDroidApp.ipAddressString, networkPrefixLength);
|
||||||
FDroidApp.subnetInfo = new SubnetUtils(cidr).getInfo();
|
FDroidApp.subnetInfo = new SubnetUtils(cidr).getInfo();
|
||||||
break;
|
break;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, e.getLocalizedMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user