Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/connectivity manager deprecations #697

Open
wants to merge 2 commits into
base: v3.0x
Choose a base branch
from

Conversation

vicajilau
Copy link
Collaborator

Description

This PR updates the usage of the ConnectivityManager API to resolve deprecation warnings related to the use of NetworkInfo and its methods, which have been replaced by NetworkCapabilities starting from Android 10 (API 29). The key updates include:

  • Replacing NetworkInfo with NetworkCapabilities for checking network type and internet availability.
  • Using hasTransport(NetworkCapabilities.TRANSPORT_WIFI) to detect if the connection is Wi-Fi and hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) to verify network availability.
  • Added backward compatibility for Android versions earlier than Marshmallow (API 23) by using the older NetworkInfo approach.
  • The deprecated allNetworkInfo method has been removed, as it's no longer needed with the newer API.
    Issues

Resolved

  • Removes deprecation warnings related to the use of activeNetworkInfo, isConnected, type, TYPE_WIFI, and allNetworkInfo.
  • Enhances compatibility with modern Android versions starting from Android 10 (API 29).

Compatibility

  • Maintains compatibility with pre-API 23 Android devices using the legacy NetworkInfo API conditionally.

Testing

Verified on devices running Android 10+ to ensure that NetworkCapabilities functions as expected.
Tested on older Android devices to ensure proper functionality using the legacy implementation.

Open Question

There remains an open question of whether it is better to completely remove the legacy NetworkInfo API code or keep it alongside the new implementation for backward compatibility. Input and suggestions are welcome on whether supporting older Android versions is still a priority for this codebase. Should we remove support for Android API 21 and move it up to API 23?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant