コード例 #1
0
 public void onNetworkConnected(NetInfo net) {
   if (Closed) return;
   Log.d(TAG, "NETWORK_CONNECTED");
   connNets[net.type] = net;
   NetInfo[] nets = new NetInfo[] {net};
   if (isLeader) {
     netConnectedAtLeader(nets);
   }
   Log.d(TAG, "activateNet type=" + net.type);
   if (net.type == chosenNType) {
     if (connMgrService != null) connMgrService.activateNetwork(net);
   }
 }
コード例 #2
0
 void doWifiHotspot() {
   chosenNType = NetInfo.WiFiHotspot;
   if (connNets[NetInfo.WiFiHotspot] != null) {
     if (actNetType != NetInfo.WiFiHotspot) {
       connMgrService.activateNetwork(connNets[NetInfo.WiFiHotspot]);
     } else {
       NetInfo net = connNets[NetInfo.WiFiHotspot];
       netActivatedAtLeader(net);
       setUseSSL(peerNetData.useSSL);
     }
   } else {
     configWifi();
   }
 }
コード例 #3
0
 void doWifiDirect() {
   chosenNType = NetInfo.WiFiDirect;
   if (connNets[NetInfo.WiFiDirect] != null) {
     if (actNetType != NetInfo.WiFiDirect) {
       connMgrService.activateNetwork(connNets[NetInfo.WiFiDirect]);
     } else {
       NetInfo net = connNets[NetInfo.WiFiDirect];
       netActivatedAtLeader(net);
       setUseSSL(peerNetData.useSSL);
     }
   } else {
     Log.d(TAG, "start Wifi Direct network");
     grpMgr.createNetwork();
   }
 }
コード例 #4
0
 void doWifi() {
   Log.d(TAG, "doWifi");
   chosenNType = NetInfo.WiFi;
   if (connNets[NetInfo.WiFi] != null) {
     if (actNetType != NetInfo.WiFi) {
       connMgrService.activateNetwork(connNets[NetInfo.WiFi]);
     } else {
       NetInfo net = connNets[NetInfo.WiFi];
       netActivatedAtLeader(net);
       setUseSSL(peerNetData.useSSL);
     }
   } else {
     configWifi();
   }
 }
コード例 #5
0
  void setupWifiConn(PeerNetInfo qrData) {
    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    /*
     * WifiInfo winfo = wifiManager.getConnectionInfo(); boolean match =
     * qrData.ssid.equals(winfo.getSSID()); //sometimes the above winfo is
     * encoded strangely, further verify if (!match) {
     * List<WifiConfiguration> existingConfigs = wifiManager
     * .getConfiguredNetworks(); for (WifiConfiguration ec :
     * existingConfigs) { if (ec.SSID.equals(qrData.ssid)) { match = true;
     * break; } } } if (winfo != null && match) {
     */
    // NetInfo connWifi = connNets[NetInfo.WiFi];
    // if(connWifi!=null&&connWifi.name!=null&&connWifi.name.equals(qrData.ssid))
    // {

    boolean match = false;
    NetInfo netWifi = connNets[NetInfo.WiFi];
    if (netWifi != null && netWifi.name != null) {
      String name1 = netWifi.name.trim();
      String name2 = qrData.ssid.trim();
      Log.d(TAG, "ssids = " + name1 + ", " + name2);
      name1 = trimQuote(name1);
      name2 = trimQuote(name2);
      Log.d(TAG, "ssids2 = " + name1 + ", " + name2);
      if (name1.equals(name2)) {
        match = true;
      }
    }
    if (match) {
      // already connect to the right wifi net
      Log.d(TAG, "already connect to right wifi");
      if (actNetType != NetInfo.WiFi) {
        connMgrService.activateNetwork(connNets[NetInfo.WiFi]);
      } else {
        setUseSSL(qrData.useSSL);
      }
    } else {
      Log.d(TAG, "start connect to wifi");
      new WifiConnector(this, wifiManager).execute(qrData);
    }
  }