mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-10 21:15:06 +00:00
reading from the stream in a loop
this ensures that desired number of bytes will be read, as stream.read(byte[] buffer) will just make effort to read at least 1 byte
This commit is contained in:
parent
5f70d943cb
commit
7d91551126
1 changed files with 9 additions and 1 deletions
|
@ -159,7 +159,15 @@ class ExposureNotificationServiceImpl(private val context: Context, private val
|
||||||
val entry = stream.nextEntry ?: break
|
val entry = stream.nextEntry ?: break
|
||||||
if (entry.name == "export.bin") {
|
if (entry.name == "export.bin") {
|
||||||
val prefix = ByteArray(16)
|
val prefix = ByteArray(16)
|
||||||
if (stream.read(prefix) == prefix.size && String(prefix).trim() == "EK Export v1") {
|
var totalBytesRead = 0
|
||||||
|
var bytesRead = 0
|
||||||
|
while (bytesRead != -1 && totalBytesRead < prefix.size) {
|
||||||
|
bytesRead = stream.read(prefix, totalBytesRead, prefix.size - totalBytesRead)
|
||||||
|
if (bytesRead > 0) {
|
||||||
|
totalBytesRead += bytesRead
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (totalBytesRead == prefix.size && String(prefix).trim() == "EK Export v1") {
|
||||||
val fileKeys = storeDiagnosisKeyExport(params.token, TemporaryExposureKeyExport.ADAPTER.decode(stream))
|
val fileKeys = storeDiagnosisKeyExport(params.token, TemporaryExposureKeyExport.ADAPTER.decode(stream))
|
||||||
keys + fileKeys
|
keys + fileKeys
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue