mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
add some logging about network state
This commit is contained in:
parent
6677a3e402
commit
8e4867eccd
1 changed files with 21 additions and 1 deletions
|
@ -69,7 +69,12 @@ public class NetStateCache {
|
|||
public static boolean netAvail( Context context )
|
||||
{
|
||||
initIfNot( context );
|
||||
return s_netAvail || s_onSim;
|
||||
boolean result = s_netAvail || s_onSim;
|
||||
if ( BuildConfig.DEBUG ) {
|
||||
checkSame( context, result );
|
||||
}
|
||||
DbgUtils.logf( "NetStateCache.netAvail() => %b", result );
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean onWifi()
|
||||
|
@ -117,6 +122,21 @@ public class NetStateCache {
|
|||
}
|
||||
}
|
||||
|
||||
private static void checkSame( Context context, boolean connectedCached )
|
||||
{
|
||||
if ( BuildConfig.DEBUG ) {
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
boolean connectedReal = activeNetwork != null &&
|
||||
activeNetwork.isConnectedOrConnecting();
|
||||
if ( connectedReal != connectedCached ) {
|
||||
DbgUtils.logf( "NetStateCache(): connected: cached: %b; actual: %b",
|
||||
connectedCached, connectedReal );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class PvtBroadcastReceiver extends BroadcastReceiver {
|
||||
private Runnable mNotifyLater;
|
||||
private Handler mHandler;
|
||||
|
|
Loading…
Add table
Reference in a new issue