Merge remote-tracking branch 'sf/android_branch' into android_branch

This commit is contained in:
Eric House 2016-10-25 06:14:33 -07:00
commit c3c2795f67
72 changed files with 562 additions and 533 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ xwords_4.4.0.0*
gcm_loop.shelf gcm_loop.shelf
nohup.out nohup.out
/xwords4/android/XWords4-dbg/src/xw4dbg/assets/gitvers.txt /xwords4/android/XWords4-dbg/src/xw4dbg/assets/gitvers.txt
/xwords4/linux/xwgames.sqldb

View file

@ -92,10 +92,11 @@ LOCAL_LDLIBS := -L${SYSROOT}/usr/lib -llog -lz
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
ifneq ($(shell which ccache),) # This recipe doesn't work with clang. Fix if using gcc again
TARGET_CC = ccache $(TOOLCHAIN_PREFIX)gcc # ifneq ($(shell which ccache),)
TARGET_CXX = ccache $(TOOLCHAIN_PREFIX)g++ # TARGET_CC = ccache $(TOOLCHAIN_PREFIX)gcc
endif # TARGET_CXX = ccache $(TOOLCHAIN_PREFIX)g++
# endif
COMMON_SRC_FILES := COMMON_SRC_FILES :=
COMMON_PATH := COMMON_PATH :=

View file

@ -33,8 +33,8 @@ public class BTReceiver extends BroadcastReceiver {
{ {
if ( XWApp.BTSUPPORTED ) { if ( XWApp.BTSUPPORTED ) {
String action = intent.getAction(); String action = intent.getAction();
DbgUtils.logdf( "BTReceiver.onReceive(action=%s, intent=%s)", DbgUtils.logd( getClass(), "BTReceiver.onReceive(action=%s, intent=%s)",
action, intent.toString() ); action, intent.toString() );
if ( action.equals( BluetoothDevice.ACTION_ACL_CONNECTED ) ) { if ( action.equals( BluetoothDevice.ACTION_ACL_CONNECTED ) ) {
BTService.startService( context ); BTService.startService( context );

View file

@ -301,7 +301,7 @@ public class BTService extends XWService {
} }
if ( -1 == nSent ) { if ( -1 == nSent ) {
DbgUtils.logf( "BTService.enqueueFor(): can't send to %s", DbgUtils.logi( BTService.class, "enqueueFor(): can't send to %s",
targetAddr.bt_hostName ); targetAddr.bt_hostName );
} }
return nSent; return nSent;
@ -328,13 +328,13 @@ public class BTService extends XWService {
? BluetoothAdapter.getDefaultAdapter() : null; ? BluetoothAdapter.getDefaultAdapter() : null;
if ( null != adapter && adapter.isEnabled() ) { if ( null != adapter && adapter.isEnabled() ) {
m_adapter = adapter; m_adapter = adapter;
DbgUtils.logf( "BTService.onCreate(); bt name = %s; bt addr = %s", DbgUtils.logi( getClass(), "onCreate(); bt name = %s; bt addr = %s",
adapter.getName(), adapter.getAddress() ); adapter.getName(), adapter.getAddress() );
initAddrs(); initAddrs();
startListener(); startListener();
startSender(); startSender();
} else { } else {
DbgUtils.logf( "not starting threads: BT not available" ); DbgUtils.logw( getClass(), "not starting threads: BT not available" );
stopSelf(); stopSelf();
} }
} }
@ -348,11 +348,11 @@ public class BTService extends XWService {
if ( -1 == ordinal ) { if ( -1 == ordinal ) {
// Drop it // Drop it
} else if ( null == m_sender ) { } else if ( null == m_sender ) {
DbgUtils.logf( "exiting: m_queue is null" ); DbgUtils.logw( getClass(), "exiting: m_queue is null" );
stopSelf(); stopSelf();
} else { } else {
BTAction cmd = BTAction.values()[ordinal]; BTAction cmd = BTAction.values()[ordinal];
DbgUtils.logf( "BTService.onStartCommand; cmd=%s", cmd.toString() ); DbgUtils.logi( getClass(), "onStartCommand; cmd=%s", cmd.toString() );
switch( cmd ) { switch( cmd ) {
case CLEAR: case CLEAR:
String[] btAddrs = intent.getStringArrayExtra( CLEAR_KEY ); String[] btAddrs = intent.getStringArrayExtra( CLEAR_KEY );
@ -365,7 +365,7 @@ public class BTService extends XWService {
case INVITE: case INVITE:
String jsonData = intent.getStringExtra( GAMEDATA_KEY ); String jsonData = intent.getStringExtra( GAMEDATA_KEY );
NetLaunchInfo nli = new NetLaunchInfo( this, jsonData ); NetLaunchInfo nli = new NetLaunchInfo( this, jsonData );
DbgUtils.logf( "onStartCommand: nli: %s", nli.toString() ); DbgUtils.logi( getClass(), "onStartCommand: nli: %s", nli.toString() );
String btAddr = intent.getStringExtra( ADDR_KEY ); String btAddr = intent.getStringExtra( ADDR_KEY );
m_sender.add( new BTQueueElem( BTCmd.INVITE, nli, btAddr ) ); m_sender.add( new BTQueueElem( BTCmd.INVITE, nli, btAddr ) );
break; break;
@ -465,7 +465,7 @@ public class BTService extends XWService {
break; break;
default: default:
DbgUtils.logf( "unexpected msg %s", cmd.toString()); DbgUtils.loge( getClass(), "unexpected msg %s", cmd.toString());
break; break;
} }
updateStatusIn( true ); updateStatusIn( true );
@ -479,7 +479,7 @@ public class BTService extends XWService {
sendBadProto( socket ); sendBadProto( socket );
} }
} catch ( IOException ioe ) { } catch ( IOException ioe ) {
DbgUtils.logf( "trying again..." ); DbgUtils.logw( getClass(), "trying again..." );
logIOE( ioe); logIOE( ioe);
continue; continue;
} }
@ -583,7 +583,7 @@ public class BTService extends XWService {
os.flush(); os.flush();
socket.close(); socket.close();
} else { } else {
DbgUtils.logf( "receiveMessages: read only %d of %d bytes", DbgUtils.loge( getClass(), "receiveMessages: read only %d of %d bytes",
nRead, len ); nRead, len );
} }
} catch ( IOException ioe ) { } catch ( IOException ioe ) {
@ -685,7 +685,7 @@ public class BTService extends XWService {
try { try {
elem = m_queue.poll( timeout, TimeUnit.SECONDS ); elem = m_queue.poll( timeout, TimeUnit.SECONDS );
} catch ( InterruptedException ie ) { } catch ( InterruptedException ie ) {
DbgUtils.logf( "BTService: interrupted; killing thread" ); DbgUtils.logw( getClass(), "interrupted; killing thread" );
break; break;
} }
@ -812,7 +812,7 @@ public class BTService extends XWService {
outStream.writeShort( nliData.length ); outStream.writeShort( nliData.length );
outStream.write( nliData, 0, nliData.length ); outStream.write( nliData, 0, nliData.length );
} }
DbgUtils.logf( "<eeh>sending invite for %d players", elem.m_nPlayersH ); DbgUtils.logi( getClass(), "<eeh>sending invite for %d players", elem.m_nPlayersH );
outStream.flush(); outStream.flush();
DataInputStream inStream = DataInputStream inStream =
@ -855,7 +855,7 @@ public class BTService extends XWService {
MultiEvent evt; MultiEvent evt;
if ( success ) { if ( success ) {
evt = MultiEvent.MESSAGE_DROPPED; evt = MultiEvent.MESSAGE_DROPPED;
DbgUtils.logf( "BTService.sendMsg: dropping message %s because game %X dead", DbgUtils.logw( getClass(), "sendMsg: dropping message %s because game %X dead",
elem.m_cmd, elem.m_gameID ); elem.m_cmd, elem.m_gameID );
} else { } else {
evt = MultiEvent.MESSAGE_REFUSED; evt = MultiEvent.MESSAGE_REFUSED;
@ -1050,7 +1050,7 @@ public class BTService extends XWService {
try { try {
m_listener.join( 100 ); m_listener.join( 100 );
} catch ( InterruptedException ie ) { } catch ( InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
} }
m_listener = null; m_listener = null;
} }
@ -1061,7 +1061,7 @@ public class BTService extends XWService {
try { try {
m_sender.join( 100 ); m_sender.join( 100 );
} catch ( InterruptedException ie ) { } catch ( InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
} }
m_sender = null; m_sender = null;
} }
@ -1133,10 +1133,10 @@ public class BTService extends XWService {
dos = new DataOutputStream( socket.getOutputStream() ); dos = new DataOutputStream( socket.getOutputStream() );
dos.writeByte( BT_PROTO ); dos.writeByte( BT_PROTO );
dos.writeByte( cmd.ordinal() ); dos.writeByte( cmd.ordinal() );
DbgUtils.logf( "connect() to %s successful", name ); DbgUtils.logi( getClass(), "connect() to %s successful", name );
} catch ( IOException ioe ) { } catch ( IOException ioe ) {
dos = null; dos = null;
DbgUtils.logf( "BTService.connect() to %s failed", name ); DbgUtils.logw( getClass(), "BTService.connect() to %s failed", name );
// logIOE( ioe ); // logIOE( ioe );
} }
return dos; return dos;
@ -1144,7 +1144,7 @@ public class BTService extends XWService {
private void logIOE( IOException ioe ) private void logIOE( IOException ioe )
{ {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
++s_errCount; ++s_errCount;
// if ( 0 == s_errCount % 10 ) { // if ( 0 == s_errCount % 10 ) {
sendResult( MultiEvent.BT_ERR_COUNT, s_errCount ); sendResult( MultiEvent.BT_ERR_COUNT, s_errCount );
@ -1181,13 +1181,13 @@ public class BTService extends XWService {
try { try {
Thread.sleep( millis ); Thread.sleep( millis );
} catch ( InterruptedException ie ) { } catch ( InterruptedException ie ) {
DbgUtils.logf( "killSocketIn: killed by owner" ); DbgUtils.logw( getClass(), "killSocketIn: killed by owner" );
return; return;
} }
try { try {
socket.close(); socket.close();
} catch( IOException ioe ) { } catch( IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
} ); } );
@ -1204,7 +1204,7 @@ public class BTService extends XWService {
{ {
int nSent = -1; int nSent = -1;
if ( null == m_sender ) { if ( null == m_sender ) {
DbgUtils.logf( "sendViaBluetooth(): no send thread" ); DbgUtils.logw( getClass(), "sendViaBluetooth(): no send thread" );
} else { } else {
String btAddr = getSafeAddr( addr ); String btAddr = getSafeAddr( addr );
if ( null != btAddr && 0 < btAddr.length() ) { if ( null != btAddr && 0 < btAddr.length() ) {
@ -1212,7 +1212,7 @@ public class BTService extends XWService {
gameID ) ); gameID ) );
nSent = buf.length; nSent = buf.length;
} else { } else {
DbgUtils.logf( "sendViaBluetooth(): no addr for dev %s", DbgUtils.logi( BTService.class, "sendViaBluetooth(): no addr for dev %s",
addr.bt_hostName ); addr.bt_hostName );
} }
} }

View file

@ -182,7 +182,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
DbgUtils.assertOnUIThread(); DbgUtils.assertOnUIThread();
if ( null == jniThread ) { if ( null == jniThread ) {
} else if ( ! jniThread.equals( m_jniThread ) ) { } else if ( ! jniThread.equals( m_jniThread ) ) {
DbgUtils.logf( "BoardCanvas changing threads" ); DbgUtils.logw( getClass(), "changing threads" );
} }
m_jniThread = jniThread; m_jniThread = jniThread;
} }

View file

@ -91,7 +91,7 @@ public class BoardContainer extends ViewGroup {
measureChild( s_isPortrait ? HBAR_INDX : VBAR_INDX, m_toolsBounds ); measureChild( s_isPortrait ? HBAR_INDX : VBAR_INDX, m_toolsBounds );
adjustBounds(); adjustBounds();
View child = getChildAt( s_isPortrait ? HBAR_INDX : VBAR_INDX ); View child = getChildAt( s_isPortrait ? HBAR_INDX : VBAR_INDX );
DbgUtils.logf( "measured %s; passed ht: %d; got back ht: %d", DbgUtils.logi( getClass(), "measured %s; passed ht: %d; got back ht: %d",
child.toString(), m_toolsBounds.height(), child.toString(), m_toolsBounds.height(),
child.getMeasuredHeight() ); child.getMeasuredHeight() );

View file

@ -568,7 +568,7 @@ public class BoardDelegate extends DelegateBase
Bundle args = getArguments(); Bundle args = getArguments();
m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 ); m_rowid = args.getLong( GameUtils.INTENT_KEY_ROWID, -1 );
DbgUtils.logf( "BoardDelegate.init(): opening rowid %d", m_rowid ); DbgUtils.logi( getClass(), "opening rowid %d", m_rowid );
m_haveInvited = args.getBoolean( GameUtils.INVITED, false ); m_haveInvited = args.getBoolean( GameUtils.INVITED, false );
m_overNotShown = true; m_overNotShown = true;
@ -703,7 +703,7 @@ public class BoardDelegate extends DelegateBase
@Override @Override
public void orientationChanged() public void orientationChanged()
{ {
DbgUtils.logdf( "BoardDelegate.orientationChanged()" ); DbgUtils.logd( getClass(), "BoardDelegate.orientationChanged()" );
initToolbar(); initToolbar();
m_view.orientationChanged(); m_view.orientationChanged();
} }
@ -957,7 +957,7 @@ public class BoardDelegate extends DelegateBase
break; break;
default: default:
DbgUtils.logf( "menuitem %d not handled", id ); DbgUtils.logw( getClass(), "menuitem %d not handled", id );
handled = false; handled = false;
} }
@ -976,7 +976,8 @@ public class BoardDelegate extends DelegateBase
{ {
boolean handled = false; boolean handled = false;
boolean positive = AlertDialog.BUTTON_POSITIVE == which; boolean positive = AlertDialog.BUTTON_POSITIVE == which;
DbgUtils.logdf("BoardDelegate.dlgButtonClicked(%s, %b)", action.toString(), positive ); DbgUtils.logd( getClass(), "BoardDelegate.dlgButtonClicked(%s, %b)",
action.toString(), positive );
if ( Action.ENABLE_RELAY_DO_OR == action ) { if ( Action.ENABLE_RELAY_DO_OR == action ) {
handled = true; handled = true;
@ -1179,7 +1180,7 @@ public class BoardDelegate extends DelegateBase
// This can be BT or SMS. In BT case there's a progress // This can be BT or SMS. In BT case there's a progress
// thing going. Not in SMS case. // thing going. Not in SMS case.
case NEWGAME_FAILURE: case NEWGAME_FAILURE:
DbgUtils.logf( "failed to create game" ); DbgUtils.logw( getClass(), "failed to create game" );
break; break;
case NEWGAME_DUP_REJECTED: case NEWGAME_DUP_REJECTED:
if ( m_progressShown ) { if ( m_progressShown ) {
@ -1334,7 +1335,7 @@ public class BoardDelegate extends DelegateBase
nli.addSMSInfo( m_activity ); nli.addSMSInfo( m_activity );
break; break;
default: default:
DbgUtils.logf( "Not doing NFC join for conn type %s", DbgUtils.logw( getClass(), "Not doing NFC join for conn type %s",
typ.toString() ); typ.toString() );
} }
} }
@ -1556,7 +1557,7 @@ public class BoardDelegate extends DelegateBase
} }
if ( null != toastStr ) { if ( null != toastStr ) {
DbgUtils.logf( "handleConndMessage(): toastStr: %s", toastStr ); DbgUtils.logi( getClass(), "handleConndMessage(): toastStr: %s", toastStr );
m_toastStr = toastStr; m_toastStr = toastStr;
if ( naMsg == 0 ) { if ( naMsg == 0 ) {
dlgButtonClicked( Action.SHOW_EXPL_ACTION, dlgButtonClicked( Action.SHOW_EXPL_ACTION,
@ -2161,7 +2162,7 @@ public class BoardDelegate extends DelegateBase
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
break; break;
default: default:
DbgUtils.logf( "tickle: unexpected type %s", DbgUtils.logw( getClass(), "tickle: unexpected type %s",
typ.toString() ); typ.toString() );
Assert.fail(); Assert.fail();
} }
@ -2257,7 +2258,7 @@ public class BoardDelegate extends DelegateBase
int result = cancelResult; int result = cancelResult;
// this has been true; dunno why // this has been true; dunno why
if ( DlgID.NONE != m_blockingDlgID ) { if ( DlgID.NONE != m_blockingDlgID ) {
DbgUtils.logf( "waitBlockingDialog: dropping dlgID %d b/c %d set", DbgUtils.logw( getClass(), "waitBlockingDialog: dropping dlgID %d b/c %d set",
dlgID, m_blockingDlgID ); dlgID, m_blockingDlgID );
} else { } else {
setBlockingThread(); setBlockingThread();
@ -2273,12 +2274,12 @@ public class BoardDelegate extends DelegateBase
try { try {
m_forResultWait.acquire(); m_forResultWait.acquire();
} catch ( java.lang.InterruptedException ie ) { } catch ( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
if ( DlgID.NONE != m_blockingDlgID ) { if ( DlgID.NONE != m_blockingDlgID ) {
try { try {
dismissDialog( m_blockingDlgID ); dismissDialog( m_blockingDlgID );
} catch ( java.lang.IllegalArgumentException iae ) { } catch ( java.lang.IllegalArgumentException iae ) {
DbgUtils.loge( iae ); DbgUtils.logex( iae );
} }
} }
} }
@ -2452,7 +2453,7 @@ public class BoardDelegate extends DelegateBase
RelayService.inviteRemote( m_activity, destDevID, RelayService.inviteRemote( m_activity, destDevID,
null, nli ); null, nli );
} catch (NumberFormatException nfi) { } catch (NumberFormatException nfi) {
DbgUtils.loge( nfi ); DbgUtils.logex( nfi );
} }
break; break;
} }
@ -2533,7 +2534,7 @@ public class BoardDelegate extends DelegateBase
if ( canPost ) { if ( canPost ) {
m_handler.post( runnable ); m_handler.post( runnable );
} else { } else {
DbgUtils.logf( "BoardDelegate.post(): dropping b/c handler null" ); DbgUtils.logw( getClass(), "post(): dropping b/c handler null" );
DbgUtils.printStack(); DbgUtils.printStack();
} }
return canPost; return canPost;
@ -2544,7 +2545,7 @@ public class BoardDelegate extends DelegateBase
if ( null != m_handler ) { if ( null != m_handler ) {
m_handler.postDelayed( runnable, when ); m_handler.postDelayed( runnable, when );
} else { } else {
DbgUtils.logf( "postDelayed: dropping %d because handler null", when ); DbgUtils.logw( getClass(), "postDelayed: dropping %d because handler null", when );
} }
} }
@ -2553,7 +2554,7 @@ public class BoardDelegate extends DelegateBase
if ( null != m_handler ) { if ( null != m_handler ) {
m_handler.removeCallbacks( which ); m_handler.removeCallbacks( which );
} else { } else {
DbgUtils.logf( "removeCallbacks: dropping %h because handler null", DbgUtils.logw( getClass(), "removeCallbacks: dropping %h because handler null",
which ); which );
} }
} }
@ -2685,7 +2686,7 @@ public class BoardDelegate extends DelegateBase
doRematchIf( activity, null, rowID, summary, gi, gamePtr ); doRematchIf( activity, null, rowID, summary, gi, gamePtr );
gamePtr.release(); gamePtr.release();
} else { } else {
DbgUtils.logf( "setupRematchFor(): unable to lock game" ); DbgUtils.logw( BoardDelegate.class, "setupRematchFor(): unable to lock game" );
} }
if ( null != thread ) { if ( null != thread ) {
@ -2755,7 +2756,7 @@ public class BoardDelegate extends DelegateBase
sendSMSInviteIf( (String)params[1], (NetLaunchInfo)params[0], sendSMSInviteIf( (String)params[1], (NetLaunchInfo)params[0],
false ); false );
} else { } else {
DbgUtils.logf( "retrySMSInvites: tests failed" ); DbgUtils.logw( getClass(), "retrySMSInvites: tests failed" );
} }
} }
@ -2767,7 +2768,7 @@ public class BoardDelegate extends DelegateBase
private void handleViaThread( JNICmd cmd, Object... args ) private void handleViaThread( JNICmd cmd, Object... args )
{ {
if ( null == m_jniThread ) { if ( null == m_jniThread ) {
DbgUtils.logf( "BoardDelegate: not calling handle(%s)", cmd.toString() ); DbgUtils.logw( getClass(), "not calling handle(%s)", cmd.toString() );
DbgUtils.printStack(); DbgUtils.printStack();
} else { } else {
m_jniThread.handle( cmd, args ); m_jniThread.handle( cmd, args );

View file

@ -107,7 +107,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
} else if ( XwJNI.board_containsPt( m_jniGamePtr, xx, yy ) ) { } else if ( XwJNI.board_containsPt( m_jniGamePtr, xx, yy ) ) {
handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy ); handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy );
} else { } else {
DbgUtils.logdf( "BoardView.onTouchEvent(): in white space" ); DbgUtils.logd( getClass(), "BoardView.onTouchEvent(): in white space" );
} }
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
@ -140,7 +140,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
m_lastSpacing = MULTI_INACTIVE; m_lastSpacing = MULTI_INACTIVE;
break; break;
default: default:
DbgUtils.logf( "onTouchEvent: unknown action: %d", action ); DbgUtils.logw( getClass(), "onTouchEvent: unknown action: %d", action );
break; break;
} }
} }
@ -158,7 +158,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
if ( BoardContainer.getIsPortrait() != (m_dims.height > m_dims.width) ) { if ( BoardContainer.getIsPortrait() != (m_dims.height > m_dims.width) ) {
// square possible; will break above! // square possible; will break above!
Assert.assertTrue( m_dims.height != m_dims.width ); Assert.assertTrue( m_dims.height != m_dims.width );
DbgUtils.logdf( "BoardView.onMeasure: discarding m_dims" ); DbgUtils.logd( getClass(), "BoardView.onMeasure: discarding m_dims" );
if ( ++m_dimsTossCount < 4 ) { if ( ++m_dimsTossCount < 4 ) {
m_dims = null; m_dims = null;
m_layoutWidth = m_layoutHeight = 0; m_layoutWidth = m_layoutHeight = 0;
@ -185,8 +185,8 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
width = minWidth; width = minWidth;
} }
setMeasuredDimension( width, height ); setMeasuredDimension( width, height );
DbgUtils.logdf( "BoardView.onMeasure: calling setMeasuredDimension( width=%d, height=%d )", DbgUtils.logd( getClass(), "BoardView.onMeasure: calling setMeasuredDimension( width=%d, height=%d )",
width, height ); width, height );
} }
// @Override // @Override
@ -207,7 +207,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
ConnStatusHandler.draw( m_context, canvas, getResources(), ConnStatusHandler.draw( m_context, canvas, getResources(),
m_connTypes, m_isSolo ); m_connTypes, m_isSolo );
} else { } else {
DbgUtils.logdf( "BoardView.onDraw(): board not laid out yet" ); DbgUtils.logd( getClass(), "BoardView.onDraw(): board not laid out yet" );
} }
} }
} }
@ -218,15 +218,15 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
final int height = getHeight(); final int height = getHeight();
boolean layoutDone = width == m_layoutWidth && height == m_layoutHeight; boolean layoutDone = width == m_layoutWidth && height == m_layoutHeight;
if ( layoutDone ) { if ( layoutDone ) {
DbgUtils.logdf( "layoutBoardOnce(): layoutDone true" ); DbgUtils.logd( getClass(), "layoutBoardOnce(): layoutDone true" );
} else if ( null == m_gi ) { } else if ( null == m_gi ) {
// nothing to do either // nothing to do either
DbgUtils.logdf( "layoutBoardOnce(): no m_gi" ); DbgUtils.logd( getClass(), "layoutBoardOnce(): no m_gi" );
} else if ( null == m_jniThread ) { } else if ( null == m_jniThread ) {
// nothing to do either // nothing to do either
DbgUtils.logdf( "layoutBoardOnce(): no m_jniThread" ); DbgUtils.logd( getClass(), "layoutBoardOnce(): no m_jniThread" );
} else if ( null == m_dims ) { } else if ( null == m_dims ) {
DbgUtils.logdf( "layoutBoardOnce(): null m_dims" ); DbgUtils.logd( getClass(), "layoutBoardOnce(): null m_dims" );
// m_canvas = null; // m_canvas = null;
// need to synchronize?? // need to synchronize??
Paint paint = new Paint(); Paint paint = new Paint();
@ -237,12 +237,13 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
int timerWidth = scratch.width(); int timerWidth = scratch.width();
int fontWidth = int fontWidth =
Math.min(m_defaultFontHt, timerWidth / timerTxt.length()); Math.min(m_defaultFontHt, timerWidth / timerTxt.length());
DbgUtils.logdf( "layoutBoardOnce(): posting JNICmd.CMD_LAYOUT(w=%d, h=%d)", width, height ); DbgUtils.logd( getClass(), "layoutBoardOnce(): posting JNICmd.CMD_LAYOUT(w=%d, h=%d)",
width, height );
handle( JNIThread.JNICmd.CMD_LAYOUT, width, height, handle( JNIThread.JNICmd.CMD_LAYOUT, width, height,
fontWidth, m_defaultFontHt ); fontWidth, m_defaultFontHt );
// We'll be back.... // We'll be back....
} else { } else {
DbgUtils.logdf( "layoutBoardOnce(): DOING IT" ); DbgUtils.logd( getClass(), "layoutBoardOnce(): DOING IT" );
// If board size has changed we need a new bitmap // If board size has changed we need a new bitmap
int bmHeight = 1 + m_dims.height; int bmHeight = 1 + m_dims.height;
int bmWidth = 1 + m_dims.width; int bmWidth = 1 + m_dims.width;
@ -276,7 +277,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
m_layoutHeight = height; m_layoutHeight = height;
layoutDone = true; layoutDone = true;
} }
DbgUtils.logdf( "BoardView.layoutBoardOnce()=>%b", layoutDone ); DbgUtils.logd( getClass(), "layoutBoardOnce()=>%b", layoutDone );
return layoutDone; return layoutDone;
} // layoutBoardOnce } // layoutBoardOnce
@ -289,7 +290,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
public void startHandling( Activity parent, JNIThread thread, public void startHandling( Activity parent, JNIThread thread,
CommsConnTypeSet connTypes ) CommsConnTypeSet connTypes )
{ {
DbgUtils.logdf( "BoardView.startHandling(thread=%H)", thread ); DbgUtils.logd( getClass(), "startHandling(thread=%H)", thread );
m_parent = parent; m_parent = parent;
m_jniThread = thread; m_jniThread = thread;
m_jniGamePtr = thread.getGamePtr(); m_jniGamePtr = thread.getGamePtr();
@ -339,7 +340,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
public void dimsChanged( BoardDims dims ) public void dimsChanged( BoardDims dims )
{ {
DbgUtils.logdf( "BoardView.dimsChanged(%s)", dims.toString() ); DbgUtils.logd( getClass(), "dimsChanged(%s)", dims.toString() );
m_dims = dims; m_dims = dims;
m_parent.runOnUiThread( new Runnable() { m_parent.runOnUiThread( new Runnable() {
public void run() public void run()
@ -404,7 +405,7 @@ public class BoardView extends View implements BoardHandler, SyncedDraw {
private void handle( JNIThread.JNICmd cmd, Object... args ) private void handle( JNIThread.JNICmd cmd, Object... args )
{ {
if ( null == m_jniThread ) { if ( null == m_jniThread ) {
DbgUtils.logf( "BoardView: not calling handle(%s)", cmd.toString() ); DbgUtils.logw( getClass(), "not calling handle(%s)", cmd.toString() );
DbgUtils.printStack(); DbgUtils.printStack();
} else { } else {
m_jniThread.handle( cmd, args ); m_jniThread.handle( cmd, args );

View file

@ -129,7 +129,7 @@ public class ChatDelegate extends DelegateBase {
super.onResume(); super.onResume();
m_jniThreadRef = JNIThread.getRetained( m_rowid ); m_jniThreadRef = JNIThread.getRetained( m_rowid );
if ( null == m_jniThreadRef ) { if ( null == m_jniThreadRef ) {
DbgUtils.logf( "ChatDelegate.onResume(): m_jniThreadRef null; exiting" ); DbgUtils.logw( getClass(), "onResume(): m_jniThreadRef null; exiting" );
finish(); finish();
} else { } else {
s_visibleThis = this; s_visibleThis = this;

View file

@ -94,9 +94,9 @@ public class CommsTransport implements TransportProcs,
closeSocket(); closeSocket();
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} catch ( UnresolvedAddressException uae ) { } catch ( UnresolvedAddressException uae ) {
DbgUtils.logf( "bad address: name: %s; port: %s; exception: %s", DbgUtils.logw( getClass(), "bad address: name: %s; port: %s; exception: %s",
m_useHost, m_relayAddr.ip_relay_port, m_useHost, m_relayAddr.ip_relay_port,
uae.toString() ); uae.toString() );
} }
@ -124,7 +124,7 @@ public class CommsTransport implements TransportProcs,
try { try {
m_socketChannel = SocketChannel.open(); m_socketChannel = SocketChannel.open();
m_socketChannel.configureBlocking( false ); m_socketChannel.configureBlocking( false );
DbgUtils.logf( "connecting to %s:%d", DbgUtils.logi( getClass(), "connecting to %s:%d",
m_useHost, m_useHost,
m_relayAddr.ip_relay_port ); m_relayAddr.ip_relay_port );
InetSocketAddress isa = new InetSocketAddress isa = new
@ -132,7 +132,7 @@ public class CommsTransport implements TransportProcs,
m_relayAddr.ip_relay_port ); m_relayAddr.ip_relay_port );
m_socketChannel.connect( isa ); m_socketChannel.connect( isa );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
failed = true; failed = true;
break outer_loop; break outer_loop;
} }
@ -149,14 +149,14 @@ public class CommsTransport implements TransportProcs,
// we get this when relay goes down. Need to notify! // we get this when relay goes down. Need to notify!
failed = true; failed = true;
closeSocket(); closeSocket();
DbgUtils.logf( "exiting: %s", cce.toString() ); DbgUtils.logw( getClass(), "exiting: %s", cce.toString() );
break; // don't try again break; // don't try again
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
closeSocket(); closeSocket();
DbgUtils.logf( "exiting: %s", ioe.toString() ); DbgUtils.logw( getClass(), "exiting: %s", ioe.toString() );
DbgUtils.logf( ioe.toString() ); DbgUtils.logw( getClass(), ioe.toString() );
} catch ( java.nio.channels.NoConnectionPendingException ncp ) { } catch ( java.nio.channels.NoConnectionPendingException ncp ) {
DbgUtils.loge( ncp ); DbgUtils.logex( ncp );
closeSocket(); closeSocket();
break; break;
} }
@ -198,13 +198,13 @@ public class CommsTransport implements TransportProcs,
} }
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.logf( "%s: cancelling key", ioe.toString() ); DbgUtils.logw( getClass(), "%s: cancelling key", ioe.toString() );
key.cancel(); key.cancel();
failed = true; failed = true;
break outer_loop; break outer_loop;
} catch ( java.nio.channels. } catch ( java.nio.channels.
NoConnectionPendingException ncp ) { NoConnectionPendingException ncp ) {
DbgUtils.loge( ncp ); DbgUtils.logex( ncp );
break outer_loop; break outer_loop;
} }
} }
@ -260,7 +260,7 @@ public class CommsTransport implements TransportProcs,
try { try {
m_socketChannel.close(); m_socketChannel.close();
} catch ( Exception e ) { } catch ( Exception e ) {
DbgUtils.logf( "closing socket: %s", e.toString() ); DbgUtils.logw( getClass(), "closing socket: %s", e.toString() );
} }
m_socketChannel = null; m_socketChannel = null;
} }
@ -341,7 +341,7 @@ public class CommsTransport implements TransportProcs,
try { try {
m_thread.join(100); // wait up to 1/10 second m_thread.join(100); // wait up to 1/10 second
} catch ( java.lang.InterruptedException ie ) { } catch ( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
} }
m_thread = null; m_thread = null;
} }
@ -355,8 +355,8 @@ public class CommsTransport implements TransportProcs,
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr, public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
CommsConnType conType, int gameID ) CommsConnType conType, int gameID )
{ {
DbgUtils.logdf( "CommsTransport.transportSend(len=%d, typ=%s)", DbgUtils.logd( getClass(), "transportSend(len=%d, typ=%s)",
buf.length, conType.toString() ); buf.length, conType.toString() );
int nSent = -1; int nSent = -1;
Assert.assertNotNull( addr ); Assert.assertNotNull( addr );
Assert.assertTrue( addr.contains( conType ) ); Assert.assertTrue( addr.contains( conType ) );
@ -384,13 +384,13 @@ public class CommsTransport implements TransportProcs,
// Keep this while debugging why the resend_all that gets // Keep this while debugging why the resend_all that gets
// fired on reconnect doesn't unstall a game but a manual // fired on reconnect doesn't unstall a game but a manual
// resend does. // resend does.
DbgUtils.logdf( "transportSend(%d)=>%d", buf.length, nSent ); DbgUtils.logd( getClass(), "transportSend(%d)=>%d", buf.length, nSent );
return nSent; return nSent;
} }
public void relayStatus( CommsRelayState newState ) public void relayStatus( CommsRelayState newState )
{ {
DbgUtils.logf( "relayStatus called; state=%s", newState.toString() ); DbgUtils.logi( getClass(), "relayStatus called; state=%s", newState.toString() );
switch( newState ) { switch( newState ) {
case COMMS_RELAYSTATE_UNCONNECTED: case COMMS_RELAYSTATE_UNCONNECTED:

View file

@ -391,7 +391,7 @@ public class ConnStatusHandler {
// } catch ( java.lang.ClassNotFoundException cnfe ) { // } catch ( java.lang.ClassNotFoundException cnfe ) {
// DbgUtils.logf( "loadState: %s", cnfe.toString() ); // DbgUtils.logf( "loadState: %s", cnfe.toString() );
} catch ( Exception ex ) { } catch ( Exception ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
} }
} }
} }
@ -510,7 +510,7 @@ public class ConnStatusHandler {
XWPrefs.setPrefsString( context, R.string.key_connstat_data, XWPrefs.setPrefsString( context, R.string.key_connstat_data,
as64 ); as64 );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
s_needsSave = false; s_needsSave = false;
} }
@ -546,7 +546,7 @@ public class ConnStatusHandler {
&& NetStateCache.netAvail( context ); && NetStateCache.netAvail( context );
break; break;
default: default:
DbgUtils.logf( "ConnStatusHandler:connTypeEnabled: %s not handled", DbgUtils.logw( ConnStatusHandler.class, "connTypeEnabled: %s not handled",
connType.toString() ); connType.toString() );
break; break;
} }

