diff --git a/java/src/org/futo/inputmethod/latin/xlm/AdapterTrainer.kt b/java/src/org/futo/inputmethod/latin/xlm/AdapterTrainer.kt index bf67e645c..717dc97bc 100644 --- a/java/src/org/futo/inputmethod/latin/xlm/AdapterTrainer.kt +++ b/java/src/org/futo/inputmethod/latin/xlm/AdapterTrainer.kt @@ -1,12 +1,10 @@ package org.futo.inputmethod.latin.xlm import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.newSingleThreadContext import kotlinx.coroutines.withContext +import org.futo.inputmethod.annotations.ExternallyReferenced @OptIn(DelicateCoroutinesApi::class) val TrainingContext = newSingleThreadContext("AdapterTrainingContext") @@ -31,10 +29,12 @@ class AdapterTrainer( private var handle: Long = 0L private fun isHandleValid() = handle != 0L + @ExternallyReferenced private fun emitProgress(progress: Float) { progressFlow?.tryEmit(progress) } + @ExternallyReferenced private fun emitLoss(loss: Float) { lossFlow?.tryEmit(loss) } diff --git a/proguard-rules.pro b/proguard-rules.pro index 760eeecfb..b3c786c87 100644 --- a/proguard-rules.pro +++ b/proguard-rules.pro @@ -27,6 +27,30 @@ -keepclasseswithmembers class * { native ; } +# Keep classes and methods that have the @UsedForTesting annotation +-keep @org.futo.inputmethod.annotations.UsedForTesting class * +-keepclassmembers class * { + @org.futo.inputmethod.annotations.UsedForTesting *; +} + +# Keep classes and methods that have the @ExternallyReferenced annotation +-keep @org.futo.inputmethod.annotations.ExternallyReferenced class * +-keepclassmembers class * { + @org.futo.inputmethod.annotations.ExternallyReferenced *; +} + +# Keep native methods +-keepclassmembers class * { + native ; +} + +# Keep classes that are used as a parameter type of methods that are also marked as keep +# to preserve changing those methods' signature. +-keep class org.futo.inputmethod.latin.AssetFileAddress +-keep class org.futo.inputmethod.latin.Dictionary +-keep class org.futo.inputmethod.latin.NgramContext +-keep class org.futo.inputmethod.latin.makedict.ProbabilityInfo +-keep class org.futo.inputmethod.keyboard.KeyboardLayout { *; } -dontobfuscate -optimizations !code/allocation/variable \ No newline at end of file