Commit 397f7326 authored by topjohnwu's avatar topjohnwu

Update SafetyNet UI to show evalType

parent 4bbd7989
package com.topjohnwu.magisk.ui.safetynet 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.R
import com.topjohnwu.magisk.databinding.FragmentSafetynetMd2Binding import com.topjohnwu.magisk.databinding.FragmentSafetynetMd2Binding
import com.topjohnwu.magisk.ui.base.BaseUIFragment import com.topjohnwu.magisk.ui.base.BaseUIFragment
...@@ -15,4 +19,13 @@ class SafetynetFragment : BaseUIFragment<SafetynetViewModel, FragmentSafetynetMd ...@@ -15,4 +19,13 @@ class SafetynetFragment : BaseUIFragment<SafetynetViewModel, FragmentSafetynetMd
activity.setTitle(R.string.safetynet) 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( ...@@ -28,6 +28,7 @@ class SafetynetViewModel(
val safetyNetTitle = KObservableField(R.string.empty) val safetyNetTitle = KObservableField(R.string.empty)
val ctsState = KObservableField(false) val ctsState = KObservableField(false)
val basicIntegrityState = KObservableField(false) val basicIntegrityState = KObservableField(false)
val evalType = KObservableField("")
val isChecking @Bindable get() = currentState == LOADING val isChecking @Bindable get() = currentState == LOADING
val isFailed @Bindable get() = currentState == FAILED val isFailed @Bindable get() = currentState == FAILED
...@@ -67,10 +68,12 @@ class SafetynetViewModel( ...@@ -67,10 +68,12 @@ class SafetynetViewModel(
runCatching { runCatching {
val cts = getBoolean("ctsProfileMatch") val cts = getBoolean("ctsProfileMatch")
val basic = getBoolean("basicIntegrity") val basic = getBoolean("basicIntegrity")
val eval = optString("evaluationType")
val result = cts && basic val result = cts && basic
cachedResult = this cachedResult = this
ctsState.value = cts ctsState.value = cts
basicIntegrityState.value = basic basicIntegrityState.value = basic
evalType.value = if (eval.contains("HARDWARE")) "HARDWARE" else "BASIC"
currentState = if (result) PASS else FAILED currentState = if (result) PASS else FAILED
safetyNetTitle.value = safetyNetTitle.value =
if (result) R.string.safetynet_attest_success if (result) R.string.safetynet_attest_success
...@@ -79,12 +82,14 @@ class SafetynetViewModel( ...@@ -79,12 +82,14 @@ class SafetynetViewModel(
currentState = FAILED currentState = FAILED
ctsState.value = false ctsState.value = false
basicIntegrityState.value = false basicIntegrityState.value = false
evalType.value = "N/A"
safetyNetTitle.value = R.string.safetynet_res_invalid safetyNetTitle.value = R.string.safetynet_res_invalid
} }
} ?: { } ?: {
currentState = FAILED currentState = FAILED
ctsState.value = false ctsState.value = false
basicIntegrityState.value = false basicIntegrityState.value = false
evalType.value = "N/A"
safetyNetTitle.value = R.string.safetynet_api_error safetyNetTitle.value = R.string.safetynet_api_error
}() }()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment