Commit d0b81738 authored by Viktor De Pasquale's avatar Viktor De Pasquale

Added "caching" of the safetynet response

parent 60a2e9b5
......@@ -34,8 +34,12 @@ class SafetynetViewModel(
.subscribeK { resolveResponse(it.responseCode) }
.add()
if (safetyNetResult >= 0) {
resolveResponse(safetyNetResult)
} else {
attest()
}
}
override fun notifyStateChanged() {
super.notifyStateChanged()
......@@ -56,6 +60,7 @@ class SafetynetViewModel(
val hasCtsPassed = response and SafetyNetHelper.CTS_PASS != 0
val hasBasicIntegrityPassed = response and SafetyNetHelper.BASIC_PASS != 0
val result = hasCtsPassed && hasBasicIntegrityPassed
safetyNetResult = response
ctsState.value = hasCtsPassed
basicIntegrityState.value = hasBasicIntegrityPassed
currentState = if (result) PASS else FAILED
......@@ -80,4 +85,8 @@ class SafetynetViewModel(
}
}
companion object {
private var safetyNetResult = -1
}
}
\ No newline at end of file
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