@capgo/capacitor-wifi 8.1.0 → 8.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,7 +44,7 @@ import java.util.List;
44
44
  )
45
45
  public class CapacitorWifiPlugin extends Plugin {
46
46
 
47
- private final String pluginVersion = "8.1.0";
47
+ private final String pluginVersion = "8.1.2";
48
48
 
49
49
  private WifiManager wifiManager;
50
50
  private ConnectivityManager connectivityManager;
@@ -238,18 +238,16 @@ public class CapacitorWifiPlugin extends Plugin {
238
238
  // Bind process to network if autoRouteTraffic is enabled
239
239
  if (autoRouteTraffic != null && autoRouteTraffic) {
240
240
  try {
241
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
242
- synchronized (boundNetworkLock) {
243
- // Unbind from previous network if any
244
- if (boundNetwork != null) {
245
- connectivityManager.bindProcessToNetwork(null);
246
- }
241
+ synchronized (boundNetworkLock) {
242
+ // Unbind from previous network if any
243
+ if (boundNetwork != null) {
244
+ connectivityManager.bindProcessToNetwork(null);
245
+ }
247
246
 
248
- // Bind to the new network
249
- boolean bound = connectivityManager.bindProcessToNetwork(network);
250
- if (bound) {
251
- boundNetwork = network;
252
- }
247
+ // Bind to the new network
248
+ boolean bound = connectivityManager.bindProcessToNetwork(network);
249
+ if (bound) {
250
+ boundNetwork = network;
253
251
  }
254
252
  }
255
253
  } catch (Exception e) {
@@ -330,33 +328,31 @@ public class CapacitorWifiPlugin extends Plugin {
330
328
 
331
329
  // Bind process to network if autoRouteTraffic is enabled
332
330
  if (autoRouteTraffic != null && autoRouteTraffic) {
333
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
334
- // Use handler to bind asynchronously after connection is established
335
- new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(
336
- () -> {
337
- try {
338
- synchronized (boundNetworkLock) {
339
- // Unbind from previous network if any
340
- if (boundNetwork != null) {
341
- connectivityManager.bindProcessToNetwork(null);
342
- }
331
+ // Use handler to bind asynchronously after connection is established
332
+ new android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(
333
+ () -> {
334
+ try {
335
+ synchronized (boundNetworkLock) {
336
+ // Unbind from previous network if any
337
+ if (boundNetwork != null) {
338
+ connectivityManager.bindProcessToNetwork(null);
339
+ }
343
340
 
344
- Network activeNetwork = connectivityManager.getActiveNetwork();
345
- if (activeNetwork != null) {
346
- boolean bound = connectivityManager.bindProcessToNetwork(activeNetwork);
347
- if (bound) {
348
- boundNetwork = activeNetwork;
349
- }
341
+ Network activeNetwork = connectivityManager.getActiveNetwork();
342
+ if (activeNetwork != null) {
343
+ boolean bound = connectivityManager.bindProcessToNetwork(activeNetwork);
344
+ if (bound) {
345
+ boundNetwork = activeNetwork;
350
346
  }
351
347
  }
352
- } catch (Exception e) {
353
- // Log error but don't fail the connection
354
- android.util.Log.e("CapacitorWifi", "Failed to bind process to network: " + e.getMessage());
355
348
  }
356
- },
357
- 500
358
- );
359
- }
349
+ } catch (Exception e) {
350
+ // Log error but don't fail the connection
351
+ android.util.Log.e("CapacitorWifi", "Failed to bind process to network: " + e.getMessage());
352
+ }
353
+ },
354
+ 500
355
+ );
360
356
  }
361
357
 
362
358
  call.resolve();
@@ -370,7 +366,7 @@ public class CapacitorWifiPlugin extends Plugin {
370
366
  try {
371
367
  // Unbind from network if we were bound
372
368
  synchronized (boundNetworkLock) {
373
- if (boundNetwork != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
369
+ if (boundNetwork != null) {
374
370
  connectivityManager.bindProcessToNetwork(null);
375
371
  boundNetwork = null;
376
372
  android.util.Log.d("CapacitorWifi", "Unbound process from network");
@@ -432,19 +428,11 @@ public class CapacitorWifiPlugin extends Plugin {
432
428
  try {
433
429
  String ipAddress = null;
434
430
 
435
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
436
- Network network = connectivityManager.getActiveNetwork();
437
- if (network != null) {
438
- NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network);
439
- if (capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
440
- ipAddress = getWifiIpAddress();
441
- }
442
- }
443
- } else {
444
- WifiInfo wifiInfo = wifiManager.getConnectionInfo();
445
- if (wifiInfo != null) {
446
- int ip = wifiInfo.getIpAddress();
447
- ipAddress = String.format("%d.%d.%d.%d", (ip & 0xff), ((ip >> 8) & 0xff), ((ip >> 16) & 0xff), ((ip >> 24) & 0xff));
431
+ Network network = connectivityManager.getActiveNetwork();
432
+ if (network != null) {
433
+ NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network);
434
+ if (capabilities != null && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
435
+ ipAddress = getWifiIpAddress();
448
436
  }
449
437
  }
450
438
 
@@ -6,7 +6,7 @@ import CoreLocation
6
6
 
7
7
  @objc(CapacitorWifiPlugin)
8
8
  public class CapacitorWifiPlugin: CAPPlugin, CAPBridgedPlugin {
9
- private let pluginVersion: String = "8.1.0"
9
+ private let pluginVersion: String = "8.1.2"
10
10
  public let identifier = "CapacitorWifiPlugin"
11
11
  public let jsName = "CapacitorWifi"
12
12
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-wifi",
3
- "version": "8.1.0",
3
+ "version": "8.1.2",
4
4
  "description": "Manage WiFi connectivity for your Capacitor app",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",