Browse Source

take 2 at samsung issues: ensure network is connected

Cristiano Coelho 5 years ago
parent
commit
99a81e5ec3
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 6
- 4
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java View File

10
 import android.os.Build;
10
 import android.os.Build;
11
 import androidx.annotation.NonNull;
11
 import androidx.annotation.NonNull;
12
 import android.net.Network;
12
 import android.net.Network;
13
+import android.net.NetworkInfo;
13
 import android.net.NetworkCapabilities;
14
 import android.net.NetworkCapabilities;
14
 import android.net.ConnectivityManager;
15
 import android.net.ConnectivityManager;
15
 import android.util.Base64;
16
 import android.util.Base64;
246
                     Network[] networks = connectivityManager.getAllNetworks();
247
                     Network[] networks = connectivityManager.getAllNetworks();
247
 
248
 
248
                     for (Network network : networks) {
249
                     for (Network network : networks) {
249
-                        //NetworkInfo netInfo = connectivityManager.getNetworkInfo(network);
250
+
251
+                        NetworkInfo netInfo = connectivityManager.getNetworkInfo(network);
250
                         NetworkCapabilities caps = connectivityManager.getNetworkCapabilities(network);
252
                         NetworkCapabilities caps = connectivityManager.getNetworkCapabilities(network);
251
-                        if(caps == null){
253
+
254
+                        if(caps == null || netInfo == null){
252
                             continue;
255
                             continue;
253
                         }
256
                         }
254
 
257
 
255
-                        // Don't use P2P Wi-Fi on recent samsung devices
256
-                        if(caps.hasTransport(NetworkCapabilities.NET_CAPABILITY_WIFI_P2P)){
258
+                        if(!netInfo.isConnected()){
257
                             continue;
259
                             continue;
258
                         }
260
                         }
259
 
261