mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
when new GCM ID is received, force re-register.
This commit is contained in:
parent
9efb044c4f
commit
9a8ed72ea1
2 changed files with 14 additions and 7 deletions
|
@ -45,7 +45,7 @@ public class GCMIntentService extends GCMBaseIntentService {
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "GCMIntentService.onRegistered(%s)", regId );
|
DbgUtils.logf( "GCMIntentService.onRegistered(%s)", regId );
|
||||||
XWPrefs.setGCMDevID( context, regId );
|
XWPrefs.setGCMDevID( context, regId );
|
||||||
notifyRelayService( true );
|
notifyRelayService( context, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,14 +54,14 @@ public class GCMIntentService extends GCMBaseIntentService {
|
||||||
DbgUtils.logf( "GCMIntentService.onUnregistered(%s)", regId );
|
DbgUtils.logf( "GCMIntentService.onUnregistered(%s)", regId );
|
||||||
XWPrefs.clearGCMDevID( context );
|
XWPrefs.clearGCMDevID( context );
|
||||||
RelayService.devIDChanged();
|
RelayService.devIDChanged();
|
||||||
notifyRelayService( false );
|
notifyRelayService( context, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMessage( Context context, Intent intent )
|
protected void onMessage( Context context, Intent intent )
|
||||||
{
|
{
|
||||||
DbgUtils.logf( "GCMIntentService.onMessage()" );
|
DbgUtils.logf( "GCMIntentService.onMessage()" );
|
||||||
notifyRelayService( true );
|
notifyRelayService( context, true );
|
||||||
|
|
||||||
String value;
|
String value;
|
||||||
boolean ignoreIt = XWApp.GCM_IGNORED;
|
boolean ignoreIt = XWApp.GCM_IGNORED;
|
||||||
|
@ -128,12 +128,12 @@ public class GCMIntentService extends GCMBaseIntentService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyRelayService( boolean working )
|
private void notifyRelayService( Context context, boolean working )
|
||||||
{
|
{
|
||||||
if ( working && XWApp.GCM_IGNORED ) {
|
if ( working && XWApp.GCM_IGNORED ) {
|
||||||
working = false;
|
working = false;
|
||||||
}
|
}
|
||||||
RelayService.gcmConfirmed( working );
|
RelayService.gcmConfirmed( context, working );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class RelayService extends XWService
|
||||||
private Runnable m_onInactivity;
|
private Runnable m_onInactivity;
|
||||||
private int m_maxIntervalSeconds = 0;
|
private int m_maxIntervalSeconds = 0;
|
||||||
private long m_lastGamePacketReceived;
|
private long m_lastGamePacketReceived;
|
||||||
|
private static DevIDType s_curType = DevIDType.ID_TYPE_NONE;
|
||||||
|
|
||||||
// These must match the enum XWPDevProto in xwrelay.h
|
// These must match the enum XWPDevProto in xwrelay.h
|
||||||
private static enum XWPDevProto { XWPDEV_PROTO_VERSION_INVALID
|
private static enum XWPDevProto { XWPDEV_PROTO_VERSION_INVALID
|
||||||
|
@ -120,13 +121,19 @@ public class RelayService extends XWService
|
||||||
,XWPDEV_UPGRADE
|
,XWPDEV_UPGRADE
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void gcmConfirmed( boolean confirmed )
|
public static void gcmConfirmed( Context context, boolean confirmed )
|
||||||
{
|
{
|
||||||
if ( s_gcmWorking != confirmed ) {
|
if ( s_gcmWorking != confirmed ) {
|
||||||
DbgUtils.logf( "RelayService.gcmConfirmed(): changing "
|
DbgUtils.logf( "RelayService.gcmConfirmed(): changing "
|
||||||
+ "s_gcmWorking to %b", confirmed );
|
+ "s_gcmWorking to %b", confirmed );
|
||||||
s_gcmWorking = confirmed;
|
s_gcmWorking = confirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we've gotten a GCM id and haven't registered it, do so!
|
||||||
|
if ( confirmed && !s_curType.equals( DevIDType.ID_TYPE_ANDROID_GCM ) ) {
|
||||||
|
devIDChanged();
|
||||||
|
timerFired( context );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startService( Context context )
|
public static void startService( Context context )
|
||||||
|
@ -143,7 +150,6 @@ public class RelayService extends XWService
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void timerFired( Context context )
|
public static void timerFired( Context context )
|
||||||
|
|
||||||
{
|
{
|
||||||
Intent intent = getIntentTo( context, MsgCmds.TIMER_FIRED );
|
Intent intent = getIntentTo( context, MsgCmds.TIMER_FIRED );
|
||||||
context.startService( intent );
|
context.startService( intent );
|
||||||
|
@ -646,6 +652,7 @@ public class RelayService extends XWService
|
||||||
DevIDType[] typa = new DevIDType[1];
|
DevIDType[] typa = new DevIDType[1];
|
||||||
String devid = getDevID( typa );
|
String devid = getDevID( typa );
|
||||||
DevIDType typ = typa[0];
|
DevIDType typ = typa[0];
|
||||||
|
s_curType = typ;
|
||||||
|
|
||||||
ByteArrayOutputStream bas = new ByteArrayOutputStream();
|
ByteArrayOutputStream bas = new ByteArrayOutputStream();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue