增加防篡改控制
This commit is contained in:
@@ -502,7 +502,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
||||
} else {
|
||||
tip.length * (1000L / 10)
|
||||
}
|
||||
if (showTime < 1000) showTime = 1500
|
||||
if (showTime < 2000) showTime = 2000
|
||||
if (showTime > 8000) showTime = 8000
|
||||
mViewBinding.root.postDelayed({
|
||||
if (!isFinishing) {
|
||||
@@ -920,7 +920,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
||||
mTranslateView = translateView
|
||||
val r = Rect()
|
||||
translateView.getWindowVisibleDisplayFrame(r)
|
||||
val heightDiff = translateView.getRootView().height - (r.bottom - r.top)
|
||||
val heightDiff = translateView.rootView.height - (r.bottom - r.top)
|
||||
if (heightDiff > 200) { // 如果高度差大于200,说明键盘是弹出的
|
||||
// 进行布局调整
|
||||
if (!isKeyboardTranslate) {
|
||||
|
||||
@@ -95,6 +95,17 @@ interface INetworkService {
|
||||
// @Url 一定要传入以“/”结尾注解会替换 baseUrl,每次调用可传入完整 URL
|
||||
suspend fun blePassThrough(@Url url: String, @Body body: RequestBody): Response<ResponseBody>
|
||||
|
||||
/**
|
||||
* 检查apk包状态
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("user/fetchPackageCheckStatus")
|
||||
suspend fun checkPackageStatus(
|
||||
@Field("packageName") packageName: String,
|
||||
@Field("signSha256") signSha256: String,
|
||||
@Field("nonce") nonce: String
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
* 获取国家代码号
|
||||
*/
|
||||
|
||||
@@ -834,6 +834,14 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
*/
|
||||
suspend fun blePassThrough(url: String, body: RequestBody) = service.blePassThrough(url, body)
|
||||
|
||||
/**
|
||||
* 检查apk包状态
|
||||
*/
|
||||
suspend fun checkPackageStatus(packageName: String, signSha256: String, nonce: String) =
|
||||
getResult {
|
||||
service.checkPackageStatus(packageName, signSha256, nonce)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消自动续费/自动订阅
|
||||
*/
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.abbidot.tracker.ui.fragment.pet.PetV2Fragment
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.AppSetViewModel
|
||||
import com.abbidot.tracker.vm.ConnectionDeviceViewModel
|
||||
import com.abbidot.tracker.vm.CountDownTimerViewModel
|
||||
import com.abbidot.tracker.vm.DataViewModel
|
||||
@@ -75,6 +76,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
private val mAutomaticConnectionDeviceViewModel: ConnectionDeviceViewModel by viewModels()
|
||||
private val mLogBleReportViewModel: LogBleReportViewModel by viewModels()
|
||||
private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels()
|
||||
private val mAppSetViewModel: AppSetViewModel by viewModels()
|
||||
|
||||
// private val mSocketSendMessageViewModel: SocketSendMessageViewModel by viewModels()
|
||||
private val mFamilyViewModel: FamilyViewModel by viewModels()
|
||||
@@ -180,6 +182,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
} else {
|
||||
//清除首次绑定设备信息
|
||||
MMKVUtil.putString(MMKVKey.FirstDeviceMac, "")
|
||||
//监听网络变化
|
||||
val connectivityManager = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val networkCallback: ConnectivityManager.NetworkCallback =
|
||||
object : ConnectivityManager.NetworkCallback() {
|
||||
@@ -187,7 +190,10 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
// 当网络可用时调用
|
||||
super.onAvailable(network)
|
||||
LogUtil.e("当网络可用时,onAvailable")
|
||||
if (mNetworkRequestsFailRetryCount == mNetworkRequestsFailMaxCount && mPetList.isEmpty()) {
|
||||
//首次启动APP,没有网络去检验APP合法性,就在网络可用时去检验
|
||||
if (MMKVUtil.getInt(MMKVKey.isCheckLegalApp) == ConstantInt.Type2) {
|
||||
mAppSetViewModel.checkPackageStatus(applicationContext)
|
||||
} else if (mNetworkRequestsFailRetryCount == mNetworkRequestsFailMaxCount && mPetList.isEmpty()) {
|
||||
mNetworkRequestsFailRetryCount = 0
|
||||
isFirst = false
|
||||
mDataViewModel.getHomeBindPetList(this@HomeV2Activity)
|
||||
@@ -295,6 +301,22 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
}
|
||||
}
|
||||
}
|
||||
mAppSetViewModel.mCheckPackageStatusLiveData.observe(this) {
|
||||
if (null == it) {
|
||||
showToast(R.string.txt_no_legal_app, true)
|
||||
} else {
|
||||
if (null == it.getOrNull()) {
|
||||
showToast(R.string.txt_no_legal_app, true, Gravity.CENTER)
|
||||
} else {
|
||||
MMKVUtil.putInt(MMKVKey.isCheckLegalApp, ConstantInt.Type1)
|
||||
if (mNetworkRequestsFailRetryCount == mNetworkRequestsFailMaxCount && mPetList.isEmpty()) {
|
||||
mNetworkRequestsFailRetryCount = 0
|
||||
isFirst = false
|
||||
mDataViewModel.getHomeBindPetList(this@HomeV2Activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//退出登录
|
||||
XEventBus.observe(this, EventName.LogOut) {
|
||||
finish()
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.baselibrary.util.Utils
|
||||
import com.abbidot.baselibrary.util.rsa.Base64
|
||||
import com.abbidot.tracker.R
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.KeyNames
|
||||
import com.abbidot.tracker.databinding.ActivitySplashBinding
|
||||
import com.abbidot.tracker.dialog.PrivacyPolicyDialog
|
||||
@@ -31,10 +32,12 @@ import com.abbidot.tracker.retrofit2.INetworkService
|
||||
import com.abbidot.tracker.util.ThirdPartyUtil
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.AppSetViewModel
|
||||
import com.abbidot.tracker.vm.CountDownTimerViewModel
|
||||
import com.baidu.location.LocationClient
|
||||
import com.baidu.mapapi.CoordType
|
||||
import com.baidu.mapapi.SDKInitializer
|
||||
import com.baidu.platform.comapi.util.NetworkUtil
|
||||
import com.hjq.toast.Toaster
|
||||
import com.qmuiteam.qmui.arch.QMUIActivity
|
||||
import com.stripe.android.PaymentConfiguration
|
||||
@@ -57,6 +60,7 @@ class SplashActivity : QMUIActivity() {
|
||||
private lateinit var mViewBinding: ActivitySplashBinding
|
||||
|
||||
private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels()
|
||||
private val mAppSetViewModel: AppSetViewModel by viewModels()
|
||||
|
||||
// IWXAPI 是第三方 app 和微信通信的 openApi 接口
|
||||
private lateinit var mApi: IWXAPI
|
||||
@@ -114,6 +118,36 @@ class SplashActivity : QMUIActivity() {
|
||||
mViewBinding.ivSplashDebug.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
if (NetworkUtil.isNetworkAvailable(mContext)) {
|
||||
mAppSetViewModel.apply {
|
||||
mCheckPackageStatusLiveData.observe(this@SplashActivity) {
|
||||
if (null == it) {
|
||||
showToastAndFinish()
|
||||
} else {
|
||||
if (null == it.getOrNull()) {
|
||||
showToastAndFinish()
|
||||
} else {
|
||||
MMKVUtil.putInt(MMKVKey.isCheckLegalApp, ConstantInt.Type1)
|
||||
legalApp()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mAppSetViewModel.checkPackageStatus(applicationContext)
|
||||
} else {
|
||||
MMKVUtil.putInt(MMKVKey.isCheckLegalApp, ConstantInt.Type2)
|
||||
legalApp()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showToastAndFinish() {
|
||||
Toaster.show(getString(R.string.txt_no_legal_app))
|
||||
mViewBinding.root.postDelayed({
|
||||
finish()
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
private fun legalApp() {
|
||||
mCountDownTimerViewModel.mCountDownEndLiveData.observe(this) {
|
||||
mViewBinding.splashLottieAnimationView.cancelAnimation()
|
||||
val userId = MMKVUtil.getString(MMKVKey.UserId)
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.abbidot.tracker.vm
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.abbidot.baselibrary.constant.MMKVKey
|
||||
import com.abbidot.baselibrary.util.AppUtils
|
||||
import com.abbidot.baselibrary.util.MMKVUtil
|
||||
import com.abbidot.tracker.bean.NotificationBean
|
||||
import com.abbidot.tracker.retrofit2.NetworkApi
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2024/9/26/026.
|
||||
@@ -18,6 +21,7 @@ class AppSetViewModel : ViewModel() {
|
||||
|
||||
val mGetNotificationLiveData = MutableLiveData<Result<MutableList<NotificationBean>>>()
|
||||
val mSetNotificationLiveData = MutableLiveData<Result<String>>()
|
||||
val mCheckPackageStatusLiveData = MutableLiveData<Result<String>>()
|
||||
|
||||
/**
|
||||
* 获取通知设置
|
||||
@@ -40,4 +44,17 @@ class AppSetViewModel : ViewModel() {
|
||||
mSetNotificationLiveData.value = result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查apk包状态
|
||||
*/
|
||||
fun checkPackageStatus(context: Context) {
|
||||
viewModelScope.launch {
|
||||
val packageName = context.packageName
|
||||
val signSha256 = AppUtils.getApkSignSha256(context)
|
||||
val nonce = UUID.randomUUID().toString()
|
||||
val result = NetworkApi.checkPackageStatus(packageName, signSha256, nonce)
|
||||
mCheckPackageStatusLiveData.value = result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -948,4 +948,5 @@
|
||||
<string name="txt_auto_renewal_on">自动续订已开启</string>
|
||||
<string name="txt_remove">移除</string>
|
||||
<string name="txt_turn_off_remove">关闭并移除</string>
|
||||
<string name="txt_no_legal_app">非法APP,请从正规渠道下载安装</string>
|
||||
</resources>
|
||||
@@ -999,4 +999,5 @@
|
||||
<string name="txt_auto_renewal_on">Auto-Renewal Is On</string>
|
||||
<string name="txt_remove">Remove</string>
|
||||
<string name="txt_turn_off_remove">Turn Off & Remove</string>
|
||||
<string name="txt_no_legal_app">非法APP,请从正规渠道下载安装</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user