wifidirectplugin 0.0.1 → 0.0.3

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.
@@ -7,6 +7,9 @@ import android.net.wifi.p2p.WifiP2pDevice;
7
7
  import android.net.wifi.p2p.WifiP2pManager;
8
8
  import android.net.wifi.p2p.WifiP2pConfig;
9
9
  import android.net.wifi.p2p.WifiP2pDeviceList;
10
+ import android.net.wifi.WifiManager;
11
+ import android.content.Intent;
12
+ import android.os.Build;
10
13
 
11
14
  import com.getcapacitor.JSObject;
12
15
  import com.getcapacitor.Logger;
@@ -41,6 +44,20 @@ public class WifiDirectPlugin extends Plugin {
41
44
 
42
45
  @PluginMethod
43
46
  public void discoverAndConnect(PluginCall call) {
47
+ WifiManager wifiManager = (WifiManager) getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
48
+
49
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
50
+ if (!wifiManager.isWifiEnabled()) {
51
+ // Android 10 이상부터는 WiFi 직접 켜기 불가, 설정 화면 이동 요청
52
+ Intent panelIntent = new Intent(android.provider.Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
53
+ panelIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
54
+ getContext().startActivity(panelIntent);
55
+
56
+ call.reject("WiFi is disabled. Please enable WiFi first.");
57
+ return;
58
+ }
59
+ }
60
+
44
61
  receiver = new BroadcastReceiver() {
45
62
  @Override
46
63
  public void onReceive(Context context, android.content.Intent intent) {
@@ -58,6 +75,7 @@ public class WifiDirectPlugin extends Plugin {
58
75
  }
59
76
  if (targetDevice != null) {
60
77
  connectToDevice(targetDevice, call);
78
+ Logger.info("Found and connecting to device: " + targetDevice.deviceName);
61
79
  } else {
62
80
  call.reject("No Direct-LINKVUE device found");
63
81
  }
@@ -68,20 +86,6 @@ public class WifiDirectPlugin extends Plugin {
68
86
  };
69
87
 
70
88
  getContext().registerReceiver(receiver, intentFilter);
71
-
72
- manager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
73
- @Override
74
- public void onSuccess() {
75
- JSObject ret = new JSObject();
76
- ret.put("message", "Discovery started");
77
- call.resolve(ret);
78
- }
79
-
80
- @Override
81
- public void onFailure(int reason) {
82
- call.reject("Peer discovery failed, reason: " + reason);
83
- }
84
- });
85
89
  }
86
90
 
87
91
  private void connectToDevice(WifiP2pDevice device, PluginCall call) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wifidirectplugin",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "HT-Installer Wifi Direct Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",