Skip to content

Commit 65f4aa0

Browse files
authored
Merge pull request #164 from shellrow/feat/android-enhancements
feat: Android enhancements
2 parents bc946e0 + 3b9c6e5 commit 65f4aa0

8 files changed

Lines changed: 885 additions & 41 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ netlink-sys = "0.8.8"
2525

2626
[target.'cfg(target_os = "android")'.dependencies]
2727
dlopen2 = { version = "0.8.2", default-features = false }
28+
jni = { version = "0.21.1", optional = true }
29+
ndk-context = { version = "0.1.1", optional = true }
2830
once_cell = "1"
2931

3032
[target.'cfg(windows)'.dependencies.windows-sys]
@@ -53,9 +55,10 @@ block2 = "0.6"
5355
serde_json = "1.0"
5456

5557
[features]
56-
default = ["gateway", "apple-system-configuration-extra"]
58+
default = ["gateway", "apple-system-configuration-extra", "android-extra"]
5759
serde = ["dep:serde", "mac-addr/serde", "ipnet/serde"]
5860
gateway = []
61+
android-extra = ["dep:jni", "dep:ndk-context"]
5962
apple-system-configuration-extra = [
6063
"objc2-system-configuration/SCPreferences",
6164
"objc2-system-configuration/SCDynamicStore",

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ For more details, see [examples][examples-url] or [doc][doc-url].
5050
- `apple-system-configuration-extra` (default)
5151
- Enables deeper Apple metadata enrichment using `SystemConfiguration` APIs.
5252
- On Apple targets, this adds metadata such as interface display names, DHCP hints, and iOS DNS resolver lookup when the platform exposes them.
53+
- `android-extra` (default)
54+
- Enables deeper Android metadata enrichment using Android platform APIs through JNI bindings.
55+
- On Android, this can add metadata such as traffic stats, DNS servers, DHCP hints, and Wi-Fi link speed when the app provides the required Android context and permissions.
5356

5457
To opt out of the deeper Apple enrichment while keeping gateway helpers:
5558

@@ -62,6 +65,9 @@ netdev = { version = "0.43", default-features = false, features = ["gateway"] }
6265
`netdev` links `SystemConfiguration.framework` automatically on `macOS` and `iOS` through the crate's own build script.
6366
If your final app link is performed by Xcode, you may still need to add `SystemConfiguration.framework` to the app target manually.
6467

68+
## Android behavior
69+
If you want Android-specific values such as DNS servers, DHCP hints, or Wi-Fi link speed, your app may still need to initialize the Android context for Rust and declare Android permissions such as `ACCESS_NETWORK_STATE` and `ACCESS_WIFI_STATE`.
70+
6571
## Project History
6672
This crate was originally published as [default-net][default-net-crates-io-url]
6773
and later rebranded to `netdev` by the author myself for future expansion, clearer naming, and long-term maintenance.

0 commit comments

Comments
 (0)