i want to stay connected to a Wifi with no Internet in case to remote Control a device. I have a foreground Service that's Holding a WiFi lock and i also tried to bindProcessToNetworkLooks like this:
val wifiManager = applicationContext
.getSystemService(WIFI_SERVICE) as WifiManager
if (wifiLock == null) {
wifiLock = wifiManager.createWifiLock(WIFI_MODE_FULL_HIGH_PERF, "cameraServiceWifiLock")
}
Timber.d("CameraService wifiLock null=%s held=%s", wifiLock != null, wifiLock?.isHeld)
if (wifiLock != null && !wifiLock!!.isHeld) {
Timber.d("CameraService wifiLock acquire")
wifiLock!!.acquire()
}
val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
if (SDK_INT >= M && CameraApi.network != null) {
Timber.d("CameraService bindProcessToNetwork")
cm.bindProcessToNetwork(CameraApi.network)
}
now i found out that the Android System keeps dropping the WiFi randomly log:
D/WificondControl: Scan result ready event
I/LOWI-8.5.0.3.a: [LOWI-Scan] lowi_close_record:Scan completed in 46343838ms and Recieved 7 APs scan results
D/WifiStateMachine: CMD_START_CONNECT sup state CompletedState my state ConnectedState nid=26 roam=false
I/WifiStateMachine: Connecting with [...] as the mac address
W/wificond: Scan is not started. Ignore abort request
D/SupplicantStaIfaceHal: connectToNetwork "FRITZ!Box 7530 ZI"WPA_PSK
I/wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED bssid=[...] reason=3 locally_generated=1
E/wpa_supplicant: nl80211: Failed to open /proc/sys/net/ipv4/conf/wlan0/drop_gratuitous_arp: No such file or directory
20E/wpa_supplicant: nl80211: Failed set gratuitous ARP filter
2E/wpa_supplicant: nl80211: Failed to open /proc/sys/net/ipv4/conf/wlan0/drop_gratuitous_arp: No such file or directory
E/wpa_supplicant: nl80211: Failed set gratuitous ARP filter
Do you know what disconnect reason=3 means or how i can tell android that this is the Network that should be used at the Moment?
Update1:
reason=3 in Linux seems to be that the device can't resolve an address via DCHP. I tried to set the static Ip of the device in the WiFi configuration - didn't change anything