mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-30 01:28:06 +00:00
Update SafetyNet UI to show evalType
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package com.topjohnwu.magisk.ui.safetynet
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.FragmentSafetynetMd2Binding
|
||||
import com.topjohnwu.magisk.ui.base.BaseUIFragment
|
||||
@@ -15,4 +19,13 @@ class SafetynetFragment : BaseUIFragment<SafetynetViewModel, FragmentSafetynetMd
|
||||
activity.setTitle(R.string.safetynet)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
|
||||
// Set barrier reference IDs in code, since resource IDs will be stripped in release mode
|
||||
binding.snetBarrier.referencedIds = intArrayOf(R.id.basic_text, R.id.cts_text)
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class SafetynetViewModel(
|
||||
val safetyNetTitle = KObservableField(R.string.empty)
|
||||
val ctsState = KObservableField(false)
|
||||
val basicIntegrityState = KObservableField(false)
|
||||
val evalType = KObservableField("")
|
||||
|
||||
val isChecking @Bindable get() = currentState == LOADING
|
||||
val isFailed @Bindable get() = currentState == FAILED
|
||||
@@ -67,10 +68,12 @@ class SafetynetViewModel(
|
||||
runCatching {
|
||||
val cts = getBoolean("ctsProfileMatch")
|
||||
val basic = getBoolean("basicIntegrity")
|
||||
val eval = optString("evaluationType")
|
||||
val result = cts && basic
|
||||
cachedResult = this
|
||||
ctsState.value = cts
|
||||
basicIntegrityState.value = basic
|
||||
evalType.value = if (eval.contains("HARDWARE")) "HARDWARE" else "BASIC"
|
||||
currentState = if (result) PASS else FAILED
|
||||
safetyNetTitle.value =
|
||||
if (result) R.string.safetynet_attest_success
|
||||
@@ -79,12 +82,14 @@ class SafetynetViewModel(
|
||||
currentState = FAILED
|
||||
ctsState.value = false
|
||||
basicIntegrityState.value = false
|
||||
evalType.value = "N/A"
|
||||
safetyNetTitle.value = R.string.safetynet_res_invalid
|
||||
}
|
||||
} ?: {
|
||||
currentState = FAILED
|
||||
ctsState.value = false
|
||||
basicIntegrityState.value = false
|
||||
evalType.value = "N/A"
|
||||
safetyNetTitle.value = R.string.safetynet_api_error
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user