mapbox / mapbox/mapbox-navigation-android

Expose API to check if offline regions are expired

Offen
#4,471 10 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

jira-sync-complete
Vorherrschende Sprache
Kotlin
Sterne
651
Forks
321
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

TileStore has a method tileRegionContainsDescriptors(...) which can be used by a customer to check single regions expiration.
We need provide some extensions to make such checks easier
It might be:

fun TileStore.checkAllRegionsTilesExpired(
    descriptorFactory: TilesetDescriptorFactory,
    callback: RegionsTilesCheckExpiredCallback
)

and for a single region

fun TileStore.checkRegionTilesExpired(
    regionId: String,
    descriptorFactory: TilesetDescriptorFactory,
    callback: RegionTilesCheckExpiredCallback
)

but in that case on android we can't cover it with unit tests, TileStore is a c++ class, it's methods can't be mocked without an additional dependency like PowerMockito.

also such methods should be implemented on each platform and we might get additional bugs.

Example (iOS has pretty close logic):

fun TileStore.checkAllRegionsTilesExpired(
    descriptorFactory: TilesetDescriptorFactory,
    callback: RegionsTilesCheckExpiredCallback
) {
    val latestDescriptors = descriptorFactory.getLatest()
    getAllTileRegions {
        if (it.isValue) {
            val regions = it.value!!
            val expiredRegions = mutableListOf<String>()
            val countDownLatch = CountDownLatch(regions.size)
            regions.forEach { region ->
                tileRegionContainsDescriptors(region.id, listOf(latestDescriptors)) { result ->
                    if (result.isValue) {
                        val regionIsExpired = result.value!!.not()
                        if (regionIsExpired) {
                            expiredRegions.add(region.id)
                        }
                    }
                    countDownLatch.countDown()
                }
            }
            countDownLatch.await()

            if (expiredRegions.isEmpty()) {
                callback.onTilesUpToDate()
            } else {
                callback.onTilesExpired(expiredRegions)
            }
        } else {
            callback.onError("type: ${it.error?.type}, message: ${it.error?.message}")
        }
    }
}

interface RegionsTilesCheckExpiredCallback {
    fun onTilesUpToDate()
    fun onTilesExpired(regionIds: List<String>)
    fun onError(message: String)
}

Should we ask common team to expose such API? Common should receive descriptors to make a check, so

  • it should be provided by a customer
  • Platforms can implement short wrappers like
fun TileStore.checkAllRegionsTilesExpired(callback: RegionsTilesCheckExpiredCallback) {
    val latestDescriptors = descriptorFactory.getLatest()
    // pass `latestDescriptors` to `common`
}

it's a little confusing that platforms need to write the same extensions. It means that base API is not enough and it should be improved, doesn't it?

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit TileStore.tileRegionContainsDescriptors(...) sowie den vorgeschlagenen Erweiterungen checkAllRegionsTilesExpired und checkRegionTilesExpired. Vergleiche den Android-Vorschlag mit der referenzierten iOS-Logik und bestimme, ob die API in common oder in Plattform-Wrapper gehört; abgeschlossen ist die Aufgabe, wenn Ownership, Descriptor-Fluss, Callbacks und der Ansatz zur Testbarkeit geklärt sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, kotlin
Bereich
api, mobile
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.