mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 20:48:00 +01:00
includ NBS sends/receives in stats on Android
This commit is contained in:
parent
e492d8f7b5
commit
df84bf6145
8 changed files with 29 additions and 22 deletions
|
@ -36,6 +36,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType
|
||||||
import org.eehouse.android.xw4.jni.XwJNI
|
import org.eehouse.android.xw4.jni.XwJNI
|
||||||
import org.eehouse.android.xw4.jni.XwJNI.SMSProtoMsg
|
import org.eehouse.android.xw4.jni.XwJNI.SMSProtoMsg
|
||||||
import org.eehouse.android.xw4.jni.XwJNI.SMS_CMD
|
import org.eehouse.android.xw4.jni.XwJNI.SMS_CMD
|
||||||
|
import org.eehouse.android.xw4.jni.XwJNI.STAT
|
||||||
import org.eehouse.android.xw4.loc.LocUtils
|
import org.eehouse.android.xw4.loc.LocUtils
|
||||||
|
|
||||||
object NBSProto {
|
object NBSProto {
|
||||||
|
@ -65,6 +66,7 @@ object NBSProto {
|
||||||
context, CommsConnType.COMMS_CONN_SMS,
|
context, CommsConnType.COMMS_CONN_SMS,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
XwJNI.sts_increment(STAT.STAT_NBS_RCVD);
|
||||||
}
|
}
|
||||||
|
|
||||||
fun inviteRemote(
|
fun inviteRemote(
|
||||||
|
@ -358,13 +360,13 @@ object NBSProto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendBuffers(fragments: Array<ByteArray>, phone: String, port: Short) {
|
private fun sendBuffers(fragments: Array<ByteArray>, phone: String,
|
||||||
|
port: Short) {
|
||||||
val context = XWApp.getContext()
|
val context = XWApp.getContext()
|
||||||
var success = false
|
var success = false
|
||||||
if (XWPrefs.getNBSEnabled(context) && Perms23.haveNBSPerms(context)
|
if (XWPrefs.getNBSEnabled(context) && Perms23.haveNBSPerms(context)
|
||||||
) {
|
) {
|
||||||
// Try send-to-self
|
// Try send-to-self
|
||||||
|
|
||||||
if (XWPrefs.getSMSToSelfEnabled(context)) {
|
if (XWPrefs.getSMSToSelfEnabled(context)) {
|
||||||
val myPhone = SMSPhoneInfo.get(context)!!.number
|
val myPhone = SMSPhoneInfo.get(context)!!.number
|
||||||
if (null != myPhone
|
if (null != myPhone
|
||||||
|
@ -388,6 +390,7 @@ object NBSProto {
|
||||||
sent, delivery
|
sent, delivery
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
XwJNI.sts_increment(STAT.STAT_NBS_SENT);
|
||||||
success = true
|
success = true
|
||||||
} catch (iae: IllegalArgumentException) {
|
} catch (iae: IllegalArgumentException) {
|
||||||
Log.w(TAG, "sendBuffers(%s): %s", phone, iae.toString())
|
Log.w(TAG, "sendBuffers(%s): %s", phone, iae.toString())
|
||||||
|
|
|
@ -214,8 +214,8 @@ class XwJNI private constructor() {
|
||||||
STAT_NEW_FOUR,
|
STAT_NEW_FOUR,
|
||||||
STAT_NEW_REMATCH,
|
STAT_NEW_REMATCH,
|
||||||
|
|
||||||
STAT_SMS_RCVD,
|
STAT_NBS_RCVD,
|
||||||
STAT_SMS_SENT,
|
STAT_NBS_SENT,
|
||||||
|
|
||||||
STAT_NSTATS,
|
STAT_NSTATS,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 by Eric House (xwords@eehouse.org). All rights reserved.
|
* Copyright 2024 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -140,8 +140,8 @@ STATtoStr(STAT stat)
|
||||||
CASESTR(STAT_NEW_THREE);
|
CASESTR(STAT_NEW_THREE);
|
||||||
CASESTR(STAT_NEW_FOUR);
|
CASESTR(STAT_NEW_FOUR);
|
||||||
CASESTR(STAT_NEW_REMATCH);
|
CASESTR(STAT_NEW_REMATCH);
|
||||||
CASESTR(STAT_SMS_SENT);
|
CASESTR(STAT_NBS_SENT);
|
||||||
CASESTR(STAT_SMS_RCVD);
|
CASESTR(STAT_NBS_RCVD);
|
||||||
default:
|
default:
|
||||||
XP_ASSERT(0);
|
XP_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -190,14 +190,9 @@ loadCountsLocked( XW_DUtilCtxt* dutil, XWEnv xwe )
|
||||||
|
|
||||||
XP_U8 version;
|
XP_U8 version;
|
||||||
if ( stream_gotU8( stream, &version ) ) {
|
if ( stream_gotU8( stream, &version ) ) {
|
||||||
XP_U32 startTime = 0;
|
|
||||||
if ( VERSION_1 <= version ) {
|
if ( VERSION_1 <= version ) {
|
||||||
startTime = stream_getU32(stream);
|
ss->startTime = stream_getU32(stream);
|
||||||
} else {
|
|
||||||
startTime = dutil_getCurSeconds( dutil, xwe );
|
|
||||||
setStoreTimerLocked( dutil, xwe ); /* something to save */
|
|
||||||
}
|
}
|
||||||
ss->startTime = startTime;
|
|
||||||
|
|
||||||
XP_U8 stat;
|
XP_U8 stat;
|
||||||
while ( stream_gotU8( stream, &stat ) ) {
|
while ( stream_gotU8( stream, &stat ) ) {
|
||||||
|
@ -206,6 +201,11 @@ loadCountsLocked( XW_DUtilCtxt* dutil, XWEnv xwe )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream_destroy( stream );
|
stream_destroy( stream );
|
||||||
|
|
||||||
|
if ( 0 == ss->startTime ) {
|
||||||
|
ss->startTime = dutil_getCurSeconds( dutil, xwe );
|
||||||
|
setStoreTimerLocked( dutil, xwe ); /* something to save */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DUTIL_TIMERS
|
#ifdef DUTIL_TIMERS
|
||||||
|
|
|
@ -38,8 +38,8 @@ typedef enum {
|
||||||
STAT_NEW_FOUR,
|
STAT_NEW_FOUR,
|
||||||
STAT_NEW_REMATCH,
|
STAT_NEW_REMATCH,
|
||||||
|
|
||||||
STAT_SMS_RCVD,
|
STAT_NBS_RCVD,
|
||||||
STAT_SMS_SENT,
|
STAT_NBS_SENT,
|
||||||
|
|
||||||
STAT_NSTATS,
|
STAT_NSTATS,
|
||||||
} STAT;
|
} STAT;
|
||||||
|
|
|
@ -125,7 +125,7 @@ mtx_unlock_prv( MutexState* state, XP_U16 XP_UNUSED(waitSecs),
|
||||||
void
|
void
|
||||||
mtx_init_prv( MutexState* mutex, XP_Bool recursive
|
mtx_init_prv( MutexState* mutex, XP_Bool recursive
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
, XP_U16 waitSecs
|
, XP_U16 waitSecs, const char* caller
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -150,7 +150,7 @@ mtx_init_prv( MutexState* mutex, XP_Bool recursive
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
mutex->waitSecs = waitSecs;
|
mutex->waitSecs = waitSecs;
|
||||||
XP_LOGFF( "set waitSecs: %d", mutex->waitSecs );
|
XP_LOGFF( "set waitSecs: %d (called by %s())", mutex->waitSecs, caller );
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_init( &mutex->mutex, &attr );
|
pthread_mutex_init( &mutex->mutex, &attr );
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -46,7 +46,7 @@ void mtx_unlock_prv(MutexState* state, XP_U16 waitSecs, const char* caller);
|
||||||
|
|
||||||
void mtx_init_prv( MutexState* mutex, XP_Bool recursive
|
void mtx_init_prv( MutexState* mutex, XP_Bool recursive
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
, XP_U16 waitSecs
|
, XP_U16 waitSecs, const char* caller
|
||||||
# endif
|
# endif
|
||||||
);
|
);
|
||||||
void mtx_destroy_prv( MutexState* mutex );
|
void mtx_destroy_prv( MutexState* mutex );
|
||||||
|
@ -54,7 +54,8 @@ void mtx_destroy_prv( MutexState* mutex );
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void mtx_crashToTest();
|
void mtx_crashToTest();
|
||||||
|
|
||||||
# define MUTEX_INIT_CHECKED(STATE, RECURSIVE, WS) mtx_init_prv((STATE), (RECURSIVE), (WS))
|
# define MUTEX_INIT_CHECKED(STATE, RECURSIVE, WS) \
|
||||||
|
mtx_init_prv((STATE), (RECURSIVE), (WS), __func__)
|
||||||
# define MUTEX_INIT(STATE, RECURSIVE) MUTEX_INIT_CHECKED(STATE, RECURSIVE, 0)
|
# define MUTEX_INIT(STATE, RECURSIVE) MUTEX_INIT_CHECKED(STATE, RECURSIVE, 0)
|
||||||
#else
|
#else
|
||||||
# define mtx_crashToTest()
|
# define mtx_crashToTest()
|
||||||
|
|
|
@ -248,6 +248,9 @@ parseAndDispatch( LaunchParams* params, uint8_t* buf, int len,
|
||||||
SMSMsgArray* arr =
|
SMSMsgArray* arr =
|
||||||
smsproto_prepInbound( storage->protoState, NULL_XWE, fromPhone,
|
smsproto_prepInbound( storage->protoState, NULL_XWE, fromPhone,
|
||||||
storage->myPort, buf, len );
|
storage->myPort, buf, len );
|
||||||
|
|
||||||
|
sts_increment( params->dutil, NULL_XWE, STAT_NBS_RCVD );
|
||||||
|
|
||||||
if ( NULL != arr ) {
|
if ( NULL != arr ) {
|
||||||
XP_ASSERT( arr->format == FORMAT_LOC );
|
XP_ASSERT( arr->format == FORMAT_LOC );
|
||||||
for ( XP_U16 ii = 0; ii < arr->nMsgs; ++ii ) {
|
for ( XP_U16 ii = 0; ii < arr->nMsgs; ++ii ) {
|
||||||
|
@ -257,7 +260,6 @@ parseAndDispatch( LaunchParams* params, uint8_t* buf, int len,
|
||||||
(*storage->procs->msgReceived)( storage->procClosure, addr,
|
(*storage->procs->msgReceived)( storage->procClosure, addr,
|
||||||
msg->gameID,
|
msg->gameID,
|
||||||
msg->data, msg->len );
|
msg->data, msg->len );
|
||||||
sts_increment( params->dutil, NULL_XWE, STAT_SMS_RCVD );
|
|
||||||
break;
|
break;
|
||||||
case INVITE: {
|
case INVITE: {
|
||||||
NetLaunchInfo nli = {};
|
NetLaunchInfo nli = {};
|
||||||
|
@ -288,6 +290,7 @@ linux_sms_init( LaunchParams* params, const gchar* myPhone, XP_U16 myPort,
|
||||||
storage->procs = procs;
|
storage->procs = procs;
|
||||||
storage->procClosure = procClosure;
|
storage->procClosure = procClosure;
|
||||||
storage->protoState = smsproto_init( MPPARM(params->mpool) NULL_XWE, params->dutil );
|
storage->protoState = smsproto_init( MPPARM(params->mpool) NULL_XWE, params->dutil );
|
||||||
|
XP_ASSERT( !!storage->protoState );
|
||||||
|
|
||||||
formatQueuePath( myPhone, myPort, storage->myQueue, sizeof(storage->myQueue) );
|
formatQueuePath( myPhone, myPort, storage->myQueue, sizeof(storage->myQueue) );
|
||||||
XP_LOGFF( " my queue: %s", storage->myQueue );
|
XP_LOGFF( " my queue: %s", storage->myQueue );
|
||||||
|
@ -385,7 +388,7 @@ sendOrRetry( LaunchParams* params, SMSMsgArray* arr, SMS_CMD cmd,
|
||||||
// doSend( params, msg->data, msg->len, phone, port, gameID );
|
// doSend( params, msg->data, msg->len, phone, port, gameID );
|
||||||
(void)write_fake_sms( params, msg->data, msg->len, msgNo,
|
(void)write_fake_sms( params, msg->data, msg->len, msgNo,
|
||||||
phone, port );
|
phone, port );
|
||||||
sts_increment( params->dutil, NULL_XWE, STAT_SMS_SENT );
|
sts_increment( params->dutil, NULL_XWE, STAT_NBS_SENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
LinSMSData* storage = getStorage( params );
|
LinSMSData* storage = getStorage( params );
|
||||||
|
|
|
@ -607,7 +607,7 @@ class Device():
|
||||||
assert not self.endTime
|
assert not self.endTime
|
||||||
|
|
||||||
def _addStats(self, stats):
|
def _addStats(self, stats):
|
||||||
stats = stats.get('stats')
|
stats = stats.get('stats').get('stats')
|
||||||
if stats and self._stats:
|
if stats and self._stats:
|
||||||
for key in stats.keys():
|
for key in stats.keys():
|
||||||
if key in self._stats:
|
if key in self._stats:
|
||||||
|
|
Loading…
Add table
Reference in a new issue