wifidirectplugin 0.0.5 → 0.0.7
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,11 +31,11 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
31
31
|
@Override
|
|
32
32
|
public void load() {
|
|
33
33
|
// WifiP2pManager 초기화
|
|
34
|
-
boolean isP2pSupported = getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
|
|
35
|
-
if (!isP2pSupported) {
|
|
36
|
-
Logger.error("WifiDirectPlugin WiFi P2P not supported on this device");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
34
|
+
// boolean isP2pSupported = getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
|
|
35
|
+
// if (!isP2pSupported) {
|
|
36
|
+
// Logger.error("WifiDirectPlugin WiFi P2P not supported on this device");
|
|
37
|
+
// return;
|
|
38
|
+
// }
|
|
39
39
|
Logger.info("WifiDirectPlugin loaded");
|
|
40
40
|
manager = (WifiP2pManager) getContext().getSystemService(Context.WIFI_P2P_SERVICE);
|
|
41
41
|
channel = manager.initialize(getContext(), getActivity().getMainLooper(), null);
|
|
@@ -92,6 +92,22 @@ public class WifiDirectPlugin extends Plugin {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
getContext().registerReceiver(receiver, intentFilter);
|
|
95
|
+
|
|
96
|
+
manager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
|
|
97
|
+
@Override
|
|
98
|
+
public void onSuccess() {
|
|
99
|
+
Logger.info("Peer discovery started");
|
|
100
|
+
JSObject ret = new JSObject();
|
|
101
|
+
ret.put("message", "Discovery started");
|
|
102
|
+
call.resolve(ret);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Override
|
|
106
|
+
public void onFailure(int reason) {
|
|
107
|
+
call.reject("Peer discovery failed, reason: " + reason);
|
|
108
|
+
getContext().unregisterReceiver(receiver);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
95
111
|
}
|
|
96
112
|
|
|
97
113
|
private void connectToDevice(WifiP2pDevice device, PluginCall call) {
|