当通过Wifi投射到Chromecast时,我的用户抱怨在Android 6设备上失去连接。查看日志时,我看到了:
12-09 19:18:56.473 I/Router ( 5337): Connectivity change detected...
12-09 19:18:56.473 I/Router ( 5337): EXTRA_NO_CONNECTIVITY: true
12-09 19:18:56.473 I/Router ( 5337): EXTRA_REASON: null
12-09 19:18:56.473 I/Router ( 5337): EXTRA_IS_FAILOVER: false
12-09 19:18:56.473 I/Router ( 5337): EXTRA_NETWORK_INFO: [type: WIFI[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: <unknown ssid>, roaming: false, failover: false, isAvailable: true]
12-09 19:18:56.473 I/Router ( 5337): EXTRA_OTHER_NETWORK_INFO: none
12-09 19:18:56.473 I/Router ( 5337): EXTRA_EXTRA_INFO: <unknown ssid>
12-09 19:18:56.475 I/NetworkUtils( 5337): Could not find any connected network...
12-09 19:18:57.475 W/Router ( 5337): WIFI => NONE network transition, waiting for new network... retry #1
12-09 19:18:57.476 I/Router ( 5337): Network type changed WIFI => MOBILE
12-09 19:18:57.477 I/Router ( 5337): WiFi multicast lock released
12-09 19:18:57.478 I/Router ( 5337): WiFi lock released
12-09 19:18:57.521 I/Router ( 5337): Disabled router on network type change (old network: WIFI)```
正如你可能猜到的那样,在投射过程中转向Wifi会导致问题。这似乎只是运行Android 6的设备的一个问题,所以我认为它与新的打盹模式有关。我看到Doze mode and foreground service已经确定前台服务不会打瞌睡(我可以确认这一点),但它似乎并没有停止打瞌睡,无法取消必要的网络访问。虽然我还没有收到有关DLNA投射的任何投诉,但我想它会有同样的问题。如果应用程序主动播放音乐并且被迫使用移动网络没有令人信服的理由,这也会导致问题。有没有办法阻止Doze在前台应用程序使用时关闭Wifi访问?