mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 10:47:38 +00:00
Added "caching" of the safetynet response
This commit is contained in:
parent
60a2e9b5dc
commit
d0b817381e
@ -34,7 +34,11 @@ class SafetynetViewModel(
|
|||||||
.subscribeK { resolveResponse(it.responseCode) }
|
.subscribeK { resolveResponse(it.responseCode) }
|
||||||
.add()
|
.add()
|
||||||
|
|
||||||
attest()
|
if (safetyNetResult >= 0) {
|
||||||
|
resolveResponse(safetyNetResult)
|
||||||
|
} else {
|
||||||
|
attest()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyStateChanged() {
|
override fun notifyStateChanged() {
|
||||||
@ -56,6 +60,7 @@ class SafetynetViewModel(
|
|||||||
val hasCtsPassed = response and SafetyNetHelper.CTS_PASS != 0
|
val hasCtsPassed = response and SafetyNetHelper.CTS_PASS != 0
|
||||||
val hasBasicIntegrityPassed = response and SafetyNetHelper.BASIC_PASS != 0
|
val hasBasicIntegrityPassed = response and SafetyNetHelper.BASIC_PASS != 0
|
||||||
val result = hasCtsPassed && hasBasicIntegrityPassed
|
val result = hasCtsPassed && hasBasicIntegrityPassed
|
||||||
|
safetyNetResult = response
|
||||||
ctsState.value = hasCtsPassed
|
ctsState.value = hasCtsPassed
|
||||||
basicIntegrityState.value = hasBasicIntegrityPassed
|
basicIntegrityState.value = hasBasicIntegrityPassed
|
||||||
currentState = if (result) PASS else FAILED
|
currentState = if (result) PASS else FAILED
|
||||||
@ -80,4 +85,8 @@ class SafetynetViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private var safetyNetResult = -1
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user