networking - Android: ProcessBuilder not bind to network (ConnectivityManager.bindProcessToNetwork set) -
i working on project needs evaluate wifi connections.
as smartphone may have data connection well, check every connection network bound type_wifi:
boolean bound = false; if (build.version.sdk_int >= build.version_codes.m) { bound = cm.bindprocesstonetwork(wifinetwork); // m , above } else if (build.version.sdk_int >= build.version_codes.lollipop) { bound = cm.setprocessdefaultnetwork(wifinetwork) } ..... it works fine far, when using httpurlconnection, okhttp-lib , webview.
however, need test icmp requests, , therefore use system ping this:
process process = new processbuilder() .command("/system/bin/ping", "-c 3", url) .redirecterrorstream(true) .start(); unfortunately, new process not bound network. (although have assumed , hoped was.)
it possible create socket bound required network, how use socket call ping?
there related question here not familiar file descriptor , have basic c knowledge. if somehow possible, prefer solution working without native code. nevertheless, didn't figure out how native solution work out either , happy suggestions!
Comments
Post a Comment