代码表更新,签名检查修复

This commit is contained in:
coldmint 2022-04-06 21:15:07 +08:00
parent fd631149ef
commit 135b46db24
13 changed files with 33 additions and 44 deletions

View File

@ -1,36 +0,0 @@
# 铁锈助手
#### Description
铁锈助手私有存储库
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -30,8 +30,8 @@ android {
applicationId "com.coldmint.rust.pro"
minSdkVersion 21
targetSdkVersion 32
versionCode 13
versionName "2.0 Release 7(2022-4-5)"
versionCode 14
versionName "2.0 Release 7(2022-4-6)"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -15,6 +15,7 @@ import com.google.android.material.snackbar.Snackbar
import android.widget.Toast
import android.net.Uri
import android.os.*
import android.util.Log
import android.view.*
import android.widget.PopupMenu
import android.widget.SearchView
@ -150,6 +151,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
val executorService = Executors.newSingleThreadExecutor()
executorService.submit {
//检查更新
val key = "应用更新"
val packageInfo: PackageInfo = packageManager.getPackageInfo(packageName, 0)
val checkBetaUpdate =
appSettings.getValue(AppSettings.Setting.CheckBetaUpdate, false)
@ -160,16 +162,25 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
//版本名不一致是Beta模式
if (packageInfo.versionName != data.versionName) {
needShowDialog = true
Log.d(key, "是测试模式,版本名称不一致")
} else {
Log.d(key, "是测试模式并且是Beta版本")
}
} else if (checkBetaUpdate) {
//版本名不一致
if (packageInfo.versionName != data.versionName) {
needShowDialog = true
Log.d(key, "开启了检查Beta版本,版本名称不一致")
} else {
Log.d(key, "开启了检查Beta版本,无需更新")
}
} else {
//版本号不一致
if (packageInfo.versionCode != data.versionNumber) {
needShowDialog = true
Log.d(key, "正式打包模式,版本号不一致")
} else {
Log.d(key, "正式打包模式,版本号一致无需更新")
}
}
@ -246,7 +257,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
recreate()
return
}
startViewModel.verifyingUserInfo()
val error = startViewModel.signatureErrorLiveData.value ?: true
if (!error) {
startViewModel.verifyingUserInfo()
}
}
}

View File

@ -299,18 +299,27 @@ class StartViewModel(application: Application) : BaseAndroidViewModel(applicatio
* 检查签名是否有错误
*/
private fun checkSignature(): Boolean {
val key = "签名检查"
val sign = AppOperator.getSignature(context)
if (BuildConfig.DEBUG) {
//是测试模式
if (GlobalMethod.DEBUG_SIGN != sign) {
Log.e(key, "测试打包,签名检查错误" + sign + "不是合法的签名。")
signatureErrorLiveData.value = true
} else {
Log.d(key, "测试打包,签名合法。")
signatureErrorLiveData.value = false
}
} else {
if (GlobalMethod.RELEASE_SIGN != sign) {
signatureErrorLiveData.value = true
Log.e(key, "正式打包,签名检查错误" + sign + "不是合法的签名。")
} else {
Log.d(key, "正式打包,签名合法。")
signatureErrorLiveData.value = false
}
}
signatureErrorLiveData.value = false
return signatureErrorLiveData.value ?: false
return signatureErrorLiveData.value ?: true
}
/**

View File

@ -812,6 +812,7 @@
<string name="select_the_image_in_the_album">在相册选择图像</string>
<string name="turret_design">炮塔设计</string>
<string name="experience_the_plan">用户体验计划</string>
<string name="experience_the_plan_describe">匿名发送软件奔溃信息。</string>
<string name="experience_the_plan_describe">匿名发送软件奔溃信息(暂不可用)</string>
<string name="update_and_iteration">版本更新与用户体验计划</string>
<string name="setting_experience_the_plan">experiencePlan</string>
</resources>

View File

@ -206,8 +206,9 @@
app:title="@string/check_beta_update" />
<SwitchPreference
android:defaultValue="true"
android:key="plan"
android:enabled="false"
android:defaultValue="false"
android:key="@string/setting_experience_the_plan"
app:summary="@string/experience_the_plan_describe"
app:title="@string/experience_the_plan" />