ReactiveNetwork icon indicating copy to clipboard operation
ReactiveNetwork copied to clipboard

Google pixel wifi change event is received in 30 sec delay

Open seladev opened this issue 4 years ago • 5 comments

Describe the bug I am using this code for listening to wifi changes - ReactiveNetwork.observeNetworkConnectivity(context) .subscribeOn(Schedulers.io()) .filter(ConnectivityPredicate.hasType(NetworkCapabilities.TRANSPORT_WIFI)) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ logWarning("###### change network = $it") },{ })

I am testing the code in different devices and its work, but in Google pixel 3a i am receiving the wifi concavity change event in 30 seconds delay. In Samsung device i am receiving the wifi concavity change event immediately

To Reproduce Steps to reproduce the behavior:

  1. Turn Off Wifi
  2. Open activity \ fragment that with the specific code
  3. Turn On Wifi in the device
  4. observe subscribe in observeNetworkConnectivity
  5. observe Wifi connection in the Device
  6. See when the Wifi connection success and when observeNetworkConnectivity subscribe received
  7. Wifi connect event received after 30 seconds from the device Wifi connection

Expected behavior The Wifi connect in the same time

Smartphone (please complete the following information):

  • Device: Google Pixel 3a
  • OS: Android 11
  • Library Version: 3.0.1

seladev avatar Apr 21 '21 08:04 seladev

Thanks for reporting this.

If you observe different behavior on two different devices with the same code where the only difference is delay, then this is clearly hardware issue and library cannot do anything about this. It can be also Android OS issue, but still it's not related to the library.

Regards, Piotr

pwittchen avatar Apr 21 '21 08:04 pwittchen

Thanks for your quick answer

When i am listening to wifi changes with BroadcastReceiver i can see that the wifi connection event immediately. This is the BroadcastReceiver: receiver = new NetworkChangeReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(receiver, intentFilter); receiver.setConnectionListener(this);

This is the logs: 2021-04-21 11:37:21.943----- NetworkChangeReceiver ###### change network wifi enable = false -------------------- 2021-04-21 11:37:49.358----- NetworkChangeReceiver ###### change network onReceive = android.net.conn.CONNECTIVITY_CHANGE -------------------- 2021-04-21 11:37:49.363----- NetworkChangeReceiver ###### change network wifi enable = true -------------------- 2021-04-21 11:37:49.370----- NetworkChangeReceiver ###### change network onReceive = android.net.conn.CONNECTIVITY_CHANGE -------------------- 2021-04-21 11:37:49.404----- NetworkChangeReceiver ###### change network wifi enable = true -------------------- 2021-04-21 11:38:19.325 Fragment -------------------- ###### change network = Connectivity{state=CONNECTED, detailedState=CONNECTED, type=1, subType=0, available=true, failover=false, roaming=false, typeName='WIFI', subTypeName='', reason='null', extraInfo=''} --------------------

seladev avatar Apr 21 '21 08:04 seladev

In this receiver you are not using NetworkCapabilities.TRANSPORT_WIFI. I haven't tested library with this option. When you will use filter(ConnectivityPredicate.hasType(ConnectivityManager.TYPE_WIFI)) in the library, then you will get immediate result as well.

pwittchen avatar Apr 21 '21 08:04 pwittchen

I tried this code filter(ConnectivityPredicate.hasType(ConnectivityManager.TYPE_WIFI)) It is the same behaviour - 30 sec delay

seladev avatar Apr 21 '21 09:04 seladev

I also tried it with no filter - and It is the same behaviour - 30 sec delay

seladev avatar Apr 21 '21 09:04 seladev