community-cordova-plugin-wifi 1.0.8 → 1.0.10
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.
- package/.idea/workspace.xml +29 -24
- package/package.json +2 -1
- package/plugin.xml +4 -4
- package/src/android/WifiPlugin.java +146 -0
- package/types/index.d.ts +32 -0
- package/www/plugin.js +10 -0
package/.idea/workspace.xml
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
<change beforePath="$PROJECT_DIR$/plugin.xml" beforeDir="false" afterPath="$PROJECT_DIR$/plugin.xml" afterDir="false" />
|
|
11
11
|
<change beforePath="$PROJECT_DIR$/src/android/PingTask.java" beforeDir="false" />
|
|
12
12
|
<change beforePath="$PROJECT_DIR$/src/android/WifiPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/WifiPlugin.java" afterDir="false" />
|
|
13
|
+
<change beforePath="$PROJECT_DIR$/types/index.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/types/index.d.ts" afterDir="false" />
|
|
14
|
+
<change beforePath="$PROJECT_DIR$/www/plugin.js" beforeDir="false" afterPath="$PROJECT_DIR$/www/plugin.js" afterDir="false" />
|
|
13
15
|
</list>
|
|
14
16
|
<option name="SHOW_DIALOG" value="false" />
|
|
15
17
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -25,12 +27,12 @@
|
|
|
25
27
|
"assignee": "EYALIN"
|
|
26
28
|
}
|
|
27
29
|
}</component>
|
|
28
|
-
<component name="GithubPullRequestsUISettings"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
<component name="GithubPullRequestsUISettings">{
|
|
31
|
+
"selectedUrlAndAccountId": {
|
|
32
|
+
"url": "https://github.com/EYALIN/community-cordova-plugin-cpu.git",
|
|
33
|
+
"accountId": "554cb47e-af38-4ebf-8263-4816fa246779"
|
|
32
34
|
}
|
|
33
|
-
}
|
|
35
|
+
}</component>
|
|
34
36
|
<component name="MarkdownSettingsMigration">
|
|
35
37
|
<option name="stateVersion" value="1" />
|
|
36
38
|
</component>
|
|
@@ -43,24 +45,24 @@
|
|
|
43
45
|
<option name="hideEmptyMiddlePackages" value="true" />
|
|
44
46
|
<option name="showLibraryContents" value="true" />
|
|
45
47
|
</component>
|
|
46
|
-
<component name="PropertiesComponent"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
<component name="PropertiesComponent">{
|
|
49
|
+
"keyToString": {
|
|
50
|
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
|
51
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
52
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
53
|
+
"WebServerToolWindowFactoryState": "false",
|
|
54
|
+
"git-widget-placeholder": "main",
|
|
55
|
+
"last_opened_file_path": "/Volumes/Development/Git/forked/community-cordova-plugin-wifi/src/android",
|
|
56
|
+
"node.js.detected.package.eslint": "true",
|
|
57
|
+
"node.js.detected.package.tslint": "true",
|
|
58
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
59
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
60
|
+
"nodejs_package_manager_path": "npm",
|
|
61
|
+
"settings.editor.selected.configurable": "preferences.lookFeel",
|
|
62
|
+
"ts.external.directory.path": "/Applications/WebStorm.app/Contents/plugins/javascript-plugin/jsLanguageServicesImpl/external",
|
|
63
|
+
"vue.rearranger.settings.migration": "true"
|
|
62
64
|
}
|
|
63
|
-
}
|
|
65
|
+
}</component>
|
|
64
66
|
<component name="RecentsManager">
|
|
65
67
|
<key name="CopyFile.RECENT_KEYS">
|
|
66
68
|
<recent name="$PROJECT_DIR$/src/android" />
|
|
@@ -73,7 +75,7 @@
|
|
|
73
75
|
<component name="SharedIndexes">
|
|
74
76
|
<attachedChunks>
|
|
75
77
|
<set>
|
|
76
|
-
<option value="bundled-js-predefined-d6986cc7102b-
|
|
78
|
+
<option value="bundled-js-predefined-d6986cc7102b-09060db00ec0-JavaScript-WS-251.29188.1" />
|
|
77
79
|
</set>
|
|
78
80
|
</attachedChunks>
|
|
79
81
|
</component>
|
|
@@ -111,7 +113,10 @@
|
|
|
111
113
|
<workItem from="1725518446319" duration="57000" />
|
|
112
114
|
<workItem from="1725611591287" duration="21000" />
|
|
113
115
|
<workItem from="1731667624026" duration="1162000" />
|
|
114
|
-
<workItem from="1751262475820" duration="
|
|
116
|
+
<workItem from="1751262475820" duration="4500000" />
|
|
117
|
+
<workItem from="1768033742670" duration="45000" />
|
|
118
|
+
<workItem from="1768033992593" duration="17000" />
|
|
119
|
+
<workItem from="1768035366231" duration="829000" />
|
|
115
120
|
</task>
|
|
116
121
|
<task id="LOCAL-00001" summary="update plugin">
|
|
117
122
|
<option name="closed" value="true" />
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
1
|
+
<?xml version="1.0.10" encoding="UTF-8"?>
|
|
2
2
|
|
|
3
3
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
id="community-cordova-plugin-wifi"
|
|
5
|
-
version="1.0.
|
|
5
|
+
version="1.0.10">
|
|
6
6
|
<name>Cordova Plugin Wifi</name>
|
|
7
7
|
<description></description>
|
|
8
8
|
<license>MIT</license>
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
</feature>
|
|
54
54
|
</config-file>
|
|
55
55
|
|
|
56
|
-
<config-file target="
|
|
56
|
+
<config-file target="App/App-Info.plist" parent="NSLocationWhenInUseUsageDescription">
|
|
57
57
|
<string>Your location is used to access WiFi information.</string>
|
|
58
58
|
</config-file>
|
|
59
|
-
<config-file target="
|
|
59
|
+
<config-file target="App/App-Info.plist" parent="NSLocationAlwaysAndWhenInUseUsageDescription">
|
|
60
60
|
<string>Your location is used to access WiFi information even when the app is in the background.</string>
|
|
61
61
|
</config-file>
|
|
62
62
|
|
|
@@ -2,6 +2,7 @@ package wifiplugin;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.net.ConnectivityManager;
|
|
5
|
+
import android.net.DhcpInfo;
|
|
5
6
|
import android.net.Network;
|
|
6
7
|
import android.net.NetworkCapabilities;
|
|
7
8
|
import android.net.NetworkRequest;
|
|
@@ -10,6 +11,7 @@ import android.net.wifi.WifiConfiguration;
|
|
|
10
11
|
import android.net.wifi.WifiInfo;
|
|
11
12
|
import android.net.wifi.WifiManager;
|
|
12
13
|
import android.os.Build;
|
|
14
|
+
import android.text.format.Formatter;
|
|
13
15
|
import androidx.annotation.RequiresApi;
|
|
14
16
|
import android.net.wifi.WifiNetworkSpecifier;
|
|
15
17
|
import android.net.NetworkSpecifier;
|
|
@@ -79,6 +81,9 @@ public class WifiPlugin extends CordovaPlugin {
|
|
|
79
81
|
} else if ("wifiToggle".equals(action)) {
|
|
80
82
|
wifiToggle(callbackContext);
|
|
81
83
|
return true;
|
|
84
|
+
} else if ("getNetworkDiagnostics".equals(action)) {
|
|
85
|
+
getNetworkDiagnostics(callbackContext);
|
|
86
|
+
return true;
|
|
82
87
|
}
|
|
83
88
|
return false;
|
|
84
89
|
}
|
|
@@ -279,4 +284,145 @@ WifiManager wifiManager = (WifiManager) cordova.getActivity().getApplicationCont
|
|
|
279
284
|
wifiManager.disconnect();
|
|
280
285
|
callbackContext.success("Disconnected from Wi-Fi network");
|
|
281
286
|
}
|
|
287
|
+
|
|
288
|
+
private void getNetworkDiagnostics(CallbackContext callbackContext) {
|
|
289
|
+
cordova.getThreadPool().execute(() -> {
|
|
290
|
+
try {
|
|
291
|
+
JSONObject diagnostics = new JSONObject();
|
|
292
|
+
Context context = cordova.getActivity().getApplicationContext();
|
|
293
|
+
|
|
294
|
+
// Get connectivity information
|
|
295
|
+
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
296
|
+
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
|
297
|
+
|
|
298
|
+
// Connection status
|
|
299
|
+
JSONObject connectionStatus = new JSONObject();
|
|
300
|
+
boolean isConnectedToInternet = false;
|
|
301
|
+
boolean isConnectedToWifi = false;
|
|
302
|
+
String connectionType = "None";
|
|
303
|
+
|
|
304
|
+
if (connectivityManager != null) {
|
|
305
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
306
|
+
Network network = connectivityManager.getActiveNetwork();
|
|
307
|
+
if (network != null) {
|
|
308
|
+
NetworkCapabilities networkCapabilities = connectivityManager.getNetworkCapabilities(network);
|
|
309
|
+
if (networkCapabilities != null) {
|
|
310
|
+
isConnectedToInternet = networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
|
311
|
+
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
|
|
312
|
+
isConnectedToWifi = networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI);
|
|
313
|
+
|
|
314
|
+
if (isConnectedToWifi) {
|
|
315
|
+
connectionType = "WiFi";
|
|
316
|
+
} else if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
|
|
317
|
+
connectionType = "Cellular";
|
|
318
|
+
} else if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) {
|
|
319
|
+
connectionType = "VPN";
|
|
320
|
+
} else if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
|
|
321
|
+
connectionType = "Ethernet";
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
} else {
|
|
326
|
+
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
|
327
|
+
isConnectedToInternet = activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
|
328
|
+
if (activeNetworkInfo != null) {
|
|
329
|
+
connectionType = activeNetworkInfo.getTypeName();
|
|
330
|
+
isConnectedToWifi = activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
connectionStatus.put("isConnectedToInternet", isConnectedToInternet);
|
|
336
|
+
connectionStatus.put("isConnectedToWifi", isConnectedToWifi);
|
|
337
|
+
connectionStatus.put("connectionType", connectionType);
|
|
338
|
+
connectionStatus.put("isWifiEnabled", wifiManager != null && wifiManager.isWifiEnabled());
|
|
339
|
+
diagnostics.put("connectionStatus", connectionStatus);
|
|
340
|
+
|
|
341
|
+
// WiFi details (if connected)
|
|
342
|
+
if (isConnectedToWifi && wifiManager != null) {
|
|
343
|
+
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
|
344
|
+
DhcpInfo dhcpInfo = wifiManager.getDhcpInfo();
|
|
345
|
+
|
|
346
|
+
JSONObject wifiDetails = new JSONObject();
|
|
347
|
+
wifiDetails.put("ssid", wifiInfo.getSSID().replace("\"", ""));
|
|
348
|
+
wifiDetails.put("bssid", wifiInfo.getBSSID());
|
|
349
|
+
wifiDetails.put("ipAddress", Formatter.formatIpAddress(wifiInfo.getIpAddress()));
|
|
350
|
+
wifiDetails.put("macAddress", wifiInfo.getMacAddress());
|
|
351
|
+
wifiDetails.put("linkSpeed", wifiInfo.getLinkSpeed());
|
|
352
|
+
wifiDetails.put("linkSpeedUnit", "Mbps");
|
|
353
|
+
wifiDetails.put("rssi", wifiInfo.getRssi());
|
|
354
|
+
wifiDetails.put("frequency", wifiInfo.getFrequency());
|
|
355
|
+
wifiDetails.put("channel", getChannelFromFrequency(wifiInfo.getFrequency()));
|
|
356
|
+
wifiDetails.put("gateway", Formatter.formatIpAddress(dhcpInfo.gateway));
|
|
357
|
+
wifiDetails.put("dns1", Formatter.formatIpAddress(dhcpInfo.dns1));
|
|
358
|
+
wifiDetails.put("dns2", Formatter.formatIpAddress(dhcpInfo.dns2));
|
|
359
|
+
wifiDetails.put("networkId", wifiInfo.getNetworkId());
|
|
360
|
+
|
|
361
|
+
// Signal quality
|
|
362
|
+
int signalLevel = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 5);
|
|
363
|
+
String signalQuality;
|
|
364
|
+
if (signalLevel >= 4) signalQuality = "excellent";
|
|
365
|
+
else if (signalLevel >= 3) signalQuality = "good";
|
|
366
|
+
else if (signalLevel >= 2) signalQuality = "fair";
|
|
367
|
+
else signalQuality = "poor";
|
|
368
|
+
wifiDetails.put("signalLevel", signalLevel);
|
|
369
|
+
wifiDetails.put("signalQuality", signalQuality);
|
|
370
|
+
|
|
371
|
+
diagnostics.put("wifiDetails", wifiDetails);
|
|
372
|
+
} else {
|
|
373
|
+
diagnostics.put("wifiDetails", JSONObject.NULL);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Network performance indicators
|
|
377
|
+
JSONObject performance = new JSONObject();
|
|
378
|
+
if (isConnectedToWifi && wifiManager != null) {
|
|
379
|
+
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
|
380
|
+
int rssi = wifiInfo.getRssi();
|
|
381
|
+
int linkSpeed = wifiInfo.getLinkSpeed();
|
|
382
|
+
|
|
383
|
+
// Overall network health score (0-100)
|
|
384
|
+
int healthScore = 0;
|
|
385
|
+
if (rssi >= -50) healthScore += 40;
|
|
386
|
+
else if (rssi >= -60) healthScore += 30;
|
|
387
|
+
else if (rssi >= -70) healthScore += 20;
|
|
388
|
+
else healthScore += 10;
|
|
389
|
+
|
|
390
|
+
if (linkSpeed >= 100) healthScore += 40;
|
|
391
|
+
else if (linkSpeed >= 50) healthScore += 30;
|
|
392
|
+
else if (linkSpeed >= 20) healthScore += 20;
|
|
393
|
+
else healthScore += 10;
|
|
394
|
+
|
|
395
|
+
if (isConnectedToInternet) healthScore += 20;
|
|
396
|
+
|
|
397
|
+
performance.put("healthScore", healthScore);
|
|
398
|
+
|
|
399
|
+
// Determine status
|
|
400
|
+
String status;
|
|
401
|
+
if (healthScore >= 80) status = "excellent";
|
|
402
|
+
else if (healthScore >= 60) status = "good";
|
|
403
|
+
else if (healthScore >= 40) status = "fair";
|
|
404
|
+
else status = "poor";
|
|
405
|
+
performance.put("status", status);
|
|
406
|
+
} else {
|
|
407
|
+
performance.put("healthScore", 0);
|
|
408
|
+
performance.put("status", "disconnected");
|
|
409
|
+
}
|
|
410
|
+
diagnostics.put("performance", performance);
|
|
411
|
+
|
|
412
|
+
callbackContext.success(diagnostics);
|
|
413
|
+
} catch (Exception e) {
|
|
414
|
+
Log.e(TAG, "Error getting network diagnostics", e);
|
|
415
|
+
callbackContext.error("Error getting network diagnostics: " + e.getMessage());
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
private int getChannelFromFrequency(int frequency) {
|
|
421
|
+
if (frequency >= 2412 && frequency <= 2484) {
|
|
422
|
+
return (frequency - 2412) / 5 + 1;
|
|
423
|
+
} else if (frequency >= 5170 && frequency <= 5825) {
|
|
424
|
+
return (frequency - 5170) / 5 + 34;
|
|
425
|
+
}
|
|
426
|
+
return -1;
|
|
427
|
+
}
|
|
282
428
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -78,6 +78,37 @@ export interface IpInfo {
|
|
|
78
78
|
zipcode?: string;
|
|
79
79
|
state?: string;
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
export interface NetworkDiagnostics {
|
|
83
|
+
connectionStatus: {
|
|
84
|
+
isConnectedToInternet: boolean;
|
|
85
|
+
isConnectedToWifi: boolean;
|
|
86
|
+
connectionType: string;
|
|
87
|
+
isWifiEnabled: boolean;
|
|
88
|
+
};
|
|
89
|
+
wifiDetails: {
|
|
90
|
+
ssid: string;
|
|
91
|
+
bssid: string;
|
|
92
|
+
ipAddress: string;
|
|
93
|
+
macAddress: string;
|
|
94
|
+
linkSpeed: number;
|
|
95
|
+
linkSpeedUnit: string;
|
|
96
|
+
rssi: number;
|
|
97
|
+
frequency: number;
|
|
98
|
+
channel: number;
|
|
99
|
+
gateway: string;
|
|
100
|
+
dns1: string;
|
|
101
|
+
dns2: string;
|
|
102
|
+
networkId: number;
|
|
103
|
+
signalLevel: number;
|
|
104
|
+
signalQuality: string;
|
|
105
|
+
} | null;
|
|
106
|
+
performance: {
|
|
107
|
+
healthScore: number;
|
|
108
|
+
status: string;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
81
112
|
export default class WifiManager {
|
|
82
113
|
getWifiList(): Promise<WifiNetwork[]>;
|
|
83
114
|
getIpInfo(): Promise<IpInfo[]>;
|
|
@@ -94,5 +125,6 @@ export default class WifiManager {
|
|
|
94
125
|
getWifiStrength(): Promise<number>;
|
|
95
126
|
getSignalStrength(): Promise<number>;
|
|
96
127
|
ping(address: string, count: number, timeout: number, successCallback: (response: PingResponse) => void, errorCallback: (error: any) => void): void;
|
|
128
|
+
getNetworkDiagnostics(): Promise<NetworkDiagnostics>;
|
|
97
129
|
|
|
98
130
|
}
|
package/www/plugin.js
CHANGED
|
@@ -96,6 +96,16 @@ class WifiManager {
|
|
|
96
96
|
exec(resolve, reject, PLUGIN_NAME, 'getConnectedDevices', []);
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get comprehensive network diagnostics
|
|
102
|
+
* @returns {Promise<Object>} Network diagnostic information including connection status, WiFi details, and performance metrics
|
|
103
|
+
*/
|
|
104
|
+
getNetworkDiagnostics() {
|
|
105
|
+
return new Promise((resolve, reject) => {
|
|
106
|
+
exec(resolve, reject, PLUGIN_NAME, 'getNetworkDiagnostics', []);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
99
109
|
}
|
|
100
110
|
|
|
101
111
|
module.exports = new WifiManager();
|