Example #1
0
 private void phoneIsAp() {
   ssid = admin.getSSID();
   Logger.e("PHONE IS AP   " + ssid);
   if (admin.isConnectCamera(ssid, admin.getBSSID())
       || WifiApAdmin.isWifiApEnabled(
           (WifiManager) mActivity.getSystemService(Context.WIFI_SERVICE))) {
     //            Logger.e("开始切换");
     ////            switchAp();
     if (!isPhoneIsAp) {
       isPhoneIsAp = true;
       if (timer == null) {
         timer = new Timer();
         TimerTask task =
             new TimerTask() {
               @Override
               public void run() {
                 loadingLenght++;
                 if (loadingLenght < 100) {
                   updateLoading(loadingLenght);
                 } else {
                   if (timer != null) {
                     timer.cancel();
                     timer = null;
                   }
                 }
               }
             };
         timer.scheduleAtFixedRate(task, 0, 200);
       }
       apStatrt();
     }
   }
 }
Example #2
0
 @Click(R.id.bt_click_connect)
 void startConnect() {
   admin.openWifi();
   admin.startScan();
   loadingConnectPage();
   getWifiList();
 }
Example #3
0
 @Click(R.id.iv_close_connect)
 void closeConnect() {
   if (!TextUtils.isEmpty(wifiName)) {
     admin.forget(wifiName);
     cameraConnectionHelper.close();
   }
   resumeConnectPage();
   //        connectSuccess();
 }
Example #4
0
  private void getWifiList() {
    boolean isCanConnect = false;
    List<String> wifiSSIDList = new ArrayList<>();
    final List<ScanResult> scanResults = admin.getWifiList();
    if (newSacn != null) {
      newSacn.clear();
    } else {
      newSacn = new ArrayList<>();
    }
    for (ScanResult scanResult : scanResults) {
      if (WifiAdmin.isConnectCamera(getActivity(), scanResult.SSID, scanResult.BSSID)) {
        newSacn.add(scanResult);
        wifiSSIDList.add(scanResult.SSID.replace("\"", ""));
      }
    }

    wifiName =
        SpUtils.getInstance(mActivity)
            .getStringValue(com.leautolink.leautocamera.config.Constant.WIFI_SSID);
    String wifiPassword = "******";
    if (!TextUtils.isEmpty(wifiName)) {
      wifiPassword =
          SpUtils.getInstance(mActivity)
              .getStringValue(com.leautolink.leautocamera.config.Constant.WIFI_PWD);
    }

    Logger.d(
        TAG,
        "wifiName -->| "
            + wifiName
            + " wifipwd -->| "
            + wifiPassword
            + " isContains -->| "
            + wifiSSIDList.contains(wifiName));

    if (wifiSSIDList.contains(wifiName)) {
      isCanConnect = connectWifi(wifiName, wifiPassword);
      tempSSID = wifiName;
    } else if (newSacn.size() == 1) {
      inputWifiPassword(newSacn.get(0));
      return;
    }
    Logger.e(TAG, wifiName + " isCanConnect  -->| " + isCanConnect);
    if (!isCanConnect) {
      // TODO 显示wifi列表
      showWifiList(true);
    }
  }
Example #5
0
 /**
  * 初始化成功 startSession成功 , 获取sd卡的状态成功
  *
  * @param event
  */
 public void onEventMainThread(ConnectToCameraEvent event) {
   Logger.e("onEventMainThread isConnectCamera=" + event.isConnectCamera());
   if (event.isConnectCamera() && admin.isWifiEnabled()) {
     statrtPlay();
     connectSuccess();
     startReFreshAnimation();
     DeviceInfo.getInstance()
         .setContext(new WeakReference<Context>(CameraFragment.this.getActivity()));
     DeviceInfo.getInstance().getDeviceInfo();
     bt_take_photo.setEnabled(true);
     bt_go_photo.setEnabled(true);
     Logger.e("onEventMainThread FRAGMENTISHIDEN=" + FRAGMENTISHIDEN);
     autoDownLoadDataTask();
   } else {
     resumeConnectPage();
     if (mPlayer != null) {
       //                if (mPlayer.isPlaying()){
       mPlayer.stop();
       //                }
     }
   }
 }