wifidirectplugin 1.2.2 → 1.2.4
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.
|
@@ -50,10 +50,19 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
50
50
|
public void load() {
|
|
51
51
|
context = getContext();
|
|
52
52
|
manager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE);
|
|
53
|
-
channel = manager.initialize(context, context.getMainLooper(),
|
|
54
|
-
|
|
53
|
+
channel = manager.initialize(context, context.getMainLooper(), new WifiP2pManager.ChannelListener() {
|
|
54
|
+
@Override
|
|
55
|
+
public void onChannelDisconnected() {
|
|
56
|
+
Log.e(TAG, "P2P Channel disconnected");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
55
60
|
IntentFilter intentFilter = new IntentFilter();
|
|
56
61
|
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
|
|
62
|
+
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
|
|
63
|
+
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
|
|
64
|
+
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
|
|
65
|
+
|
|
57
66
|
context.registerReceiver(wifiP2pReceiver, intentFilter);
|
|
58
67
|
}
|
|
59
68
|
|
|
@@ -84,11 +93,11 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
84
93
|
JSONArray devicesJson = new JSONArray();
|
|
85
94
|
for(WifiP2pDevice device: peerWifiDirDevices) {
|
|
86
95
|
try {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
if (targetDeviceName != null && !targetDeviceName.isEmpty()) {
|
|
97
|
+
if (!device.deviceName.toUpperCase().contains(targetDeviceName.toUpperCase())) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
92
101
|
JSONObject deviceJson = new JSONObject();
|
|
93
102
|
deviceJson.put("deviceName", device.deviceName);
|
|
94
103
|
deviceJson.put("deviceAddress", device.deviceAddress);
|