View file

@ -259,7 +259,8 @@ public class DBHelper extends SQLiteOpenHelper {
@SuppressWarnings("fallthrough") @SuppressWarnings("fallthrough")
public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion ) public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion )
{ {
DbgUtils.logf( false, "onUpgrade: old: %d; new: %d", oldVersion, newVersion ); DbgUtils.logi( getClass(), false, "onUpgrade: old: %d; new: %d",
oldVersion, newVersion );
boolean madeSumTable = false; boolean madeSumTable = false;
switch( oldVersion ) { switch( oldVersion ) {

View file

@ -787,7 +787,7 @@ public class DBUtils {
db.close(); db.close();
} }
if ( null != result && 1 < result.length ) { if ( null != result && 1 < result.length ) {
DbgUtils.logf( "getRowIDsFor(%x)=>length %d array", gameID, DbgUtils.logi( DBUtils.class, "getRowIDsFor(%x)=>length %d array", gameID,
result.length ); result.length );
} }
return result; return result;
@ -835,7 +835,7 @@ public class DBUtils {
int gameID = cursor.getInt( col ); int gameID = cursor.getInt( col );
col = cursor.getColumnIndex( DBHelper.REMOTEDEVS ); col = cursor.getColumnIndex( DBHelper.REMOTEDEVS );
String devs = cursor.getString( col ); String devs = cursor.getString( col );
DbgUtils.logf( "gameid %d has remote[s] %s", gameID, devs ); DbgUtils.logi( DBUtils.class, "gameid %d has remote[s] %s", gameID, devs );
if ( null != devs && 0 < devs.length() ) { if ( null != devs && 0 < devs.length() ) {
for ( String dev : TextUtils.split( devs, "\n" ) ) { for ( String dev : TextUtils.split( devs, "\n" ) ) {
@ -951,7 +951,7 @@ public class DBUtils {
long result = db.replaceOrThrow( DBHelper.TABLE_NAME_OBITS, long result = db.replaceOrThrow( DBHelper.TABLE_NAME_OBITS,
"", values ); "", values );
} catch ( Exception ex ) { } catch ( Exception ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
} }
db.close(); db.close();
} }
@ -1086,7 +1086,7 @@ public class DBUtils {
result = cursor.getBlob( cursor result = cursor.getBlob( cursor
.getColumnIndex(DBHelper.SNAPSHOT)); .getColumnIndex(DBHelper.SNAPSHOT));
} else { } else {
DbgUtils.logf( "DBUtils.loadGame: none for rowid=%d", DbgUtils.loge( DBUtils.class, "loadGame: none for rowid=%d",
rowid ); rowid );
} }
cursor.close(); cursor.close();
@ -1104,7 +1104,7 @@ public class DBUtils {
deleteGame( context, lock ); deleteGame( context, lock );
lock.unlock(); lock.unlock();
} else { } else {
DbgUtils.logf( "deleteGame: unable to lock rowid %d", rowid ); DbgUtils.loge( DBUtils.class, "deleteGame: unable to lock rowid %d", rowid );
if ( BuildConfig.DEBUG ) { if ( BuildConfig.DEBUG ) {
Assert.fail(); Assert.fail();
} }
@ -1195,15 +1195,15 @@ public class DBUtils {
HistoryPair[] result = null; HistoryPair[] result = null;
String oldHistory = getChatHistoryStr( context, rowid ); String oldHistory = getChatHistoryStr( context, rowid );
if ( null != oldHistory ) { if ( null != oldHistory ) {
DbgUtils.logdf( "convertChatString(): got string: %s", oldHistory ); DbgUtils.logd( DBUtils.class, "convertChatString(): got string: %s", oldHistory );
ArrayList<ContentValues> valuess = new ArrayList<ContentValues>(); ArrayList<ContentValues> valuess = new ArrayList<ContentValues>();
ArrayList<HistoryPair> pairs = new ArrayList<HistoryPair>(); ArrayList<HistoryPair> pairs = new ArrayList<HistoryPair>();
String localPrefix = LocUtils.getString( context, R.string.chat_local_id ); String localPrefix = LocUtils.getString( context, R.string.chat_local_id );
String rmtPrefix = LocUtils.getString( context, R.string.chat_other_id ); String rmtPrefix = LocUtils.getString( context, R.string.chat_other_id );
DbgUtils.logdf( "convertChatString(): prefixes: \"%s\" and \"%s\"", localPrefix, rmtPrefix ); DbgUtils.logd( DBUtils.class, "convertChatString(): prefixes: \"%s\" and \"%s\"", localPrefix, rmtPrefix );
String[] msgs = oldHistory.split( "\n" ); String[] msgs = oldHistory.split( "\n" );
DbgUtils.logdf( "convertChatString(): split into %d", msgs.length ); DbgUtils.logd( DBUtils.class, "convertChatString(): split into %d", msgs.length );
int localPlayerIndx = -1; int localPlayerIndx = -1;
int remotePlayerIndx = -1; int remotePlayerIndx = -1;
for ( int ii = playersLocal.length - 1; ii >= 0; --ii ) { for ( int ii = playersLocal.length - 1; ii >= 0; --ii ) {
@ -1214,24 +1214,24 @@ public class DBUtils {
} }
} }
for ( String msg : msgs ) { for ( String msg : msgs ) {
DbgUtils.logdf( "convertChatString(): msg: %s", msg ); DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s", msg );
int indx = -1; int indx = -1;
String prefix = null; String prefix = null;
if ( msg.startsWith( localPrefix ) ) { if ( msg.startsWith( localPrefix ) ) {
DbgUtils.logdf( "convertChatString(): msg: %s starts with %s", msg, localPrefix ); DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s starts with %s", msg, localPrefix );
prefix = localPrefix; prefix = localPrefix;
indx = localPlayerIndx; indx = localPlayerIndx;
} else if ( msg.startsWith( rmtPrefix ) ) { } else if ( msg.startsWith( rmtPrefix ) ) {
DbgUtils.logdf( "convertChatString(): msg: %s starts with %s", msg, rmtPrefix ); DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s starts with %s", msg, rmtPrefix );
prefix = rmtPrefix; prefix = rmtPrefix;
indx = remotePlayerIndx; indx = remotePlayerIndx;
} else { } else {
DbgUtils.logdf( "convertChatString(): msg: %s starts with neither", msg ); DbgUtils.logd( DBUtils.class, "convertChatString(): msg: %s starts with neither", msg );
} }
if ( -1 != indx ) { if ( -1 != indx ) {
DbgUtils.logdf( "convertChatString(): removing substring %s; was: %s", prefix, msg ); DbgUtils.logd( DBUtils.class, "convertChatString(): removing substring %s; was: %s", prefix, msg );
msg = msg.substring( prefix.length(), msg.length() ); msg = msg.substring( prefix.length(), msg.length() );
DbgUtils.logdf( "convertChatString(): removED substring; now %s", msg ); DbgUtils.logd( DBUtils.class, "convertChatString(): removED substring; now %s", msg );
valuess.add( cvForChat( rowid, msg, indx ) ); valuess.add( cvForChat( rowid, msg, indx ) );
HistoryPair pair = new HistoryPair(msg, indx ); HistoryPair pair = new HistoryPair(msg, indx );
@ -1301,8 +1301,8 @@ public class DBUtils {
startAndEndOut[1] = Math.min( result.length(), startAndEndOut[1] = Math.min( result.length(),
Integer.parseInt( parts[1] ) ); Integer.parseInt( parts[1] ) );
} }
DbgUtils.logdf( "getCurChat(): => %s [%d,%d]", result, DbgUtils.logd( DBUtils.class, "getCurChat(): => %s [%d,%d]", result,
startAndEndOut[0], startAndEndOut[1] ); startAndEndOut[0], startAndEndOut[1] );
return result; return result;
} }
@ -1823,7 +1823,7 @@ public class DBUtils {
ArrayList<ContentValues> valuess = new ArrayList<ContentValues>(); ArrayList<ContentValues> valuess = new ArrayList<ContentValues>();
valuess.add( cvForChat( rowid, msg, fromPlayer ) ); valuess.add( cvForChat( rowid, msg, fromPlayer ) );
appendChatHistory( context, valuess ); appendChatHistory( context, valuess );
DbgUtils.logf( "appendChatHistory: inserted \"%s\" from player %d", DbgUtils.logi( DBUtils.class, "appendChatHistory: inserted \"%s\" from player %d",
msg, fromPlayer ); msg, fromPlayer );
} // appendChatHistory } // appendChatHistory
@ -1884,13 +1884,13 @@ public class DBUtils {
channelSrc.transferTo( 0, channelSrc.size(), channelDest ); channelSrc.transferTo( 0, channelSrc.size(), channelDest );
success = true; success = true;
} catch( java.io.IOException ioe ) { } catch( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} finally { } finally {
try { try {
channelSrc.close(); channelSrc.close();
channelDest.close(); channelDest.close();
} catch( java.io.IOException ioe ) { } catch( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
return success; return success;
@ -2248,7 +2248,7 @@ public class DBUtils {
try { try {
updateStmt.execute(); updateStmt.execute();
} catch ( Exception ex ) { } catch ( Exception ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
Assert.fail(); Assert.fail();
} }
} }
@ -2475,7 +2475,7 @@ public class DBUtils {
String.format( "not rowid in (select rowid from %s order by TIMESTAMP desc limit %d)", String.format( "not rowid in (select rowid from %s order by TIMESTAMP desc limit %d)",
DBHelper.TABLE_NAME_LOGS, LOGLIMIT ); DBHelper.TABLE_NAME_LOGS, LOGLIMIT );
int nGone = db.delete( DBHelper.TABLE_NAME_LOGS, where, null ); int nGone = db.delete( DBHelper.TABLE_NAME_LOGS, where, null );
DbgUtils.logf( false, "appendLog(): deleted %d rows", nGone ); DbgUtils.logi( DBUtils.class, false, "appendLog(): deleted %d rows", nGone );
} }
db.close(); db.close();
} }
@ -2506,7 +2506,7 @@ public class DBUtils {
invalGroupsCache(); invalGroupsCache();
} }
} catch( java.io.FileNotFoundException fnfe ) { } catch( java.io.FileNotFoundException fnfe ) {
DbgUtils.loge( fnfe ); DbgUtils.logex( fnfe );
} }
} }
@ -2550,7 +2550,7 @@ public class DBUtils {
int result = updateRowImpl( db, table, rowid, values ); int result = updateRowImpl( db, table, rowid, values );
db.close(); db.close();
if ( 0 == result ) { if ( 0 == result ) {
DbgUtils.logf( "updateRow failed" ); DbgUtils.logw( DBUtils.class, "updateRow failed" );
} }
} }
} }

View file

@ -38,6 +38,8 @@ public class DbgUtils {
private static final String TAG = BuildConstants.DBG_TAG; private static final String TAG = BuildConstants.DBG_TAG;
private static boolean s_doLog = BuildConfig.DEBUG; private static boolean s_doLog = BuildConfig.DEBUG;
private enum LogType { ERROR, WARN, DEBUG, INFO };
private static Time s_time = new Time(); private static Time s_time = new Time();
public static void logEnable( boolean enable ) public static void logEnable( boolean enable )
@ -52,50 +54,43 @@ public class DbgUtils {
logEnable( on ); logEnable( on );
} }
public static void logf( String msg ) private static void callLog( LogType lt, Class claz, String fmt, Object... args )
{
logf( true, msg );
}
public static void logf( boolean persist, String msg )
{ {
if ( s_doLog ) { if ( s_doLog ) {
String time = ""; String tag = claz.getSimpleName();
// No need for timestamp on marshmallow, as the OS provides it String msg = new Formatter().format( fmt, args ).toString();
if ( true /*Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1*/ ) { switch( lt ) {
s_time.setToNow(); case DEBUG:
time = s_time.format("[%H:%M:%S]-"); Log.d( tag, msg );
} break;
long id = Thread.currentThread().getId();
msg = time + id + "-" + msg;
Log.d( TAG, msg );
if ( persist && BuildConfig.DEBUG ) {
DBUtils.appendLog( TAG, msg );
} }
} }
} // logf
public static void logf( String format, Object... args )
{
logf( true, format, args );
} }
public static void logf( boolean persist, String format, Object... args ) public static void logd( Class claz, String fmt, Object... args )
{ {
if ( s_doLog ) { callLog( LogType.DEBUG, claz, fmt, args );
Formatter formatter = new Formatter(); }
logf( persist, formatter.format( format, args ).toString() );
}
} // logf
public static void logdf( String format, Object... args ) public static void loge( Class claz, String fmt, Object... args )
{ {
if ( s_doLog && BuildConfig.DEBUG ) { callLog( LogType.ERROR, claz, fmt, args );
Formatter formatter = new Formatter(); }
logf( formatter.format( format, args ).toString() );
} public static void logi( Class claz, String fmt, Object... args )
} // logdf {
logi( claz, true, fmt, args );
}
public static void logi( Class claz, boolean persist, String fmt, Object... args )
{
callLog( LogType.INFO, claz, fmt, args );
}
public static void logw( Class claz, String fmt, Object... args )
{
callLog( LogType.WARN, claz, fmt, args );
}
public static void showf( Context context, String format, Object... args ) public static void showf( Context context, String format, Object... args )
{ {
@ -109,9 +104,9 @@ public class DbgUtils {
showf( context, LocUtils.getString( context, formatid ), args ); showf( context, LocUtils.getString( context, formatid ), args );
} // showf } // showf
public static void loge( Exception exception ) public static void logex( Exception exception )
{ {
logf( "Exception: %s", exception.toString() ); logw( DbgUtils.class, "Exception: %s", exception.toString() );
printStack( exception.getStackTrace() ); printStack( exception.getStackTrace() );
} }
@ -125,7 +120,7 @@ public class DbgUtils {
if ( s_doLog && null != trace ) { if ( s_doLog && null != trace ) {
// 2: skip printStack etc. // 2: skip printStack etc.
for ( int ii = 2; ii < trace.length; ++ii ) { for ( int ii = 2; ii < trace.length; ++ii ) {
DbgUtils.logf( "ste %d: %s", ii, trace[ii].toString() ); DbgUtils.logi( DbgUtils.class, "ste %d: %s", ii, trace[ii].toString() );
} }
} }
} }
@ -157,7 +152,7 @@ public class DbgUtils {
{ {
if ( s_doLog ) { if ( s_doLog ) {
String dump = DatabaseUtils.dumpCursorToString( cursor ); String dump = DatabaseUtils.dumpCursorToString( cursor );
logf( "cursor: %s", dump ); logi( DbgUtils.class, "cursor: %s", dump );
} }
} }

View file

@ -118,16 +118,14 @@ public class DelegateBase implements DlgClickNotify,
protected void onActivityResult( RequestCode requestCode, int resultCode, protected void onActivityResult( RequestCode requestCode, int resultCode,
Intent data ) Intent data )
{ {
DbgUtils.logf( "%s.onActivityResult(): subclass responsibility!!!", DbgUtils.logi( getClass(), "onActivityResult(): subclass responsibility!!!" );
getClass().getSimpleName() );
} }
protected void onStart() protected void onStart()
{ {
Class clazz = getClass(); Class clazz = getClass();
if ( s_instances.containsKey( clazz ) ) { if ( s_instances.containsKey( clazz ) ) {
DbgUtils.logdf( "%s.onStart(): replacing curThis", DbgUtils.logd( getClass(), "onStart(): replacing curThis" );
clazz.getSimpleName() );
} }
s_instances.put( clazz, new WeakReference<DelegateBase>(this) ); s_instances.put( clazz, new WeakReference<DelegateBase>(this) );
} }
@ -162,7 +160,7 @@ public class DelegateBase implements DlgClickNotify,
result = ref.get(); result = ref.get();
} }
if ( this != result ) { if ( this != result ) {
DbgUtils.logdf( "%s.curThis() => " + result, this.toString() ); DbgUtils.logd( getClass(), "%s.curThis() => " + result, this.toString() );
} }
return result; return result;
} }
@ -424,7 +422,7 @@ public class DelegateBase implements DlgClickNotify,
try { try {
m_activity.dismissDialog( dlgID.ordinal() ); m_activity.dismissDialog( dlgID.ordinal() );
} catch ( Exception ex ) { } catch ( Exception ex ) {
// DbgUtils.loge( ex ); // DbgUtils.logex( ex );
} }
} }
@ -572,14 +570,13 @@ public class DelegateBase implements DlgClickNotify,
protected boolean canHandleNewIntent( Intent intent ) protected boolean canHandleNewIntent( Intent intent )
{ {
DbgUtils.logdf( "%s.canHandleNewIntent() => false", DbgUtils.logd( getClass(), "canHandleNewIntent() => false" );
getClass().getSimpleName(), intent.toString() );
return false; return false;
} }
protected void handleNewIntent( Intent intent ) { protected void handleNewIntent( Intent intent ) {
DbgUtils.logdf( "%s.handleNewIntent(%s): not handling", DbgUtils.logd( getClass(), "handleNewIntent(%s): not handling",
getClass().getSimpleName(), intent.toString() ); intent.toString() );
} }
protected void runWhenActive( Runnable proc ) protected void runWhenActive( Runnable proc )
@ -597,7 +594,7 @@ public class DelegateBase implements DlgClickNotify,
switch( event ) { switch( event ) {
case BT_ERR_COUNT: case BT_ERR_COUNT:
int count = (Integer)args[0]; int count = (Integer)args[0];
DbgUtils.logf( "Bluetooth error count: %d", count ); DbgUtils.logi( getClass(), "Bluetooth error count: %d", count );
break; break;
case BAD_PROTO_BT: case BAD_PROTO_BT:
fmtId = R.string.bt_bad_proto_fmt; fmtId = R.string.bt_bad_proto_fmt;
@ -612,8 +609,8 @@ public class DelegateBase implements DlgClickNotify,
m_dlgDelegate.eventOccurred( event, args ); m_dlgDelegate.eventOccurred( event, args );
break; break;
default: default:
DbgUtils.logdf( "DelegateBase.eventOccurred(event=%s) (DROPPED)", DbgUtils.logd( getClass(), "eventOccurred(event=%s) (DROPPED)",
event.toString() ); event.toString() );
break; break;
} }
@ -674,7 +671,7 @@ public class DelegateBase implements DlgClickNotify,
Assert.fail(); Assert.fail();
break; break;
} }
DbgUtils.logf( "DelegateBase.dlgButtonClicked(action=%s button=%s): UNHANDLED", DbgUtils.logi( getClass(), "dlgButtonClicked(action=%s button=%s): UNHANDLED",
action.toString(), buttonName ); action.toString(), buttonName );
} }
} }

View file

@ -84,18 +84,18 @@ public class DevID {
s_relayDevID = asStr; s_relayDevID = asStr;
} }
} }
DbgUtils.logdf( "DevID.getRelayDevID() => %s", s_relayDevID ); DbgUtils.logd( DevID.class, "getRelayDevID() => %s", s_relayDevID );
return s_relayDevID; return s_relayDevID;
} }
public static void setRelayDevID( Context context, String devID ) public static void setRelayDevID( Context context, String devID )
{ {
DbgUtils.logdf( "DevID.setRelayDevID()" ); DbgUtils.logd( DevID.class, "setRelayDevID()" );
if ( BuildConfig.DEBUG ) { if ( BuildConfig.DEBUG ) {
String oldID = getRelayDevID( context ); String oldID = getRelayDevID( context );
if ( null != oldID && 0 < oldID.length() if ( null != oldID && 0 < oldID.length()
&& ! devID.equals( oldID ) ) { && ! devID.equals( oldID ) ) {
DbgUtils.logdf( "devID changing!!!: %s => %s", oldID, devID ); DbgUtils.logd( DevID.class, "devID changing!!!: %s => %s", oldID, devID );
} }
} }
DBUtils.setStringFor( context, DEVID_KEY, devID ); DBUtils.setStringFor( context, DEVID_KEY, devID );
@ -107,7 +107,7 @@ public class DevID {
public static void clearRelayDevID( Context context ) public static void clearRelayDevID( Context context )
{ {
DbgUtils.logf( "DevID.clearRelayDevID()" ); DbgUtils.logi( DevID.class, "clearRelayDevID()" );
DBUtils.setStringFor( context, DEVID_KEY, "" ); DBUtils.setStringFor( context, DEVID_KEY, "" );
// DbgUtils.printStack(); // DbgUtils.printStack();
} }

View file

@ -258,7 +258,7 @@ public class DictBrowseDelegate extends DelegateBase
try { try {
super.finalize(); super.finalize();
} catch ( java.lang.Throwable err ){ } catch ( java.lang.Throwable err ){
DbgUtils.logf( "%s", err.toString() ); DbgUtils.logi( getClass(), "%s", err.toString() );
} }
} }
@ -453,7 +453,7 @@ public class DictBrowseDelegate extends DelegateBase
DictUtils.DictLoc loc DictUtils.DictLoc loc
= DictUtils.getDictLoc( delegator.getActivity(), name ); = DictUtils.getDictLoc( delegator.getActivity(), name );
if ( null == loc ) { if ( null == loc ) {
DbgUtils.logf( "DictBrowseDelegate.launch(): DictLoc null; try again?" ); DbgUtils.logw( DictBrowseDelegate.class, "launch(): DictLoc null; try again?" );
} else { } else {
launch( delegator, name, loc ); launch( delegator, name, loc );
} }

View file

@ -361,7 +361,7 @@ public class DictLangCache {
for ( DictAndLoc dal : dals ) { for ( DictAndLoc dal : dals ) {
String name = getLangName( context, dal.name ); String name = getLangName( context, dal.name );
if ( null == name || 0 == name.length() ) { if ( null == name || 0 == name.length() ) {
DbgUtils.logf( "bad lang name for dal name %s", dal.name ); DbgUtils.logw( DictLangCache.class, "bad lang name for dal name %s", dal.name );
// Assert.fail(); // Assert.fail();
} }
langs.add( name ); langs.add( name );
@ -473,7 +473,7 @@ public class DictLangCache {
// Tmp test that recovers from problem with new background download code // Tmp test that recovers from problem with new background download code
if ( null != info && 0 == info.langCode ) { if ( null != info && 0 == info.langCode ) {
DbgUtils.logf( "getInfo: dropping info for %s b/c lang code wrong", DbgUtils.logw( DictLangCache.class, "getInfo: dropping info for %s b/c lang code wrong",
dal.name ); dal.name );
info = null; info = null;
} }
@ -493,10 +493,10 @@ public class DictLangCache {
DBUtils.dictsSetInfo( context, dal, info ); DBUtils.dictsSetInfo( context, dal, info );
} else { } else {
info = null; info = null;
DbgUtils.logf( "getInfo(): unable to open dict %s", dal.name ); DbgUtils.logi( DictLangCache.class,
"getInfo(): unable to open dict %s", dal.name );
} }
} }
return info; return info;
} }
} }

View file

@ -192,9 +192,9 @@ public class DictUtils {
fis.close(); fis.close();
loc = DictLoc.INTERNAL; loc = DictLoc.INTERNAL;
} catch ( java.io.FileNotFoundException fnf ) { } catch ( java.io.FileNotFoundException fnf ) {
// DbgUtils.loge( fnf ); // DbgUtils.logex( fnf );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -263,7 +263,7 @@ public class DictUtils {
success = DBUtils.copyFileStream( fos, fis ); success = DBUtils.copyFileStream( fos, fis );
} catch ( java.io.FileNotFoundException fnfe ) { } catch ( java.io.FileNotFoundException fnfe ) {
DbgUtils.loge( fnfe ); DbgUtils.logex( fnfe );
} }
return success; return success;
} // copyDict } // copyDict
@ -360,11 +360,11 @@ public class DictUtils {
bytes = new byte[len]; bytes = new byte[len];
fis.read( bytes, 0, len ); fis.read( bytes, 0, len );
fis.close(); fis.close();
DbgUtils.logf( "Successfully loaded %s", name ); DbgUtils.logi( DictUtils.class, "Successfully loaded %s", name );
} catch ( java.io.FileNotFoundException fnf ) { } catch ( java.io.FileNotFoundException fnf ) {
// DbgUtils.loge( fnf ); // DbgUtils.logex( fnf );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -477,9 +477,9 @@ public class DictUtils {
invalDictList(); invalDictList();
} }
} catch ( java.io.FileNotFoundException fnf ) { } catch ( java.io.FileNotFoundException fnf ) {
DbgUtils.loge( fnf ); DbgUtils.logex( fnf );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
tmpFile.delete(); tmpFile.delete();
} }
} }
@ -564,7 +564,7 @@ public class DictUtils {
AssetManager am = context.getAssets(); AssetManager am = context.getAssets();
return am.list(""); return am.list("");
} catch( java.io.IOException ioe ) { } catch( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
return new String[0]; return new String[0];
} }
} }
@ -589,7 +589,7 @@ public class DictUtils {
if ( !result.exists() ) { if ( !result.exists() ) {
result.mkdirs(); result.mkdirs();
if ( !result.exists() ) { if ( !result.exists() ) {
DbgUtils.logf( "unable to create sd dir %s", packdir ); DbgUtils.logw( DictUtils.class, "unable to create sd dir %s", packdir );
result = null; result = null;
} }
} }

View file

@ -329,7 +329,7 @@ public class DictsDelegate extends ListDelegateBase
} }
} }
} else { } else {
DbgUtils.logf( "No remote info for lang %s", langName ); DbgUtils.logw( getClass(), "No remote info for lang %s", langName );
} }
} }
@ -383,7 +383,7 @@ public class DictsDelegate extends ListDelegateBase
DictLoc fromLoc = (DictLoc)selItem.getCached(); DictLoc fromLoc = (DictLoc)selItem.getCached();
String name = selItem.getText(); String name = selItem.getText();
if ( fromLoc == toLoc ) { if ( fromLoc == toLoc ) {
DbgUtils.logf( "not moving %s: same loc", name ); DbgUtils.logw( getClass(), "not moving %s: same loc", name );
} else if ( DictUtils.moveDict( self.m_activity, } else if ( DictUtils.moveDict( self.m_activity,
name, fromLoc, name, fromLoc,
toLoc ) ) { toLoc ) ) {
@ -393,7 +393,7 @@ public class DictsDelegate extends ListDelegateBase
DBUtils.dictsMoveInfo( self.m_activity, name, DBUtils.dictsMoveInfo( self.m_activity, name,
fromLoc, toLoc ); fromLoc, toLoc );
} else { } else {
DbgUtils.logf( "moveDict(%s) failed", name ); DbgUtils.logw( getClass(), "moveDict(%s) failed", name );
} }
} }
} }
@ -851,7 +851,7 @@ public class DictsDelegate extends ListDelegateBase
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
public void cardMounted( boolean nowMounted ) public void cardMounted( boolean nowMounted )
{ {
DbgUtils.logf( "DictsActivity.cardMounted(%b)", nowMounted ); DbgUtils.logi( getClass(), "cardMounted(%b)", nowMounted );
// post so other SDCardNotifiee implementations get a chance // post so other SDCardNotifiee implementations get a chance
// to process first: avoid race conditions // to process first: avoid race conditions
post( new Runnable() { post( new Runnable() {
@ -986,7 +986,7 @@ public class DictsDelegate extends ListDelegateBase
Assert.fail(); Assert.fail();
} }
} }
DbgUtils.logf( "countSelDicts() => {loc: %d; remote: %d}", DbgUtils.logi( getClass(), "countSelDicts() => {loc: %d; remote: %d}",
results[SEL_LOCAL], results[SEL_REMOTE] ); results[SEL_LOCAL], results[SEL_REMOTE] );
return results; return results;
} }
@ -1149,7 +1149,7 @@ public class DictsDelegate extends ListDelegateBase
public void itemClicked( SelectableItem.LongClickHandler clicked, public void itemClicked( SelectableItem.LongClickHandler clicked,
GameSummary summary ) GameSummary summary )
{ {
DbgUtils.logf( "itemClicked not implemented" ); DbgUtils.logi( getClass(), "itemClicked not implemented" );
} }
public void itemToggled( SelectableItem.LongClickHandler toggled, public void itemToggled( SelectableItem.LongClickHandler toggled,
@ -1242,7 +1242,7 @@ public class DictsDelegate extends ListDelegateBase
} }
} catch ( JSONException ex ) { } catch ( JSONException ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
theOne = null; theOne = null;
} }
} }
@ -1340,7 +1340,7 @@ public class DictsDelegate extends ListDelegateBase
new HashSet<String>( Arrays.asList( m_langs ) ); new HashSet<String>( Arrays.asList( m_langs ) );
// DictLangCache hits the DB hundreds of times below. Fix! // DictLangCache hits the DB hundreds of times below. Fix!
DbgUtils.logf( "Fix me I'm stupid" ); DbgUtils.logw( getClass(), "Fix me I'm stupid" );
try { try {
// DbgUtils.logf( "data: %s", jsonData ); // DbgUtils.logf( "data: %s", jsonData );
JSONObject obj = new JSONObject( jsonData ); JSONObject obj = new JSONObject( jsonData );
@ -1422,7 +1422,7 @@ public class DictsDelegate extends ListDelegateBase
success = true; success = true;
} catch ( JSONException ex ) { } catch ( JSONException ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
} }
} }

View file

