Bläddra i källkod

take 2 at samsung issues: ensure network is connected

Cristiano Coelho 5 år sedan
förälder
incheckning
99a81e5ec3
1 ändrade filer med 6 tillägg och 4 borttagningar
  1. 6
    4
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 6
- 4
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Visa fil

@@ -10,6 +10,7 @@ import android.net.Uri;
10 10
 import android.os.Build;
11 11
 import androidx.annotation.NonNull;
12 12
 import android.net.Network;
13
+import android.net.NetworkInfo;
13 14
 import android.net.NetworkCapabilities;
14 15
 import android.net.ConnectivityManager;
15 16
 import android.util.Base64;
@@ -246,14 +247,15 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
246 247
                     Network[] networks = connectivityManager.getAllNetworks();
247 248
 
248 249
                     for (Network network : networks) {
249
-                        //NetworkInfo netInfo = connectivityManager.getNetworkInfo(network);
250
+
251
+                        NetworkInfo netInfo = connectivityManager.getNetworkInfo(network);
250 252
                         NetworkCapabilities caps = connectivityManager.getNetworkCapabilities(network);
251
-                        if(caps == null){
253
+
254
+                        if(caps == null || netInfo == null){
252 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 259
                             continue;
258 260
                         }
259 261