mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
fixed possible NPE
This commit is contained in:
parent
92759bc5ec
commit
00a3438dc3
1 changed files with 15 additions and 5 deletions
|
@ -62,8 +62,6 @@ public class SynchroniserService extends Service implements IBookCollection.List
|
|||
}
|
||||
}
|
||||
|
||||
private final ConnectivityManager myConnectivityManager =
|
||||
(ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
|
||||
private final SyncOptions mySyncOptions = new SyncOptions();
|
||||
|
||||
private static final class SyncronizationDisabledException extends RuntimeException {
|
||||
|
@ -140,11 +138,23 @@ public class SynchroniserService extends Service implements IBookCollection.List
|
|||
case never:
|
||||
return false;
|
||||
case always:
|
||||
return myConnectivityManager.getActiveNetworkInfo().isConnected();
|
||||
{
|
||||
final ConnectivityManager cm =
|
||||
(ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
|
||||
return cm != null && cm.getActiveNetworkInfo().isConnected();
|
||||
}
|
||||
case viaWifi:
|
||||
{
|
||||
final NetworkInfo info = myConnectivityManager.getActiveNetworkInfo();
|
||||
return info.isConnected() && info.getType() == ConnectivityManager.TYPE_WIFI;
|
||||
final ConnectivityManager cm =
|
||||
(ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
|
||||
if (cm == null) {
|
||||
return false;
|
||||
}
|
||||
final NetworkInfo info = cm.getActiveNetworkInfo();
|
||||
return
|
||||
info != null &&
|
||||
info.isConnected() &&
|
||||
info.getType() == ConnectivityManager.TYPE_WIFI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue