[Request]: network_info_plus: use ConnectivityManager for getWifiIP and getWifiGatewayIP from Android 7 (N), so ethernet works below Android 12
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 22/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 領域
- mobile, mobile-dev
調査の方向性
Work is already in open PR #3999; do not start a duplicate. The Android path lives in the network_info_plus plugin: NetworkInfoPlusPlugin.setupChannels() currently constructs ConnectivityManager only from VERSION_CODES.S, and NetworkInfo.getWifiIPAddress() / getGatewayIPAddress() use the same S gate (WifiInfo/dhcpInfo below that). Confirm minSdk 19 still needs the Wi-Fi fallback below N. Done means ethernet IP/gateway work on API 24–30 without crashing getDhcpServerAddress on API 24–29.
索引モデルが issue の本文から書いたものです。
説明
Plugin
network_info_plus
Use case
If an Android device below version 12 is on ethernet, the plugin can't find the network:
getWifiIP()gives backnullgetWifiSubmask()gives back an empty stringgetWifiBroadcast()andgetWifiIPv6()don't work eithergetWifiGatewayIP()doesn't give the ethernet gateway
On Android 12 and up it works fine. The Android code uses ConnectivityManager there, and that works for any kind of connection. But it only turns on at Build.VERSION_CODES.S. Below that, the plugin uses WifiInfo and dhcpInfo instead. Those only know about Wi-Fi, so on ethernet they just give back 0.
The thing is, the ConnectivityManager calls are much older than Android 12. getActiveNetwork() is API 23, and the rest are API 21. The only newer one is getDhcpServerAddress(), which the gateway code uses. That one is API 30.
The S check came in with #1151. #420 asks for something similar, but this is just for Android.
Proposal
Turn on the ConnectivityManager code from Android 7 (Build.VERSION_CODES.N, API 24) instead of Android 12. That takes 3 small changes.
1. Get ConnectivityManager from N in NetworkInfoPlusPlugin.setupChannels()
Right now it's only set up on S and above, so it's null on older devices. If you only change the check in NetworkInfo.kt, nothing happens.
var connectivityManager: ConnectivityManager? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
connectivityManager = context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
}
2. Change the check in NetworkInfo.getWifiIPAddress()
Only the version number changes. The rest stays the same.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val linkAddresses =
connectivityManager?.getLinkProperties(connectivityManager.activeNetwork)?.linkAddresses
// ...unchanged
}
3. Get the gateway from the default route in NetworkInfo.getGatewayIPAddress()
You can't just change the version number here. getDhcpServerAddress() needs API 30, so it would crash on API 24 to 29. The default route works from API 21. It's also a bit better on Android 12+, because it gives you the real gateway and not the DHCP server. Those aren't always the same thing.
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val linkProperties =
connectivityManager?.getLinkProperties(connectivityManager.activeNetwork)
val defaultRoute = linkProperties?.routes?.firstOrNull { route -> route.isDefaultRoute }
defaultRoute?.gateway?.hostAddress
} else {
// ...existing dhcpInfo fallback, unchanged
}
Subnet mask, broadcast and IPv6 don't need any changes. They all use the IP from getWifiIPAddress(), so they start working once that does.
The plugin's minSdk is 19, so the old Wi-Fi code still runs on anything below N.
I tried this on ethernet on API 25, 28 and 30, and it works on all of them. Before the change, none of them showed anything. It might work on API 23 (M) too, but I haven't tried that.
- 主要言語
- Dart
- スター
- 1.9k
- フォーク
- 1.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluttercommunity/plus_plugins のほかの issue
-
[Bug]: (share_plus) iOS drops the subject when sharing a uri対応中かも @kaluli123123 が 5 日前に担当しました。 オープンbug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
fluttercommunity/plus_plugins#3994 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[package_info_plus]: Use Flutter's compile-time build name/number on web instead of version.json対応中かも @Ortes が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
fluttercommunity/plus_plugins#3989 ·
メンテナーはふだん 1 日以内に返信
-
enhancement triage
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
fluttercommunity/plus_plugins#3976 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
fluttercommunity/plus_plugins#3974 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement triage
難易度 5/5 1週間以上 初心者へのやさしさ 48/100
fluttercommunity/plus_plugins#3973 ·
メンテナーはふだん 1 日以内に返信
fluttercommunity/plus_plugins の issue をすべて見る
似ている issue
-
bug product: very_good_flutter_plugin
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
VeryGoodOpenSource/very_good_templates#654 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
Server never consumes the request body on early-error paths: _sinkIncoming does not resume the paused subscription再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
[BUG][All] VLESS URIs with flow=xtls-rprx-vision-udp443 are silently dropped on subscription importオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
simonoppowa/OpenNutriTracker#1336 ·
メンテナーはふだん 1 日以内に返信