diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java index ec7961238..ecd37e431 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java @@ -392,6 +392,7 @@ public class RelayService extends JobIntentService } // NetStateCache.StateChangedIf interface + @Override public void onNetAvail( boolean nowAvailable ) { startService( this ); // bad name: will *stop* threads too @@ -759,9 +760,9 @@ public class RelayService extends JobIntentService out.writeShort( BuildConfig.CLIENT_VERS_RELAY ); writeVLIString( out, BuildConfig.GIT_REV ); - // writeVLIString( out, String.format( "€%s", Build.MODEL) ); writeVLIString( out, Build.MODEL ); writeVLIString( out, Build.VERSION.RELEASE ); + writeVLIString( out, BuildConfig.VARIANT_NAME ); postPacket( bas, XWRelayReg.XWPDEV_REG ); s_regStartTime = now; diff --git a/xwords4/linux/relaycon.c b/xwords4/linux/relaycon.c index a1cdfb179..995ccbd38 100644 --- a/xwords4/linux/relaycon.c +++ b/xwords4/linux/relaycon.c @@ -305,6 +305,7 @@ relaycon_reg( LaunchParams* params, const XP_UCHAR* rDevID, indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, SVN_REV ); indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux box" ); indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux version" ); + indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux variant" ); sendIt( storage, tmpbuf, indx, 0.5 ); } diff --git a/xwords4/relay/dbmgr.cpp b/xwords4/relay/dbmgr.cpp index aecdb29ec..c269bd638 100644 --- a/xwords4/relay/dbmgr.cpp +++ b/xwords4/relay/dbmgr.cpp @@ -276,7 +276,7 @@ DBMgr::FindRelayIDFor( const char* connName, HostID hid, if ( found ) { devID = (DevIDRelay)strtoul( PQgetvalue( result, 0, 0 ), NULL, 10 ); *devIDP = devID; - ReregisterDevice( devID, host, NULL, 0, NULL, NULL ); + ReregisterDevice( devID, host, NULL, 0, NULL, NULL, NULL ); } PQclear( result ); if ( !found ) { @@ -390,7 +390,7 @@ DBMgr::AllDevsAckd( const char* const connName ) DevIDRelay DBMgr::RegisterDevice( const DevID* host, int clientVersion, const char* const desc, const char* const model, - const char* const osVers ) + const char* const osVers, const char* const variant ) { DevIDRelay devID; assert( host->m_devIDType != ID_TYPE_NONE ); @@ -418,8 +418,8 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion, QueryBuilder qb; qb.appendQueryf( "INSERT INTO " DEVICES_TABLE " (id, devTypes[1]," - " devids[1], clntVers, versdesc, model, osvers)" - " VALUES($$, $$, $$, $$, $$, $$, $$)" ) + " devids[1], clntVers, versdesc, model, osvers, variant)" + " VALUES($$, $$, $$, $$, $$, $$, $$, $$)" ) .appendParam( devID ) .appendParam( host->m_devIDType ) @@ -428,6 +428,7 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion, .appendParam( desc ) .appendParam( model ) .appendParam( osVers ) + .appendParam( variant ) .finish(); success = execParams( qb ); @@ -439,13 +440,14 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion, DevIDRelay DBMgr::RegisterDevice( const DevID* host ) { - return RegisterDevice( host, 0, NULL, NULL, NULL ); + return RegisterDevice( host, 0, NULL, NULL, NULL, NULL ); } void DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host, const char* const desc, int clientVersion, - const char* const model, const char* const osVers ) + const char* const model, const char* const osVers, + const char* const variant ) { QueryBuilder qb; qb.appendQueryf( "UPDATE " DEVICES_TABLE " SET " @@ -455,7 +457,7 @@ DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host, .appendParam( host->m_devIDType ) .appendParam( host->m_devIDString.c_str() ); - formatUpdate( qb, true, desc, clientVersion, model, osVers, relayID ); + formatUpdate( qb, true, desc, clientVersion, model, osVers, variant, relayID ); qb.finish(); execParams( qb ); } @@ -464,7 +466,8 @@ DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host, bool DBMgr::UpdateDevice( DevIDRelay relayID, const char* const desc, int clientVersion, const char* const model, - const char* const osVers, bool check ) + const char* const osVers, const char* const variant, + bool check ) { bool exists = !check; if ( !exists ) { @@ -476,7 +479,8 @@ DBMgr::UpdateDevice( DevIDRelay relayID, const char* const desc, if ( exists ) { QueryBuilder qb; qb.appendQueryf( "UPDATE " DEVICES_TABLE " SET " ); - formatUpdate( qb, false, desc, clientVersion, model, osVers, relayID ); + formatUpdate( qb, false, desc, clientVersion, model, osVers, + variant, relayID ); qb.finish(); execParams( qb ); } @@ -486,14 +490,15 @@ DBMgr::UpdateDevice( DevIDRelay relayID, const char* const desc, bool DBMgr::UpdateDevice( DevIDRelay relayID ) { - return UpdateDevice( relayID, NULL, 0, NULL, NULL, false ); + return UpdateDevice( relayID, NULL, 0, NULL, NULL, NULL, false ); } void DBMgr::formatUpdate( QueryBuilder& qb, bool append, const char* const desc, int clientVersion, const char* const model, - const char* const osVers, DevIDRelay relayID ) + const char* const osVers, const char* const variant, + DevIDRelay relayID ) { if ( append ) { qb.appendQueryf( "mtimes=array_prepend('now', mtimes)" ); // FIXME: too many @@ -515,6 +520,10 @@ DBMgr::formatUpdate( QueryBuilder& qb, qb.appendQueryf( ", osvers=$$" ) .appendParam( osVers ); } + if ( NULL != variant && '\0' != variant[0] ) { + qb.appendQueryf( ", variant=$$" ) + .appendParam( variant ); + } qb.appendQueryf( " WHERE id = $$" ) .appendParam( relayID ); } diff --git a/xwords4/relay/dbmgr.h b/xwords4/relay/dbmgr.h index 026d06851..74aa347bc 100644 --- a/xwords4/relay/dbmgr.h +++ b/xwords4/relay/dbmgr.h @@ -101,13 +101,15 @@ class DBMgr { DevIDRelay RegisterDevice( const DevID* host ); DevIDRelay RegisterDevice( const DevID* host, int clientVersion, const char* const desc, const char* const model, - const char* const osVers ); + const char* const osVers, const char* const variant ); void ReregisterDevice( DevIDRelay relayID, const DevID* host, const char* const desc, int clientVersion, - const char* const model, const char* const osVers ); + const char* const model, const char* const osVers, + const char* const variant ); bool UpdateDevice( DevIDRelay relayID, const char* const desc, int clientVersion, const char* const model, - const char* const osVers, bool check ); + const char* const osVers, const char* const variant, + bool check ); HostID AddToGame( const char* const connName, HostID curID, int clientVersion, int nToAdd, unsigned short seed, const AddrInfo* addr, @@ -174,7 +176,8 @@ class DBMgr { bool UpdateDevice( DevIDRelay relayID ); void formatUpdate( QueryBuilder& qb, bool append, const char* const desc, int clientVersion, const char* const model, - const char* const osVers, DevIDRelay relayID ); + const char* const osVers, const char* const variant, + DevIDRelay relayID ); PGconn* getThreadConn( void ); diff --git a/xwords4/relay/xwrelay.cpp b/xwords4/relay/xwrelay.cpp index 6ec028328..556bbe183 100644 --- a/xwords4/relay/xwrelay.cpp +++ b/xwords4/relay/xwrelay.cpp @@ -1598,7 +1598,8 @@ addRegID( uint8_t* ptr, DevIDRelay relayID ) static void registerDevice( const string& relayIDStr, const DevID* devID, const AddrInfo* addr, int clientVers, const string& devDesc, - const string& model, const string& osVers ) + const string& model, const string& osVers, + const string& variant ) { DevIDRelay relayID = DBMgr::DEVID_NONE; DBMgr* dbMgr = DBMgr::Get(); @@ -1610,15 +1611,16 @@ registerDevice( const string& relayIDStr, const DevID* devID, if ( DBMgr::DEVID_NONE == relayID ) { // new device relayID = dbMgr->RegisterDevice( devID, clientVers, devDesc.c_str(), - model.c_str(), osVers.c_str() ); + model.c_str(), osVers.c_str(), variant.c_str() ); } else if ( ID_TYPE_RELAY < devID->m_devIDType ) { // re-registering dbMgr->ReregisterDevice( relayID, devID, devDesc.c_str(), clientVers, - model.c_str(), osVers.c_str() ); + model.c_str(), osVers.c_str(), variant.c_str() ); checkMsgs = true; } else { // No new information; just update the time checkMsgs = dbMgr->UpdateDevice( relayID, devDesc.c_str(), clientVers, - model.c_str(), osVers.c_str(), true ); + model.c_str(), osVers.c_str(), variant.c_str(), + true ); if ( !checkMsgs ) { uint8_t buf[32]; int indx = addRegID( &buf[0], relayID ); @@ -1770,8 +1772,13 @@ handle_udp_packet( PacketThreadClosure* ptc ) if ( 3 >= clientVers ) { checkAllAscii( model, "bad model" ); } + string variant; + if ( getVLIString( &ptr, end, variant ) ) { + logf( XW_LOGINFO, "%s(): got variant %s", __func__, variant.c_str() ); + } + registerDevice( relayID, &devID, ptc->addr(), - clientVers, devDesc, model, osVers ); + clientVers, devDesc, model, osVers, variant ); } } } diff --git a/xwords4/relay/xwrelay.sh b/xwords4/relay/xwrelay.sh index 1665c603f..d5fc99679 100755 --- a/xwords4/relay/xwrelay.sh +++ b/xwords4/relay/xwrelay.sh @@ -87,6 +87,7 @@ id INTEGER UNIQUE PRIMARY KEY ,versDesc TEXT ,model TEXT ,osvers TEXT +,variant TEXT ,ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,mtimes TIMESTAMP[] ,unreg BOOLEAN DEFAULT FALSE