@ -582,7 +582,7 @@ public class DlgDelegate {
break; break;
default: default:
DbgUtils.logf( "eventOccurred: unhandled event %s", event.toString() ); DbgUtils.loge( getClass(), "eventOccurred: unhandled event %s", event.toString() );
} }
if ( null != msg ) { if ( null != msg ) {
@ -994,8 +994,8 @@ public class DlgDelegate {
if ( null == oneBase ) { if ( null == oneBase ) {
iter.remove(); // no point in keeping it iter.remove(); // no point in keeping it
} else if ( base.equals( oneBase ) ) { } else if ( base.equals( oneBase ) ) {
DbgUtils.logdf( "removing alert %s for %s", dlgID.toString(), DbgUtils.logd( DlgDelegate.class, "removing alert %s for %s", dlgID.toString(),
oneBase.toString() ); oneBase.toString() );
activity.removeDialog( dlgID.ordinal() ); activity.removeDialog( dlgID.ordinal() );
iter.remove(); // no point in keeping this either iter.remove(); // no point in keeping this either
} }

View file

@ -60,7 +60,7 @@ public class DualpaneDelegate extends DelegateBase {
{ {
MainActivity main = (MainActivity)m_activity; MainActivity main = (MainActivity)m_activity;
main.dispatchNewIntent( intent ); main.dispatchNewIntent( intent );
DbgUtils.logf( "DualpaneDelegate.handleNewIntent()" ); DbgUtils.logi( getClass(), "handleNewIntent()" );
} }
@Override @Override
@ -68,7 +68,7 @@ public class DualpaneDelegate extends DelegateBase {
{ {
MainActivity main = (MainActivity)m_activity; MainActivity main = (MainActivity)m_activity;
boolean handled = main.dispatchBackPressed(); boolean handled = main.dispatchBackPressed();
DbgUtils.logf( "DualpaneDelegate.handleBackPressed() => %b", handled ); DbgUtils.logi( getClass(), "handleBackPressed() => %b", handled );
return handled; return handled;
} }

View file

@ -137,11 +137,11 @@ public class DwnldDelegate extends ListDelegateBase {
} }
is.close(); is.close();
} catch ( java.net.URISyntaxException use ) { } catch ( java.net.URISyntaxException use ) {
DbgUtils.loge( use ); DbgUtils.logex( use );
} catch ( java.net.MalformedURLException mue ) { } catch ( java.net.MalformedURLException mue ) {
DbgUtils.loge( mue ); DbgUtils.logex( mue );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
return null; return null;
} }
@ -217,9 +217,9 @@ public class DwnldDelegate extends ListDelegateBase {
fos.close(); fos.close();
success = !cancelled; success = !cancelled;
} catch ( java.io.FileNotFoundException fnf ) { } catch ( java.io.FileNotFoundException fnf ) {
DbgUtils.loge( fnf ); DbgUtils.logex( fnf );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
if ( !success ) { if ( !success ) {

View file

@ -91,8 +91,8 @@ public class ExpiringDelegate {
} }
} }
DbgUtils.logdf( "ExpUpdater: ref had %d refs, now has %d expiringdelegate views", DbgUtils.logd( getClass(), "ref had %d refs, now has %d expiringdelegate views",
sizeBefore, dlgts.size() ); sizeBefore, dlgts.size() );
for ( ExpiringDelegate dlgt : dlgts ) { for ( ExpiringDelegate dlgt : dlgts ) {
dlgt.timerFired(); dlgt.timerFired();
@ -120,7 +120,7 @@ public class ExpiringDelegate {
private void setHandler( Handler handler ) private void setHandler( Handler handler )
{ {
if ( handler != m_handler ) { if ( handler != m_handler ) {
DbgUtils.logdf( "handler changing from %H to %H", DbgUtils.logd( getClass(), "handler changing from %H to %H",
m_handler, handler ); m_handler, handler );
m_handler = handler; m_handler = handler;
reschedule(); reschedule();

View file

@ -39,13 +39,13 @@ public class GCMIntentService extends GCMBaseIntentService {
@Override @Override
protected void onError( Context context, String error ) protected void onError( Context context, String error )
{ {
DbgUtils.logdf("GCMIntentService.onError(%s)", error ); DbgUtils.logd( getClass(), "onError(%s)", error );
} }
@Override @Override
protected void onRegistered( Context context, String regId ) protected void onRegistered( Context context, String regId )
{ {
DbgUtils.logdf( "GCMIntentService.onRegistered(%s)", regId ); DbgUtils.logd( getClass(), "onRegistered(%s)", regId );
DevID.setGCMDevID( context, regId ); DevID.setGCMDevID( context, regId );
notifyRelayService( context, true ); notifyRelayService( context, true );
} }
@ -53,7 +53,7 @@ public class GCMIntentService extends GCMBaseIntentService {
@Override @Override
protected void onUnregistered( Context context, String regId ) protected void onUnregistered( Context context, String regId )
{ {
DbgUtils.logdf( "GCMIntentService.onUnregistered(%s)", regId ); DbgUtils.logd( getClass(), "onUnregistered(%s)", regId );
DevID.clearGCMDevID( context ); DevID.clearGCMDevID( context );
RelayService.devIDChanged(); RelayService.devIDChanged();
notifyRelayService( context, false ); notifyRelayService( context, false );
@ -62,13 +62,13 @@ public class GCMIntentService extends GCMBaseIntentService {
@Override @Override
protected void onMessage( Context context, Intent intent ) protected void onMessage( Context context, Intent intent )
{ {
DbgUtils.logdf( "GCMIntentService.onMessage()" ); DbgUtils.logd( getClass(), "onMessage()" );
notifyRelayService( context, true ); notifyRelayService( context, true );
String value; String value;
boolean ignoreIt = XWApp.GCM_IGNORED; boolean ignoreIt = XWApp.GCM_IGNORED;
if ( ignoreIt ) { if ( ignoreIt ) {
DbgUtils.logdf( "received GCM but ignoring it" ); DbgUtils.logd( getClass(), "received GCM but ignoring it" );
} else { } else {
value = intent.getStringExtra( "checkUpdates" ); value = intent.getStringExtra( "checkUpdates" );
if ( null != value && Boolean.parseBoolean( value ) ) { if ( null != value && Boolean.parseBoolean( value ) ) {
@ -95,7 +95,7 @@ public class GCMIntentService extends GCMBaseIntentService {
RelayService.processGameMsgs( context, connname, strs64 ); RelayService.processGameMsgs( context, connname, strs64 );
} }
} catch (org.json.JSONException jse ) { } catch (org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
@ -129,10 +129,10 @@ public class GCMIntentService extends GCMBaseIntentService {
GCMRegistrar.register( app, BuildConstants.GCM_SENDER_ID ); GCMRegistrar.register( app, BuildConstants.GCM_SENDER_ID );
} }
} catch ( UnsupportedOperationException uoe ) { } catch ( UnsupportedOperationException uoe ) {
DbgUtils.logf( "Device can't do GCM." ); DbgUtils.logw( GCMIntentService.class, "Device can't do GCM." );
} catch ( Exception whatever ) { } catch ( Exception whatever ) {
// funky devices could do anything // funky devices could do anything
DbgUtils.loge( whatever ); DbgUtils.logex( whatever );
} }
} }
} }

View file

@ -229,7 +229,7 @@ public class GameConfigDelegate extends DelegateBase
self.showToast( R.string.forced_consistent ); self.showToast( R.string.forced_consistent );
self.loadPlayersList(); self.loadPlayersList();
} else { } else {
DbgUtils.logf( "GameConfigDelegate.onDismiss(): " DbgUtils.logw( getClass(), "onDismiss(): "
+ "no visible self" ); + "no visible self" );
} }
} }
@ -774,14 +774,13 @@ public class GameConfigDelegate extends DelegateBase
} }
} else { } else {
DbgUtils.logf( "unknown v: " + view.toString() ); DbgUtils.logw( getClass(), "unknown v: " + view.toString() );
} }
} // onClick } // onClick
private void saveAndClose( boolean forceNew ) private void saveAndClose( boolean forceNew )
{ {
DbgUtils.logf( "GameConfigDelegate.saveAndClose(forceNew=%b)", DbgUtils.logi( getClass(), "saveAndClose(forceNew=%b)", forceNew );
forceNew );
applyChanges( forceNew ); applyChanges( forceNew );
finishAndLaunch(); finishAndLaunch();
@ -1031,7 +1030,7 @@ public class GameConfigDelegate extends DelegateBase
setting = 2; setting = 2;
break; break;
default: default:
DbgUtils.logf( "setSmartnessSpinner got %d from getRobotSmartness()", DbgUtils.logw( getClass(), "setSmartnessSpinner got %d from getRobotSmartness()",
m_gi.getRobotSmartness() ); m_gi.getRobotSmartness() );
Assert.fail(); Assert.fail();
} }
@ -1073,7 +1072,7 @@ public class GameConfigDelegate extends DelegateBase
private void adjustPlayersLabel() private void adjustPlayersLabel()
{ {
DbgUtils.logf( "adjustPlayersLabel()" ); DbgUtils.logi( getClass(), "adjustPlayersLabel()" );
String label; String label;
if ( localOnlyGame() ) { if ( localOnlyGame() ) {
label = getString( R.string.players_label_standalone ); label = getString( R.string.players_label_standalone );

View file

@ -455,7 +455,7 @@ public class GameListItem extends LinearLayout
try { try {
elem = s_queue.take(); elem = s_queue.take();
} catch ( InterruptedException ie ) { } catch ( InterruptedException ie ) {
DbgUtils.logf( "interrupted; killing " DbgUtils.logw( getClass(), "interrupted; killing "
+ "s_thumbThread" ); + "s_thumbThread" );
break; break;
} }

View file

@ -55,7 +55,7 @@ public class GameLock {
m_isForWrite = isForWrite; m_isForWrite = isForWrite;
m_lockCount = 0; m_lockCount = 0;
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "GameLock.GameLock(rowid:%d,isForWrite:%b)=>" DbgUtils.logi( getClass(), "GameLock(rowid:%d,isForWrite:%b)=>"
+ "this: %H", rowid, isForWrite, this ); + "this: %H", rowid, isForWrite, this );
DbgUtils.printStack(); DbgUtils.printStack();
} }
@ -91,19 +91,19 @@ public class GameLock {
} }
} else if ( this == owner && ! m_isForWrite ) { } else if ( this == owner && ! m_isForWrite ) {
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "tryLock(): incrementing lock count" ); DbgUtils.logi( getClass(), "tryLock(): incrementing lock count" );
} }
Assert.assertTrue( 0 == m_lockCount ); Assert.assertTrue( 0 == m_lockCount );
++m_lockCount; ++m_lockCount;
gotIt = true; gotIt = true;
owner = null; owner = null;
} else if ( DEBUG_LOCKS ) { } else if ( DEBUG_LOCKS ) {
DbgUtils.logf( "tryLock(): rowid %d already held by lock %H", DbgUtils.logi( getClass(), "tryLock(): rowid %d already held by lock %H",
m_rowid, owner ); m_rowid, owner );
} }
} }
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "GameLock.tryLock %H (rowid=%d) => %b", DbgUtils.logi( getClass(), "tryLock %H (rowid=%d) => %b",
this, m_rowid, gotIt ); this, m_rowid, gotIt );
} }
return owner; return owner;
@ -124,7 +124,7 @@ public class GameLock {
long sleptTime = 0; long sleptTime = 0;
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid, DbgUtils.logi( getClass(), "lock %H (rowid:%d, maxMillis=%d)", this, m_rowid,
maxMillis ); maxMillis );
} }
@ -135,11 +135,11 @@ public class GameLock {
break; break;
} }
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "GameLock.lock() %H failed; sleeping", this ); DbgUtils.logi( getClass(), "lock() %H failed; sleeping", this );
if ( 0 == sleptTime || sleptTime + SLEEP_TIME >= ASSERT_TIME ) { if ( 0 == sleptTime || sleptTime + SLEEP_TIME >= ASSERT_TIME ) {
DbgUtils.logf( "lock %H seeking stack:", curOwner ); DbgUtils.logi( getClass(), "lock %H seeking stack:", curOwner );
DbgUtils.printStack( curOwner.m_lockTrace ); DbgUtils.printStack( curOwner.m_lockTrace );
DbgUtils.logf( "lock %H seeking stack:", this ); DbgUtils.logi( getClass(), "lock %H seeking stack:", this );
DbgUtils.printStack(); DbgUtils.printStack();
} }
} }
@ -147,12 +147,12 @@ public class GameLock {
Thread.sleep( SLEEP_TIME ); // milliseconds Thread.sleep( SLEEP_TIME ); // milliseconds
sleptTime += SLEEP_TIME; sleptTime += SLEEP_TIME;
} catch( InterruptedException ie ) { } catch( InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
break; break;
} }
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "GameLock.lock() %H awake; " DbgUtils.logi( getClass(), "lock() %H awake; "
+ "sleptTime now %d millis", this, sleptTime ); + "sleptTime now %d millis", this, sleptTime );
} }
@ -162,7 +162,7 @@ public class GameLock {
throw new GameLockedException(); throw new GameLockedException();
} else if ( sleptTime >= ASSERT_TIME ) { } else if ( sleptTime >= ASSERT_TIME ) {
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "lock %H overlocked", this ); DbgUtils.logi( getClass(), "lock %H overlocked", this );
} }
Assert.fail(); Assert.fail();
} }
@ -188,7 +188,7 @@ public class GameLock {
--m_lockCount; --m_lockCount;
if ( DEBUG_LOCKS ) { if ( DEBUG_LOCKS ) {
DbgUtils.logf( "GameLock.unlock: this: %H (rowid:%d) unlocked", DbgUtils.logi( getClass(), "unlock: this: %H (rowid:%d) unlocked",
this, m_rowid ); this, m_rowid );
} }
} }
@ -204,7 +204,7 @@ public class GameLock {
{ {
boolean result = m_isForWrite && 1 == m_lockCount; boolean result = m_isForWrite && 1 == m_lockCount;
if ( !result ) { if ( !result ) {
DbgUtils.logf( "GameLock.canWrite(): %H, returning false", this ); DbgUtils.logw( getClass(), "canWrite(): %H, returning false", this );
} }
return result; return result;
} }

View file

@ -72,8 +72,7 @@ public class GameUtils {
public static class NoSuchGameException extends RuntimeException { public static class NoSuchGameException extends RuntimeException {
public NoSuchGameException() { public NoSuchGameException() {
super(); // superfluous DbgUtils.logi( getClass(), "NoSuchGameException()");
DbgUtils.logf( "creating NoSuchGameException");
} }
} }
@ -168,7 +167,7 @@ public class GameUtils {
Utils.cancelNotification( context, (int)rowidIn ); Utils.cancelNotification( context, (int)rowidIn );
success = true; success = true;
} else { } else {
DbgUtils.logf( "resetGame: unable to open rowid %d", rowidIn ); DbgUtils.logw( GameUtils.class, "resetGame: unable to open rowid %d", rowidIn );
} }
return success; return success;
} }
@ -225,7 +224,7 @@ public class GameUtils {
try { try {
lock = new GameLock( rowid, false ).lock( maxMillis ); lock = new GameLock( rowid, false ).lock( maxMillis );
} catch ( GameLock.GameLockedException gle ) { } catch ( GameLock.GameLockedException gle ) {
DbgUtils.loge( gle ); DbgUtils.logex( gle );
} }
} }
@ -269,7 +268,8 @@ public class GameUtils {
lockSrc.unlock(); lockSrc.unlock();
} }
} else { } else {
DbgUtils.logdf( "dupeGame: unable to open rowid %d", rowidIn ); DbgUtils.logd( GameUtils.class, "dupeGame: unable to open rowid %d",
rowidIn );
} }
return rowid; return rowid;
} }
@ -292,7 +292,7 @@ public class GameUtils {
lock.unlock(); lock.unlock();
success = true; success = true;
} else { } else {
DbgUtils.logf( "deleteGame: unable to delete rowid %d", rowid ); DbgUtils.logw( GameUtils.class, "deleteGame: unable to delete rowid %d", rowid );
success = false; success = false;
} }
return success; return success;
@ -355,13 +355,13 @@ public class GameUtils {
GamePtr gamePtr = null; GamePtr gamePtr = null;
if ( null == stream ) { if ( null == stream ) {
DbgUtils.logf( "loadMakeGame: no saved game!"); DbgUtils.logw( GameUtils.class, "loadMakeGame: no saved game!");
} else { } else {
XwJNI.gi_from_stream( gi, stream ); XwJNI.gi_from_stream( gi, stream );
String[] dictNames = gi.dictNames(); String[] dictNames = gi.dictNames();
DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames ); DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames );
if ( pairs.anyMissing( dictNames ) ) { if ( pairs.anyMissing( dictNames ) ) {
DbgUtils.logf( "loadMakeGame() failing: dicts %s unavailable", DbgUtils.logw( GameUtils.class, "loadMakeGame() failing: dicts %s unavailable",
TextUtils.join( ",", dictNames ) ); TextUtils.join( ",", dictNames ) );
} else { } else {
String langName = gi.langName(); String langName = gi.langName();
@ -443,8 +443,8 @@ public class GameUtils {
long oldest = s_sendTimes[s_sendTimes.length - 1]; long oldest = s_sendTimes[s_sendTimes.length - 1];
long age = now - oldest; long age = now - oldest;
force = RESEND_INTERVAL_SECS < age; force = RESEND_INTERVAL_SECS < age;
DbgUtils.logdf( "resendAllIf(): based on last send age of %d sec, doit = %b", DbgUtils.logd( GameUtils.class, "resendAllIf(): based on last send age of %d sec, doit = %b",
age, force ); age, force );
} }
if ( force ) { if ( force ) {
@ -523,7 +523,7 @@ public class GameUtils {
public static long makeNewMultiGame( Context context, NetLaunchInfo nli, public static long makeNewMultiGame( Context context, NetLaunchInfo nli,
MultiMsgSink sink, UtilCtxt util ) MultiMsgSink sink, UtilCtxt util )
{ {
DbgUtils.logdf( "makeNewMultiGame(nli=%s)", nli.toString() ); DbgUtils.logd( GameUtils.class, "makeNewMultiGame(nli=%s)", nli.toString() );
CommsAddrRec addr = nli.makeAddrRec( context ); CommsAddrRec addr = nli.makeAddrRec( context );
return makeNewMultiGame( context, sink, util, DBUtils.GROUPID_UNSPEC, return makeNewMultiGame( context, sink, util, DBUtils.GROUPID_UNSPEC,
@ -853,7 +853,7 @@ public class GameUtils {
} }
allHere = 0 == missingSet.size(); allHere = 0 == missingSet.size();
} else { } else {
DbgUtils.logf( "gameDictsHere: game has no dicts!" ); DbgUtils.logw( GameUtils.class, "gameDictsHere: game has no dicts!" );
} }
if ( null != missingNames ) { if ( null != missingNames ) {
missingNames[0] = missingNames[0] =
@ -1054,7 +1054,7 @@ public class GameUtils {
lock.unlock(); lock.unlock();
} else { } else {
DbgUtils.logf( "replaceDicts: unable to open rowid %d", rowid ); DbgUtils.logw( GameUtils.class, "replaceDicts: unable to open rowid %d", rowid );
} }
return success; return success;
} // replaceDicts } // replaceDicts
@ -1140,7 +1140,7 @@ public class GameUtils {
do { do {
rint = Utils.nextRandomInt(); rint = Utils.nextRandomInt();
} while ( 0 == rint ); } while ( 0 == rint );
DbgUtils.logf( "newGameID()=>%X (%d)", rint, rint ); DbgUtils.logi( GameUtils.class, "newGameID()=>%X (%d)", rint, rint );
return rint; return rint;
} }
@ -1176,8 +1176,8 @@ public class GameUtils {
Utils.postNotification( context, intent, title, msg, (int)rowid ); Utils.postNotification( context, intent, title, msg, (int)rowid );
} }
} else { } else {
DbgUtils.logdf( "postMoveNotification(): posting nothing for lack" DbgUtils.logd( GameUtils.class, "postMoveNotification(): posting nothing for lack"
+ " of brm" ); + " of brm" );
} }
} }
@ -1237,7 +1237,7 @@ public class GameUtils {
fos.close(); fos.close();
result = file; result = file;
} catch ( Exception ex ) { } catch ( Exception ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
} }
} }
return result; return result;
@ -1283,15 +1283,16 @@ public class GameUtils {
int nSent = XwJNI.comms_resendAll( gamePtr, true, int nSent = XwJNI.comms_resendAll( gamePtr, true,
m_filter, false ); m_filter, false );
gamePtr.release(); gamePtr.release();
DbgUtils.logdf( "ResendTask.doInBackground(): sent %d " DbgUtils.logd( getClass(), "ResendTask.doInBackground(): sent %d "
+ "messages for rowid %d", nSent, rowid ); + "messages for rowid %d", nSent, rowid );
} else { } else {
DbgUtils.logdf( "ResendTask.doInBackground(): loadMakeGame()" DbgUtils.logd( getClass(), "ResendTask.doInBackground(): loadMakeGame()"
+ " failed for rowid %d", rowid ); + " failed for rowid %d", rowid );
} }
lock.unlock(); lock.unlock();
} else { } else {
DbgUtils.logf( "ResendTask.doInBackground: unable to unlock %d", DbgUtils.logw( ResendTask.class,
"ResendTask.doInBackground: unable to unlock %d",
rowid ); rowid );
} }
} }

View file

