mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
Merge remote-tracking branch 'origin/android_translate' into android_translate
This commit is contained in:
commit
380ae5bf1f
18 changed files with 138 additions and 37 deletions
|
@ -36,7 +36,6 @@ android {
|
||||||
|
|
||||||
// FIX ME
|
// FIX ME
|
||||||
variant.buildConfigField "String", "STRINGS_HASH", "\"00000\""
|
variant.buildConfigField "String", "STRINGS_HASH", "\"00000\""
|
||||||
variant.buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
|
||||||
|
|
||||||
def senderID = System.getenv("GCM_SENDER_ID")
|
def senderID = System.getenv("GCM_SENDER_ID")
|
||||||
variant.buildConfigField "String", "GCM_SENDER_ID", "\"$senderID\""
|
variant.buildConfigField "String", "GCM_SENDER_ID", "\"$senderID\""
|
||||||
|
@ -53,6 +52,7 @@ android {
|
||||||
resValue "string", "app_name", "CrossWords"
|
resValue "string", "app_name", "CrossWords"
|
||||||
resValue "string", "nbs_port", "3344"
|
resValue "string", "nbs_port", "3344"
|
||||||
resValue "string", "invite_prefix", "/and/"
|
resValue "string", "invite_prefix", "/and/"
|
||||||
|
buildConfigField "boolean", "WIDIR_ENABLED", "false"
|
||||||
}
|
}
|
||||||
xw4dbg {
|
xw4dbg {
|
||||||
dimension "variant"
|
dimension "variant"
|
||||||
|
@ -61,6 +61,7 @@ android {
|
||||||
resValue "string", "app_name", "CrossDbg"
|
resValue "string", "app_name", "CrossDbg"
|
||||||
resValue "string", "nbs_port", "3345"
|
resValue "string", "nbs_port", "3345"
|
||||||
resValue "string", "invite_prefix", "/anddbg/"
|
resValue "string", "invite_prefix", "/anddbg/"
|
||||||
|
buildConfigField "boolean", "WIDIR_ENABLED", "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARNING: "all" breaks things. Seems to be a keyword. Need
|
// WARNING: "all" breaks things. Seems to be a keyword. Need
|
||||||
|
@ -94,6 +95,16 @@ android {
|
||||||
storePassword "notReal"
|
storePassword "notReal"
|
||||||
keyPassword "notReal"
|
keyPassword "notReal"
|
||||||
}
|
}
|
||||||
|
debug {
|
||||||
|
def path = System.getenv("DEBUG_KEYSTORE_PATH")
|
||||||
|
if (! path) {
|
||||||
|
path = "./debug.keystore"
|
||||||
|
}
|
||||||
|
storeFile file(path)
|
||||||
|
keyAlias "androiddebugkey"
|
||||||
|
storePassword "android"
|
||||||
|
keyPassword "android"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
enabled = RelayService.relayEnabled( context );
|
enabled = RelayService.relayEnabled( context );
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_P2P:
|
case COMMS_CONN_P2P:
|
||||||
enabled = WiDirService.supported();
|
enabled = WiDirService.enabled();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
|
|
|
@ -510,7 +510,7 @@ public class DlgDelegate {
|
||||||
if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity ))
|
if ( (XWApp.SMS_INVITE_ENABLED && Utils.deviceSupportsSMS( m_activity ))
|
||||||
|| XWPrefs.getNFCToSelfEnabled( m_activity )
|
|| XWPrefs.getNFCToSelfEnabled( m_activity )
|
||||||
|| NFCUtils.nfcAvail( m_activity )[0]
|
|| NFCUtils.nfcAvail( m_activity )[0]
|
||||||
|| WiDirService.supported()
|
|| WiDirService.enabled()
|
||||||
|| BTService.BTAvailable() ) {
|
|| BTService.BTAvailable() ) {
|
||||||
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN )
|
DlgState state = new DlgState( DlgID.INVITE_CHOICES_THEN )
|
||||||
.setAction( action )
|
.setAction( action )
|
||||||
|
@ -755,7 +755,7 @@ public class DlgDelegate {
|
||||||
items.add( getString( R.string.invite_choice_relay ) );
|
items.add( getString( R.string.invite_choice_relay ) );
|
||||||
means.add( DlgClickNotify.InviteMeans.RELAY );
|
means.add( DlgClickNotify.InviteMeans.RELAY );
|
||||||
}
|
}
|
||||||
if ( WiDirService.supported() ) {
|
if ( WiDirService.enabled() ) {
|
||||||
items.add( getString( R.string.invite_choice_p2p ) );
|
items.add( getString( R.string.invite_choice_p2p ) );
|
||||||
means.add( DlgClickNotify.InviteMeans.WIFIDIRECT );
|
means.add( DlgClickNotify.InviteMeans.WIFIDIRECT );
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,5 +350,9 @@ public class PrefsDelegate extends DelegateBase
|
||||||
if ( Perms23.haveNativePerms() ) {
|
if ( Perms23.haveNativePerms() ) {
|
||||||
hideOne( R.string.key_enable_sms, R.string.key_network_behavior );
|
hideOne( R.string.key_enable_sms, R.string.key_network_behavior );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! BuildConfig.WIDIR_ENABLED ) {
|
||||||
|
hideOne( R.string.key_enable_p2p, R.string.key_network_behavior );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ import android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceRequest;
|
||||||
import android.net.wifi.p2p.nsd.WifiP2pUpnpServiceInfo;
|
import android.net.wifi.p2p.nsd.WifiP2pUpnpServiceInfo;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
@ -77,6 +78,7 @@ public class WiDirService extends XWService {
|
||||||
private static final String SERVICE_NAME = "srvc_" + BuildConfig.FLAVOR;
|
private static final String SERVICE_NAME = "srvc_" + BuildConfig.FLAVOR;
|
||||||
private static final String SERVICE_REG_TYPE = "_presence._tcp";
|
private static final String SERVICE_REG_TYPE = "_presence._tcp";
|
||||||
private static final int OWNER_PORT = 5432;
|
private static final int OWNER_PORT = 5432;
|
||||||
|
private static final String PEERS_LIST_KEY = TAG + ".peers_key";
|
||||||
|
|
||||||
private enum P2PAction { _NONE,
|
private enum P2PAction { _NONE,
|
||||||
GOT_MSG,
|
GOT_MSG,
|
||||||
|
@ -96,6 +98,7 @@ public class WiDirService extends XWService {
|
||||||
private static final String KEY_MAP = "map";
|
private static final String KEY_MAP = "map";
|
||||||
private static final String KEY_RETADDR = "raddr";
|
private static final String KEY_RETADDR = "raddr";
|
||||||
|
|
||||||
|
private static boolean s_enabled = false;
|
||||||
private static Channel sChannel;
|
private static Channel sChannel;
|
||||||
private static ServiceDiscoverer s_discoverer;
|
private static ServiceDiscoverer s_discoverer;
|
||||||
private static IntentFilter sIntentFilter;
|
private static IntentFilter sIntentFilter;
|
||||||
|
@ -119,6 +122,7 @@ public class WiDirService extends XWService {
|
||||||
private static String sDeviceName;
|
private static String sDeviceName;
|
||||||
private static Set<DevSetListener> s_devListeners
|
private static Set<DevSetListener> s_devListeners
|
||||||
= new HashSet<DevSetListener>();
|
= new HashSet<DevSetListener>();
|
||||||
|
private static Set<String> s_peersSet;
|
||||||
|
|
||||||
private P2pMsgSink m_sink;
|
private P2pMsgSink m_sink;
|
||||||
|
|
||||||
|
@ -137,7 +141,7 @@ public class WiDirService extends XWService {
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if ( BuildConfig.WIDIR_ENABLED && null != intent ) {
|
if ( enabled() && null != intent ) {
|
||||||
result = Service.START_STICKY;
|
result = Service.START_STICKY;
|
||||||
|
|
||||||
int ordinal = intent.getIntExtra( KEY_CMD, -1 );
|
int ordinal = intent.getIntExtra( KEY_CMD, -1 );
|
||||||
|
@ -181,6 +185,20 @@ public class WiDirService extends XWService {
|
||||||
public static void init( Context context )
|
public static void init( Context context )
|
||||||
{
|
{
|
||||||
DbgUtils.logd( TAG, "init()" );
|
DbgUtils.logd( TAG, "init()" );
|
||||||
|
s_enabled = XWPrefs.getPrefsBoolean( context, R.string.key_enable_p2p,
|
||||||
|
false );
|
||||||
|
|
||||||
|
Assert.assertNull( s_peersSet );
|
||||||
|
s_peersSet = new HashSet<String>();
|
||||||
|
String peers = DBUtils.getStringFor( context, PEERS_LIST_KEY, null );
|
||||||
|
if ( null != peers ) {
|
||||||
|
String[] macs = TextUtils.split( peers, "," );
|
||||||
|
for ( String mac : macs ) {
|
||||||
|
s_peersSet.add( mac );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DbgUtils.logd( TAG, "loaded saved peers: %s", s_peersSet.toString() );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ChannelListener listener = new ChannelListener() {
|
ChannelListener listener = new ChannelListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -190,7 +208,7 @@ public class WiDirService extends XWService {
|
||||||
};
|
};
|
||||||
sChannel = getMgr().initialize( context, Looper.getMainLooper(),
|
sChannel = getMgr().initialize( context, Looper.getMainLooper(),
|
||||||
listener );
|
listener );
|
||||||
s_discoverer = new ServiceDiscoverer( sChannel );
|
s_discoverer = new ServiceDiscoverer();
|
||||||
sHavePermission = true;
|
sHavePermission = true;
|
||||||
} catch ( NoClassDefFoundError ndf ) { // old os version
|
} catch ( NoClassDefFoundError ndf ) { // old os version
|
||||||
sHavePermission = false;
|
sHavePermission = false;
|
||||||
|
@ -202,22 +220,28 @@ public class WiDirService extends XWService {
|
||||||
public static void reset( Context context )
|
public static void reset( Context context )
|
||||||
{
|
{
|
||||||
// Put experimental stuff here that might help get a connection
|
// Put experimental stuff here that might help get a connection
|
||||||
|
|
||||||
|
if ( null != s_discoverer ) {
|
||||||
|
s_discoverer.restart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean supported()
|
public static boolean enabled()
|
||||||
{
|
{
|
||||||
return BuildConfig.WIDIR_ENABLED;
|
boolean result = BuildConfig.WIDIR_ENABLED && s_enabled;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean connecting() {
|
public static boolean connecting()
|
||||||
return supported()
|
{
|
||||||
|
return enabled()
|
||||||
&& 0 < sSocketWrapMap.size()
|
&& 0 < sSocketWrapMap.size()
|
||||||
&& sSocketWrapMap.values().iterator().next().isConnected();
|
&& sSocketWrapMap.values().iterator().next().isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMyMacAddress( Context context )
|
public static String getMyMacAddress( Context context )
|
||||||
{
|
{
|
||||||
if ( BuildConfig.WIDIR_ENABLED ) {
|
if ( enabled() ) {
|
||||||
if ( null == sMacAddress && null != context ) {
|
if ( null == sMacAddress && null != context ) {
|
||||||
sMacAddress = DBUtils.getStringFor( context, MAC_ADDR_KEY, null );
|
sMacAddress = DBUtils.getStringFor( context, MAC_ADDR_KEY, null );
|
||||||
}
|
}
|
||||||
|
@ -230,10 +254,16 @@ public class WiDirService extends XWService {
|
||||||
|
|
||||||
public static String formatNetStateInfo()
|
public static String formatNetStateInfo()
|
||||||
{
|
{
|
||||||
|
String connectState = "";
|
||||||
|
if ( null != s_discoverer ) {
|
||||||
|
connectState = s_discoverer.stateToString();
|
||||||
|
}
|
||||||
|
|
||||||
String map = mapToString( copyUserMap() );
|
String map = mapToString( copyUserMap() );
|
||||||
return String.format( "role: %s; map: %s nThreads: %d",
|
connectState += String.format( "; role: %s; map: %s nThreads: %d",
|
||||||
sAmGroupOwner ? "owner" : "guest", map,
|
sAmGroupOwner ? "owner" : "guest", map,
|
||||||
Thread.activeCount() );
|
Thread.activeCount() );
|
||||||
|
return connectState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getMyMacAddress() { return getMyMacAddress(null); }
|
private static String getMyMacAddress() { return getMyMacAddress(null); }
|
||||||
|
@ -306,7 +336,7 @@ public class WiDirService extends XWService {
|
||||||
|
|
||||||
public static void activityResumed( Activity activity )
|
public static void activityResumed( Activity activity )
|
||||||
{
|
{
|
||||||
if ( BuildConfig.WIDIR_ENABLED && sHavePermission ) {
|
if ( enabled() && sHavePermission ) {
|
||||||
if ( initListeners( activity ) ) {
|
if ( initListeners( activity ) ) {
|
||||||
activity.registerReceiver( sReceiver, sIntentFilter );
|
activity.registerReceiver( sReceiver, sIntentFilter );
|
||||||
DbgUtils.logd( TAG, "activityResumed() done" );
|
DbgUtils.logd( TAG, "activityResumed() done" );
|
||||||
|
@ -317,7 +347,7 @@ public class WiDirService extends XWService {
|
||||||
|
|
||||||
public static void activityPaused( Activity activity )
|
public static void activityPaused( Activity activity )
|
||||||
{
|
{
|
||||||
if ( BuildConfig.WIDIR_ENABLED && sHavePermission ) {
|
if ( enabled() && sHavePermission ) {
|
||||||
Assert.assertNotNull( sReceiver );
|
Assert.assertNotNull( sReceiver );
|
||||||
// No idea why I'm seeing this exception...
|
// No idea why I'm seeing this exception...
|
||||||
try {
|
try {
|
||||||
|
@ -346,7 +376,7 @@ public class WiDirService extends XWService {
|
||||||
private static boolean initListeners( final Context context )
|
private static boolean initListeners( final Context context )
|
||||||
{
|
{
|
||||||
boolean succeeded = false;
|
boolean succeeded = false;
|
||||||
if ( BuildConfig.WIDIR_ENABLED ) {
|
if ( enabled() ) {
|
||||||
if ( null == sIface ) {
|
if ( null == sIface ) {
|
||||||
try {
|
try {
|
||||||
WifiP2pManager mgr = getMgr();
|
WifiP2pManager mgr = getMgr();
|
||||||
|
@ -447,10 +477,13 @@ public class WiDirService extends XWService {
|
||||||
// See: http://stackoverflow.com/questions/26300889/wifi-p2p-service-discovery-works-intermittently
|
// See: http://stackoverflow.com/questions/26300889/wifi-p2p-service-discovery-works-intermittently
|
||||||
private static class ServiceDiscoverer implements Runnable, ActionListener {
|
private static class ServiceDiscoverer implements Runnable, ActionListener {
|
||||||
private State m_curState = State.START;
|
private State m_curState = State.START;
|
||||||
|
private State m_lastGoodState = State.START;
|
||||||
|
private State m_lastBadState = State.START;
|
||||||
private Channel m_channel;
|
private Channel m_channel;
|
||||||
private Handler m_handler;
|
private Handler m_handler;
|
||||||
private WifiP2pManager m_mgr;
|
private WifiP2pManager m_mgr;
|
||||||
private int[] m_failures;
|
private int[] m_failures;
|
||||||
|
private boolean m_lastSucceeded;
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
START,
|
START,
|
||||||
|
@ -463,13 +496,21 @@ public class WiDirService extends XWService {
|
||||||
DONE,
|
DONE,
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceDiscoverer( Channel channel )
|
public ServiceDiscoverer()
|
||||||
{
|
{
|
||||||
m_mgr = getMgr();
|
m_mgr = getMgr();
|
||||||
m_channel = sChannel;
|
m_channel = sChannel;
|
||||||
m_handler = new Handler();
|
m_handler = new Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String stateToString()
|
||||||
|
{
|
||||||
|
return String.format("last good: %s(%d); last bad: %s(%d); success last: %b",
|
||||||
|
m_lastGoodState.toString(), m_lastGoodState.ordinal(),
|
||||||
|
m_lastBadState.toString(), m_lastBadState.ordinal(),
|
||||||
|
m_lastSucceeded );
|
||||||
|
}
|
||||||
|
|
||||||
public void restart()
|
public void restart()
|
||||||
{
|
{
|
||||||
m_curState = State.START;
|
m_curState = State.START;
|
||||||
|
@ -487,6 +528,8 @@ public class WiDirService extends XWService {
|
||||||
// ActionListener interface
|
// ActionListener interface
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
m_lastSucceeded = true;
|
||||||
|
m_lastGoodState = m_curState;
|
||||||
DbgUtils.logd( TAG, "onSuccess(): state %s done",
|
DbgUtils.logd( TAG, "onSuccess(): state %s done",
|
||||||
m_curState.toString() );
|
m_curState.toString() );
|
||||||
m_curState = State.values()[m_curState.ordinal() + 1];
|
m_curState = State.values()[m_curState.ordinal() + 1];
|
||||||
|
@ -495,6 +538,9 @@ public class WiDirService extends XWService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure( int code ) {
|
public void onFailure( int code ) {
|
||||||
|
m_lastSucceeded = false;
|
||||||
|
m_lastBadState = m_curState;
|
||||||
|
|
||||||
int count = ++m_failures[m_curState.ordinal()];
|
int count = ++m_failures[m_curState.ordinal()];
|
||||||
String codeStr = null;
|
String codeStr = null;
|
||||||
switch ( code ) {
|
switch ( code ) {
|
||||||
|
@ -568,8 +614,10 @@ public class WiDirService extends XWService {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DONE:
|
case DONE:
|
||||||
m_curState = State.START;
|
DbgUtils.logd( TAG, "machine done; should I try connecting to: %s?",
|
||||||
schedule( /*5 * */ 60 );
|
s_peersSet.toString() );
|
||||||
|
// m_curState = State.START;
|
||||||
|
// schedule( /*5 * */ 60 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -594,7 +642,7 @@ public class WiDirService extends XWService {
|
||||||
|
|
||||||
private static void setDiscoveryListeners( WifiP2pManager mgr )
|
private static void setDiscoveryListeners( WifiP2pManager mgr )
|
||||||
{
|
{
|
||||||
if ( BuildConfig.WIDIR_ENABLED ) {
|
if ( enabled() ) {
|
||||||
DnsSdServiceResponseListener srl = new DnsSdServiceResponseListener() {
|
DnsSdServiceResponseListener srl = new DnsSdServiceResponseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDnsSdServiceAvailable(String instanceName,
|
public void onDnsSdServiceAvailable(String instanceName,
|
||||||
|
@ -922,9 +970,12 @@ public class WiDirService extends XWService {
|
||||||
boolean forwarded = false;
|
boolean forwarded = false;
|
||||||
String destAddr = packet.getString( KEY_DEST );
|
String destAddr = packet.getString( KEY_DEST );
|
||||||
if ( null != destAddr && 0 < destAddr.length() ) {
|
if ( null != destAddr && 0 < destAddr.length() ) {
|
||||||
Assert.assertFalse( destAddr.equals( sMacAddress ) );
|
forwarded = destAddr.equals( sMacAddress );
|
||||||
forwardPacket( bytes, destAddr );
|
if ( forwarded ) {
|
||||||
forwarded = true;
|
forwardPacket( bytes, destAddr );
|
||||||
|
} else {
|
||||||
|
DbgUtils.logd( TAG, "addr mismatch: %s vs %s", destAddr, sMacAddress );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return forwarded;
|
return forwarded;
|
||||||
}
|
}
|
||||||
|
@ -1011,6 +1062,22 @@ public class WiDirService extends XWService {
|
||||||
return wrap;
|
return wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updatePeersList( WifiP2pDeviceList peerList )
|
||||||
|
{
|
||||||
|
Set<String> newSet = new HashSet<String>();
|
||||||
|
for ( WifiP2pDevice device : peerList.getDeviceList() ) {
|
||||||
|
String macAddress = device.deviceAddress;
|
||||||
|
newSet.add( macAddress );
|
||||||
|
}
|
||||||
|
|
||||||
|
DbgUtils.logd( TAG, "updatePeersList(): old set: %s; new set: %s",
|
||||||
|
s_peersSet.toString(), newSet.toString() );
|
||||||
|
s_peersSet = newSet;
|
||||||
|
|
||||||
|
DBUtils.setStringFor( XWApp.getContext(), PEERS_LIST_KEY,
|
||||||
|
TextUtils.join( ",", s_peersSet ) );
|
||||||
|
}
|
||||||
|
|
||||||
private static class WFDBroadcastReceiver extends BroadcastReceiver
|
private static class WFDBroadcastReceiver extends BroadcastReceiver
|
||||||
implements WifiP2pManager.ConnectionInfoListener,
|
implements WifiP2pManager.ConnectionInfoListener,
|
||||||
WifiP2pManager.PeerListListener {
|
WifiP2pManager.PeerListListener {
|
||||||
|
@ -1025,7 +1092,7 @@ public class WiDirService extends XWService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive( Context context, Intent intent ) {
|
public void onReceive( Context context, Intent intent ) {
|
||||||
if ( BuildConfig.WIDIR_ENABLED ) {
|
if ( enabled() ) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
DbgUtils.logd( TAG, "got intent: " + intent.toString() );
|
DbgUtils.logd( TAG, "got intent: " + intent.toString() );
|
||||||
|
|
||||||
|
@ -1115,6 +1182,8 @@ public class WiDirService extends XWService {
|
||||||
DbgUtils.logd( TAG, "got list of %d peers",
|
DbgUtils.logd( TAG, "got list of %d peers",
|
||||||
peerList.getDeviceList().size() );
|
peerList.getDeviceList().size() );
|
||||||
|
|
||||||
|
updatePeersList( peerList );
|
||||||
|
|
||||||
for ( WifiP2pDevice device : peerList.getDeviceList() ) {
|
for ( WifiP2pDevice device : peerList.getDeviceList() ) {
|
||||||
// DbgUtils.logd( TAG, "not connecting to: %s", device.toString() );
|
// DbgUtils.logd( TAG, "not connecting to: %s", device.toString() );
|
||||||
tryConnect( device );
|
tryConnect( device );
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class CommsAddrRec {
|
||||||
if ( Utils.isGSMPhone( context ) ) {
|
if ( Utils.isGSMPhone( context ) ) {
|
||||||
supported.add( CommsConnType.COMMS_CONN_SMS );
|
supported.add( CommsConnType.COMMS_CONN_SMS );
|
||||||
}
|
}
|
||||||
if ( WiDirService.supported() ) {
|
if ( WiDirService.enabled() ) {
|
||||||
supported.add( CommsConnType.COMMS_CONN_P2P );
|
supported.add( CommsConnType.COMMS_CONN_P2P );
|
||||||
}
|
}
|
||||||
return supported;
|
return supported;
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
<string name="key_disable_relay">key_disable_relay</string>
|
<string name="key_disable_relay">key_disable_relay</string>
|
||||||
<string name="key_notify_vibrate">key_notify_vibrate</string>
|
<string name="key_notify_vibrate">key_notify_vibrate</string>
|
||||||
<string name="key_enable_sms">key_enable_sms</string>
|
<string name="key_enable_sms">key_enable_sms</string>
|
||||||
|
<string name="key_enable_p2p">key_enable_p2p</string>
|
||||||
<string name="key_network_behavior">key_network_behavior</string>
|
<string name="key_network_behavior">key_network_behavior</string>
|
||||||
<string name="key_keep_screenon">key_keep_screenon</string>
|
<string name="key_keep_screenon">key_keep_screenon</string>
|
||||||
<string name="key_thumbsize">key_thumbsize3</string>
|
<string name="key_thumbsize">key_thumbsize3</string>
|
||||||
|
|
|
@ -2081,6 +2081,9 @@
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="enable_sms_summary">Only if you have unlimited texting!</string>
|
<string name="enable_sms_summary">Only if you have unlimited texting!</string>
|
||||||
|
|
||||||
|
<string name="title_enable_p2p">Enable WiFi Direct</string>
|
||||||
|
<string name="summary_enable_p2p">Experimental, uses lots of battery</string>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="confirm_sms_title">Confirm your SMS plan</string>
|
<string name="confirm_sms_title">Confirm your SMS plan</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
|
@ -325,6 +325,11 @@
|
||||||
android:summary="@string/notify_other_summary"
|
android:summary="@string/notify_other_summary"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
/>
|
/>
|
||||||
|
<CheckBoxPreference android:key="@string/key_enable_p2p"
|
||||||
|
android:title="@string/title_enable_p2p"
|
||||||
|
android:summary="@string/summary_enable_p2p"
|
||||||
|
android:defaultValue="false"
|
||||||
|
/>
|
||||||
|
|
||||||
<PreferenceScreen android:title="@string/network_advanced_title"
|
<PreferenceScreen android:title="@string/network_advanced_title"
|
||||||
android:summary="@string/network_advanced_summary"
|
android:summary="@string/network_advanced_summary"
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "xportwrapper.h"
|
#include "xportwrapper.h"
|
||||||
#include "andutils.h"
|
#include "andutils.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
|
|
||||||
typedef struct _AndTransportProcs {
|
typedef struct _AndTransportProcs {
|
||||||
|
@ -145,7 +146,7 @@ and_xport_sendNoConn( const XP_U8* buf, XP_U16 len, const XP_UCHAR* msgNo,
|
||||||
jbytes, jMsgNo, jRelayID );
|
jbytes, jMsgNo, jRelayID );
|
||||||
deleteLocalRefs( env, jbytes, jRelayID, jMsgNo, DELETE_NO_REF );
|
deleteLocalRefs( env, jbytes, jRelayID, jMsgNo, DELETE_NO_REF );
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", result );
|
LOG_RETURNF( "%s", boolToStr(result) );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* -*- compile-command: "find-and-ant.sh debug install"; -*- */
|
/* -*- compile-command: "find-and-gradle.sh installXw4Debug"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright © 2009 - 2014 by Eric House (xwords@eehouse.org). All rights
|
* Copyright © 2009 - 2014 by Eric House (xwords@eehouse.org). All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "mempool.h"
|
#include "mempool.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
#include "dictnry.h"
|
#include "dictnry.h"
|
||||||
#include "dictiter.h"
|
#include "dictiter.h"
|
||||||
#include "dictmgr.h"
|
#include "dictmgr.h"
|
||||||
|
@ -1507,7 +1508,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1initClientConnection
|
||||||
stream_setOnCloseProc( stream, and_send_on_close );
|
stream_setOnCloseProc( stream, and_send_on_close );
|
||||||
result = server_initClientConnection( state->game.server, stream );
|
result = server_initClientConnection( state->game.server, stream );
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
LOG_RETURNF( "%d", result );
|
LOG_RETURNF( "%s", boolToStr(result) );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "memstream.h"
|
#include "memstream.h"
|
||||||
#include "xwrelay.h"
|
#include "xwrelay.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
|
|
||||||
#define HEARTBEAT_NONE 0
|
#define HEARTBEAT_NONE 0
|
||||||
|
|
||||||
|
@ -1812,7 +1813,7 @@ relayPreProcess( CommsCtxt* comms, XWStreamCtxt* stream, XWHostID* senderID )
|
||||||
XP_LOGF( "%s: dropping relay msg with cmd %d", __func__, (XP_U16)cmd );
|
XP_LOGF( "%s: dropping relay msg with cmd %d", __func__, (XP_U16)cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_RETURNF( "%d", consumed );
|
LOG_RETURNF( "%s", boolToStr(consumed) );
|
||||||
return consumed;
|
return consumed;
|
||||||
} /* relayPreProcess */
|
} /* relayPreProcess */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1893,7 +1894,7 @@ preProcess( CommsCtxt* comms, const CommsAddrRec* useAddr,
|
||||||
XP_ASSERT(0);
|
XP_ASSERT(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", consumed );
|
LOG_RETURNF( "%s", boolToStr(consumed) );
|
||||||
return consumed;
|
return consumed;
|
||||||
} /* preProcess */
|
} /* preProcess */
|
||||||
|
|
||||||
|
@ -1981,6 +1982,7 @@ getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr,
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
checkChannelNo( CommsCtxt* comms, XP_PlayerAddr* channelNoP )
|
checkChannelNo( CommsCtxt* comms, XP_PlayerAddr* channelNoP )
|
||||||
{
|
{
|
||||||
|
XP_Bool success = XP_TRUE;
|
||||||
XP_PlayerAddr channelNo = *channelNoP;
|
XP_PlayerAddr channelNo = *channelNoP;
|
||||||
if ( 0 == (channelNo & CHANNEL_MASK) ) {
|
if ( 0 == (channelNo & CHANNEL_MASK) ) {
|
||||||
channelNo |= ++comms->nextChannelNo;
|
channelNo |= ++comms->nextChannelNo;
|
||||||
|
@ -1990,7 +1992,8 @@ checkChannelNo( CommsCtxt* comms, XP_PlayerAddr* channelNoP )
|
||||||
comms->nextChannelNo = channelNo;
|
comms->nextChannelNo = channelNo;
|
||||||
}
|
}
|
||||||
*channelNoP = channelNo;
|
*channelNoP = channelNo;
|
||||||
return XP_TRUE; /* for now */
|
LOG_RETURNF( "%s", boolToStr(success) );
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An initial message comes only from a client to a server, and from the
|
/* An initial message comes only from a client to a server, and from the
|
||||||
|
|
|
@ -37,6 +37,7 @@ void dbg_logstream( const XWStreamCtxt* stream, const char* func, int line );
|
||||||
# define XP_LOGSTREAM( s )
|
# define XP_LOGSTREAM( s )
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#define boolToStr(b) ((b)?"true" : "false")
|
||||||
|
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
# define DIRTY_SLOT XP_Bool _isDirty;
|
# define DIRTY_SLOT XP_Bool _isDirty;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "nli.h"
|
#include "nli.h"
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
nli_init( NetLaunchInfo* nli, const CurGameInfo* gi, const CommsAddrRec* addr,
|
nli_init( NetLaunchInfo* nli, const CurGameInfo* gi, const CommsAddrRec* addr,
|
||||||
|
@ -135,7 +136,7 @@ nli_makeFromStream( NetLaunchInfo* nli, XWStreamCtxt* stream )
|
||||||
nli->osVers = stream_getU32( stream );
|
nli->osVers = stream_getU32( stream );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", success );
|
LOG_RETURNF( "%s", boolToStr(success) );
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "movestak.h"
|
#include "movestak.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
#include "gtkask.h"
|
#include "gtkask.h"
|
||||||
#include "gtkinvit.h"
|
#include "gtkinvit.h"
|
||||||
#include "gtkaskm.h"
|
#include "gtkaskm.h"
|
||||||
|
@ -2819,7 +2820,7 @@ makeNewGame( GtkGameGlobals* globals )
|
||||||
gi->dictName, XP_TRUE );
|
gi->dictName, XP_TRUE );
|
||||||
gi->dictLang = dict_getLangCode( cGlobals->dict );
|
gi->dictLang = dict_getLangCode( cGlobals->dict );
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", success );
|
LOG_RETURNF( "%s", boolToStr(success) );
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "strutils.h"
|
#include "strutils.h"
|
||||||
|
#include "dbgutil.h"
|
||||||
#include "dictiter.h"
|
#include "dictiter.h"
|
||||||
/* #include "commgr.h" */
|
/* #include "commgr.h" */
|
||||||
/* #include "compipe.h" */
|
/* #include "compipe.h" */
|
||||||
|
@ -1052,7 +1053,7 @@ send_or_close( CommonGlobals* cGlobals, const XP_U8* buf, size_t len )
|
||||||
g_slist_free( cGlobals->packetQueue );
|
g_slist_free( cGlobals->packetQueue );
|
||||||
cGlobals->packetQueue = NULL;
|
cGlobals->packetQueue = NULL;
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", success );
|
LOG_RETURNF( "%s", boolToStr(success) );
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2664,4 +2665,3 @@ main( int argc, char** argv )
|
||||||
XP_LOGF( "%s exiting main, returning %d", argv[0], result );
|
XP_LOGF( "%s exiting main, returning %d", argv[0], result );
|
||||||
return result;
|
return result;
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ remembered( const LinUDPStuff* stuff, int sock )
|
||||||
known = XP_TRUE;
|
known = XP_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_RETURNF( "%d", (int)known );
|
LOG_RETURNF( "%s", boolToStr(known) );
|
||||||
return known;
|
return known;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue