Check for null netmask variable to prevent NPE.

Not sure if this is the correct course of action to prevent the problem,
but it prevents the crash documented in Issue #413.
This commit is contained in:
Peter Serwylo 2015-09-12 20:30:07 +10:00
parent 828cc272ee
commit 90ede44790

View File

@ -86,7 +86,7 @@ public class WifiStateChangeService extends Service {
wifiInfo = wifiManager.getConnectionInfo();
FDroidApp.ipAddressString = formatIpAddress(wifiInfo.getIpAddress());
String netmask = formatIpAddress(wifiManager.getDhcpInfo().netmask);
if (!TextUtils.isEmpty(FDroidApp.ipAddressString))
if (!TextUtils.isEmpty(FDroidApp.ipAddressString) && netmask != null)
FDroidApp.subnetInfo = new SubnetUtils(FDroidApp.ipAddressString, netmask).getInfo();
} else if (wifiState == WifiManager.WIFI_STATE_DISABLED
|| wifiState == WifiManager.WIFI_STATE_DISABLING) {