@ -274,7 +274,7 @@ public class GamesListDelegate extends ListDelegateBase
} }
} }
if ( -1 == posn ) { if ( -1 == posn ) {
DbgUtils.logf( "getGroupPosition: group %d not found", groupID ); DbgUtils.logd( getClass(), "getGroupPosition: group %d not found", groupID );
} }
return posn; return posn;
} }
@ -336,7 +336,7 @@ public class GamesListDelegate extends ListDelegateBase
boolean changed = false; boolean changed = false;
int newID = fieldToID( newField ); int newID = fieldToID( newField );
if ( -1 == newID ) { if ( -1 == newID ) {
DbgUtils.logf( "GameListAdapter.setField(): unable to match" DbgUtils.logd( getClass(), "setField(): unable to match"
+ " fieldName %s", newField ); + " fieldName %s", newField );
} else if ( m_fieldID != newID ) { } else if ( m_fieldID != newID ) {
m_fieldID = newID; m_fieldID = newID;
@ -432,7 +432,7 @@ public class GamesListDelegate extends ListDelegateBase
private ArrayList<Object> removeRange( ArrayList<Object> list, private ArrayList<Object> removeRange( ArrayList<Object> list,
int start, int len ) int start, int len )
{ {
DbgUtils.logf( "removeRange(start=%d, len=%d)", start, len ); DbgUtils.logd( getClass(), "removeRange(start=%d, len=%d)", start, len );
ArrayList<Object> result = new ArrayList<Object>(len); ArrayList<Object> result = new ArrayList<Object>(len);
for ( int ii = 0; ii < len; ++ii ) { for ( int ii = 0; ii < len; ++ii ) {
result.add( list.remove( start ) ); result.add( list.remove( start ) );
@ -1338,7 +1338,7 @@ public class GamesListDelegate extends ListDelegateBase
switch ( requestCode ) { switch ( requestCode ) {
case REQUEST_LANG_GL: case REQUEST_LANG_GL:
if ( !cancelled ) { if ( !cancelled ) {
DbgUtils.logf( "lang need met" ); DbgUtils.logd( getClass(), "lang need met" );
if ( checkWarnNoDict( m_missingDictRowId ) ) { if ( checkWarnNoDict( m_missingDictRowId ) ) {
launchGameIf(); launchGameIf();
} }
@ -1467,7 +1467,7 @@ public class GamesListDelegate extends ListDelegateBase
Assert.assertTrue( m_menuPrepared ); Assert.assertTrue( m_menuPrepared );
} else { } else {
DbgUtils.logf( "onPrepareOptionsMenu: incomplete so bailing" ); DbgUtils.logd( getClass(), "onPrepareOptionsMenu: incomplete so bailing" );
} }
return m_menuPrepared; return m_menuPrepared;
} // onPrepareOptionsMenu } // onPrepareOptionsMenu
@ -1592,7 +1592,7 @@ public class GamesListDelegate extends ListDelegateBase
AdapterView.AdapterContextMenuInfo info AdapterView.AdapterContextMenuInfo info
= (AdapterView.AdapterContextMenuInfo)menuInfo; = (AdapterView.AdapterContextMenuInfo)menuInfo;
View targetView = info.targetView; View targetView = info.targetView;
DbgUtils.logf( "onCreateContextMenu(t=%s)", DbgUtils.logd( getClass(), "onCreateContextMenu(t=%s)",
targetView.getClass().getSimpleName() ); targetView.getClass().getSimpleName() );
if ( targetView instanceof GameListItem ) { if ( targetView instanceof GameListItem ) {
item = (GameListItem)targetView; item = (GameListItem)targetView;
@ -2373,7 +2373,7 @@ public class GamesListDelegate extends ListDelegateBase
private void launchGame( long rowid, boolean invited ) private void launchGame( long rowid, boolean invited )
{ {
if ( DBUtils.ROWID_NOTFOUND == rowid ) { if ( DBUtils.ROWID_NOTFOUND == rowid ) {
DbgUtils.logdf( "launchGame(): dropping bad rowid" ); DbgUtils.logd( getClass(), "launchGame(): dropping bad rowid" );
} else if ( ! m_launchedGames.contains( rowid ) ) { } else if ( ! m_launchedGames.contains( rowid ) ) {
m_launchedGames.add( rowid ); m_launchedGames.add( rowid );
if ( m_adapter.inExpandedGroup( rowid ) ) { if ( m_adapter.inExpandedGroup( rowid ) ) {
@ -2419,7 +2419,7 @@ public class GamesListDelegate extends ListDelegateBase
launchGame( rowid ); launchGame( rowid );
} }
} catch ( GameLock.GameLockedException gle ) { } catch ( GameLock.GameLockedException gle ) {
DbgUtils.loge( gle ); DbgUtils.logex( gle );
finish(); finish();
} }
} }

View file

@ -277,7 +277,7 @@ public class LookupAlert extends LinearLayout
private static void lookupWord( Context context, String word, String fmt ) private static void lookupWord( Context context, String word, String fmt )
{ {
if ( false ) { if ( false ) {
DbgUtils.logf( "skipping lookupWord(%s)", word ); DbgUtils.logw( LookupAlert.class, "skipping lookupWord(%s)", word );
} else { } else {
String langCode = s_langCodes[s_lang]; String langCode = s_langCodes[s_lang];
String dict_url = String.format( fmt, langCode, word ); String dict_url = String.format( fmt, langCode, word );
@ -288,7 +288,7 @@ public class LookupAlert extends LinearLayout
try { try {
context.startActivity( intent ); context.startActivity( intent );
} catch ( android.content.ActivityNotFoundException anfe ) { } catch ( android.content.ActivityNotFoundException anfe ) {
DbgUtils.loge( anfe ); DbgUtils.logex( anfe );
} }
} }
} // lookupWord } // lookupWord

View file

@ -122,13 +122,13 @@ public class MainActivity extends XWActivity
boolean isPortrait boolean isPortrait
= Configuration.ORIENTATION_PORTRAIT == newConfig.orientation; = Configuration.ORIENTATION_PORTRAIT == newConfig.orientation;
DbgUtils.logf( "MainActivity.onConfigurationChanged(isPortrait=%b)", DbgUtils.logi( getClass(), "onConfigurationChanged(isPortrait=%b)",
isPortrait ); isPortrait );
m_isPortrait = isPortrait; m_isPortrait = isPortrait;
if ( isPortrait != (rect.width() <= rect.height()) ) { if ( isPortrait != (rect.width() <= rect.height()) ) {
DbgUtils.logdf( "FragActivity.onConfigurationChanged(): isPortrait:" DbgUtils.logd( getClass(), "onConfigurationChanged(): isPortrait:"
+ " %b; width: %d; height: %d", + " %b; width: %d; height: %d",
isPortrait, rect.width(), rect.height() ); isPortrait, rect.width(), rect.height() );
} }
int maxPanes = isPortrait? 1 : MAX_PANES_LANDSCAPE; int maxPanes = isPortrait? 1 : MAX_PANES_LANDSCAPE;
if ( m_maxPanes != maxPanes ) { if ( m_maxPanes != maxPanes ) {
@ -184,10 +184,10 @@ public class MainActivity extends XWActivity
break; break;
} }
String name = frag.getClass().getSimpleName(); String name = frag.getClass().getSimpleName();
DbgUtils.logdf( "MainActivity.popIntoView(): popping %d: %s", top, name ); DbgUtils.logd( getClass(), "popIntoView(): popping %d: %s", top, name );
fm.popBackStackImmediate(); fm.popBackStackImmediate();
DbgUtils.logdf( "MainActivity.popIntoView(): DONE popping %s", DbgUtils.logd( getClass(), "popIntoView(): DONE popping %s",
name ); name );
} }
} }
@ -211,14 +211,14 @@ public class MainActivity extends XWActivity
frag.getDelegate().handleNewIntent( intent ); frag.getDelegate().handleNewIntent( intent );
} }
} else { } else {
DbgUtils.logdf( "no fragment for child %s indx %d", DbgUtils.logd( getClass(), "no fragment for child %s indx %d",
child.getClass().getSimpleName(), ii ); child.getClass().getSimpleName(), ii );
} }
} }
if ( BuildConfig.DEBUG && !handled ) { if ( BuildConfig.DEBUG && !handled ) {
// DbgUtils.showf( this, "dropping intent %s", intent.toString() ); // DbgUtils.showf( this, "dropping intent %s", intent.toString() );
DbgUtils.logdf( "dropping intent %s", intent.toString() ); DbgUtils.logd( getClass(), "dropping intent %s", intent.toString() );
// DbgUtils.printStack(); // DbgUtils.printStack();
// setIntent( intent ); -- look at handling this in onPostResume()? // setIntent( intent ); -- look at handling this in onPostResume()?
m_newIntent = intent; m_newIntent = intent;
@ -245,8 +245,8 @@ public class MainActivity extends XWActivity
if ( null != frag ) { if ( null != frag ) {
frag.onActivityResult( requestCode.ordinal(), resultCode, data ); frag.onActivityResult( requestCode.ordinal(), resultCode, data );
} else { } else {
DbgUtils.logdf( "dispatchOnActivityResult(): can't dispatch %s", DbgUtils.logd( getClass(), "dispatchOnActivityResult(): can't dispatch %s",
requestCode.toString() ); requestCode.toString() );
} }
} }
@ -337,14 +337,14 @@ public class MainActivity extends XWActivity
{ {
// make sure the right-most are visible // make sure the right-most are visible
int fragCount = getSupportFragmentManager().getBackStackEntryCount(); int fragCount = getSupportFragmentManager().getBackStackEntryCount();
DbgUtils.logf( "MainActivity.onBackStackChanged(); count now %d", fragCount ); DbgUtils.logi( getClass(), "onBackStackChanged(); count now %d", fragCount );
if ( 0 == fragCount ) { if ( 0 == fragCount ) {
finish(); finish();
} else { } else {
if ( fragCount == m_root.getChildCount() - 1 ) { if ( fragCount == m_root.getChildCount() - 1 ) {
View child = m_root.getChildAt( fragCount ); View child = m_root.getChildAt( fragCount );
if ( LOG_IDS ) { if ( LOG_IDS ) {
DbgUtils.logf( "onBackStackChanged(): removing view with id %x", DbgUtils.logi( getClass(), "onBackStackChanged(): removing view with id %x",
child.getId() ); child.getId() );
} }
m_root.removeView( child ); m_root.removeView( child );
@ -355,7 +355,7 @@ public class MainActivity extends XWActivity
if ( null != m_pendingResult ) { if ( null != m_pendingResult ) {
Fragment target = m_pendingResult.getTarget(); Fragment target = m_pendingResult.getTarget();
if ( null != target ) { if ( null != target ) {
DbgUtils.logf( "onBackStackChanged(): calling onActivityResult()" ); DbgUtils.logi( getClass(),"onBackStackChanged(): calling onActivityResult()" );
target.onActivityResult( m_pendingResult.m_request, target.onActivityResult( m_pendingResult.m_request,
m_pendingResult.m_result, m_pendingResult.m_result,
m_pendingResult.m_data ); m_pendingResult.m_data );
@ -404,7 +404,7 @@ public class MainActivity extends XWActivity
int id = frame.getId(); int id = frame.getId();
Fragment frag = fm.findFragmentById( id ); Fragment frag = fm.findFragmentById( id );
if ( null == frag ) { if ( null == frag ) {
DbgUtils.logf( "tellOrienationChanged: NO FRAG at %d, id=%d", ii, id ); DbgUtils.logw( getClass(),"tellOrienationChanged: NO FRAG at %d, id=%d", ii, id );
} else if ( frag instanceof XWFragment ) { } else if ( frag instanceof XWFragment ) {
((XWFragment)frag).getDelegate().orientationChanged(); ((XWFragment)frag).getDelegate().orientationChanged();
} }
@ -432,7 +432,7 @@ public class MainActivity extends XWActivity
for ( int ii = 0; ii < nPanes; ++ii ) { for ( int ii = 0; ii < nPanes; ++ii ) {
View child = m_root.getChildAt( ii ); View child = m_root.getChildAt( ii );
boolean visible = ii >= nPanes - m_maxPanes; boolean visible = ii >= nPanes - m_maxPanes;
DbgUtils.logf( "pane %d: visible=%b", ii, visible ); DbgUtils.logi( getClass(), "pane %d: visible=%b", ii, visible );
child.setVisibility( visible ? View.VISIBLE : View.GONE ); child.setVisibility( visible ? View.VISIBLE : View.GONE );
setMenuVisibility( child, visible ); setMenuVisibility( child, visible );
if ( visible ) { if ( visible ) {
@ -448,7 +448,7 @@ public class MainActivity extends XWActivity
if ( null != frag ) { if ( null != frag ) {
frag.setTitle(); frag.setTitle();
} else { } else {
DbgUtils.logdf( "trySetTitle(): no fragment for id %x", DbgUtils.logd( getClass(), "trySetTitle(): no fragment for id %x",
view.getId() ); view.getId() );
} }
} }
@ -498,7 +498,7 @@ public class MainActivity extends XWActivity
FragmentManager fm = getSupportFragmentManager(); FragmentManager fm = getSupportFragmentManager();
int fragCount = fm.getBackStackEntryCount(); int fragCount = fm.getBackStackEntryCount();
int containerCount = m_root.getChildCount(); int containerCount = m_root.getChildCount();
DbgUtils.logf( "fragCount: %d; containerCount: %d", fragCount, containerCount ); DbgUtils.logi( getClass(), "fragCount: %d; containerCount: %d", fragCount, containerCount );
// Assert.assertTrue( fragCount == containerCount ); // Assert.assertTrue( fragCount == containerCount );
// Replace IF we're adding something of the same class at right OR if // Replace IF we're adding something of the same class at right OR if
@ -528,7 +528,7 @@ public class MainActivity extends XWActivity
int id = --m_nextID; int id = --m_nextID;
cont.setId( id ); cont.setId( id );
if ( LOG_IDS ) { if ( LOG_IDS ) {
DbgUtils.logf( "assigning id %x to view with name %s", id, newName ); DbgUtils.logi( getClass(), "assigning id %x to view with name %s", id, newName );
} }
m_root.addView( cont, replace ? containerCount - 1 : containerCount ); m_root.addView( cont, replace ? containerCount - 1 : containerCount );
@ -539,7 +539,7 @@ public class MainActivity extends XWActivity
setMenuVisibility( child, false ); setMenuVisibility( child, false );
DbgUtils.logf( "hiding %dth container", indx ); DbgUtils.logi( getClass(), "hiding %dth container", indx );
} }
fm.beginTransaction() fm.beginTransaction()

View file

@ -38,7 +38,7 @@ public class MountEventReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive( Context context, Intent intent ) public void onReceive( Context context, Intent intent )
{ {
DbgUtils.logf( "MountEventReceiver.onReceive(%s)", intent.getAction() ); DbgUtils.logi( getClass(), "onReceive(%s)", intent.getAction() );
synchronized( s_procs ) { synchronized( s_procs ) {
do { do {
if ( s_procs.isEmpty() ) { if ( s_procs.isEmpty() ) {

View file

@ -99,10 +99,10 @@ public class MultiMsgSink implements TransportProcs {
Assert.fail(); Assert.fail();
break; break;
} }
DbgUtils.logf( "MultiMsgSink.transportSend(): sent %d via %s", DbgUtils.logi( getClass(), "transportSend(): sent %d via %s",
nSent, typ.toString() ); nSent, typ.toString() );
if ( 0 < nSent ) { if ( 0 < nSent ) {
DbgUtils.logdf( "MultiMsgSink.transportSend: adding %s", msgNo ); DbgUtils.logd( getClass(), "transportSend: adding %s", msgNo );
m_sentSet.add( msgNo ); m_sentSet.add( msgNo );
} }
@ -129,7 +129,7 @@ public class MultiMsgSink implements TransportProcs {
relayID, buf ); relayID, buf );
boolean success = buf.length == nSent; boolean success = buf.length == nSent;
if ( success ) { if ( success ) {
DbgUtils.logdf( "MultiMsgSink.relayNoConnProc: adding %s", msgNo ); DbgUtils.logd( getClass(), "relayNoConnProc: adding %s", msgNo );
m_sentSet.add( msgNo ); m_sentSet.add( msgNo );
} }
return success; return success;

View file

@ -189,7 +189,7 @@ public class MultiService {
if ( downloaded ) { if ( downloaded ) {
int ordinal = intent.getIntExtra( OWNER, -1 ); int ordinal = intent.getIntExtra( OWNER, -1 );
if ( -1 == ordinal ) { if ( -1 == ordinal ) {
DbgUtils.logf( "unexpected OWNER" ); DbgUtils.logw( DBUtils.class, "unexpected OWNER" );
} else { } else {
DictFetchOwner owner = DictFetchOwner.values()[ordinal]; DictFetchOwner owner = DictFetchOwner.values()[ordinal];
switch ( owner ) { switch ( owner ) {

View file

@ -177,7 +177,7 @@ public class NagTurnReceiver extends BroadcastReceiver {
al.add(value); al.add(value);
} }
} catch ( Exception ex ) { } catch ( Exception ex ) {
DbgUtils.loge(ex); DbgUtils.logex(ex);
} }
} }
if ( 0 < al.size() ) { if ( 0 < al.size() ) {

View file

@ -199,7 +199,7 @@ public class NetLaunchInfo {
} }
calcValid(); calcValid();
} catch ( Exception e ) { } catch ( Exception e ) {
DbgUtils.logf( "unable to parse \"%s\"", data.toString() ); DbgUtils.loge( getClass(), "unable to parse \"%s\"", data.toString() );
} }
} }
calcValid(); calcValid();
@ -277,7 +277,7 @@ public class NetLaunchInfo {
int result = gameID; int result = gameID;
if ( 0 == result ) { if ( 0 == result ) {
Assert.assertNotNull( inviteID ); Assert.assertNotNull( inviteID );
DbgUtils.logf( "gameID(): looking at inviteID: %s", inviteID ); DbgUtils.logi( getClass(), "gameID(): looking at inviteID: %s", inviteID );
result = Integer.parseInt( inviteID, 16 ); result = Integer.parseInt( inviteID, 16 );
// DbgUtils.logf( "gameID(): gameID -1 so substituting %d", result ); // DbgUtils.logf( "gameID(): gameID -1 so substituting %d", result );
gameID = result; gameID = result;
@ -335,7 +335,7 @@ public class NetLaunchInfo {
result = obj.toString(); result = obj.toString();
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
// DbgUtils.logf( "makeLaunchJSON() => %s", result ); // DbgUtils.logf( "makeLaunchJSON() => %s", result );
return result; return result;
@ -419,7 +419,7 @@ public class NetLaunchInfo {
} }
} catch ( JSONException jse ) { } catch ( JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
removeUnsupported( supported ); removeUnsupported( supported );
@ -469,7 +469,7 @@ public class NetLaunchInfo {
Uri result = ub.build(); Uri result = ub.build();
if ( BuildConfig.DEBUG ) { // Test... if ( BuildConfig.DEBUG ) { // Test...
DbgUtils.logf( "testing %s...", result.toString() ); DbgUtils.logi( getClass(), "testing %s...", result.toString() );
NetLaunchInfo instance = new NetLaunchInfo( context, result ); NetLaunchInfo instance = new NetLaunchInfo( context, result );
Assert.assertTrue( instance.isValid() ); Assert.assertTrue( instance.isValid() );
} }
@ -492,7 +492,7 @@ public class NetLaunchInfo {
btAddress = got[1]; btAddress = got[1];
m_addrs.add( CommsConnType.COMMS_CONN_BT ); m_addrs.add( CommsConnType.COMMS_CONN_BT );
} else { } else {
DbgUtils.logf( "addBTInfo(): no BT info available" ); DbgUtils.logw( getClass(), "addBTInfo(): no BT info available" );
} }
} }

View file

@ -83,7 +83,7 @@ public class NetStateCache {
boolean netAvail = getIsConnected( context ); boolean netAvail = getIsConnected( context );
if ( netAvail ) { if ( netAvail ) {
DbgUtils.logf( "netAvail(): second-guessing successful!!!" ); DbgUtils.logi( NetStateCache.class, "netAvail(): second-guessing successful!!!" );
s_netAvail = true; s_netAvail = true;
if ( null != s_receiver ) { if ( null != s_receiver ) {
s_receiver.notifyStateChanged( context ); s_receiver.notifyStateChanged( context );
@ -93,7 +93,7 @@ public class NetStateCache {
} }
boolean result = s_netAvail || s_onSDKSim; boolean result = s_netAvail || s_onSDKSim;
DbgUtils.logdf( "netAvail() => %b", result ); DbgUtils.logd( NetStateCache.class, "netAvail() => %b", result );
return result; return result;
} }
@ -123,7 +123,7 @@ public class NetStateCache {
if ( null != ni && ni.isConnectedOrConnecting() ) { if ( null != ni && ni.isConnectedOrConnecting() ) {
result = true; result = true;
} }
DbgUtils.logf( "NetStateCache.getConnected() => %b", result ); DbgUtils.logi( NetStateCache.class, "NetStateCache.getConnected() => %b", result );
return result; return result;
} }
@ -164,7 +164,7 @@ public class NetStateCache {
boolean connectedReal = activeNetwork != null && boolean connectedReal = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting(); activeNetwork.isConnectedOrConnecting();
if ( connectedReal != connectedCached ) { if ( connectedReal != connectedCached ) {
DbgUtils.logf( "NetStateCache(): connected: cached: %b; actual: %b", DbgUtils.logw( NetStateCache.class, "connected: cached: %b; actual: %b",
connectedCached, connectedReal ); connectedCached, connectedReal );
} }
} }
@ -193,8 +193,7 @@ public class NetStateCache {
NetworkInfo ni = (NetworkInfo)intent. NetworkInfo ni = (NetworkInfo)intent.
getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
NetworkInfo.State state = ni.getState(); NetworkInfo.State state = ni.getState();
DbgUtils.logdf( "NetStateCache.PvtBroadcastReceiver.onReceive(state=%s)", DbgUtils.logd( getClass(), "onReceive(state=%s)", state.toString() );
state.toString() );
boolean netAvail; boolean netAvail;
switch ( state ) { switch ( state ) {
@ -215,9 +214,8 @@ public class NetStateCache {
s_netAvail = netAvail; // keep current in case we're asked s_netAvail = netAvail; // keep current in case we're asked
notifyStateChanged( context ); notifyStateChanged( context );
} else { } else {
DbgUtils.logdf( "NetStateCache.PvtBroadcastReceiver.onReceive:" DbgUtils.logd( getClass(), "onReceive: no change; "
+ " no change; doing nothing; s_netAvail=%b", + "doing nothing; s_netAvail=%b", s_netAvail );
s_netAvail );
} }
} }
} }
@ -241,7 +239,7 @@ public class NetStateCache {
Assert.assertTrue( mLastStateSent != s_netAvail ); Assert.assertTrue( mLastStateSent != s_netAvail );
mLastStateSent = s_netAvail; mLastStateSent = s_netAvail;
DbgUtils.logf( "NetStateCache.notifyStateChanged(%b)", DbgUtils.logi( getClass(), "notifyStateChanged(%b)",
s_netAvail ); s_netAvail );
synchronized( s_ifs ) { synchronized( s_ifs ) {

View file

@ -71,9 +71,9 @@ public class NetUtils {
socket.setSoTimeout( timeoutMillis ); socket.setSoTimeout( timeoutMillis );
} catch ( java.net.UnknownHostException uhe ) { } catch ( java.net.UnknownHostException uhe ) {
DbgUtils.loge( uhe ); DbgUtils.logex( uhe );
} catch( java.io.IOException ioe ) { } catch( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
return socket; return socket;
} }
@ -128,7 +128,7 @@ public class NetUtils {
DBUtils.clearObits( m_context, m_obits ); DBUtils.clearObits( m_context, m_obits );
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
} }
@ -192,13 +192,13 @@ public class NetUtils {
} }
if ( 0 != dis.available() ) { if ( 0 != dis.available() ) {
msgs = null; msgs = null;
DbgUtils.logf( "format error: bytes left over in stream" ); DbgUtils.loge( NetUtils.class, "format error: bytes left over in stream" );
} }
socket.close(); socket.close();
} }
} catch( Exception npe ) { } catch( Exception npe ) {
DbgUtils.loge( npe ); DbgUtils.logex( npe );
} }
return msgs; return msgs;
} // queryRelay } // queryRelay
@ -224,10 +224,10 @@ public class NetUtils {
result = (HttpURLConnection)new URL(url).openConnection(); result = (HttpURLConnection)new URL(url).openConnection();
} catch ( java.net.MalformedURLException mue ) { } catch ( java.net.MalformedURLException mue ) {
Assert.assertNull( result ); Assert.assertNull( result );
DbgUtils.loge( mue ); DbgUtils.logex( mue );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
Assert.assertNull( result ); Assert.assertNull( result );
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
return result; return result;
} }
@ -272,12 +272,12 @@ public class NetUtils {
} }
result = new String( bas.toByteArray() ); result = new String( bas.toByteArray() );
} else { } else {
DbgUtils.logf( "runConn: responseCode: %d", responseCode ); DbgUtils.logw( NetUtils.class, "runConn: responseCode: %d", responseCode );
} }
} catch ( java.net.ProtocolException pe ) { } catch ( java.net.ProtocolException pe ) {
DbgUtils.loge( pe ); DbgUtils.logex( pe );
} catch( java.io.IOException ioe ) { } catch( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -298,7 +298,7 @@ public class NetUtils {
} }
result = TextUtils.join( "&", pairs ); result = TextUtils.join( "&", pairs );
} catch ( java.io.UnsupportedEncodingException uee ) { } catch ( java.io.UnsupportedEncodingException uee ) {
DbgUtils.loge( uee ); DbgUtils.logex( uee );
} }
return result; return result;

View file

@ -31,7 +31,7 @@ public class OnBootReceiver extends BroadcastReceiver {
{ {
if ( null != intent && null != intent.getAction() if ( null != intent && null != intent.getAction()
&& intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) { && intent.getAction().equals( Intent.ACTION_BOOT_COMPLETED ) ) {
DbgUtils.logdf( "OnBootReceiver: got ACTION_BOOT_COMPLETED" ); DbgUtils.logd( getClass(), "got ACTION_BOOT_COMPLETED" );
startTimers( context ); startTimers( context );
} }
} }

View file

@ -68,7 +68,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
protected String[] doInBackground( Void...unused ) protected String[] doInBackground( Void...unused )
{ {
ArrayList<String> names = new ArrayList<String>(); ArrayList<String> names = new ArrayList<String>();
DbgUtils.logf( "doInBackground()" ); DbgUtils.logi( getClass(), "doInBackground()" );
try { try {
Socket socket = NetUtils.makeProxySocket( m_context, 15000 ); Socket socket = NetUtils.makeProxySocket( m_context, 15000 );
@ -88,7 +88,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
new DataInputStream(socket.getInputStream()); new DataInputStream(socket.getInputStream());
short len = dis.readShort(); short len = dis.readShort();
short nRooms = dis.readShort(); short nRooms = dis.readShort();
DbgUtils.logf( "%s: got %d rooms", "doInBackground", nRooms ); DbgUtils.logi( getClass(), "doInBackground(): got %d rooms", nRooms );
// Can't figure out how to read a null-terminated string // Can't figure out how to read a null-terminated string
// from DataInputStream so parse it myself. // from DataInputStream so parse it myself.
@ -102,16 +102,16 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
++index; ++index;
} }
String name = new String( bytes, lastIndex, index - lastIndex ); String name = new String( bytes, lastIndex, index - lastIndex );
DbgUtils.logf( "got public room name: %s", name ); DbgUtils.logi( getClass(), "got public room name: %s", name );
int indx = name.lastIndexOf( "/" ); int indx = name.lastIndexOf( "/" );
indx = name.lastIndexOf( "/", indx-1 ); indx = name.lastIndexOf( "/", indx-1 );
names.add( name.substring(0, indx ) ); names.add( name.substring(0, indx ) );
} }
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
DbgUtils.logf( "doInBackground() returning" ); DbgUtils.logi( getClass(), "doInBackground() returning" );
return names.toArray( new String[names.size()] ); return names.toArray( new String[names.size()] );
} }
@ -122,7 +122,7 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
@Override @Override
protected void onPostExecute( String[] result ) protected void onPostExecute( String[] result )
{ {
DbgUtils.logf( "onPostExecute()" ); DbgUtils.logi( getClass(), "onPostExecute()" );
ArrayAdapter<String> adapter = ArrayAdapter<String> adapter =
new ArrayAdapter<String>( m_context, new ArrayAdapter<String>( m_context,
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_item,
@ -137,6 +137,6 @@ public class RefreshNamesTask extends AsyncTask<Void, Void, String[]> {
m_nnf.NoNameFound(); m_nnf.NoNameFound();
} }
DbgUtils.logf( "onPostExecute() done" ); DbgUtils.logi( getClass(), "onPostExecute() done" );
} }
} }

View file

