mapbox / mapbox/mapbox-navigation-android

[Android 13] - Bundle#get is deprecated

Open
#6,133 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

jira-sync-complete
Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

We use this API to create FixLocation#extras. The logic is simple: there are multiple predefined types, we use bundle.get and check if the returned value is instance of one of the predefined types. If yes, create map entry with the following type, if no, ignore the entry. Code:

        val key = iterator.next()
        when (val value = this.get(key)) {
            is Boolean -> map[key] = Value(value)
            is Byte -> map[key] = Value(value.toLong())
            is Char -> map[key] = Value(value.toString())
            is Double -> map[key] = Value(value)
            is Float -> map[key] = Value(value.toDouble())
            is Int -> map[key] = Value(value.toLong())
            is Long -> map[key] = Value(value)
            is Short -> map[key] = Value(value.toLong())
            is String -> map[key] = Value(value)
            else -> {
                logW(
                    "Unsupported type in location extras",
                    LOG_CATEGORY
                )
            }
        }

Now Bundle#get is deprecated and there is no other way to determine which type has the value by a concrete key. For now we can leave it as-is because deprecation is not removal, but it's very probable that in the future we'll have to face this problem anyway.
Questions:

  1. Where is FixLocation#extras used? We use it only to convert back to Location#extras. The whole object is passed to Navigator#updateLocation. Are the extras somehow used there? I see that iOS does not have any extras.
  2. Do we need all extras there or just some predefined ones? This way we can use type-safe methods like Bundle#getString if we know the key (and which type the value has).

cc @mapbox/navnative

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing FixLocation#extras through its conversion back to Location#extras and the Navigator#updateLocation call. Determine whether extras are required and which predefined keys and types are supported; done means an agreed replacement for Bundle#get or a documented reason to retain it.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.