mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 21:59:11 +00:00
copy user-supplied library to final file instead of renaming
apparently fixes #1251
This commit is contained in:
parent
e9a2a7ebb1
commit
bf713d6967
3 changed files with 6 additions and 7 deletions
|
@ -9,7 +9,6 @@ import helium314.keyboard.keyboard.KeyboardTheme
|
|||
import helium314.keyboard.latin.BuildConfig
|
||||
import helium314.keyboard.latin.common.Constants.Separators
|
||||
import helium314.keyboard.latin.common.Constants.Subtype.ExtraValue
|
||||
import helium314.keyboard.latin.utils.JniUtils
|
||||
import helium314.keyboard.latin.utils.LayoutType
|
||||
import helium314.keyboard.latin.utils.POPUP_KEYS_LABEL_DEFAULT
|
||||
import helium314.keyboard.latin.utils.POPUP_KEYS_ORDER_DEFAULT
|
||||
|
@ -152,8 +151,6 @@ object Defaults {
|
|||
const val PREF_EMOJI_RECENT_KEYS = ""
|
||||
const val PREF_LAST_SHOWN_EMOJI_CATEGORY_PAGE_ID = 0
|
||||
const val PREF_PINNED_CLIPS = ""
|
||||
@JvmField
|
||||
val PREF_LIBRARY_CHECKSUM: String = JniUtils.expectedDefaultChecksum()
|
||||
const val PREF_SHOW_DEBUG_SETTINGS = false
|
||||
val PREF_DEBUG_MODE = BuildConfig.DEBUG
|
||||
const val PREF_SHOW_SUGGESTION_INFOS = false
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.text.TextUtils;
|
|||
|
||||
import helium314.keyboard.latin.App;
|
||||
import helium314.keyboard.latin.BuildConfig;
|
||||
import helium314.keyboard.latin.settings.Defaults;
|
||||
import helium314.keyboard.latin.settings.Settings;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -63,7 +62,7 @@ public final class JniUtils {
|
|||
// we want the default preferences, because storing the checksum in device protected storage is discouraged
|
||||
// see https://developer.android.com/reference/android/content/Context#createDeviceProtectedStorageContext()
|
||||
// if device is locked, this will throw an IllegalStateException
|
||||
wantedChecksum = KtxKt.protectedPrefs(app).getString(Settings.PREF_LIBRARY_CHECKSUM, Defaults.PREF_LIBRARY_CHECKSUM);
|
||||
wantedChecksum = KtxKt.protectedPrefs(app).getString(Settings.PREF_LIBRARY_CHECKSUM, expectedDefaultChecksum());
|
||||
}
|
||||
final FileInputStream libStream = new FileInputStream(userSuppliedLibrary);
|
||||
final String checksum = ChecksumCalculator.INSTANCE.checksum(libStream);
|
||||
|
|
|
@ -35,10 +35,13 @@ fun LoadGestureLibPreference(setting: Setting) {
|
|||
val abi = Build.SUPPORTED_ABIS[0]
|
||||
val libFile = File(ctx.filesDir?.absolutePath + File.separator + JniUtils.JNI_LIB_IMPORT_FILE_NAME)
|
||||
fun renameToLibFileAndRestart(file: File, checksum: String) {
|
||||
libFile.setWritable(true)
|
||||
libFile.delete()
|
||||
// store checksum in default preferences (soo JniUtils)
|
||||
// store checksum in default preferences (see JniUtils)
|
||||
prefs.edit().putString(Settings.PREF_LIBRARY_CHECKSUM, checksum).commit()
|
||||
file.renameTo(libFile)
|
||||
file.copyTo(libFile)
|
||||
libFile.setReadOnly()
|
||||
file.delete()
|
||||
Runtime.getRuntime().exit(0) // exit will restart the app, so library will be loaded
|
||||
}
|
||||
var tempFilePath: String? by rememberSaveable { mutableStateOf(null) }
|
||||
|
|
Loading…
Add table
Reference in a new issue