Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set TCP as default mode, do not save too often #17

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/main/kotlin/com/zoffcc/applications/trifa/HelperGeneric.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@ package com.zoffcc.applications.trifa

import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.loadImageBitmap
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.loadImageBitmap
import androidx.compose.ui.res.loadSvgPainter
import androidx.compose.ui.res.loadXmlImageVector
import androidx.compose.ui.unit.Density
import com.zoffcc.applications.trifa.MainActivity.Companion.update_savedata_file
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.xml.sax.InputSource
import java.io.BufferedInputStream
import java.io.File
import java.io.IOException
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import kotlin.reflect.KFunction1

object HelperGeneric {
private const val TAG = "trifa.Hlp.Generic"
Expand Down Expand Up @@ -90,14 +88,23 @@ object HelperGeneric {
}

fun update_savedata_file_wrapper() {
var callerMethodName = ""
try {
val stacktrace = Thread.currentThread().stackTrace
val e = stacktrace[2]
callerMethodName = " called from:" + e.methodName
} catch (e: Exception) {
e.printStackTrace()
}

try {
MainActivity.semaphore_tox_savedata!!.acquire()
val password_hash_2 = MainActivity.password_hash
val start_timestamp = System.currentTimeMillis()
update_savedata_file(password_hash_2)
val end_timestamp = System.currentTimeMillis()
MainActivity.semaphore_tox_savedata!!.release()
Log.i(TAG, "update_savedata_file() took:" + (end_timestamp - start_timestamp).toFloat() / 1000f + "s")
Log.i(TAG, "update_savedata_file()" + callerMethodName + " took:" + (end_timestamp - start_timestamp).toFloat() / 1000f + "s")
} catch (e: InterruptedException) {
MainActivity.semaphore_tox_savedata!!.release()
e.printStackTrace()
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MainActivity
var native_lib_loaded = false
var tox_service_fg: TrifaToxService? = null
var tox_savefile_directory = "."
var PREF__udp_enabled = 1
var PREF__udp_enabled = 0
var PREF__orbot_enabled_to_int = 0
var PREF__local_discovery_enabled = 1
var PREF__ipv6_enabled = 1
Expand Down Expand Up @@ -1196,7 +1196,7 @@ class MainActivity
@JvmStatic
fun android_tox_callback_group_moderation_cb_method(group_number: Long, source_peer_id: Long, target_peer_id: Long, a_Tox_Group_Mod_Event: Int)
{
update_savedata_file_wrapper()
// ** this happens non stop, so don't save here ** // update_savedata_file_wrapper()
}

@JvmStatic
Expand Down
Loading