mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 20:48:00 +01:00
add debug-only stats submenu, and ability to print stats
They won't persist on Android if I count on dutil shutting down, since there's no such thing. So I save on every change, which is way too often but good enough for now.
This commit is contained in:
parent
35e3487f9d
commit
464e124038
6 changed files with 76 additions and 2 deletions
|
@ -1761,8 +1761,14 @@ class GamesListDelegate(delegator: Delegator) :
|
||||||
|
|
||||||
R.id.games_menu_emailLogs -> Perms23.tryGetPerms(
|
R.id.games_menu_emailLogs -> Perms23.tryGetPerms(
|
||||||
this, Perm.STORAGE, null,
|
this, Perm.STORAGE, null,
|
||||||
DlgDelegate.Action.WRITE_LOG_DB
|
DlgDelegate.Action.WRITE_LOG_DB)
|
||||||
)
|
|
||||||
|
R.id.games_menu_statsShow -> {
|
||||||
|
val stats = XwJNI.sts_export().toString()
|
||||||
|
makeOkOnlyBuilder(stats)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
R.id.games_menu_statsClear -> XwJNI.sts_clearAll()
|
||||||
|
|
||||||
else -> handled = (handleSelGamesItem(itemID, selRowIDs)
|
else -> handled = (handleSelGamesItem(itemID, selRowIDs)
|
||||||
|| handleSelGroupsItem(itemID, selGroupIDs))
|
|| handleSelGroupsItem(itemID, selGroupIDs))
|
||||||
|
@ -2935,6 +2941,7 @@ class GamesListDelegate(delegator: Delegator) :
|
||||||
private val DEBUG_ITEMS = intArrayOf(
|
private val DEBUG_ITEMS = intArrayOf(
|
||||||
R.id.games_menu_writegit,
|
R.id.games_menu_writegit,
|
||||||
R.id.games_submenu_logs,
|
R.id.games_submenu_logs,
|
||||||
|
R.id.games_submenu_stats,
|
||||||
R.id.games_submenu_mqtt,
|
R.id.games_submenu_mqtt,
|
||||||
R.id.games_menu_restart,
|
R.id.games_menu_restart,
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.eehouse.android.xw4.jni
|
package org.eehouse.android.xw4.jni
|
||||||
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
import org.eehouse.android.xw4.Assert
|
import org.eehouse.android.xw4.Assert
|
||||||
import org.eehouse.android.xw4.BuildConfig
|
import org.eehouse.android.xw4.BuildConfig
|
||||||
|
@ -884,6 +885,14 @@ class XwJNI private constructor() {
|
||||||
return smsproto_prepInbound(jNI.m_ptrGlobals, data, fromPhone, wantPort)
|
return smsproto_prepInbound(jNI.m_ptrGlobals, data, fromPhone, wantPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun sts_export(): JSONObject {
|
||||||
|
val str = sts_export(jNI.m_ptrGlobals)
|
||||||
|
return JSONObject(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun sts_clearAll() { sts_clearAll(jNI.m_ptrGlobals) }
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
external fun dict_tilesAreSame(dict1: Long, dict2: Long): Boolean
|
external fun dict_tilesAreSame(dict1: Long, dict2: Long): Boolean
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -1127,6 +1136,11 @@ class XwJNI private constructor() {
|
||||||
wantPort: Int
|
wantPort: Int
|
||||||
): Array<SMSProtoMsg>?
|
): Array<SMSProtoMsg>?
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
private external fun sts_export(jniState: Long): String?
|
||||||
|
@JvmStatic
|
||||||
|
private external fun sts_clearAll(jniState: Long)
|
||||||
|
|
||||||
// This always returns true on release builds now.
|
// This always returns true on release builds now.
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
private external fun haveEnv(jniState: Long): Boolean
|
private external fun haveEnv(jniState: Long): Boolean
|
||||||
|
|
|
@ -158,6 +158,20 @@
|
||||||
</menu>
|
</menu>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item android:id="@+id/games_submenu_stats"
|
||||||
|
android:title="@string/gamel_menu_stats"
|
||||||
|
>
|
||||||
|
<menu>
|
||||||
|
<item android:id="@+id/games_menu_statsShow"
|
||||||
|
android:title="@string/gamel_menu_statsShow"
|
||||||
|
/>
|
||||||
|
<item android:id="@+id/games_menu_statsClear"
|
||||||
|
android:title="@string/gamel_menu_statsClear"
|
||||||
|
/>
|
||||||
|
</menu>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
|
||||||
<item android:id="@+id/games_submenu_backup"
|
<item android:id="@+id/games_submenu_backup"
|
||||||
android:title="@string/gamel_menu_backup"
|
android:title="@string/gamel_menu_backup"
|
||||||
>
|
>
|
||||||
|
|
|
@ -40,4 +40,9 @@
|
||||||
someone. </string>
|
someone. </string>
|
||||||
|
|
||||||
<string name="have_mtqq_games_fmt">I have %1$d games using mqtt.</string>
|
<string name="have_mtqq_games_fmt">I have %1$d games using mqtt.</string>
|
||||||
|
|
||||||
|
<string name="gamel_menu_stats">Stats</string>
|
||||||
|
<string name="gamel_menu_statsShow">Show</string>
|
||||||
|
<string name="gamel_menu_statsClear">Clear</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -46,6 +46,9 @@
|
||||||
#include "andglobals.h"
|
#include "andglobals.h"
|
||||||
#include "jniutlswrapper.h"
|
#include "jniutlswrapper.h"
|
||||||
#include "paths.h"
|
#include "paths.h"
|
||||||
|
#include "stats.h"
|
||||||
|
|
||||||
|
#include "cJSON.h"
|
||||||
|
|
||||||
#ifdef MAP_THREAD_TO_ENV
|
#ifdef MAP_THREAD_TO_ENV
|
||||||
# define LOG_MAPPING
|
# define LOG_MAPPING
|
||||||
|
@ -1218,6 +1221,34 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1getDesc
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_eehouse_android_xw4_jni_XwJNI_sts_1export
|
||||||
|
( JNIEnv* env, jclass C, jlong jniGlobalPtr )
|
||||||
|
{
|
||||||
|
jstring result = NULL;
|
||||||
|
DVC_HEADER(jniGlobalPtr);
|
||||||
|
cJSON* stats = sts_export( globalState->dutil, env );
|
||||||
|
|
||||||
|
char* replyStr = cJSON_PrintUnformatted( stats );
|
||||||
|
result = (*env)->NewStringUTF( env, replyStr );
|
||||||
|
free( replyStr );
|
||||||
|
cJSON_Delete( stats );
|
||||||
|
|
||||||
|
DVC_HEADER_END();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_eehouse_android_xw4_jni_XwJNI_sts_1clearAll
|
||||||
|
( JNIEnv* env, jclass C, jlong jniGlobalPtr )
|
||||||
|
{
|
||||||
|
jstring result = NULL;
|
||||||
|
DVC_HEADER(jniGlobalPtr);
|
||||||
|
sts_clearAll( globalState->dutil, env );
|
||||||
|
DVC_HEADER_END();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* Dictionary methods: don't use gamePtr */
|
/* Dictionary methods: don't use gamePtr */
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_dict_1tilesAreSame
|
Java_org_eehouse_android_xw4_jni_XwJNI_dict_1tilesAreSame
|
||||||
|
|
|
@ -62,6 +62,9 @@ sts_increment( XW_DUtilCtxt* dutil, XWEnv xwe, STAT stat )
|
||||||
}
|
}
|
||||||
++ss->statsVals[stat];
|
++ss->statsVals[stat];
|
||||||
END_WITH_MUTEX();
|
END_WITH_MUTEX();
|
||||||
|
|
||||||
|
XP_LOGFF( "bad: storing after every change" );
|
||||||
|
storeCounts( dutil, xwe );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue