cleanup from review of diffs (nothing significant)

This commit is contained in:
Eric House 2019-01-15 07:44:38 -08:00
parent 73a469a428
commit cf3d3bc156
7 changed files with 39 additions and 63 deletions

View file

@ -341,9 +341,8 @@ public class BTService extends XWService {
NetLaunchInfo nli )
{
Assert.assertTrue( null != btAddr && 0 < btAddr.length() );
String nliData = nli.toString();
Intent intent = getIntentTo( context, BTAction.INVITE )
.putExtra( GAMEDATA_KEY, nliData )
.putExtra( GAMEDATA_KEY, nli.toString() )
.putExtra( ADDR_KEY, btAddr );
startService( context, intent );
}
@ -410,9 +409,7 @@ public class BTService extends XWService {
private static boolean canRunForegroundService()
{
// added in API level 26
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
// && Prefs.runForegroundServiceEnabled( context, true )
;
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
}
private static Intent getIntentTo( Context context, BTAction cmd )
@ -458,13 +455,6 @@ public class BTService extends XWService {
return result;
}
@Override
public void onDestroy()
{
Log.d( TAG, "%s.onDestroy()", this );
super.onDestroy();
}
private int handleCommand( Intent intent )
{
int result;
@ -497,7 +487,7 @@ public class BTService extends XWService {
case INVITE:
String jsonData = intent.getStringExtra( GAMEDATA_KEY );
NetLaunchInfo nli = NetLaunchInfo.makeFrom( this, jsonData );
Log.i( TAG, "handleCommand: nli: %s", nli.toString() );
Log.i( TAG, "handleCommand: nli: %s", nli );
String btAddr = intent.getStringExtra( ADDR_KEY );
m_sender.add( new BTQueueElem( BTCmd.INVITE, nli, btAddr ) );
break;

View file

@ -367,7 +367,6 @@ public class DBUtils {
String phone, String relayID, String p2pAddr )
{
try ( GameLock lock = GameLock.getFor( rowid ).tryLock() ) {
Assert.assertNotNull( lock );
if ( null != lock ) {
GameSummary summary = getSummary( context, lock );
if ( null != btAddr ) {
@ -384,6 +383,7 @@ public class DBUtils {
}
saveSummary( context, lock, summary );
} else {
Assert.assertFalse( BuildConfig.DEBUG );
Log.e( TAG, "addRematchInfo(%d): unable to lock game" );
}
}
@ -1124,9 +1124,7 @@ public class DBUtils {
deleteGame( context, lock );
} else {
Log.e( TAG, "deleteGame: unable to lock rowid %d", rowid );
if ( BuildConfig.DEBUG ) {
Assert.fail();
}
Assert.assertFalse( BuildConfig.DEBUG );
}
}
}

View file

@ -30,7 +30,6 @@ import android.text.format.Time;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.Iterator;
import java.util.Set;

View file

@ -91,7 +91,7 @@ public class GameLock implements AutoCloseable {
// OR
// * existing locks are ReadOnly and this request is readOnly
// OR
// * the requesting thread already holds the lock
// * the requesting thread already holds the lock (later...)
private GameLock tryLockImpl( boolean readOnly )
{
GameLock result = null;
@ -169,17 +169,6 @@ public class GameLock implements AutoCloseable {
return result;
}
// @NonNull
// public GameLock lockRO() throws InterruptedException
// {
// if ( BuildConfig.DEBUG ) {
// DbgUtils.assertOnUIThread( false );
// }
// GameLock result = lockImpl( Long.MAX_VALUE, true );
// Assert.assertNotNull( result );
// return result;
// }
// Version that's allowed to return null -- if maxMillis > 0
public GameLock lock( long maxMillis ) throws GameLockedException
{

View file

@ -1231,14 +1231,6 @@ public class GamesListDelegate extends ListDelegateBase
final Object ... args )
{
switch( event ) {
// case HOST_PONGED:
// post( new Runnable() {
// public void run() {
// DbgUtils.showf( m_activity,
// "Pong from %s", args[0].toString() );
// }
// });
// break;
case BT_GAME_CREATED:
post( new Runnable() {
public void run() {
@ -2689,30 +2681,29 @@ public class GamesListDelegate extends ListDelegateBase
private static Intent makeSelfIntent( Context context )
{
Intent intent = new Intent( context, MainActivity.class );
intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP );
Intent intent = new Intent( context, MainActivity.class )
.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP );
return intent;
}
public static Intent makeBackgroundIntent( Context context )
{
Intent intent = makeSelfIntent( context );
intent.putExtra( BACKGROUND_EXTRA, true );
return intent;
return makeSelfIntent( context )
.putExtra( BACKGROUND_EXTRA, true );
}
public static Intent makeRowidIntent( Context context, long rowid )
{
Intent intent = makeSelfIntent( context );
intent.putExtra( ROWID_EXTRA, rowid );
Intent intent = makeSelfIntent( context )
.putExtra( ROWID_EXTRA, rowid );
return intent;
}
public static Intent makeGameIDIntent( Context context, int gameID )
{
Intent intent = makeSelfIntent( context );
intent.putExtra( GAMEID_EXTRA, gameID );
Intent intent = makeSelfIntent( context )
.putExtra( GAMEID_EXTRA, gameID );
return intent;
}
@ -2724,14 +2715,14 @@ public class GamesListDelegate extends ListDelegateBase
String newName )
{
Intent intent = null;
intent = makeSelfIntent( context );
intent.putExtra( REMATCH_ROWID_EXTRA, rowid );
intent.putExtra( REMATCH_DICT_EXTRA, gi.dictName );
boolean isSolo = gi.serverRole == CurGameInfo.DeviceRole.SERVER_STANDALONE;
intent.putExtra( REMATCH_IS_SOLO, isSolo );
intent.putExtra( REMATCH_LANG_EXTRA, gi.dictLang );
intent.putExtra( REMATCH_PREFS_EXTRA, gi.getJSONData() );
intent.putExtra( REMATCH_NEWNAME_EXTRA, newName );
intent = makeSelfIntent( context )
.putExtra( REMATCH_ROWID_EXTRA, rowid )
.putExtra( REMATCH_DICT_EXTRA, gi.dictName )
.putExtra( REMATCH_IS_SOLO, isSolo )
.putExtra( REMATCH_LANG_EXTRA, gi.dictLang )
.putExtra( REMATCH_PREFS_EXTRA, gi.getJSONData() )
.putExtra( REMATCH_NEWNAME_EXTRA, newName );
if ( null != addrTypes ) {
intent.putExtra( REMATCH_ADDRS_EXTRA, addrTypes.toInt() );
@ -2757,8 +2748,8 @@ public class GamesListDelegate extends ListDelegateBase
public static Intent makeAlertIntent( Context context, String msg )
{
Intent intent = makeSelfIntent( context );
intent.putExtra( ALERT_MSG, msg );
Intent intent = makeSelfIntent( context )
.putExtra( ALERT_MSG, msg );
return intent;
}
@ -2771,8 +2762,8 @@ public class GamesListDelegate extends ListDelegateBase
public static void openGame( Context context, Uri data )
{
Intent intent = makeSelfIntent( context );
intent.setData( data );
Intent intent = makeSelfIntent( context )
.setData( data );
context.startActivity( intent );
}
}

View file

@ -101,6 +101,16 @@ public class MultiService {
public void setListener( MultiEventListener li )
{
synchronized( this ) {
// If this is happening, the order of resume/pause isn't what we
// expect. Might need to keep a set of these instead of a
// singleton.
if ( BuildConfig.DEBUG ) {
if ( m_li == null && li == null ) {
Assert.fail();
} else if ( m_li != null && li != null ) {
Assert.fail();
}
}
m_li = li;
}
}

View file

@ -982,6 +982,7 @@ public class RelayService extends JobIntentService
void setService( RelayService service )
{
Assert.assertNotNull( service );
synchronized ( mServiceHolder ) {
mServiceHolder[0] = service;
// unblock waiters for non-null Service
@ -1058,11 +1059,9 @@ public class RelayService extends JobIntentService
private void connectSocket() throws InterruptedException
{
if ( null == m_UDPSocket ) {
int port;
String host;
final RelayService service = getService();
port = XWPrefs.getDefaultRelayPort( service );
host = XWPrefs.getDefaultRelayHost( service );
int port = XWPrefs.getDefaultRelayPort( service );
String host = XWPrefs.getDefaultRelayHost( service );
try {
m_UDPSocket = new DatagramSocket();