add version consistency check
This commit is contained in:
parent
0218543935
commit
ade47131f9
|
@ -15,8 +15,9 @@ android {
|
||||||
applicationId "io.github.chinosk.gakumas.localify"
|
applicationId "io.github.chinosk.gakumas.localify"
|
||||||
minSdk 29
|
minSdk 29
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 10
|
versionCode 11
|
||||||
versionName "v2.0.2"
|
versionName "v2.1.0"
|
||||||
|
buildConfigField "String", "VERSION_NAME", "\"${versionName}\""
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
|
|
@ -1510,10 +1510,6 @@ namespace GakumasLocal::HookMain {
|
||||||
Local::LoadData();
|
Local::LoadData();
|
||||||
MasterLocal::LoadData();
|
MasterLocal::LoadData();
|
||||||
|
|
||||||
if (Config::lazyInit) {
|
|
||||||
UnityResolveProgress::classProgress.current = 1;
|
|
||||||
// UnityResolveProgress::startInit = false;
|
|
||||||
}
|
|
||||||
UnityResolveProgress::startInit = false;
|
UnityResolveProgress::startInit = false;
|
||||||
|
|
||||||
Log::Info("Plugin init finished.");
|
Log::Info("Plugin init finished.");
|
||||||
|
|
|
@ -107,6 +107,7 @@ fun <T> T.onClickStartGame() where T : Activity, T : IHasConfigItems {
|
||||||
getProgramConfigContent(listOf("transRemoteZipUrl", "useAPIAssetsURL",
|
getProgramConfigContent(listOf("transRemoteZipUrl", "useAPIAssetsURL",
|
||||||
"localAPIAssetsVersion", "p"), programConfig)
|
"localAPIAssetsVersion", "p"), programConfig)
|
||||||
)
|
)
|
||||||
|
putExtra("lVerName", version)
|
||||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,9 @@ class GakumasHookMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
||||||
val gkmsData = intent.getStringExtra("gkmsData")
|
val gkmsData = intent.getStringExtra("gkmsData")
|
||||||
val programData = intent.getStringExtra("localData")
|
val programData = intent.getStringExtra("localData")
|
||||||
if (gkmsData != null) {
|
if (gkmsData != null) {
|
||||||
|
val readVersion = intent.getStringExtra("lVerName")
|
||||||
|
checkPluginVersion(activity, readVersion)
|
||||||
|
|
||||||
gkmsDataInited = true
|
gkmsDataInited = true
|
||||||
val initConfig = try {
|
val initConfig = try {
|
||||||
json.decodeFromString<GakumasConfig>(gkmsData)
|
json.decodeFromString<GakumasConfig>(gkmsData)
|
||||||
|
@ -313,6 +316,40 @@ class GakumasHookMain : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkPluginVersion(activity: Activity, readVersion: String?) {
|
||||||
|
val buildVersionName = BuildConfig.VERSION_NAME
|
||||||
|
Log.i(TAG, "Checking Plugin Version: Build: $buildVersionName, Request: $readVersion")
|
||||||
|
if (readVersion?.trim() == buildVersionName.trim()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(activity)
|
||||||
|
val infoBuilder = AlertDialog.Builder(activity)
|
||||||
|
builder.setTitle("Warning")
|
||||||
|
builder.setCancelable(false)
|
||||||
|
builder.setMessage(when (getCurrentLanguage(activity)) {
|
||||||
|
"zh" -> "检测到插件版本不一致\n内置版本: $buildVersionName\n请求版本: $readVersion\n\n这可能是使用了 LSPatch 的集成模式,仅更新了插件本体,未重新修补游戏导致的。请使用 $readVersion 版本的插件重新修补或使用本地模式。"
|
||||||
|
else -> "Detected plugin version mismatch\nBuilt-in version: $buildVersionName\nRequested version: $readVersion\n\nThis may be caused by using the LSPatch integration mode, where only the plugin itself was updated without re-patching the game. Please re-patch the game using the $readVersion version of the plugin or use the local mode."
|
||||||
|
})
|
||||||
|
|
||||||
|
builder.setPositiveButton("OK") { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.setNegativeButton("Exit") { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
activity.finishAffinity()
|
||||||
|
}
|
||||||
|
|
||||||
|
val dialog = builder.create()
|
||||||
|
|
||||||
|
infoBuilder.setOnCancelListener {
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
private fun showGetConfigFailedImpl(activity: Context, title: String, msg: String, infoButton: String, dlButton: String, okButton: String) {
|
private fun showGetConfigFailedImpl(activity: Context, title: String, msg: String, infoButton: String, dlButton: String, okButton: String) {
|
||||||
if (getConfigError == null) return
|
if (getConfigError == null) return
|
||||||
val builder = AlertDialog.Builder(activity)
|
val builder = AlertDialog.Builder(activity)
|
||||||
|
|
Loading…
Reference in New Issue