switch from static final ints to an enum; no other change.

This commit is contained in:
Eric House 2013-08-11 10:47:01 -07:00
parent 1d52a9afea
commit a96c0c548f
3 changed files with 20 additions and 19 deletions

View file

@ -598,23 +598,23 @@ public class RelayService extends XWService {
private String getDevID( byte[] typp )
{
byte typ;
UtilCtxt.DevIDType typ;
String devid = XWPrefs.getRelayDevID( this );
if ( null != devid && 0 < devid.length() ) {
typ = UtilCtxt.ID_TYPE_RELAY;
typ = UtilCtxt.DevIDType.ID_TYPE_RELAY;
} else {
devid = XWPrefs.getGCMDevID( this );
if ( null != devid && 0 < devid.length() ) {
typ = UtilCtxt.ID_TYPE_ANDROID_GCM;
typ = UtilCtxt.DevIDType.ID_TYPE_ANDROID_GCM;
} else {
devid = "";
typ = UtilCtxt.ID_TYPE_ANON;
typ = UtilCtxt.DevIDType.ID_TYPE_ANON;
}
}
if ( null != typp ) {
typp[0] = typ;
typp[0] = (byte)typ.ordinal();
} else {
Assert.assertTrue( typ == UtilCtxt.ID_TYPE_RELAY );
Assert.assertTrue( typ == UtilCtxt.DevIDType.ID_TYPE_RELAY );
}
return devid;
}

View file

@ -57,14 +57,15 @@ public interface UtilCtxt {
void setIsServer( boolean isServer );
// Possible values for typ[0], these must match enum in xwrelay.sh
public static final int ID_TYPE_NONE = 0;
public static final int ID_TYPE_RELAY = 1;
public static final int ID_TYPE_ANDROID_GCM = 3;
public static final int ID_TYPE_ANDROID_OTHER = 4;
public static final int ID_TYPE_ANON = 5;
public enum DevIDType { ID_TYPE_NONE
, ID_TYPE_RELAY
, ID_TYPE_ANDROID_GCM
, ID_TYPE_ANDROID_OTHER
, ID_TYPE_ANON
}
String getDevID( /*out*/ byte[] typ );
void deviceRegistered( int devIDType, String idRelay );
void deviceRegistered( DevIDType devIDType, String idRelay );
void bonusSquareHeld( int bonus );
void playerScoreHeld( int player );

View file

@ -96,29 +96,29 @@ public class UtilCtxtImpl implements UtilCtxt {
public String getDevID( /*out*/ byte[] typa )
{
byte typ = UtilCtxt.ID_TYPE_NONE;
UtilCtxt.DevIDType typ = UtilCtxt.DevIDType.ID_TYPE_NONE;
String result = XWPrefs.getRelayDevID( m_context );
if ( null != result ) {
typ = UtilCtxt.ID_TYPE_RELAY;
typ = UtilCtxt.DevIDType.ID_TYPE_RELAY;
} else {
result = XWPrefs.getGCMDevID( m_context );
if ( result.equals("") ) {
result = null;
} else {
typ = UtilCtxt.ID_TYPE_ANDROID_GCM;
typ = UtilCtxt.DevIDType.ID_TYPE_ANDROID_GCM;
}
}
typa[0] = typ;
typa[0] = (byte)typ.ordinal();
return result;
}
public void deviceRegistered( int devIDType, String idRelay )
public void deviceRegistered( UtilCtxt.DevIDType devIDType, String idRelay )
{
switch ( devIDType ) {
case UtilCtxt.ID_TYPE_RELAY:
case ID_TYPE_RELAY:
XWPrefs.setRelayDevID( m_context, idRelay );
break;
case UtilCtxt.ID_TYPE_NONE:
case ID_TYPE_NONE:
XWPrefs.clearRelayDevID( m_context );
break;
default: