mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
wifi start adding network status updates
This commit is contained in:
parent
239beafcfa
commit
d45635273d
3 changed files with 26 additions and 3 deletions
|
@ -545,6 +545,9 @@ public class ConnStatusHandler {
|
||||||
result = RelayService.relayEnabled( context )
|
result = RelayService.relayEnabled( context )
|
||||||
&& NetStateCache.netAvail( context );
|
&& NetStateCache.netAvail( context );
|
||||||
break;
|
break;
|
||||||
|
case COMMS_CONN_P2P:
|
||||||
|
result = WifiDirectService.connecting();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
DbgUtils.logw( ConnStatusHandler.class, "connTypeEnabled: %s not handled",
|
DbgUtils.logw( ConnStatusHandler.class, "connTypeEnabled: %s not handled",
|
||||||
connType.toString() );
|
connType.toString() );
|
||||||
|
|
|
@ -118,8 +118,8 @@ public class DbgUtils {
|
||||||
public static void printStack( StackTraceElement[] trace )
|
public static void printStack( StackTraceElement[] trace )
|
||||||
{
|
{
|
||||||
if ( s_doLog && null != trace ) {
|
if ( s_doLog && null != trace ) {
|
||||||
// 2: skip printStack etc.
|
// 1: skip printStack etc.
|
||||||
for ( int ii = 2; ii < trace.length; ++ii ) {
|
for ( int ii = 1; ii < trace.length; ++ii ) {
|
||||||
DbgUtils.logd( DbgUtils.class, "ste %d: %s", ii, trace[ii].toString() );
|
DbgUtils.logd( DbgUtils.class, "ste %d: %s", ii, trace[ii].toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ public class WifiDirectService extends XWService {
|
||||||
switch ( cmd ) {
|
switch ( cmd ) {
|
||||||
case GOT_MSG:
|
case GOT_MSG:
|
||||||
handleGotMessage( intent );
|
handleGotMessage( intent );
|
||||||
|
updateStatusIn( true );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,11 +130,29 @@ public class WifiDirectService extends XWService {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateStatusOut( boolean success )
|
||||||
|
{
|
||||||
|
ConnStatusHandler
|
||||||
|
.updateStatusOut( this, null, CommsConnType.COMMS_CONN_P2P, success );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatusIn( boolean success )
|
||||||
|
{
|
||||||
|
ConnStatusHandler
|
||||||
|
.updateStatusIn( this, null, CommsConnType.COMMS_CONN_P2P, success );
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean supported()
|
public static boolean supported()
|
||||||
{
|
{
|
||||||
return WIFI_DIRECT_ENABLED;
|
return WIFI_DIRECT_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean connecting() {
|
||||||
|
return supported()
|
||||||
|
&& 0 < sSocketWrapMap.size()
|
||||||
|
&& sSocketWrapMap.values().iterator().next().isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
public static String getMyMacAddress( Context context )
|
public static String getMyMacAddress( Context context )
|
||||||
{
|
{
|
||||||
if ( WIFI_DIRECT_ENABLED ) {
|
if ( WIFI_DIRECT_ENABLED ) {
|
||||||
|
@ -382,7 +401,8 @@ public class WifiDirectService extends XWService {
|
||||||
String macAddress = packet.optString( KEY_MAC, null );
|
String macAddress = packet.optString( KEY_MAC, null );
|
||||||
// Assert.assertNotNull( macAddress );
|
// Assert.assertNotNull( macAddress );
|
||||||
if ( null != macAddress ) {
|
if ( null != macAddress ) {
|
||||||
Assert.assertNull( sSocketWrapMap.get( macAddress ) );
|
// this has fired. Sockets close and re-open?
|
||||||
|
// Assert.assertNull( sSocketWrapMap.get( macAddress ) );
|
||||||
wrap.setMacAddress( macAddress );
|
wrap.setMacAddress( macAddress );
|
||||||
sSocketWrapMap.put( macAddress, wrap );
|
sSocketWrapMap.put( macAddress, wrap );
|
||||||
DbgUtils.logd( WifiDirectService.class,
|
DbgUtils.logd( WifiDirectService.class,
|
||||||
|
|
Loading…
Reference in a new issue