@ -503,12 +503,12 @@ public class RelayInviteDelegate extends InviteDelegate {
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put( "relayIDs", ids ); params.put( "relayIDs", ids );
params.put( "me", DevID.getRelayDevIDInt( m_activity ) ); params.put( "me", DevID.getRelayDevIDInt( m_activity ) );
DbgUtils.logf( "sending to server: %s", params.toString() ); DbgUtils.logi( getClass(), "sending to server: %s", params.toString() );
HttpURLConnection conn = NetUtils.makeHttpConn( m_context, "opponentIDsFor" ); HttpURLConnection conn = NetUtils.makeHttpConn( m_context, "opponentIDsFor" );
if ( null != conn ) { if ( null != conn ) {
String str = NetUtils.runConn( conn, params ); String str = NetUtils.runConn( conn, params );
DbgUtils.logf( "got json from server: %s", str ); DbgUtils.logi( getClass(), "got json from server: %s", str );
reply = new JSONObject( str ); reply = new JSONObject( str );
} }
@ -532,7 +532,7 @@ public class RelayInviteDelegate extends InviteDelegate {
} }
} catch ( org.json.JSONException je ) { } catch ( org.json.JSONException je ) {
DbgUtils.loge( je ); DbgUtils.logex( je );
} }
stopProgress(); stopProgress();
@ -542,7 +542,7 @@ public class RelayInviteDelegate extends InviteDelegate {
@Override protected void onPostExecute( Set<String> devIDs ) @Override protected void onPostExecute( Set<String> devIDs )
{ {
if ( null == devIDs ) { if ( null == devIDs ) {
DbgUtils.logf( "onPostExecute: no results from server?" ); DbgUtils.logw( getClass(), "onPostExecute: no results from server?" );
} else { } else {
m_devIDRecs = new ArrayList<DevIDRec>(devIDs.size()); m_devIDRecs = new ArrayList<DevIDRec>(devIDs.size());
Iterator<String> iter = devIDs.iterator(); Iterator<String> iter = devIDs.iterator();

View file

@ -139,7 +139,7 @@ public class RelayService extends XWService
public static void gcmConfirmed( Context context, boolean confirmed ) public static void gcmConfirmed( Context context, boolean confirmed )
{ {
if ( s_gcmWorking != confirmed ) { if ( s_gcmWorking != confirmed ) {
DbgUtils.logf( "RelayService.gcmConfirmed(): changing " DbgUtils.logi( RelayService.class, "gcmConfirmed(): changing "
+ "s_gcmWorking to %b", confirmed ); + "s_gcmWorking to %b", confirmed );
s_gcmWorking = confirmed; s_gcmWorking = confirmed;
} }
@ -156,7 +156,7 @@ public class RelayService extends XWService
{ {
boolean enabled = ! XWPrefs boolean enabled = ! XWPrefs
.getPrefsBoolean( context, R.string.key_disable_relay, false ); .getPrefsBoolean( context, R.string.key_disable_relay, false );
DbgUtils.logdf( "relayEnabled() => %b", enabled ); DbgUtils.logd( RelayService.class, "relayEnabled() => %b", enabled );
return enabled; return enabled;
} }
@ -176,7 +176,7 @@ public class RelayService extends XWService
public static void startService( Context context ) public static void startService( Context context )
{ {
DbgUtils.logf( "RelayService.startService()" ); DbgUtils.logi( RelayService.class, "startService()" );
Intent intent = getIntentTo( context, MsgCmds.UDP_CHANGED ); Intent intent = getIntentTo( context, MsgCmds.UDP_CHANGED );
context.startService( intent ); context.startService( intent );
} }
@ -214,7 +214,7 @@ public class RelayService extends XWService
public static int sendPacket( Context context, long rowid, byte[] msg ) public static int sendPacket( Context context, long rowid, byte[] msg )
{ {
DbgUtils.logdf( "RelayService.sendPacket(len=%d)", msg.length ); DbgUtils.logd( RelayService.class, "sendPacket(len=%d)", msg.length );
int result = -1; int result = -1;
if ( NetStateCache.netAvail( context ) ) { if ( NetStateCache.netAvail( context ) ) {
Intent intent = getIntentTo( context, MsgCmds.SEND ) Intent intent = getIntentTo( context, MsgCmds.SEND )
@ -223,7 +223,7 @@ public class RelayService extends XWService
context.startService( intent ); context.startService( intent );
result = msg.length; result = msg.length;
} else { } else {
DbgUtils.logf( "RelayService.sendPacket: network down" ); DbgUtils.logw( RelayService.class, "sendPacket: network down" );
} }
return result; return result;
} }
@ -250,7 +250,7 @@ public class RelayService extends XWService
private void receiveInvitation( int srcDevID, NetLaunchInfo nli ) private void receiveInvitation( int srcDevID, NetLaunchInfo nli )
{ {
DbgUtils.logdf( "receiveInvitation: got nli from %d: %s", srcDevID, DbgUtils.logd( getClass(), "receiveInvitation: got nli from %d: %s", srcDevID,
nli.toString() ); nli.toString() );
if ( checkNotDupe( nli ) ) { if ( checkNotDupe( nli ) ) {
makeOrNotify( nli ); makeOrNotify( nli );
@ -302,15 +302,15 @@ public class RelayService extends XWService
// Exists to get incoming data onto the main thread // Exists to get incoming data onto the main thread
private static void postData( Context context, long rowid, byte[] msg ) private static void postData( Context context, long rowid, byte[] msg )
{ {
DbgUtils.logdf( "RelayService::postData: packet of length %d for token %d", DbgUtils.logd( RelayService.class, "postData(): packet of "
msg.length, rowid ); + "length %d for token %d", msg.length, rowid );
if ( DBUtils.haveGame( context, rowid ) ) { if ( DBUtils.haveGame( context, rowid ) ) {
Intent intent = getIntentTo( context, MsgCmds.RECEIVE ) Intent intent = getIntentTo( context, MsgCmds.RECEIVE )
.putExtra( ROWID, rowid ) .putExtra( ROWID, rowid )
.putExtra( BINBUFFER, msg ); .putExtra( BINBUFFER, msg );
context.startService( intent ); context.startService( intent );
} else { } else {
DbgUtils.logf( "RelayService.postData(): Dropping message for " DbgUtils.logw( RelayService.class, "postData(): Dropping message for "
+ "rowid %d: not on device", rowid ); + "rowid %d: not on device", rowid );
} }
} }
@ -360,7 +360,7 @@ public class RelayService extends XWService
m_handler = new Handler(); m_handler = new Handler();
m_onInactivity = new Runnable() { m_onInactivity = new Runnable() {
public void run() { public void run() {
DbgUtils.logdf( "RelayService: m_onInactivity fired" ); DbgUtils.logd( getClass(), "m_onInactivity fired" );
if ( !shouldMaintainConnection() ) { if ( !shouldMaintainConnection() ) {
NetStateCache.unregister( RelayService.this, NetStateCache.unregister( RelayService.this,
RelayService.this ); RelayService.this );
@ -384,7 +384,7 @@ public class RelayService extends XWService
cmd = null; cmd = null;
} }
if ( null != cmd ) { if ( null != cmd ) {
DbgUtils.logdf( "RelayService::onStartCommand: cmd=%s", DbgUtils.logd( getClass(), "onStartCommand(): cmd=%s",
cmd.toString() ); cmd.toString() );
switch( cmd ) { switch( cmd ) {
case PROCESS_GAME_MSGS: case PROCESS_GAME_MSGS:
@ -445,7 +445,7 @@ public class RelayService extends XWService
break; break;
case TIMER_FIRED: case TIMER_FIRED:
if ( !NetStateCache.netAvail( this ) ) { if ( !NetStateCache.netAvail( this ) ) {
DbgUtils.logf( "not connecting: no network" ); DbgUtils.logw( getClass(), "not connecting: no network" );
} else if ( startFetchThreadIf() ) { } else if ( startFetchThreadIf() ) {
// do nothing // do nothing
} else if ( registerWithRelayIfNot() ) { } else if ( registerWithRelayIfNot() ) {
@ -527,11 +527,11 @@ public class RelayService extends XWService
private void stopFetchThreadIf() private void stopFetchThreadIf()
{ {
while ( null != m_fetchThread ) { while ( null != m_fetchThread ) {
DbgUtils.logf( "2: m_fetchThread NOT NULL; WHAT TO DO???" ); DbgUtils.logw( getClass(), "2: m_fetchThread NOT NULL; WHAT TO DO???" );
try { try {
Thread.sleep( 20 ); Thread.sleep( 20 );
} catch( java.lang.InterruptedException ie ) { } catch( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
} }
} }
} }
@ -546,7 +546,7 @@ public class RelayService extends XWService
connectSocket(); // block until this is done connectSocket(); // block until this is done
startWriteThread(); startWriteThread();
DbgUtils.logf( "RelayService:read thread running" ); DbgUtils.logi( getClass(), "read thread running" );
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
for ( ; ; ) { for ( ; ; ) {
DatagramPacket packet = DatagramPacket packet =
@ -561,16 +561,16 @@ public class RelayService extends XWService
break; break;
} }
} }
DbgUtils.logf( "RelayService:read thread exiting" ); DbgUtils.logi( getClass(), "read thread exiting" );
} }
}, getClass().getName() ); }, getClass().getName() );
m_UDPReadThread.start(); m_UDPReadThread.start();
} else { } else {
DbgUtils.logf( "m_UDPReadThread not null and assumed to " DbgUtils.logi( getClass(), "m_UDPReadThread not null and assumed to "
+ "be running" ); + "be running" );
} }
} else { } else {
DbgUtils.logf( "RelayService.startUDPThreadsIfNot(): UDP disabled" ); DbgUtils.logi( getClass(), "startUDPThreadsIfNot(): UDP disabled" );
} }
} // startUDPThreadsIfNot } // startUDPThreadsIfNot
@ -585,17 +585,17 @@ public class RelayService extends XWService
InetAddress addr = InetAddress.getByName( host ); InetAddress addr = InetAddress.getByName( host );
m_UDPSocket.connect( addr, port ); // remember this address m_UDPSocket.connect( addr, port ); // remember this address
DbgUtils.logdf( "RelayService.connectSocket(%s:%d): m_UDPSocket" DbgUtils.logd( getClass(), "connectSocket(%s:%d): m_UDPSocket"
+ " now %H", host, port, m_UDPSocket ); + " now %H", host, port, m_UDPSocket );
} catch( java.net.SocketException se ) { } catch( java.net.SocketException se ) {
DbgUtils.loge( se ); DbgUtils.logex( se );
Assert.fail(); Assert.fail();
} catch( java.net.UnknownHostException uhe ) { } catch( java.net.UnknownHostException uhe ) {
DbgUtils.loge( uhe ); DbgUtils.logex( uhe );
} }
} else { } else {
Assert.assertTrue( m_UDPSocket.isConnected() ); Assert.assertTrue( m_UDPSocket.isConnected() );
DbgUtils.logf( "m_UDPSocket not null" ); DbgUtils.logi( getClass(), "m_UDPSocket not null" );
} }
} }
@ -604,19 +604,18 @@ public class RelayService extends XWService
if ( null == m_UDPWriteThread ) { if ( null == m_UDPWriteThread ) {
m_UDPWriteThread = new Thread( null, new Runnable() { m_UDPWriteThread = new Thread( null, new Runnable() {
public void run() { public void run() {
DbgUtils.logf( "RelayService: write thread starting" ); DbgUtils.logi( getClass(), "write thread starting" );
for ( ; ; ) { for ( ; ; ) {
PacketData outData; PacketData outData;
try { try {
outData = m_queue.take(); outData = m_queue.take();
} catch ( InterruptedException ie ) { } catch ( InterruptedException ie ) {
DbgUtils.logf( "RelayService; write thread " DbgUtils.logw( getClass(), "write thread killed" );
+ "killed" );
break; break;
} }
if ( null == outData if ( null == outData
|| 0 == outData.getLength() ) { || 0 == outData.getLength() ) {
DbgUtils.logf( "stopping write thread" ); DbgUtils.logi( getClass(), "stopping write thread" );
break; break;
} }
@ -624,7 +623,7 @@ public class RelayService extends XWService
DatagramPacket outPacket = outData.assemble(); DatagramPacket outPacket = outData.assemble();
m_UDPSocket.send( outPacket ); m_UDPSocket.send( outPacket );
int pid = outData.m_packetID; int pid = outData.m_packetID;
DbgUtils.logdf( "Sent udp packet, cmd=%s, id=%d," DbgUtils.logd( getClass(), "Sent udp packet, cmd=%s, id=%d,"
+ " of length %d", + " of length %d",
outData.m_cmd.toString(), outData.m_cmd.toString(),
pid, outPacket.getLength()); pid, outPacket.getLength());
@ -634,8 +633,8 @@ public class RelayService extends XWService
resetExitTimer(); resetExitTimer();
ConnStatusHandler.showSuccessOut(); ConnStatusHandler.showSuccessOut();
} catch ( java.net.SocketException se ) { } catch ( java.net.SocketException se ) {
DbgUtils.loge( se ); DbgUtils.logex( se );
DbgUtils.logf( "Restarting threads to force" DbgUtils.logi( getClass(), "Restarting threads to force"
+ " new socket" ); + " new socket" );
m_handler.post( new Runnable() { m_handler.post( new Runnable() {
public void run() { public void run() {
@ -643,17 +642,17 @@ public class RelayService extends XWService
} }
} ); } );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} catch ( NullPointerException npe ) { } catch ( NullPointerException npe ) {
DbgUtils.logf( "network problem; dropping packet" ); DbgUtils.logw( getClass(), "network problem; dropping packet" );
} }
} }
DbgUtils.logf( "RelayService: write thread exiting" ); DbgUtils.logi( getClass(), "write thread exiting" );
} }
}, getClass().getName() ); }, getClass().getName() );
m_UDPWriteThread.start(); m_UDPWriteThread.start();
} else { } else {
DbgUtils.logf( "m_UDPWriteThread not null and assumed to " DbgUtils.logi( getClass(), "m_UDPWriteThread not null and assumed to "
+ "be running" ); + "be running" );
} }
} }
@ -664,11 +663,11 @@ public class RelayService extends XWService
// can't add null // can't add null
m_queue.add( new PacketData() ); m_queue.add( new PacketData() );
try { try {
DbgUtils.logdf( "joining m_UDPWriteThread" ); DbgUtils.logd( getClass(), "joining m_UDPWriteThread" );
m_UDPWriteThread.join(); m_UDPWriteThread.join();
DbgUtils.logdf( "SUCCESSFULLY joined m_UDPWriteThread" ); DbgUtils.logd( getClass(), "SUCCESSFULLY joined m_UDPWriteThread" );
} catch( java.lang.InterruptedException ie ) { } catch( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
} }
m_UDPWriteThread = null; m_UDPWriteThread = null;
m_queue.clear(); m_queue.clear();
@ -678,7 +677,7 @@ public class RelayService extends XWService
try { try {
m_UDPReadThread.join(); m_UDPReadThread.join();
} catch( java.lang.InterruptedException ie ) { } catch( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
} }
m_UDPReadThread = null; m_UDPReadThread = null;
m_UDPSocket = null; m_UDPSocket = null;
@ -696,11 +695,11 @@ public class RelayService extends XWService
if ( !skipAck ) { if ( !skipAck ) {
sendAckIf( header ); sendAckIf( header );
} }
DbgUtils.logdf( "RelayService.gotPacket: cmd=%s", header.m_cmd.toString() ); DbgUtils.logd( getClass(), "gotPacket(): cmd=%s", header.m_cmd.toString() );
switch ( header.m_cmd ) { switch ( header.m_cmd ) {
case XWPDEV_UNAVAIL: case XWPDEV_UNAVAIL:
int unavail = dis.readInt(); int unavail = dis.readInt();
DbgUtils.logf( "relay unvailable for another %d seconds", DbgUtils.logi( getClass(), "relay unvailable for another %d seconds",
unavail ); unavail );
String str = getVLIString( dis ); String str = getVLIString( dis );
sendResult( MultiEvent.RELAY_ALERT, str ); sendResult( MultiEvent.RELAY_ALERT, str );
@ -714,7 +713,7 @@ public class RelayService extends XWService
break; break;
case XWPDEV_BADREG: case XWPDEV_BADREG:
str = getVLIString( dis ); str = getVLIString( dis );
DbgUtils.logf( "bad relayID \"%s\" reported", str ); DbgUtils.logi( getClass(), "bad relayID \"%s\" reported", str );
DevID.clearRelayDevID( this ); DevID.clearRelayDevID( this );
s_registered = false; s_registered = false;
registerWithRelay(); registerWithRelay();
@ -722,7 +721,7 @@ public class RelayService extends XWService
case XWPDEV_REGRSP: case XWPDEV_REGRSP:
str = getVLIString( dis ); str = getVLIString( dis );
short maxIntervalSeconds = dis.readShort(); short maxIntervalSeconds = dis.readShort();
DbgUtils.logdf( "got relayid %s (%d), maxInterval %d", str, DbgUtils.logd( getClass(), "got relayid %s (%d), maxInterval %d", str,
Integer.parseInt( str, 16 ), Integer.parseInt( str, 16 ),
maxIntervalSeconds ); maxIntervalSeconds );
setMaxIntervalSeconds( maxIntervalSeconds ); setMaxIntervalSeconds( maxIntervalSeconds );
@ -759,7 +758,7 @@ public class RelayService extends XWService
NetLaunchInfo nli = XwJNI.nliFromStream( nliData ); NetLaunchInfo nli = XwJNI.nliFromStream( nliData );
intent.putExtra( INVITE_FROM, srcDevID ); intent.putExtra( INVITE_FROM, srcDevID );
String asStr = nli.toString(); String asStr = nli.toString();
DbgUtils.logdf( "got invitation: %s", asStr ); DbgUtils.logd( getClass(), "got invitation: %s", asStr );
intent.putExtra( NLI_DATA, asStr ); intent.putExtra( NLI_DATA, asStr );
startService( intent ); startService( intent );
break; break;
@ -772,12 +771,12 @@ public class RelayService extends XWService
// DbgUtils.logf( "RelayService: got invite: %s", nliData ); // DbgUtils.logf( "RelayService: got invite: %s", nliData );
// break; // break;
default: default:
DbgUtils.logf( "RelayService.gotPacket(): Unhandled cmd" ); DbgUtils.logw( getClass(), "gotPacket(): Unhandled cmd" );
break; break;
} }
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -800,7 +799,7 @@ public class RelayService extends XWService
boolean registered = null != relayID; boolean registered = null != relayID;
should = !registered; should = !registered;
} }
DbgUtils.logdf( "RelayService.shouldRegister()=>%b", should ); DbgUtils.logd( getClass(), "shouldRegister()=>%b", should );
return should; return should;
} }
@ -817,7 +816,7 @@ public class RelayService extends XWService
long now = Utils.getCurSeconds(); long now = Utils.getCurSeconds();
long interval = now - s_regStartTime; long interval = now - s_regStartTime;
if ( interval < REG_WAIT_INTERVAL ) { if ( interval < REG_WAIT_INTERVAL ) {
DbgUtils.logf( "registerWithRelay: skipping because only %d " DbgUtils.logi( getClass(), "registerWithRelay: skipping because only %d "
+ "seconds since last start", interval ); + "seconds since last start", interval );
} else { } else {
String relayID = DevID.getRelayDevID( this ); String relayID = DevID.getRelayDevID( this );
@ -838,8 +837,8 @@ public class RelayService extends XWService
writeVLIString( out, devid ); writeVLIString( out, devid );
} }
DbgUtils.logdf( "registering devID \"%s\" (type=%s)", devid, DbgUtils.logd( getClass(), "registering devID \"%s\" (type=%s)", devid,
typ.toString() ); typ.toString() );
out.writeShort( BuildConstants.CLIENT_VERS_RELAY ); out.writeShort( BuildConstants.CLIENT_VERS_RELAY );
writeVLIString( out, BuildConstants.GIT_REV ); writeVLIString( out, BuildConstants.GIT_REV );
@ -850,7 +849,7 @@ public class RelayService extends XWService
postPacket( bas, XWRelayReg.XWPDEV_REG ); postPacket( bas, XWRelayReg.XWPDEV_REG );
s_regStartTime = now; s_regStartTime = now;
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
} }
@ -874,7 +873,7 @@ public class RelayService extends XWService
postPacket( bas, reg ); postPacket( bas, reg );
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -898,7 +897,7 @@ public class RelayService extends XWService
out.write( msg, 0, msg.length ); out.write( msg, 0, msg.length );
postPacket( bas, XWRelayReg.XWPDEV_MSG ); postPacket( bas, XWRelayReg.XWPDEV_MSG );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -914,21 +913,21 @@ public class RelayService extends XWService
out.write( msg, 0, msg.length ); out.write( msg, 0, msg.length );
postPacket( bas, XWRelayReg.XWPDEV_MSGNOCONN ); postPacket( bas, XWRelayReg.XWPDEV_MSGNOCONN );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
private void sendInvitation( int srcDevID, int destDevID, String relayID, private void sendInvitation( int srcDevID, int destDevID, String relayID,
String nliStr ) String nliStr )
{ {
DbgUtils.logdf( "sendInvitation(%d->%d/%s [%s])", srcDevID, destDevID, DbgUtils.logd( getClass(), "sendInvitation(%d->%d/%s [%s])", srcDevID, destDevID,
relayID, nliStr ); relayID, nliStr );
NetLaunchInfo nli = new NetLaunchInfo( this, nliStr ); NetLaunchInfo nli = new NetLaunchInfo( this, nliStr );
byte[] nliData = XwJNI.nliToStream( nli ); byte[] nliData = XwJNI.nliToStream( nli );
if ( BuildConfig.DEBUG ) { if ( BuildConfig.DEBUG ) {
NetLaunchInfo tmp = XwJNI.nliFromStream( nliData ); NetLaunchInfo tmp = XwJNI.nliFromStream( nliData );
DbgUtils.logdf( "sendInvitation: compare these: %s vs %s", DbgUtils.logd( getClass(), "sendInvitation: compare these: %s vs %s",
nli.toString(), tmp.toString() ); nli.toString(), tmp.toString() );
} }
@ -948,7 +947,7 @@ public class RelayService extends XWService
out.write( nliData, 0, nliData.length ); out.write( nliData, 0, nliData.length );
postPacket( bas, XWRelayReg.XWPDEV_INVITE ); postPacket( bas, XWRelayReg.XWPDEV_INVITE );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -961,7 +960,7 @@ public class RelayService extends XWService
un2vli( header.m_packetID, out ); un2vli( header.m_packetID, out );
postPacket( bas, XWRelayReg.XWPDEV_ACK ); postPacket( bas, XWRelayReg.XWPDEV_ACK );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
} }
@ -974,13 +973,13 @@ public class RelayService extends XWService
if ( XWPDevProto.XWPDEV_PROTO_VERSION_1.ordinal() == proto ) { if ( XWPDevProto.XWPDEV_PROTO_VERSION_1.ordinal() == proto ) {
int packetID = vli2un( dis ); int packetID = vli2un( dis );
if ( 0 != packetID ) { if ( 0 != packetID ) {
DbgUtils.logdf( "RelayService.readHeader: got packetID %d", packetID ); DbgUtils.logd( getClass(), "readHeader(): got packetID %d", packetID );
} }
byte ordinal = dis.readByte(); byte ordinal = dis.readByte();
XWRelayReg cmd = XWRelayReg.values()[ordinal]; XWRelayReg cmd = XWRelayReg.values()[ordinal];
result = new PacketHeader( cmd, packetID ); result = new PacketHeader( cmd, packetID );
} else { } else {
DbgUtils.logf( "bad proto: %d", proto ); DbgUtils.logw( getClass(), "bad proto: %d", proto );
} }
return result; return result;
} }
@ -1105,7 +1104,7 @@ public class RelayService extends XWService
if ( msgLen + thisLen > MAX_BUF ) { if ( msgLen + thisLen > MAX_BUF ) {
// Need to deal with this case by sending multiple // Need to deal with this case by sending multiple
// packets. It WILL happen. // packets. It WILL happen.
DbgUtils.logf( "dropping send for lack of space; FIX ME!!" ); DbgUtils.logw( getClass(), "dropping send for lack of space; FIX ME!!" );
Assert.fail(); Assert.fail();
break; break;
} }
@ -1135,7 +1134,7 @@ public class RelayService extends XWService
socket.close(); socket.close();
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
return null; return null;
} // doInBackground } // doInBackground
@ -1147,7 +1146,7 @@ public class RelayService extends XWService
if ( null != msgHash ) { if ( null != msgHash ) {
new AsyncSender( context, msgHash ).execute(); new AsyncSender( context, msgHash ).execute();
} else { } else {
DbgUtils.logf( "sendToRelay: null msgs" ); DbgUtils.logw( RelayService.class, "sendToRelay: null msgs" );
} }
} // sendToRelay } // sendToRelay
@ -1211,11 +1210,11 @@ public class RelayService extends XWService
if ( s_packetsSent.contains( packetID ) ) { if ( s_packetsSent.contains( packetID ) ) {
s_packetsSent.remove( packetID ); s_packetsSent.remove( packetID );
} else { } else {
DbgUtils.logf( "Weird: got ack %d but never sent", packetID ); DbgUtils.logw( RelayService.class, "Weird: got ack %d but never sent", packetID );
} }
DbgUtils.logdf( "RelayService.noteAck(): Got ack for %d; " DbgUtils.logd( RelayService.class, "noteAck(): Got ack for %d; "
+ "there are %d unacked packets", + "there are %d unacked packets",
packetID, s_packetsSent.size() ); packetID, s_packetsSent.size() );
} }
} }
@ -1233,7 +1232,7 @@ public class RelayService extends XWService
private void startThreads() private void startThreads()
{ {
DbgUtils.logdf( "RelayService.startThreads()" ); DbgUtils.logd( getClass(), "startThreads()" );
if ( !relayEnabled( this ) || !NetStateCache.netAvail( this ) ) { if ( !relayEnabled( this ) || !NetStateCache.netAvail( this ) ) {
stopThreads(); stopThreads();
} else if ( XWApp.UDP_ENABLED ) { } else if ( XWApp.UDP_ENABLED ) {
@ -1248,7 +1247,7 @@ public class RelayService extends XWService
private void stopThreads() private void stopThreads()
{ {
DbgUtils.logdf( "RelayService.stopThreads()" ); DbgUtils.logd( getClass(), "stopThreads()" );
stopFetchThreadIf(); stopFetchThreadIf();
stopUDPThreadsIf(); stopUDPThreadsIf();
} }
@ -1279,7 +1278,7 @@ public class RelayService extends XWService
for ( int count = 0; !done; ++count ) { for ( int count = 0; !done; ++count ) {
nRead = is.read( buf ); nRead = is.read( buf );
if ( 1 != nRead ) { if ( 1 != nRead ) {
DbgUtils.logf( "vli2un: unable to read from stream" ); DbgUtils.logw( RelayService.class, "vli2un: unable to read from stream" );
break; break;
} }
int byt = buf[0]; int byt = buf[0];
@ -1360,7 +1359,7 @@ public class RelayService extends XWService
long interval = Utils.getCurSeconds() - m_lastGamePacketReceived; long interval = Utils.getCurSeconds() - m_lastGamePacketReceived;
result = interval < MAX_KEEPALIVE_SECS; result = interval < MAX_KEEPALIVE_SECS;
} }
DbgUtils.logdf( "RelayService.shouldMaintainConnection=>%b", result ); DbgUtils.logd( getClass(), "shouldMaintainConnection=>%b", result );
return result; return result;
} }
@ -1409,14 +1408,14 @@ public class RelayService extends XWService
try { try {
m_packetID = nextPacketID( m_cmd ); m_packetID = nextPacketID( m_cmd );
DataOutputStream out = new DataOutputStream( bas ); DataOutputStream out = new DataOutputStream( bas );
DbgUtils.logdf( "RelayService.makeHeader(): building packet with cmd %s", DbgUtils.logd( getClass(), "makeHeader(): building packet with cmd %s",
m_cmd.toString() ); m_cmd.toString() );
out.writeByte( XWPDevProto.XWPDEV_PROTO_VERSION_1.ordinal() ); out.writeByte( XWPDevProto.XWPDEV_PROTO_VERSION_1.ordinal() );
un2vli( m_packetID, out ); un2vli( m_packetID, out );
out.writeByte( m_cmd.ordinal() ); out.writeByte( m_cmd.ordinal() );
m_header = bas.toByteArray(); m_header = bas.toByteArray();
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }

View file

@ -197,7 +197,7 @@ public class SMSService extends XWService {
Intent intent = getIntentTo( context, SMSAction.INVITE ); Intent intent = getIntentTo( context, SMSAction.INVITE );
intent.putExtra( PHONE, phone ); intent.putExtra( PHONE, phone );
String asString = nli.toString(); String asString = nli.toString();
DbgUtils.logf( "SMSService.inviteRemote(%s, '%s')", phone, asString ); DbgUtils.logw( SMSService.class, "inviteRemote(%s, '%s')", phone, asString );
intent.putExtra( GAMEDATA_STR, asString ); intent.putExtra( GAMEDATA_STR, asString );
context.startService( intent ); context.startService( intent );
} }
@ -214,7 +214,7 @@ public class SMSService extends XWService {
context.startService( intent ); context.startService( intent );
nSent = binmsg.length; nSent = binmsg.length;
} else { } else {
DbgUtils.logf( "sendPacket: dropping because SMS disabled" ); DbgUtils.logi( SMSService.class, "sendPacket: dropping because SMS disabled" );
} }
return nSent; return nSent;
} }
@ -251,7 +251,7 @@ public class SMSService extends XWService {
if ( hashRead == hashCode ) { if ( hashRead == hashCode ) {
result = tmp; result = tmp;
} else { } else {
DbgUtils.logf( "fromPublicFmt: hash code mismatch" ); DbgUtils.logw( SMSService.class, "fromPublicFmt: hash code mismatch" );
} }
} catch( Exception e ) { } catch( Exception e ) {
} }
@ -375,7 +375,7 @@ public class SMSService extends XWService {
private void inviteRemote( String phone, String nliData ) private void inviteRemote( String phone, String nliData )
{ {
DbgUtils.logf( "SMSService.inviteRemote()" ); DbgUtils.logi( getClass(), "inviteRemote()" );
ByteArrayOutputStream bas = new ByteArrayOutputStream( 128 ); ByteArrayOutputStream bas = new ByteArrayOutputStream( 128 );
DataOutputStream dos = new DataOutputStream( bas ); DataOutputStream dos = new DataOutputStream( bas );
try { try {
@ -384,7 +384,7 @@ public class SMSService extends XWService {
send( SMS_CMD.INVITE, bas.toByteArray(), phone ); send( SMS_CMD.INVITE, bas.toByteArray(), phone );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -398,7 +398,7 @@ public class SMSService extends XWService {
send( SMS_CMD.ACK, bas.toByteArray(), phone ); send( SMS_CMD.ACK, bas.toByteArray(), phone );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -413,7 +413,7 @@ public class SMSService extends XWService {
send( SMS_CMD.DEATH, bas.toByteArray(), phone ); send( SMS_CMD.DEATH, bas.toByteArray(), phone );
s_sentDied.add( gameID ); s_sentDied.add( gameID );
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
} }
@ -431,7 +431,7 @@ public class SMSService extends XWService {
nSent = bytes.length; nSent = bytes.length;
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
return nSent; return nSent;
} }
@ -482,7 +482,7 @@ public class SMSService extends XWService {
start = end; start = end;
} }
} else { } else {
DbgUtils.logf( "breakAndEncode(): msg count %d too large; dropping", DbgUtils.logw( getClass(), "breakAndEncode(): msg count %d too large; dropping",
count ); count );
} }
return result; return result;
@ -490,7 +490,7 @@ public class SMSService extends XWService {
private void receive( SMS_CMD cmd, byte[] data, String phone ) private void receive( SMS_CMD cmd, byte[] data, String phone )
{ {
DbgUtils.logf( "SMSService.receive(cmd=%s)", cmd.toString() ); DbgUtils.logi( getClass(), "receive(cmd=%s)", cmd.toString() );
DataInputStream dis = DataInputStream dis =
new DataInputStream( new ByteArrayInputStream(data) ); new DataInputStream( new ByteArrayInputStream(data) );
try { try {
@ -509,7 +509,7 @@ public class SMSService extends XWService {
nli.gameID() ); nli.gameID() );
} }
} else { } else {
DbgUtils.logf( "invalid nli from: %s", nliData ); DbgUtils.logw( getClass(), "invalid nli from: %s", nliData );
} }
break; break;
case DATA: case DATA:
@ -528,11 +528,11 @@ public class SMSService extends XWService {
gameID ); gameID );
break; break;
default: default:
DbgUtils.logf( "unexpected cmd %s", cmd.toString() ); DbgUtils.logw( getClass(), "unexpected cmd %s", cmd.toString() );
break; break;
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} }
} }
@ -547,7 +547,7 @@ public class SMSService extends XWService {
if ( tryAssemble( senderPhone, id, index, count, rest ) ) { if ( tryAssemble( senderPhone, id, index, count, rest ) ) {
sendResult( MultiEvent.SMS_RECEIVE_OK ); sendResult( MultiEvent.SMS_RECEIVE_OK );
} else { } else {
DbgUtils.logf( "SMSService: receiveBuffer(): bogus message from" DbgUtils.logw( getClass(), "SMSService: receiveBuffer(): bogus message from"
+ " phone %s", senderPhone ); + " phone %s", senderPhone );
} }
} }
@ -599,12 +599,12 @@ public class SMSService extends XWService {
gotPort = dis.readShort(); gotPort = dis.readShort();
} }
if ( SMS_PROTO_VERSION < proto ) { if ( SMS_PROTO_VERSION < proto ) {
DbgUtils.logf( "SMSService.disAssemble: bad proto %d from %s;" DbgUtils.logw( getClass(), "SMSService.disAssemble: bad proto %d from %s;"
+ " dropping", proto, senderPhone ); + " dropping", proto, senderPhone );
sendResult( MultiEvent.BAD_PROTO_SMS, senderPhone ); sendResult( MultiEvent.BAD_PROTO_SMS, senderPhone );
} else if ( gotPort != myPort ) { } else if ( gotPort != myPort ) {
DbgUtils.logdf( "SMSService.disAssemble(): received on port %d" DbgUtils.logd( getClass(), "disAssemble(): received on port %d"
+ " but expected %d", gotPort, myPort ); + " but expected %d", gotPort, myPort );
} else { } else {
SMS_CMD cmd = SMS_CMD.values()[dis.readByte()]; SMS_CMD cmd = SMS_CMD.values()[dis.readByte()];
byte[] rest = new byte[dis.available()]; byte[] rest = new byte[dis.available()];
@ -613,10 +613,10 @@ public class SMSService extends XWService {
success = true; success = true;
} }
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.loge( ioe ); DbgUtils.logex( ioe );
} catch ( ArrayIndexOutOfBoundsException oob ) { } catch ( ArrayIndexOutOfBoundsException oob ) {
// enum this older code doesn't know about; drop it // enum this older code doesn't know about; drop it
DbgUtils.logf( "disAssemble: dropping message with too-new enum" ); DbgUtils.logw( getClass(), "disAssemble: dropping message with too-new enum" );
} }
return success; return success;
} }
@ -669,20 +669,20 @@ public class SMSService extends XWService {
for ( byte[] fragment : fragments ) { for ( byte[] fragment : fragments ) {
mgr.sendDataMessage( phone, null, nbsPort, fragment, sent, mgr.sendDataMessage( phone, null, nbsPort, fragment, sent,
delivery ); delivery );
DbgUtils.logf( "SMSService.sendBuffers(): sent %d byte fragment", DbgUtils.logi( getClass(), "sendBuffers(): sent %d byte fragment",
fragment.length ); fragment.length );
} }
success = true; success = true;
} catch ( IllegalArgumentException iae ) { } catch ( IllegalArgumentException iae ) {
DbgUtils.logf( "sendBuffers(%s): %s", phone, iae.toString() ); DbgUtils.logw( getClass(), "sendBuffers(%s): %s", phone, iae.toString() );
} catch ( NullPointerException npe ) { } catch ( NullPointerException npe ) {
Assert.fail(); // shouldn't be trying to do this!!! Assert.fail(); // shouldn't be trying to do this!!!
} catch ( Exception ee ) { } catch ( Exception ee ) {
DbgUtils.loge( ee ); DbgUtils.logex( ee );
} }
} }
} else { } else {
DbgUtils.logf( "sendBuffers(): dropping because SMS disabled" ); DbgUtils.logi( getClass(), "dropping because SMS disabled" );
} }
if ( showToasts( this ) && success && (0 == (s_nSent % 5)) ) { if ( showToasts( this ) && success && (0 == (s_nSent % 5)) ) {
@ -720,7 +720,7 @@ public class SMSService extends XWService {
case SmsManager.RESULT_ERROR_NO_SERVICE: case SmsManager.RESULT_ERROR_NO_SERVICE:
DbgUtils.showf( SMSService.this, "NO SERVICE!!!" ); DbgUtils.showf( SMSService.this, "NO SERVICE!!!" );
default: default:
DbgUtils.logf( "FAILURE!!!" ); DbgUtils.logw( getClass(), "FAILURE!!!" );
sendResult( MultiEvent.SMS_SEND_FAILED ); sendResult( MultiEvent.SMS_SEND_FAILED );
break; break;
} }
@ -733,7 +733,7 @@ public class SMSService extends XWService {
public void onReceive( Context context, Intent intent ) public void onReceive( Context context, Intent intent )
{ {
if ( Activity.RESULT_OK != getResultCode() ) { if ( Activity.RESULT_OK != getResultCode() ) {
DbgUtils.logf( "SMS delivery result: FAILURE" ); DbgUtils.logw( getClass(), "SMS delivery result: FAILURE" );
} }
} }
}; };
@ -753,7 +753,7 @@ public class SMSService extends XWService {
} }
} }
} }
DbgUtils.logf( "matchKeyIf(%s) => %s", phone, result ); DbgUtils.logi( SMSService.class, "matchKeyIf(%s) => %s", phone, result );
return result; return result;
} }

