Android 9断开了WiFi连接,没有互联网

时间:2019-01-04 16:39:28

标签: android wifi dhcp connectivity

我想保持没有互联网的Wifi连接,以防远程控制设备。 我有一个持有WiFi锁的前台服务,而且我也尝试像这样绑定bindProcessToNetworkLooks:

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)
    }

现在我发现Android系统一直在随机丢弃WiFi日志:

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

您知道断开原因= 3是什么意思,还是我该如何告诉android这是应该立即使用的网络?

更新1:

在Linux中,

reason = 3似乎是设备无法通过DCHP解析地址。我试图在WiFi配置中设置设备的静态Ip-没有进行任何更改

0 个答案:

没有答案
相关问题