cleanup: mostly removing logging and wrapping rematch code in an

if(false) so it goes away.
This commit is contained in:
Eric House 2015-06-14 22:39:47 -07:00
parent 4b6ea57e70
commit d4bfaca127
19 changed files with 119 additions and 148 deletions

View file

@ -431,12 +431,9 @@ and_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode )
return result;
}
/* FIXME: This will always return the same string, ignoring quantity all but
the first time (because of util->userStrings) */
static const XP_UCHAR*
and_util_getUserQuantityString( XW_UtilCtxt* uc, XP_U16 stringCode, XP_U16 quantity )
{
LOG_FUNC();
XP_UCHAR* result = "";
UTIL_CBK_HEADER("getUserQuantityString", "(II)Ljava/lang/String;" );
int index = stringCode - 1; /* see LocalizedStrIncludes.h */
@ -478,7 +475,6 @@ and_util_getUserQuantityString( XW_UtilCtxt* uc, XP_U16 stringCode, XP_U16 quant
result = ptrs[indx];
UTIL_CBK_TAIL();
LOG_RETURNF( "%s", result );
return result;
}

View file

@ -1385,8 +1385,6 @@ public class BoardDelegate extends DelegateBase
private void handleConndMessage( String room, int devOrder, // <- hostID
boolean allHere, int nMissing )
{
DbgUtils.logf( "BoardDelegate.handleConndMessage(): nMissing = %d", nMissing );
dismissInviteAlert( nMissing, true );
int naMsg = 0;
@ -1732,8 +1730,8 @@ public class BoardDelegate extends DelegateBase
{
m_connTypes = connTypes;
Assert.assertTrue( isServer || 0 == nMissing );
DbgUtils.logf( "BoardDelegate.informMissing(isServer=%b, nDevs=%d, nMissing=%d)",
isServer, nDevs, nMissing );
// DbgUtils.logf( "BoardDelegate.informMissing(isServer=%b, nDevs=%d, nMissing=%d)",
// isServer, nDevs, nMissing );
m_nGuestDevs = nDevs;
// If we might have put up an alert earlier, take it down
@ -1891,7 +1889,6 @@ public class BoardDelegate extends DelegateBase
m_gi = new CurGameInfo( m_activity );
m_gi.setName( gameName );
XwJNI.gi_from_stream( m_gi, stream );
DbgUtils.logf( "BoardDelegate:after loadGame: gi.nPlayers: %d", m_gi.nPlayers );
String langName = m_gi.langName();
m_summary = DBUtils.getSummary( m_activity, m_gameLock );
@ -2443,39 +2440,41 @@ public class BoardDelegate extends DelegateBase
private void doRematch()
{
String phone = null;
String btAddr = null;
String relayID = null;
if ( m_gi.serverRole != DeviceRole.SERVER_STANDALONE ) {
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( m_jniGamePtr );
for ( CommsAddrRec addr : addrs ) {
if ( addr.contains( CommsConnType.COMMS_CONN_BT ) ) {
Assert.assertNull( btAddr );
btAddr = addr.bt_btAddr;
}
if ( addr.contains( CommsConnType.COMMS_CONN_SMS ) ) {
Assert.assertNull( phone );
phone = addr.sms_phone;
}
if ( addr.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
Assert.assertNull( relayID );
relayID = m_summary.relayID;
if ( XWApp.REMATCH_SUPPORTED ) {
String phone = null;
String btAddr = null;
String relayID = null;
if ( m_gi.serverRole != DeviceRole.SERVER_STANDALONE ) {
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( m_jniGamePtr );
for ( CommsAddrRec addr : addrs ) {
if ( addr.contains( CommsConnType.COMMS_CONN_BT ) ) {
Assert.assertNull( btAddr );
btAddr = addr.bt_btAddr;
}
if ( addr.contains( CommsConnType.COMMS_CONN_SMS ) ) {
Assert.assertNull( phone );
phone = addr.sms_phone;
}
if ( addr.contains( CommsConnType.COMMS_CONN_RELAY ) ) {
Assert.assertNull( relayID );
relayID = m_summary.relayID;
}
}
}
}
Intent intent = GamesListDelegate
.makeRematchIntent( m_activity, m_rowid, m_connTypes, btAddr,
phone, relayID );
if ( null != intent ) {
startActivity( intent );
finish();
Intent intent = GamesListDelegate
.makeRematchIntent( m_activity, m_rowid, m_connTypes, btAddr,
phone, relayID );
if ( null != intent ) {
startActivity( intent );
finish();
}
}
}
private void tryRematchInvites()
{
if ( !m_rematchInvitesSent ) {
if ( XWApp.REMATCH_SUPPORTED && !m_rematchInvitesSent ) {
m_rematchInvitesSent = true;
Assert.assertNotNull( m_summary );

View file

@ -453,8 +453,6 @@ public class CommsTransport implements TransportProcs,
Assert.fail();
break;
}
DbgUtils.logf( "sendForAddr(addr=%s)=>%d", conType.toString(),
nSent );
return nSent;
}

View file

@ -60,7 +60,6 @@ public class DBHelper extends SQLiteOpenHelper {
public static final String GAMEID = "GAMEID";
public static final String REMOTEDEVS = "REMOTEDEVS";
public static final String EXTRAS = "EXTRAS";
public static final String JSON_EXTRAS = "JSON_EXTRAS";
public static final String DICTLANG = "DICTLANG";
public static final String DICTLIST = "DICTLIST";
public static final String HASMSGS = "HASMSGS";

View file

@ -373,19 +373,21 @@ public class DBUtils {
public static void addRematchInfo( Context context, long rowid, String btAddr,
String phone, String relayID )
{
GameLock lock = new GameLock( rowid, true ).lock();
GameSummary summary = getSummary( context, lock );
if ( null != btAddr ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_BTADDR, btAddr );
if ( XWApp.REMATCH_SUPPORTED ) {
GameLock lock = new GameLock( rowid, true ).lock();
GameSummary summary = getSummary( context, lock );
if ( null != btAddr ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_BTADDR, btAddr );
}
if ( null != phone ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_PHONE, phone );
}
if ( null != relayID ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_RELAY, relayID );
}
saveSummary( context, lock, summary );
lock.unlock();
}
if ( null != phone ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_PHONE, phone );
}
if ( null != relayID ) {
summary.putStringExtra( GameSummary.EXTRA_REMATCH_RELAY, relayID );
}
saveSummary( context, lock, summary );
lock.unlock();
}
public static int countGamesUsingLang( Context context, int lang )
@ -718,7 +720,7 @@ public class DBUtils {
cursor.close();
db.close();
}
DbgUtils.logf( "getMostRecentCreate(%d) => %H", gameID, result );
return result;
}
@ -763,7 +765,6 @@ public class DBUtils {
long[][] rowIDss = new long[1][];
String[] relayIDs = getRelayIDs( context, rowIDss );
boolean result = null != relayIDs && 0 < relayIDs.length;
DbgUtils.logf( "haveRelayGames() => %b", result );
return result;
}

View file

@ -194,8 +194,7 @@ public class DlgDelegate {
protected void showDialog( DlgID dlgID )
{
if ( !m_activity.isFinishing() ) {
int id = dlgID.ordinal();
m_activity.showDialog( id );
m_activity.showDialog( dlgID.ordinal() );
}
}

View file

@ -67,7 +67,6 @@ public class DwnldDelegate extends ListDelegateBase {
public interface OnGotLcDictListener {
void gotDictInfo( boolean success, String lc, String name );
}
public DwnldDelegate( ListDelegator delegator, Bundle savedInstanceState )

View file

@ -24,12 +24,10 @@ import android.os.Bundle;
public class GameConfigActivity extends XWActivity {
private GameConfigDelegate m_dlgt;
@Override
public void onCreate( Bundle savedInstanceState )
{
m_dlgt = new GameConfigDelegate( this, savedInstanceState );
super.onCreate( savedInstanceState, m_dlgt );
super.onCreate( savedInstanceState,
new GameConfigDelegate( this, savedInstanceState ) );
} // onCreate
}

View file

@ -601,9 +601,9 @@ public class GameUtils {
public static void launchEmailInviteActivity( Activity activity, NetLaunchInfo nli )
{
DbgUtils.logf( "launchEmailInviteActivity: nli=%s", nli.makeLaunchJSON() );
// DbgUtils.logf( "launchEmailInviteActivity: nli=%s", nli.makeLaunchJSON() );
Uri gameUri = nli.makeLaunchUri( activity );
DbgUtils.logf( "launchEmailInviteActivity: uri=%s", gameUri );
// DbgUtils.logf( "launchEmailInviteActivity: uri=%s", gameUri );
String msgString = null == gameUri ? null : gameUri.toString();
if ( null != msgString ) {

View file

@ -48,9 +48,9 @@ public class GamesListActivity extends XWListActivity {
// Trying to debug situation where two of this activity are running at
// once. finish()ing when Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT is
// passed is not the fix, but perhaps there's another
int flags = getIntent().getFlags();
DbgUtils.logf( "GamesListActivity.onCreate(this=%H): flags=0x%x",
this, flags );
// int flags = getIntent().getFlags();
// DbgUtils.logf( "GamesListActivity.onCreate(this=%H): flags=0x%x",
// this, flags );
} // onCreate
// called when we're brought to the front (probably as a result of

View file

@ -1847,28 +1847,30 @@ public class GamesListDelegate extends ListDelegateBase
// used to connect.
private void startRematch( Intent intent )
{
long rowid = intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 );
if ( XWApp.REMATCH_SUPPORTED && -1 != rowid ) {
String btAddr = intent.getStringExtra( REMATCH_BTADDR_EXTRA );
String phone = intent.getStringExtra( REMATCH_PHONE_EXTRA );
String relayID = intent.getStringExtra( REMATCH_RELAYID_EXTRA );
long newid;
if ( null == btAddr && null == phone && null == relayID ) {
// this will juggle if the preference is set
newid = GameUtils.dupeGame( m_activity, rowid );
} else {
int bits = intent.getIntExtra( REMATCH_ADDRS_EXTRA, -1 );
CommsConnTypeSet addrs = new CommsConnTypeSet( bits );
if ( XWApp.REMATCH_SUPPORTED ) {
long rowid = intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 );
if ( -1 != rowid ) {
String btAddr = intent.getStringExtra( REMATCH_BTADDR_EXTRA );
String phone = intent.getStringExtra( REMATCH_PHONE_EXTRA );
String relayID = intent.getStringExtra( REMATCH_RELAYID_EXTRA );
long newid;
if ( null == btAddr && null == phone && null == relayID ) {
// this will juggle if the preference is set
newid = GameUtils.dupeGame( m_activity, rowid );
} else {
int bits = intent.getIntExtra( REMATCH_ADDRS_EXTRA, -1 );
CommsConnTypeSet addrs = new CommsConnTypeSet( bits );
long groupID = DBUtils.getGroupForGame( m_activity, rowid );
String gameName = "rematch"; // FIX ME :-)
newid = GameUtils.makeNewMultiGame( m_activity, groupID, addrs,
gameName );
long groupID = DBUtils.getGroupForGame( m_activity, rowid );
String gameName = "rematch"; // FIX ME :-)
newid = GameUtils.makeNewMultiGame( m_activity, groupID,
addrs, gameName );
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
relayID );
DBUtils.addRematchInfo( m_activity, newid, btAddr, phone,
relayID );
}
launchGame( newid );
}
launchGame( newid );
}
}
@ -2104,12 +2106,6 @@ public class GamesListDelegate extends ListDelegateBase
launchGame( rowid, true );
}
// private void makeNewBTGame( NetLaunchInfo nli )
// {
// long rowid = GameUtils.makeNewBTGame( m_activity, nli );
// launchGame( rowid, true );
// }
private void tryStartsFromIntent( Intent intent )
{
startFirstHasDict( intent );
@ -2128,17 +2124,6 @@ public class GamesListDelegate extends ListDelegateBase
if ( summary.conTypes.contains( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY )
&& summary.roomName.length() == 0 ) {
Assert.fail();
// If it's unconfigured and of the type RelayGameActivity
// can handle send it there, otherwise use the full-on
// config.
// Class clazz;
// if ( RelayGameDelegate.isSimpleGame( summary ) ) {
// clazz = RelayGameActivity.class;
// } else {
// clazz = GameConfigActivity.class;
// }
// GameUtils.doConfig( m_activity, rowid, clazz );
} else {
if ( checkWarnNoDict( rowid ) ) {
launchGame( rowid );
@ -2273,18 +2258,21 @@ public class GamesListDelegate extends ListDelegateBase
String btAddr, String phone,
String relayID )
{
DbgUtils.logf( "makeRematchIntent(btAddr=%s; phone=%s)", btAddr, phone );
Intent intent = makeSelfIntent( context );
intent.putExtra( REMATCH_ROWID_EXTRA, rowid );
intent.putExtra( REMATCH_ADDRS_EXTRA, addrTypes.toInt() );
if ( null != btAddr ) {
intent.putExtra( REMATCH_BTADDR_EXTRA, btAddr );
}
if ( null != phone ) {
intent.putExtra( REMATCH_PHONE_EXTRA, phone );
}
if ( null != relayID ) {
intent.putExtra( REMATCH_RELAYID_EXTRA, relayID );
Intent intent = null;
if ( XWApp.REMATCH_SUPPORTED ) {
DbgUtils.logf( "makeRematchIntent(btAddr=%s; phone=%s)", btAddr, phone );
intent = makeSelfIntent( context );
intent.putExtra( REMATCH_ROWID_EXTRA, rowid );
intent.putExtra( REMATCH_ADDRS_EXTRA, addrTypes.toInt() );
if ( null != btAddr ) {
intent.putExtra( REMATCH_BTADDR_EXTRA, btAddr );
}
if ( null != phone ) {
intent.putExtra( REMATCH_PHONE_EXTRA, phone );
}
if ( null != relayID ) {
intent.putExtra( REMATCH_RELAYID_EXTRA, relayID );
}
}
return intent;
}

View file

@ -235,7 +235,7 @@ public class NetLaunchInfo {
this( gi );
for ( CommsConnType typ : summary.conTypes.getTypes() ) {
DbgUtils.logf( "NetLaunchInfo(): got type %s", typ.toString() );
// DbgUtils.logf( "NetLaunchInfo(): got type %s", typ.toString() );
switch( typ ) {
case COMMS_CONN_BT:
addBTInfo();
@ -268,7 +268,7 @@ public class NetLaunchInfo {
String result = m_inviteID;
if ( null == result ) {
result = GameUtils.formatGameID( m_gameID );
DbgUtils.logf( "inviteID(): m_inviteID null so substituting %s", result );
// DbgUtils.logf( "inviteID(): m_inviteID null so substituting %s", result );
}
return result;
}
@ -279,7 +279,7 @@ public class NetLaunchInfo {
if ( 0 == result ) {
Assert.assertNotNull( m_inviteID );
result = Integer.parseInt( m_inviteID, 16 );
DbgUtils.logf( "gameID(): m_gameID -1 so substituting %d", result );
// DbgUtils.logf( "gameID(): m_gameID -1 so substituting %d", result );
m_gameID = result;
}
Assert.assertTrue( 0 != result );
@ -465,10 +465,11 @@ public class NetLaunchInfo {
}
Uri result = ub.build();
// Now test
DbgUtils.logf( "testing %s...", result.toString() );
NetLaunchInfo instance = new NetLaunchInfo( context, result );
Assert.assertTrue( instance.isValid() );
if ( BuildConfig.DEBUG ) { // Test...
DbgUtils.logf( "testing %s...", result.toString() );
NetLaunchInfo instance = new NetLaunchInfo( context, result );
Assert.assertTrue( instance.isValid() );
}
return result;
}
@ -505,7 +506,7 @@ public class NetLaunchInfo {
public boolean isValid()
{
DbgUtils.logf( "NetLaunchInfo(%s).isValid() => %b", toString(), m_valid );
// DbgUtils.logf( "NetLaunchInfo(%s).isValid() => %b", toString(), m_valid );
return m_valid;
}
@ -531,7 +532,7 @@ public class NetLaunchInfo {
private void calcValid()
{
boolean valid = hasCommon() && null != m_addrs;
DbgUtils.logf( "calcValid(%s)", toString() );
// DbgUtils.logf( "calcValid(%s)", toString() );
if ( valid ) {
for ( Iterator<CommsConnType> iter = m_addrs.iterator();
valid && iter.hasNext(); ) {

View file

@ -101,8 +101,8 @@ public class NetStateCache {
NetworkInfo ni = connMgr.getActiveNetworkInfo();
s_netAvail = ni != null && ni.isAvailable() && ni.isConnected();
DbgUtils.logf( "NetStateCache.initIfNot(): set s_netAvail = %b",
s_netAvail );
// DbgUtils.logf( "NetStateCache.initIfNot(): set s_netAvail = %b",
// s_netAvail );
s_receiver = new PvtBroadcastReceiver();
IntentFilter filter = new IntentFilter();
@ -132,7 +132,6 @@ public class NetStateCache {
@Override
public void onReceive( final Context context, Intent intent )
{
DbgUtils.logf( "NetStateCache.onReceive()" );
DbgUtils.assertOnUIThread();
if ( intent.getAction().
@ -159,8 +158,6 @@ public class NetStateCache {
if ( s_netAvail != netAvail ) {
s_netAvail = netAvail; // keep current in case we're asked
DbgUtils.logf( "NetStateCache.onReceive(): set s_netAvail"
+ " = %b", s_netAvail );
// We want to wait for WAIT_STABLE_MILLIS of inactivity
// before informing listeners. So each time there's a

View file

@ -43,7 +43,6 @@ public class RelayReceiver extends BroadcastReceiver {
public static void setTimer( Context context, long interval_millis )
{
DbgUtils.logf( "RelayReceiver.restartTimer(%d)", interval_millis );
AlarmManager am =
(AlarmManager)context.getSystemService( Context.ALARM_SERVICE );
@ -56,7 +55,6 @@ public class RelayReceiver extends BroadcastReceiver {
long fire_millis = SystemClock.elapsedRealtime() + interval_millis;
am.set( AlarmManager.ELAPSED_REALTIME_WAKEUP, fire_millis, pi );
} else {
DbgUtils.logf( "RelayReceiver.restartTimer(): cancelling" );
// will happen if user's set getProxyIntervalSeconds to return 0
am.cancel( pi );
}

View file

@ -588,7 +588,7 @@ public class RelayService extends XWService
if ( !skipAck ) {
sendAckIf( header );
}
DbgUtils.logf( "RelayService.gotPacket: cmd=%s", header.m_cmd.toString() );
// DbgUtils.logf( "RelayService.gotPacket: cmd=%s", header.m_cmd.toString() );
switch ( header.m_cmd ) {
case XWPDEV_UNAVAIL:
int unavail = dis.readInt();
@ -614,8 +614,8 @@ public class RelayService extends XWService
case XWPDEV_REGRSP:
str = getVLIString( dis );
short maxIntervalSeconds = dis.readShort();
DbgUtils.logf( "got relayid %s, maxInterval %d", str,
maxIntervalSeconds );
// DbgUtils.logf( "got relayid %s, maxInterval %d", str,
// maxIntervalSeconds );
setMaxIntervalSeconds( maxIntervalSeconds );
XWPrefs.setRelayDevID( this, str );
s_registered = true;

View file

@ -43,13 +43,11 @@ public class SMSReceiver extends BroadcastReceiver {
for ( int ii = 0; ii < pdus.length; ++ii ) {
SmsMessage sms = SmsMessage.createFromPdu((byte[])pdus[ii]);
if ( null == sms ) {
continue;
if ( null != sms ) {
String phone = sms.getOriginatingAddress();
byte[] body = sms.getUserData();
SMSService.handleFrom( context, body, phone );
}
String phone = sms.getOriginatingAddress();
byte[] body = sms.getUserData();
SMSService.handleFrom( context, body, phone );
}
}
}

View file

@ -87,7 +87,6 @@ public class XWConnAddrPreference extends DialogPreference {
public void onClick( DialogInterface dialog, int which )
{
if ( AlertDialog.BUTTON_POSITIVE == which ) {
DbgUtils.logf( "ok pressed" );
CommsConnTypeSet curSet = m_view.getTypes();
XWPrefs.setAddrTypes( m_context, curSet );
setSummary( curSet.toString( m_context ) );

View file

@ -30,6 +30,7 @@ import org.json.JSONObject;
import org.eehouse.android.xw4.DbgUtils;
import org.eehouse.android.xw4.R;
import org.eehouse.android.xw4.Utils;
import org.eehouse.android.xw4.XWApp;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
@ -429,17 +430,19 @@ public class GameSummary {
public boolean hasRematchInfo()
{
boolean found = false;
String[] keys = { EXTRA_REMATCH_BTADDR,
EXTRA_REMATCH_PHONE,
EXTRA_REMATCH_RELAY,
};
for ( String key : keys ) {
found = null != getStringExtra( key );
if ( found ) {
break;
if ( XWApp.REMATCH_SUPPORTED ) {
String[] keys = { EXTRA_REMATCH_BTADDR,
EXTRA_REMATCH_PHONE,
EXTRA_REMATCH_RELAY,
};
for ( String key : keys ) {
found = null != getStringExtra( key );
if ( found ) {
break;
}
}
DbgUtils.logf( "hasRematchInfo() => %b", found );
}
DbgUtils.logf( "hasRematchInfo() => %b", found );
return found;
}

View file

@ -234,7 +234,6 @@ public class UtilCtxtImpl implements UtilCtxt {
if ( 0 != pluralsId ) {
result = LocUtils.getQuantityString( m_context, pluralsId, quantity );
}
DbgUtils.logf( "UtilCtxtImpl.getUserQuantityString() => %s", result );
return result;
}
@ -303,7 +302,6 @@ public class UtilCtxtImpl implements UtilCtxt {
{
Assert.assertTrue( XWApp.SMSSUPPORTED );
boolean same = PhoneNumberUtils.compare( m_context, num1, num2 );
DbgUtils.logf( "phoneNumbersSame => %b", same );
return same;
}