View file

@ -92,7 +92,7 @@ public class Toolbar implements BoardContainer.SizeChangeListener {
m_onClickListeners.put( index, new View.OnClickListener() { m_onClickListeners.put( index, new View.OnClickListener() {
@Override @Override
public void onClick( View view ) { public void onClick( View view ) {
DbgUtils.logf( "Toolbar.setListener(): click on %s with action %s", DbgUtils.logi( getClass(), "setListener(): click on %s with action %s",
view.toString(), action.toString() ); view.toString(), action.toString() );
m_dlgDlgt.makeNotAgainBuilder( msgID, prefsKey, action ) m_dlgDlgt.makeNotAgainBuilder( msgID, prefsKey, action )
.show(); .show();

View file

@ -118,7 +118,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
try { try {
versionCode = pm.getPackageInfo( packageName, 0 ).versionCode; versionCode = pm.getPackageInfo( packageName, 0 ).versionCode;
} catch ( PackageManager.NameNotFoundException nnfe ) { } catch ( PackageManager.NameNotFoundException nnfe ) {
DbgUtils.loge( nnfe ); DbgUtils.logex( nnfe );
versionCode = 0; versionCode = 0;
} }
@ -142,7 +142,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
params.put( k_APP, appParams ); params.put( k_APP, appParams );
params.put( k_DEVID, XWPrefs.getDevID( context ) ); params.put( k_DEVID, XWPrefs.getDevID( context ) );
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
@ -157,7 +157,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
params.put( k_DICTS, dictParams ); params.put( k_DICTS, dictParams );
params.put( k_DEVID, XWPrefs.getDevID( context ) ); params.put( k_DEVID, XWPrefs.getDevID( context ) );
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
@ -167,7 +167,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
try { try {
params.put( k_XLATEINFO, xlationUpdate ); params.put( k_XLATEINFO, xlationUpdate );
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
@ -176,11 +176,12 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
params.put( k_STRINGSHASH, BuildConstants.STRINGS_HASH ); params.put( k_STRINGSHASH, BuildConstants.STRINGS_HASH );
params.put( k_NAME, packageName ); params.put( k_NAME, packageName );
params.put( k_AVERS, versionCode ); params.put( k_AVERS, versionCode );
DbgUtils.logdf( "current update: %s", params.toString() ); DbgUtils.logd( UpdateCheckReceiver.class, "current update: %s",
params.toString() );
new UpdateQueryTask( context, params, fromUI, pm, new UpdateQueryTask( context, params, fromUI, pm,
packageName, dals ).execute(); packageName, dals ).execute();
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
} }
@ -223,7 +224,7 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
params.put( k_MD5SUM, sum ); params.put( k_MD5SUM, sum );
params.put( k_INDEX, index ); params.put( k_INDEX, index );
} catch( org.json.JSONException jse ) { } catch( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
return params; return params;
} }
@ -363,11 +364,11 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
} }
} }
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
DbgUtils.logf( "sent: \"%s\"", params.toString() ); DbgUtils.logw( getClass(), "sent: \"%s\"", params.toString() );
DbgUtils.logf( "received: \"%s\"", jstr ); DbgUtils.logw( getClass(), "received: \"%s\"", jstr );
} catch ( PackageManager.NameNotFoundException nnfe ) { } catch ( PackageManager.NameNotFoundException nnfe ) {
DbgUtils.loge( nnfe ); DbgUtils.logex( nnfe );
} }
if ( !gotOne && m_fromUI ) { if ( !gotOne && m_fromUI ) {

View file

@ -140,7 +140,7 @@ public class Utils {
try { try {
Toast.makeText( context, msg, Toast.LENGTH_SHORT).show(); Toast.makeText( context, msg, Toast.LENGTH_SHORT).show();
} catch ( java.lang.RuntimeException re ) { } catch ( java.lang.RuntimeException re ) {
DbgUtils.loge( re ); DbgUtils.logex( re );
} }
} }
@ -431,7 +431,7 @@ public class Utils {
.versionCode; .versionCode;
s_appVersion = new Integer( version ); s_appVersion = new Integer( version );
} catch ( Exception e ) { } catch ( Exception e ) {
DbgUtils.loge( e ); DbgUtils.logex( e );
} }
} }
return null == s_appVersion? 0 : s_appVersion; return null == s_appVersion? 0 : s_appVersion;

View file

