mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-12-02 17:02:54 +01:00
EN: Fixed rare case of incorrectly reporting more exposures than happened
This commit is contained in:
parent
9ef9f29940
commit
50c241ab63
@ -73,7 +73,7 @@ class ExposureNotificationsAppPreferencesFragment : PreferenceFragmentCompat() {
|
|||||||
val encountersLine = if (merged.isEmpty()) {
|
val encountersLine = if (merged.isEmpty()) {
|
||||||
getString(R.string.pref_exposure_app_last_report_summary_encounters_no)
|
getString(R.string.pref_exposure_app_last_report_summary_encounters_no)
|
||||||
} else {
|
} else {
|
||||||
database.findAllMeasuredExposures(config.first).merge().map {
|
merged.map {
|
||||||
val riskScore = it.getRiskScore(config.second.orDefault())
|
val riskScore = it.getRiskScore(config.second.orDefault())
|
||||||
"· " + getString(R.string.pref_exposure_app_last_report_summary_encounters_line, DateUtils.formatDateRange(requireContext(), it.timestamp, it.timestamp + it.durationInMinutes * 60 * 1000L, DateUtils.FORMAT_SHOW_TIME or DateUtils.FORMAT_SHOW_DATE), riskScore)
|
"· " + getString(R.string.pref_exposure_app_last_report_summary_encounters_line, DateUtils.formatDateRange(requireContext(), it.timestamp, it.timestamp + it.durationInMinutes * 60 * 1000L, DateUtils.FORMAT_SHOW_TIME or DateUtils.FORMAT_SHOW_DATE), riskScore)
|
||||||
}.joinToString("<br>").let { getString(R.string.pref_exposure_app_last_report_summary_encounters_prefix, merged.size) + "<br>$it<br><i>" + getString(R.string.pref_exposure_app_last_report_summary_encounters_suffix) + "</i>" }
|
}.joinToString("<br>").let { getString(R.string.pref_exposure_app_last_report_summary_encounters_prefix, merged.size) + "<br>$it<br><i>" + getString(R.string.pref_exposure_app_last_report_summary_encounters_suffix) + "</i>" }
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
android:title="@string/open_app" />
|
android:title="@string/open_app" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:layout="@layout/preference_category_no_label">
|
<PreferenceCategory android:layout="@layout/preference_category_no_label">
|
||||||
<Preference
|
<org.microg.gms.ui.TextPreference
|
||||||
android:key="pref_exposure_app_report"
|
android:key="pref_exposure_app_report"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
tools:summary="@string/pref_exposure_app_last_report_summary_encounters_no"
|
tools:summary="@string/pref_exposure_app_last_report_summary_encounters_no"
|
||||||
|
@ -393,9 +393,11 @@ class ExposureDatabase private constructor(private val context: Context) : SQLit
|
|||||||
var processed = 0
|
var processed = 0
|
||||||
var found = 0
|
var found = 0
|
||||||
var riskLogged = -1
|
var riskLogged = -1
|
||||||
|
var startLogged = -1
|
||||||
for (key in keys) {
|
for (key in keys) {
|
||||||
if (key.transmissionRiskLevel > riskLogged) {
|
if (key.transmissionRiskLevel > riskLogged || key.rollingStartIntervalNumber > startLogged) {
|
||||||
riskLogged = key.transmissionRiskLevel
|
riskLogged = key.transmissionRiskLevel
|
||||||
|
startLogged = key.rollingStartIntervalNumber
|
||||||
Log.d(TAG, "First key with risk ${key.transmissionRiskLevel}: ${ByteString.of(*key.keyData).hex()} starts ${key.rollingStartIntervalNumber}")
|
Log.d(TAG, "First key with risk ${key.transmissionRiskLevel}: ${ByteString.of(*key.keyData).hex()} starts ${key.rollingStartIntervalNumber}")
|
||||||
}
|
}
|
||||||
if ((key.rollingStartIntervalNumber + key.rollingPeriod).toLong() * ROLLING_WINDOW_LENGTH_MS + ALLOWED_KEY_OFFSET_MS < oldestRpi) {
|
if ((key.rollingStartIntervalNumber + key.rollingPeriod).toLong() * ROLLING_WINDOW_LENGTH_MS + ALLOWED_KEY_OFFSET_MS < oldestRpi) {
|
||||||
|
@ -21,8 +21,8 @@ fun List<MeasuredExposure>.merge(): List<MergedExposure> {
|
|||||||
val result = arrayListOf<MergedExposure>()
|
val result = arrayListOf<MergedExposure>()
|
||||||
for (key in keys) {
|
for (key in keys) {
|
||||||
var merged: MergedExposure? = null
|
var merged: MergedExposure? = null
|
||||||
for (exposure in filter { it.key == key }.sortedBy { it.timestamp }) {
|
for (exposure in filter { it.key == key }.distinctBy { it.timestamp }.sortedBy { it.timestamp }) {
|
||||||
if (merged != null && merged.timestamp + MergedExposure.MAXIMUM_DURATION + ROLLING_WINDOW_LENGTH_MS > exposure.timestamp) {
|
if (merged != null && merged.timestamp + MergedExposure.MAXIMUM_DURATION > exposure.timestamp) {
|
||||||
merged += exposure
|
merged += exposure
|
||||||
} else {
|
} else {
|
||||||
if (merged != null) {
|
if (merged != null) {
|
||||||
@ -30,7 +30,7 @@ fun List<MeasuredExposure>.merge(): List<MergedExposure> {
|
|||||||
}
|
}
|
||||||
merged = MergedExposure(key, exposure.timestamp, exposure.txPower, exposure.confidence, listOf(MergedSubExposure(exposure.attenuation, exposure.duration)))
|
merged = MergedExposure(key, exposure.timestamp, exposure.txPower, exposure.confidence, listOf(MergedSubExposure(exposure.attenuation, exposure.duration)))
|
||||||
}
|
}
|
||||||
if (merged.durationInMinutes > 30) {
|
if (merged.durationInMinutes >= 30) {
|
||||||
result.add(merged)
|
result.add(merged)
|
||||||
merged = null
|
merged = null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user