wifidirectplugin 0.0.8 → 0.0.9
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.
|
@@ -31,6 +31,7 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
31
31
|
private IntentFilter intentFilter;
|
|
32
32
|
|
|
33
33
|
private final Handler handler = new Handler(Looper.getMainLooper());
|
|
34
|
+
private boolean isConnecting = false;
|
|
34
35
|
|
|
35
36
|
@Override
|
|
36
37
|
public void load() {
|
|
@@ -57,16 +58,28 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
private void cancelExistingConnection(Runnable onComplete) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
if (!isConnecting) {
|
|
62
|
+
onComplete.run();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
|
|
68
|
+
manager.cancelConnect(channel, new WifiP2pManager.ActionListener() {
|
|
69
|
+
@Override
|
|
70
|
+
public void onSuccess() {
|
|
71
|
+
onComplete.run();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Override
|
|
75
|
+
public void onFailure(int reason) {
|
|
76
|
+
onComplete.run();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} catch (Throwable t) {
|
|
80
|
+
isConnecting = false;
|
|
81
|
+
onComplete.run();
|
|
82
|
+
}
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
@PluginMethod
|
|
@@ -136,6 +149,8 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
136
149
|
}
|
|
137
150
|
|
|
138
151
|
private void connectToDevice(WifiP2pDevice device, PluginCall call) {
|
|
152
|
+
isConnecting = true;
|
|
153
|
+
|
|
139
154
|
WifiP2pConfig config = new WifiP2pConfig();
|
|
140
155
|
config.deviceAddress = device.deviceAddress;
|
|
141
156
|
|