@ -43,8 +43,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onCreate( Bundle savedInstanceState, DelegateBase dlgt ) protected void onCreate( Bundle savedInstanceState, DelegateBase dlgt )
{ {
if ( XWApp.LOG_LIFECYLE ) { if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onCreate(this=%H)", DbgUtils.logi( getClass(), "onCreate(this=%H)", this );
getClass().getSimpleName(), this );
} }
super.onCreate( savedInstanceState ); super.onCreate( savedInstanceState );
m_dlgt = dlgt; m_dlgt = dlgt;
@ -68,8 +67,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onPause() protected void onPause()
{ {
if ( XWApp.LOG_LIFECYLE ) { if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onPause(this=%H)", DbgUtils.logi( getClass(), "onPause(this=%H)", this );
getClass().getSimpleName(), this );
} }
m_dlgt.onPause(); m_dlgt.onPause();
super.onPause(); super.onPause();
@ -79,8 +77,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onResume() protected void onResume()
{ {
if ( XWApp.LOG_LIFECYLE ) { if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onResume(this=%H)", DbgUtils.logi( getClass(), "onResume(this=%H)", this );
getClass().getSimpleName(), this );
} }
super.onResume(); super.onResume();
m_dlgt.onResume(); m_dlgt.onResume();
@ -90,8 +87,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onPostResume() protected void onPostResume()
{ {
if ( XWApp.LOG_LIFECYLE ) { if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onPostResume(this=%H)", DbgUtils.logi( getClass(), "onPostResume(this=%H)", this );
getClass().getSimpleName(), this );
} }
super.onPostResume(); super.onPostResume();
} }
@ -100,8 +96,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onStart() protected void onStart()
{ {
if ( XWApp.LOG_LIFECYLE ) { if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onStart(this=%H)", DbgUtils.logi( getClass(), "%s.onStart(this=%H)", this );
getClass().getSimpleName(), this );
} }
super.onStart(); super.onStart();
m_dlgt.onStart(); m_dlgt.onStart();
@ -111,8 +106,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onStop() protected void onStop()
{ {
if ( XWApp.LOG_LIFECYLE ) { if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onStop(this=%H)", DbgUtils.logi( getClass(), "%s.onStop(this=%H)", this );
getClass().getSimpleName(), this );
} }
m_dlgt.onStop(); m_dlgt.onStop();
super.onStop(); super.onStop();
@ -122,8 +116,7 @@ public class XWActivity extends FragmentActivity implements Delegator {
protected void onDestroy() protected void onDestroy()
{ {
if ( XWApp.LOG_LIFECYLE ) { if ( XWApp.LOG_LIFECYLE ) {
DbgUtils.logf( "%s.onDestroy(this=%H)", DbgUtils.logi( getClass(), "onDestroy(this=%H)", this );
getClass().getSimpleName(), this );
} }
m_dlgt.onDestroy(); m_dlgt.onDestroy();
super.onDestroy(); super.onDestroy();

View file

@ -65,7 +65,7 @@ public class XWApp extends Application {
// This one line should always get logged even if logging is // This one line should always get logged even if logging is
// off -- because logging is on by default until logEnable is // off -- because logging is on by default until logEnable is
// called. // called.
DbgUtils.logf( "XWApp.onCreate(); git_rev=%s", DbgUtils.logi( getClass(), "onCreate(); git_rev=%s",
getString( R.string.git_rev ) ); getString( R.string.git_rev ) );
DbgUtils.logEnable( this ); DbgUtils.logEnable( this );
@ -95,7 +95,7 @@ public class XWApp extends Application {
@Override @Override
public void onTerminate() public void onTerminate()
{ {
DbgUtils.logf( "XwApp.onTerminate() called" ); DbgUtils.logi( getClass(), "onTerminate() called" );
XwJNI.cleanGlobals(); XwJNI.cleanGlobals();
super.onTerminate(); super.onTerminate();
} }

View file

@ -71,7 +71,7 @@ abstract class XWFragment extends Fragment implements Delegator {
protected void onCreate( DelegateBase dlgt, Bundle sis ) protected void onCreate( DelegateBase dlgt, Bundle sis )
{ {
DbgUtils.logdf( "%s.onCreate() called", this.getClass().getSimpleName() ); DbgUtils.logd( getClass(), "onCreate() called" );
super.onCreate( sis ); super.onCreate( sis );
if ( null != sis ) { if ( null != sis ) {
m_parentName = sis.getString( PARENT_NAME ); m_parentName = sis.getString( PARENT_NAME );
@ -94,15 +94,14 @@ abstract class XWFragment extends Fragment implements Delegator {
public View onCreateView( LayoutInflater inflater, ViewGroup container, public View onCreateView( LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState ) Bundle savedInstanceState )
{ {
DbgUtils.logdf( "%s.onCreateView() called", this.getClass().getSimpleName() ); DbgUtils.logd( getClass(), "onCreateView() called" );
return m_dlgt.inflateView( inflater, container ); return m_dlgt.inflateView( inflater, container );
} }
@Override @Override
public void onActivityCreated( Bundle savedInstanceState ) public void onActivityCreated( Bundle savedInstanceState )
{ {
DbgUtils.logdf( "%s.onActivityCreated() called", DbgUtils.logd( getClass(), "onActivityCreated() called" );
this.getClass().getSimpleName() );
m_dlgt.init( savedInstanceState ); m_dlgt.init( savedInstanceState );
super.onActivityCreated( savedInstanceState ); super.onActivityCreated( savedInstanceState );
if ( m_hasOptionsMenu ) { if ( m_hasOptionsMenu ) {
@ -113,8 +112,7 @@ abstract class XWFragment extends Fragment implements Delegator {
@Override @Override
public void onPause() public void onPause()
{ {
DbgUtils.logdf( "%s.onPause() called", DbgUtils.logd( getClass(), "onPause() called" );
this.getClass().getSimpleName() );
m_dlgt.onPause(); m_dlgt.onPause();
super.onPause(); super.onPause();
} }
@ -122,8 +120,7 @@ abstract class XWFragment extends Fragment implements Delegator {
@Override @Override
public void onResume() public void onResume()
{ {
DbgUtils.logdf( "%s.onResume() called", DbgUtils.logd( getClass(), "onResume() called" );
this.getClass().getSimpleName() );
super.onResume(); super.onResume();
m_dlgt.onResume(); m_dlgt.onResume();
} }
@ -131,8 +128,7 @@ abstract class XWFragment extends Fragment implements Delegator {
@Override @Override
public void onStart() public void onStart()
{ {
DbgUtils.logdf( "%s.onStart() called", DbgUtils.logd( getClass(), "onStart() called" );
this.getClass().getSimpleName() );
super.onStart(); super.onStart();
m_dlgt.onStart(); m_dlgt.onStart();
} }
@ -140,8 +136,7 @@ abstract class XWFragment extends Fragment implements Delegator {
@Override @Override
public void onStop() public void onStop()
{ {
DbgUtils.logdf( "%s.onStop() called", DbgUtils.logd( getClass(), "onStop() called" );
this.getClass().getSimpleName() );
m_dlgt.onStop(); m_dlgt.onStop();
super.onStop(); super.onStop();
} }
@ -149,8 +144,7 @@ abstract class XWFragment extends Fragment implements Delegator {
@Override @Override
public void onDestroy() public void onDestroy()
{ {
DbgUtils.logdf( "%s.onDestroy() called", DbgUtils.logd( getClass(), "onDestroy() called" );
this.getClass().getSimpleName() );
m_dlgt.onDestroy(); m_dlgt.onDestroy();
super.onDestroy(); super.onDestroy();
} }
@ -158,8 +152,7 @@ abstract class XWFragment extends Fragment implements Delegator {
@Override @Override
public void onActivityResult( int requestCode, int resultCode, Intent data ) public void onActivityResult( int requestCode, int resultCode, Intent data )
{ {
DbgUtils.logdf( "%s.onActivityResult() called", DbgUtils.logd( getClass(), "onActivityResult() called" );
this.getClass().getSimpleName() );
m_dlgt.onActivityResult( RequestCode.values()[requestCode], m_dlgt.onActivityResult( RequestCode.values()[requestCode],
resultCode, data ); resultCode, data );
} }

View file

@ -64,7 +64,7 @@ class XWService extends Service {
if ( null != s_srcMgr ) { if ( null != s_srcMgr ) {
s_srcMgr.sendResult( event, args ); s_srcMgr.sendResult( event, args );
} else { } else {
DbgUtils.logdf( "XWService.sendResult: dropping %s event", event.toString() ); DbgUtils.logd( getClass(), "sendResult(): dropping %s event", event.toString() );
} }
} }
@ -80,7 +80,7 @@ class XWService extends Service {
s_seen.add( inviteID ); s_seen.add( inviteID );
} }
} }
DbgUtils.logdf( "XWService.checkNotDupe(%s) => %b", inviteID, !isDupe ); DbgUtils.logd( getClass(), "checkNotDupe(%s) => %b", inviteID, !isDupe );
return !isDupe; return !isDupe;
} }

View file

@ -296,7 +296,7 @@ public class CommsAddrRec {
|| ip_relay_port != other.ip_relay_port; || ip_relay_port != other.ip_relay_port;
break; break;
default: default:
DbgUtils.logf( "changesMatter: not handling case: %s", DbgUtils.logw( getClass(), "changesMatter: not handling case: %s",
conType.toString() ); conType.toString() );
break; break;
} }

View file

@ -164,7 +164,7 @@ public class CurGameInfo {
; ;
jsonData = obj.toString(); jsonData = obj.toString();
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
return jsonData; return jsonData;
@ -182,7 +182,7 @@ public class CurGameInfo {
int tmp = obj.optInt( PHONIES, phoniesAction.ordinal() ); int tmp = obj.optInt( PHONIES, phoniesAction.ordinal() );
phoniesAction = XWPhoniesChoice.values()[tmp]; phoniesAction = XWPhoniesChoice.values()[tmp];
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
} }

View file

@ -424,9 +424,9 @@ public class GameSummary {
} }
m_extras = asObj.toString(); m_extras = asObj.toString();
} catch( org.json.JSONException ex ) { } catch( org.json.JSONException ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
} }
DbgUtils.logf( "putStringExtra(%s,%s) => %s", key, value, m_extras ); DbgUtils.logi( getClass(), "putStringExtra(%s,%s) => %s", key, value, m_extras );
} }
public String getStringExtra( String key ) public String getStringExtra( String key )
@ -440,10 +440,10 @@ public class GameSummary {
result = null; result = null;
} }
} catch( org.json.JSONException ex ) { } catch( org.json.JSONException ex ) {
DbgUtils.loge( ex ); DbgUtils.logex( ex );
} }
} }
DbgUtils.logf( "getStringExtra(%s) => %s", key, result ); DbgUtils.logi( getClass(), "getStringExtra(%s) => %s", key, result );
return result; return result;
} }

View file

@ -180,7 +180,7 @@ public class JNIThread extends Thread {
if ( BuildConfig.DEBUG ) { if ( BuildConfig.DEBUG ) {
Iterator<QueueElem> iter = m_queue.iterator(); Iterator<QueueElem> iter = m_queue.iterator();
while ( iter.hasNext() ) { while ( iter.hasNext() ) {
DbgUtils.logf( "removing %s from queue", DbgUtils.logi( getClass(), "removing %s from queue",
iter.next().m_cmd.toString() ); iter.next().m_cmd.toString() );
} }
} }
@ -210,7 +210,7 @@ public class JNIThread extends Thread {
// Assert.assertNull( m_jniGamePtr ); // fired!! // Assert.assertNull( m_jniGamePtr ); // fired!!
if ( null != m_jniGamePtr ) { if ( null != m_jniGamePtr ) {
DbgUtils.logdf( "configure(): m_jniGamePtr not null; that ok?" ); DbgUtils.logd( getClass(), "configure(): m_jniGamePtr not null; that ok?" );
} }
m_jniGamePtr = null; m_jniGamePtr = null;
if ( null != stream ) { if ( null != stream ) {
@ -249,7 +249,7 @@ public class JNIThread extends Thread {
join(); join();
// Assert.assertFalse( isAlive() ); // Assert.assertFalse( isAlive() );
} catch ( java.lang.InterruptedException ie ) { } catch ( java.lang.InterruptedException ie ) {
DbgUtils.loge( ie ); DbgUtils.logex( ie );
} }
m_lock.unlock(); m_lock.unlock();
} }
@ -366,7 +366,7 @@ public class JNIThread extends Thread {
// PENDING: once certain this is true, stop saving the full array and // PENDING: once certain this is true, stop saving the full array and
// instead save the hash. Also, update it after each save. // instead save the hash. Also, update it after each save.
if ( hashesEqual ) { if ( hashesEqual ) {
DbgUtils.logdf( "JNIThread.save_jni(): no change in game; can skip saving" ); DbgUtils.logd( getClass(), "save_jni(): no change in game; can skip saving" );
} else { } else {
// Don't need this!!!! this only runs on the run() thread // Don't need this!!!! this only runs on the run() thread
synchronized( this ) { synchronized( this ) {
@ -421,7 +421,7 @@ public class JNIThread extends Thread {
try { try {
elem = m_queue.take(); elem = m_queue.take();
} catch ( InterruptedException ie ) { } catch ( InterruptedException ie ) {
DbgUtils.logf( "interrupted; killing thread" ); DbgUtils.logw( getClass(), "interrupted; killing thread" );
break; break;
} }
boolean draw = false; boolean draw = false;
@ -667,7 +667,7 @@ public class JNIThread extends Thread {
case CMD_NONE: // ignored case CMD_NONE: // ignored
break; break;
default: default:
DbgUtils.logf( "dropping cmd: %s", elem.m_cmd.toString() ); DbgUtils.logw( getClass(), "dropping cmd: %s", elem.m_cmd.toString() );
Assert.fail(); Assert.fail();
} }
@ -685,7 +685,7 @@ public class JNIThread extends Thread {
XwJNI.comms_stop( m_jniGamePtr ); XwJNI.comms_stop( m_jniGamePtr );
save_jni(); save_jni();
} else { } else {
DbgUtils.logf( "JNIThread.run(): exiting without saving" ); DbgUtils.logw( getClass(), "run(): exiting without saving" );
} }
m_jniGamePtr.release(); m_jniGamePtr.release();
m_jniGamePtr = null; m_jniGamePtr = null;
@ -712,7 +712,7 @@ public class JNIThread extends Thread {
{ {
m_queue.add( new QueueElem( cmd, true, args ) ); m_queue.add( new QueueElem( cmd, true, args ) );
if ( m_stopped && ! JNICmd.CMD_NONE.equals(cmd) ) { if ( m_stopped && ! JNICmd.CMD_NONE.equals(cmd) ) {
DbgUtils.logf( "WARNING: adding %s to stopped thread!!!", DbgUtils.logw( getClass(), "adding %s to stopped thread!!!",
cmd.toString() ); cmd.toString() );
DbgUtils.printStack(); DbgUtils.printStack();
} }
@ -731,7 +731,7 @@ public class JNIThread extends Thread {
private void retain_sync() private void retain_sync()
{ {
++m_refCount; ++m_refCount;
DbgUtils.logf( "JNIThread.retain_sync(rowid=%d): m_refCount: %d", DbgUtils.logi( getClass(), "retain_sync(rowid=%d): m_refCount: %d",
m_rowid, m_refCount ); m_rowid, m_refCount );
} }
@ -754,7 +754,7 @@ public class JNIThread extends Thread {
stop = true; stop = true;
} }
} }
DbgUtils.logf( "JNIThread.release(rowid=%d): m_refCount: %d", DbgUtils.logi( getClass(), "release(rowid=%d): m_refCount: %d",
m_rowid, m_refCount ); m_rowid, m_refCount );
if ( stop ) { if ( stop ) {

View file

@ -70,7 +70,7 @@ public class JNIUtilsImpl implements JNIUtils {
try { try {
isr = new InputStreamReader( bais, isUTF8? "UTF8" : "ISO8859_1" ); isr = new InputStreamReader( bais, isUTF8? "UTF8" : "ISO8859_1" );
} catch( java.io.UnsupportedEncodingException uee ) { } catch( java.io.UnsupportedEncodingException uee ) {
DbgUtils.logf( "splitFaces: %s", uee.toString() ); DbgUtils.logi( getClass(), "splitFaces: %s", uee.toString() );
isr = new InputStreamReader( bais ); isr = new InputStreamReader( bais );
} }
@ -84,7 +84,7 @@ public class JNIUtilsImpl implements JNIUtils {
try { try {
chr = isr.read(); chr = isr.read();
} catch ( java.io.IOException ioe ) { } catch ( java.io.IOException ioe ) {
DbgUtils.logf( ioe.toString() ); DbgUtils.logw( getClass(), ioe.toString() );
} }
if ( -1 == chr ) { if ( -1 == chr ) {
addFace( faces, face ); addFace( faces, face );
@ -147,7 +147,7 @@ public class JNIUtilsImpl implements JNIUtils {
} }
digest = md.digest(); digest = md.digest();
} catch ( java.security.NoSuchAlgorithmException nsae ) { } catch ( java.security.NoSuchAlgorithmException nsae ) {
DbgUtils.loge( nsae ); DbgUtils.logex( nsae );
} }
return Utils.digestToString( digest ); return Utils.digestToString( digest );
} }

View file

@ -208,7 +208,7 @@ public class UtilCtxtImpl implements UtilCtxt {
break; break;
default: default:
DbgUtils.logf( "no such stringCode: %d", stringCode ); DbgUtils.logw( getClass(), "no such stringCode: %d", stringCode );
} }
String result = (0 == id) ? "" : LocUtils.getString( m_context, id ); String result = (0 == id) ? "" : LocUtils.getString( m_context, id );

View file

@ -51,8 +51,8 @@ public class XwJNI {
public synchronized GamePtr retain() public synchronized GamePtr retain()
{ {
++m_refCount; ++m_refCount;
DbgUtils.logdf( "GamePtr.retain(this=%H, rowid=%d): refCount now %d", DbgUtils.logd( getClass(), "retain(this=%H, rowid=%d): refCount now %d",
this, m_rowid, m_refCount ); this, m_rowid, m_refCount );
return this; return this;
} }
@ -61,8 +61,8 @@ public class XwJNI {
public synchronized void release() public synchronized void release()
{ {
--m_refCount; --m_refCount;
DbgUtils.logdf( "GamePtr.release(this=%H, rowid=%d): refCount now %d", DbgUtils.logd( getClass(), "release(this=%H, rowid=%d): refCount now %d",
this, m_rowid, m_refCount ); this, m_rowid, m_refCount );
if ( 0 == m_refCount ) { if ( 0 == m_refCount ) {
if ( 0 != m_ptr ) { if ( 0 != m_ptr ) {
if ( !haveEnv( getJNI().m_ptr ) ) { if ( !haveEnv( getJNI().m_ptr ) ) {

View file

@ -80,7 +80,7 @@ public class LocDelegate extends ListDelegateBase
protected void onWindowFocusChanged( boolean hasFocus ) protected void onWindowFocusChanged( boolean hasFocus )
{ {
if ( hasFocus && null != m_lastItem ) { if ( hasFocus && null != m_lastItem ) {
DbgUtils.logf( "updating LocListItem instance %H", m_lastItem ); DbgUtils.logi( getClass(), "updating LocListItem instance %H", m_lastItem );
m_lastItem.update(); m_lastItem.update();
m_lastItem = null; m_lastItem = null;
} }

View file

@ -35,7 +35,7 @@ public class LocIDs extends LocIDsData {
int result = LocIDsData.NOT_FOUND; int result = LocIDsData.NOT_FOUND;
if ( null != key && getS_MAP(context).containsKey( key ) ) { if ( null != key && getS_MAP(context).containsKey( key ) ) {
// Assert.assertNotNull( LocIDsData.S_MAP ); // Assert.assertNotNull( LocIDsData.S_MAP );
DbgUtils.logf( "calling get with key %s", key ); DbgUtils.logw( LocIDs.class, "calling get with key %s", key );
result = getS_MAP( context ).get( key ); // NPE result = getS_MAP( context ).get( key ); // NPE
} }
return result; return result;

View file

@ -133,7 +133,7 @@ public class LocSearcher {
} else { } else {
Pair[] usePairs = null != m_lastTerm && term.contains(m_lastTerm) Pair[] usePairs = null != m_lastTerm && term.contains(m_lastTerm)
? m_matchingPairs : m_filteredPairs; ? m_matchingPairs : m_filteredPairs;
DbgUtils.logf( "start: searching %d pairs", usePairs.length ); DbgUtils.logi( getClass(), "start: searching %d pairs", usePairs.length );
ArrayList<Pair> matches = new ArrayList<Pair>(); ArrayList<Pair> matches = new ArrayList<Pair>();
for ( Pair pair : usePairs ) { for ( Pair pair : usePairs ) {
if ( pair.matches( term ) ) { if ( pair.matches( term ) ) {

View file

@ -306,7 +306,7 @@ public class LocUtils {
int quantity ) int quantity )
{ {
if ( XWApp.LOCUTILS_ENABLED ) { if ( XWApp.LOCUTILS_ENABLED ) {
DbgUtils.logf( "getQuantityString(%d): punting on locutils stuff for" DbgUtils.logw( LocUtils.class, "getQuantityString(%d): punting on locutils stuff for"
+ " now. FIXME", quantity ); + " now. FIXME", quantity );
} }
String result = context.getResources().getQuantityString( id, quantity ); String result = context.getResources().getQuantityString( id, quantity );
@ -317,7 +317,7 @@ public class LocUtils {
int quantity, Object... params ) int quantity, Object... params )
{ {
if ( XWApp.LOCUTILS_ENABLED ) { if ( XWApp.LOCUTILS_ENABLED ) {
DbgUtils.logf( "getQuantityString(%d): punting on locutils stuff for" DbgUtils.logw( LocUtils.class, "getQuantityString(%d): punting on locutils stuff for"
+ " now. FIXME", quantity ); + " now. FIXME", quantity );
} }
String result = context.getResources() String result = context.getResources()
@ -413,7 +413,7 @@ public class LocUtils {
.put( k_LOCALE, locale ) .put( k_LOCALE, locale )
.put( k_XLATEVERS, version ); .put( k_XLATEVERS, version );
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
return result; return result;
@ -439,7 +439,7 @@ public class LocUtils {
String locale = entry.getString( k_LOCALE ); String locale = entry.getString( k_LOCALE );
String newVersion = entry.getString( k_NEW ); String newVersion = entry.getString( k_NEW );
JSONArray pairs = entry.getJSONArray( k_PAIRS ); JSONArray pairs = entry.getJSONArray( k_PAIRS );
DbgUtils.logf( "addXlations: locale %s: got pairs of len %d," DbgUtils.logi( LocUtils.class, "addXlations: locale %s: got pairs of len %d,"
+ " version %s", locale, + " version %s", locale,
pairs.length(), newVersion ); pairs.length(), newVersion );
@ -463,7 +463,7 @@ public class LocUtils {
s_xlationsBlessed = null; s_xlationsBlessed = null;
loadXlations( context ); loadXlations( context );
} catch ( org.json.JSONException jse ) { } catch ( org.json.JSONException jse ) {
DbgUtils.loge( jse ); DbgUtils.logex( jse );
} }
} }
return nAdded; return nAdded;
@ -598,7 +598,7 @@ public class LocUtils {
DBUtils.getXlations( context, getCurLocale( context ) ); DBUtils.getXlations( context, getCurLocale( context ) );
s_xlationsLocal = (Map<String,String>)asObjs[0]; s_xlationsLocal = (Map<String,String>)asObjs[0];
s_xlationsBlessed = (Map<String,String>)asObjs[1]; s_xlationsBlessed = (Map<String,String>)asObjs[1];
DbgUtils.logf( "loadXlations: got %d local strings, %d blessed strings", DbgUtils.logi( LocUtils.class, "loadXlations: got %d local strings, %d blessed strings",
s_xlationsLocal.size(), s_xlationsLocal.size(),
s_xlationsBlessed.size() ); s_xlationsBlessed.size() );
} }
@ -761,7 +761,7 @@ public class LocUtils {
String locale = getCurLocale( context ); String locale = getCurLocale( context );
String msg = String.format( "Dropping bad translations for %s", locale ); String msg = String.format( "Dropping bad translations for %s", locale );
Utils.showToast( context, msg ); Utils.showToast( context, msg );
DbgUtils.logf( msg ); DbgUtils.logw( LocUtils.class, msg );
DBUtils.dropXLations( context, locale ); DBUtils.dropXLations( context, locale );
DBUtils.setStringFor( context, localeKey(locale), "" ); DBUtils.setStringFor( context, localeKey(locale), "" );

View file

@ -9,9 +9,9 @@
<arg value="./local.properties" /> <arg value="./local.properties" />
</exec> </exec>
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null" <exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null"
failonerror="true" > failonerror="true" >
<arg value="${build.target}"/> <arg value="--with-clang"/>
</exec> </exec>
</target> </target>
@ -23,8 +23,8 @@
</exec> </exec>
<exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null" <exec dir="." executable="../scripts/ndksetup.sh" output="/dev/null"
failonerror="true"> failonerror="true" >
<arg value="${build.target}"/> <arg value="--with-clang"/>
</exec> </exec>
<exec dir="." executable="../scripts/ndkbuild.sh" failonerror="true"> <exec dir="." executable="../scripts/ndkbuild.sh" failonerror="true">

View file

@ -120,8 +120,10 @@ public class %s {
fil.write( " /* %04d */ \"%s\",\n" % (ii, pairs[key]['text']) ) fil.write( " /* %04d */ \"%s\",\n" % (ii, pairs[key]['text']) )
fil.write( " };\n" ); fil.write( " };\n" );
names = ()
func = "\n protected static void checkStrings( Context context ) \n {\n" func = "\n protected static void checkStrings( Context context ) \n {\n"
if "debug" == target: if "debug" == target:
names = (name, name)
func += """ func += """
int nMatches = 0; int nMatches = 0;
for ( int ii = 0; ii < strs.length; ++ii ) { for ( int ii = 0; ii < strs.length; ++ii ) {
@ -129,15 +131,15 @@ public class %s {
if ( strs[ii].equals( fromCtxt ) ) { if ( strs[ii].equals( fromCtxt ) ) {
++nMatches; ++nMatches;
} else { } else {
DbgUtils.logf( "unequal strings: \\"%s\\" vs \\"%s\\"", DbgUtils.logi( %s.class, "unequal strings: \\"%%s\\" vs \\"%%s\\"",
strs[ii], fromCtxt ); strs[ii], fromCtxt );
} }
} }
DbgUtils.logf( "checkStrings: %d of %d strings matched", nMatches, strs.length ); DbgUtils.logi( %s.class, "checkStrings: %%d of %%d strings matched", nMatches, strs.length );
""" """
func += " }" func += " }"
fil.write( func ) fil.write( func % names )
# Now the end of the class # Now the end of the class
lines = """ lines = """

View file

@ -2,14 +2,33 @@
set -u -e set -u -e
USE_CLANG=''
APPMK=./jni/Application.mk APPMK=./jni/Application.mk
TMP_MK=/tmp/tmp_$$_Application.mk TMP_MK=/tmp/tmp_$$_Application.mk
XWORDS_DEBUG_ARMONLY=${XWORDS_DEBUG_ARMONLY:-""} XWORDS_DEBUG_ARMONLY=${XWORDS_DEBUG_ARMONLY:-""}
XWORDS_DEBUG_X86ONLY=${XWORDS_DEBUG_X86ONLYx:-""} XWORDS_DEBUG_X86ONLY=${XWORDS_DEBUG_X86ONLYx:-""}
usage() {
echo "usage $0 [--with-clang]"
exit 1
}
while [ $# -gt 0 ]; do
case $1 in
--with-clang)
USE_CLANG=1
;;
*)
usage "Unexpected param $1"
;;
esac
shift
done
echo "# Generated by $0; do not edit!!!" > $TMP_MK echo "# Generated by $0; do not edit!!!" > $TMP_MK
echo "NDK_TOOLCHAIN_VERSION := clang" >> $TMP_MK [ -n "$USE_CLANG" ] && echo "NDK_TOOLCHAIN_VERSION := clang" >> $TMP_MK
if [ -n "$XWORDS_DEBUG_ARMONLY" ]; then if [ -n "$XWORDS_DEBUG_ARMONLY" ]; then
echo "APP_ABI := armeabi" >> $TMP_MK echo "APP_ABI := armeabi" >> $TMP_MK
@ -26,7 +45,7 @@ fi
if [ ! -f $APPMK ]; then if [ ! -f $APPMK ]; then
cp $TMP_MK $APPMK cp $TMP_MK $APPMK
elif ! diff $APPMK $TMP_MK; then elif ! diff -q $APPMK $TMP_MK >/dev/null; then
cp $TMP_MK $APPMK cp $TMP_MK $APPMK
fi fi
rm -f $TMP_MK rm -f $TMP_MK

View file

@ -784,11 +784,15 @@ wordScoreFormatterAddTile( WordScoreFormatter* fmtr, Tile tile,
} }
fullBufPtr = fmtr->fullBuf + fmtr->bufLen; fullBufPtr = fmtr->fullBuf + fmtr->bufLen;
fmtr->bufLen += XP_U16 len = sizeof(fmtr->fullBuf) - fmtr->bufLen;
XP_SNPRINTF( fullBufPtr, if ( tileMultiplier > 1 ) {
(XP_U16)(sizeof(fmtr->fullBuf) - fmtr->bufLen), fmtr->bufLen += XP_SNPRINTF( fullBufPtr, len,
(XP_UCHAR*)(tileMultiplier > 1?"%s(%dx%d)":"%s%d"), "%s(%dx%d)", prefix, tileScore,
prefix, tileScore, tileMultiplier ); tileMultiplier );
} else {
fmtr->bufLen += XP_SNPRINTF( fullBufPtr, len,
"%s%d", prefix, tileScore );
}
XP_ASSERT( XP_STRLEN(fmtr->fullBuf) == fmtr->bufLen ); XP_ASSERT( XP_STRLEN(fmtr->fullBuf) == fmtr->bufLen );
XP_ASSERT( fmtr->bufLen < sizeof(fmtr->fullBuf) ); XP_ASSERT( fmtr->bufLen < sizeof(fmtr->fullBuf) );

View file

@ -122,8 +122,7 @@ XP_Bool server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream );
#endif #endif
#ifdef XWFEATURE_CHAT #ifdef XWFEATURE_CHAT
void server_sendChat( ServerCtxt* server, const XP_UCHAR* msg, void server_sendChat( ServerCtxt* server, const XP_UCHAR* msg, XP_S16 from );
XP_S16 from );
#endif #endif
void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream, void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,

View file

@ -112,6 +112,7 @@ DEFINES += -DXWFEATURE_WALKDICT_FILTER
DEFINES += -DXWFEATURE_DICTSANITY DEFINES += -DXWFEATURE_DICTSANITY
DEFINES += -DHASH_STREAM DEFINES += -DHASH_STREAM
DEFINES += -DRELAY_NAME_DEFAULT="\"localhost\"" DEFINES += -DRELAY_NAME_DEFAULT="\"localhost\""
DEFINES += -DXWFEATURE_TURNCHANGENOTIFY
#DEFINES += -DXWFEATURE_SCOREONEPASS #DEFINES += -DXWFEATURE_SCOREONEPASS
### Enable zero or one of these two ### ### Enable zero or one of these two ###
#DEFINES += -DXWFEATURE_TRAYUNDO_ALL #DEFINES += -DXWFEATURE_TRAYUNDO_ALL

View file

@ -1382,6 +1382,14 @@ curses_util_yOffsetChange( XW_UtilCtxt* XP_UNUSED(uc),
/* } */ /* } */
} /* curses_util_yOffsetChange */ } /* curses_util_yOffsetChange */
#ifdef XWFEATURE_TURNCHANGENOTIFY
static void
curses_util_turnChanged( XW_UtilCtxt* XP_UNUSED(uc), XP_S16 newTurn )
{
XP_LOGF( "%s(turn=%d)", __func__, newTurn );
}
#endif
static XP_Bool static XP_Bool
curses_util_warnIllegalWord( XW_UtilCtxt* XP_UNUSED(uc), curses_util_warnIllegalWord( XW_UtilCtxt* XP_UNUSED(uc),
BadWordInfo* XP_UNUSED(bwi), BadWordInfo* XP_UNUSED(bwi),
@ -1453,6 +1461,9 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
util->vtable->m_util_getVTManager = curses_util_getVTManager; util->vtable->m_util_getVTManager = curses_util_getVTManager;
util->vtable->m_util_askPassword = curses_util_askPassword; util->vtable->m_util_askPassword = curses_util_askPassword;
util->vtable->m_util_yOffsetChange = curses_util_yOffsetChange; util->vtable->m_util_yOffsetChange = curses_util_yOffsetChange;
#ifdef XWFEATURE_TURNCHANGENOTIFY
util->vtable->m_util_turnChanged = curses_util_turnChanged;
#endif
util->vtable->m_util_warnIllegalWord = curses_util_warnIllegalWord; util->vtable->m_util_warnIllegalWord = curses_util_warnIllegalWord;
util->vtable->m_util_remSelected = curses_util_remSelected; util->vtable->m_util_remSelected = curses_util_remSelected;
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY

View file

@ -171,7 +171,7 @@ writeToDB( XWStreamCtxt* stream, void* closure )
} }
static void static void
addSnap( CommonGlobals* cGlobals ) addSnapshot( CommonGlobals* cGlobals )
{ {
LOG_FUNC(); LOG_FUNC();
@ -184,9 +184,8 @@ addSnap( CommonGlobals* cGlobals )
XWStreamCtxt* stream = make_simple_stream( cGlobals ); XWStreamCtxt* stream = make_simple_stream( cGlobals );
getImage( dctx, stream ); getImage( dctx, stream );
removeSurface( dctx ); removeSurface( dctx );
sqlite3_int64 newRow = writeBlobColumnStream( stream, cGlobals->pDb, writeBlobColumnStream( stream, cGlobals->pDb, cGlobals->selRow, "snap" );
cGlobals->selRow, "snap" ); // XP_ASSERT( cGlobals->selRow == newRow );
XP_ASSERT( cGlobals->selRow == newRow );
stream_destroy( stream ); stream_destroy( stream );
} }
@ -264,7 +263,7 @@ summarize( CommonGlobals* cGlobals )
sqlite3_finalize( stmt ); sqlite3_finalize( stmt );
XP_USE( result ); XP_USE( result );
addSnap( cGlobals ); addSnapshot( cGlobals );
} }
GSList* GSList*

View file

@ -1764,6 +1764,15 @@ gtk_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 maxOffset,
} }
} /* gtk_util_yOffsetChange */ } /* gtk_util_yOffsetChange */
#ifdef XWFEATURE_TURNCHANGENOTIFY
static void
gtk_util_turnChanged( XW_UtilCtxt* uc, XP_S16 XP_UNUSED(newTurn) )
{
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
saveGame( &globals->cGlobals );
}
#endif
static void static void
gtkShowFinalScores( const GtkGameGlobals* globals, XP_Bool ignoreTimeout ) gtkShowFinalScores( const GtkGameGlobals* globals, XP_Bool ignoreTimeout )
{ {
@ -2396,6 +2405,9 @@ setupGtkUtilCallbacks( GtkGameGlobals* globals, XW_UtilCtxt* util )
util->vtable->m_util_askPassword = gtk_util_askPassword; util->vtable->m_util_askPassword = gtk_util_askPassword;
util->vtable->m_util_trayHiddenChange = gtk_util_trayHiddenChange; util->vtable->m_util_trayHiddenChange = gtk_util_trayHiddenChange;
util->vtable->m_util_yOffsetChange = gtk_util_yOffsetChange; util->vtable->m_util_yOffsetChange = gtk_util_yOffsetChange;
#ifdef XWFEATURE_TURNCHANGENOTIFY
util->vtable->m_util_turnChanged = gtk_util_turnChanged;
#endif
util->vtable->m_util_informMove = gtk_util_informMove; util->vtable->m_util_informMove = gtk_util_informMove;
util->vtable->m_util_informUndo = gtk_util_informUndo; util->vtable->m_util_informUndo = gtk_util_informUndo;
util->vtable->m_util_notifyGameOver = gtk_util_notifyGameOver; util->vtable->m_util_notifyGameOver = gtk_util_notifyGameOver;

View file

@ -359,6 +359,10 @@ saveGame( CommonGlobals* cGlobals )
} }
if ( doSave ) { if ( doSave ) {
if ( !!cGlobals->pDb ) {
summarize( cGlobals );
}
XWStreamCtxt* outStream; XWStreamCtxt* outStream;
MemStreamCloseCallback onClose = !!cGlobals->pDb? MemStreamCloseCallback onClose = !!cGlobals->pDb?
writeToDB : writeToFile; writeToDB : writeToFile;
@ -377,9 +381,6 @@ saveGame( CommonGlobals* cGlobals )
game_saveSucceeded( &cGlobals->game, cGlobals->curSaveToken ); game_saveSucceeded( &cGlobals->game, cGlobals->curSaveToken );
XP_LOGF( "%s: saved", __func__ ); XP_LOGF( "%s: saved", __func__ );
if ( !!cGlobals->pDb ) {
summarize( cGlobals );
}
} else { } else {
XP_LOGF( "%s: simulating save failure", __func__ ); XP_LOGF( "%s: simulating save failure", __func__ );
} }