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(); } } }
/** 发命令让记录仪切换为sta状态 */ private void apStatrt() { final String password = "******"; CameraMessage cameraMessage = new CameraMessage( 1543, new CameraMessageCallback() { @Override public void onReceiveErrorMessage( CameraMessage cameraMessage, JSONObject jsonObject) {} @Override public void onReceiveMessage(CameraMessage cameraMessage, JSONObject jsonObject) { // wifiAp.startWifiAp(ssid, password); Constant.token = 0; RemoteCamHelper.getRemoteCam().closeChannel(); } @Override public void onReceiveNotification(JSONObject jsonObject) {} }); cameraMessage.put("type", "sta"); cameraMessage.put("ssid", ssid); cameraMessage.put("password", password); cameraMessage.put("times", 30); remoteCamHelper.sendCommand(cameraMessage); Logger.e("Send 'sta' command to recorder!"); // CheckUDPService.chekUdpTimeOut(); }
@Override public void onError(int what, String extra) { Logger.e("CDEOnError. what: " + what + "extra: " + extra); if (201 == what) { if (LeautoCameraAppLication.isConnectCamera) { stopAndStartPlay(); } } }
/** * 删除下载不完整的文件 * * @param path */ public static void deleteIntactFile(String path) { File file = new File(path); if (file.exists()) { file.delete(); if (!file.exists()) { Logger.i(TAG, "下载不成功,已将文件删除--" + path); } else { Logger.e(TAG, "下载不成功,文件未成功删除--" + path); } } }
/** * 初始化成功 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(); // } } } }
@UiThread void stopAndStartPlay() { Logger.e(TAG, "stopAndStartPlay"); if (mPlayer != null) { mPlayer.stop(); mPlayer.play(liveUrl); } // mPlayer.play(mActivity, video_layout, liveUrl, LeHighPlayer.PLAY_TYPE_RTSP, // LeHighPlayer.ENCODE_TYPE_SOFT); // mPlayer.play(mActivity, video_layout, liveUrl, MedIaPlayerManager.PLAY_TYPE_LIVE, // MedIaPlayerManager.ENCODE_TYPE_SOFT); }
public void onEventBackgroundThread(EventOrPhotoRemovedNotificationEvent event) { Logger.e(TAG, "删除event 或者 photo了 param :" + event.getParam()); Logger.e(TAG, "list :" + homePhotoInfos.toString()); if (!TextUtils.isEmpty(event.getParam())) { String jsonStr = event.getParam().replace("[", "").replace("]", ""); FileRemovedInfo removedInfo = GsonUtils.fromJson(jsonStr, FileRemovedInfo.class); String thumbName = removedInfo.getFilename(); if (thumbName.endsWith("A.MP4")) { thumbName = thumbName.replace("A.MP4", "T.JPG"); } else if (thumbName.endsWith("A.JPG")) { thumbName = thumbName.replace("A.JPG", "T.JPG"); } if (homePhotoInfos != null && homePhotoInfos.size() > 0) { for (HomePhotoInfo info : homePhotoInfos) { if (info.getOrginalName().equals(thumbName)) { remoevdHomeInfos.add(info); } } Logger.e(TAG, "removedHomeInfos :" + remoevdHomeInfos.toString()); homePhotoInfos.removeAll(remoevdHomeInfos); remoevdHomeInfos.clear(); } } }
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); } }
/** * 取消相同的tag请求 * * @param tag */ public static void cancelSameTagCall(Object tag) { if (mClient != null) { Dispatcher dispatcher = mClient.dispatcher(); for (Call call : dispatcher.queuedCalls()) { if (tag.equals(call.request().tag())) { call.cancel(); } } for (Call call : dispatcher.runningCalls()) { if (tag.equals(call.request().tag())) { call.cancel(); } } setCancel(true); } else { Logger.e(TAG, "cancelSameTagCall mClient 为 null"); } }
public void onEventMainThread(AddEventFileEvent event) { Logger.e("记录仪有新文件产生了"); if (!TextUtils.isEmpty(event.getParam())) { String jsonStr = event.getParam().replace("[", "").replace("]", ""); AddFileInfo addfileInfo = GsonUtils.fromJson(jsonStr, AddFileInfo.class); String thumbPhoto; HomePhotoInfo homePhotoInfo; if (addfileInfo.getFilename().contains("MP4")) { thumbPhoto = addfileInfo.getFilename().replace("A.MP4", "T.JPG"); homePhotoInfo = new HomePhotoInfo(thumbPhoto, HomePhotoInfo.EVENT_PIC); } else { thumbPhoto = addfileInfo.getFilename().replace("A.JPG", "T.JPG"); homePhotoInfo = new HomePhotoInfo(thumbPhoto, HomePhotoInfo.NORMAL_PIC); } homePhotoInfos.add(0, homePhotoInfo); showPhoto(); } }
public void onEventMainThread(NotificationEvent event) { if (event.getType() == NotificationEvent.IDLE) { mPlayer.stop(); /* if (this.mPlayController != null) { this.mPlayController.stopPlayback(); }*/ cameraStatus = "idle"; initRecordedIcon(); } else { if (event.getType() == NotificationEvent.VF || event.getType() == NotificationEvent.RECORD) { if (!mPlayer.isPlaying()) { mPlayer.play(liveUrl); } if (event.getType() == NotificationEvent.VF) { cameraStatus = "vf"; } if (event.getType() == NotificationEvent.RECORD) { cameraStatus = "record"; } initRecordedIcon(); } } if (event.getType() == NotificationEvent.SD_INSERTED) { getPhotoDataFromCamera(); } if (event.getType() == NotificationEvent.GET_FILE_FAIL) { Logger.e("失败!!!!!!!!!!!!!!!!!!!!!!!!!!!"); hideLoading(); showToastSafe(getResources().getString(R.string.download_to_phone_error)); if (runnable != null) { handler_.removeCallbacks(runnable); } } if (event.getType() == NotificationEvent.GET_FILE_COMPLETE) { hideLoading(); showToastSafe(getResources().getString(R.string.take_photo_and_download)); if (runnable != null) { handler_.removeCallbacks(runnable); } } }
@Override public void onPause() { super.onPause(); Logger.e(TAG, "onPause"); Log.e(TAG, " <============== onPause"); FRAGMENTISHIDEN = true; hideReFreshAnimation(); cameraStatus = ""; initRecordedIcon(); // mPlayer.suspend(); /* if (this.mPlayController != null) { //Modify by donghongwei 20160405 for LECAMERA-402 begin this.mPlayController.stopPlayback(); //Modify by donghongwei 20160405 for LECAMERA-402 begin }*/ DeviceDiscovery.getInstance().stopDiscovery(); }
public void onEventMainThread(UDPTimeOutEvent event) { Logger.e( "CameraFragment UDPTimeOutEvent CheckUDPServiceIsOk=" + LeautoCameraAppLication.CheckUDPServiceIsOk); isPhoneIsAp = false; FRAGMENTISHIDEN = false; SpUtils.getInstance(mActivity.getApplicationContext()) .getStringValue(com.leautolink.leautocamera.config.Constant.WIFI_SSID); new Thread( new Runnable() { @Override public void run() { admin.forget(ssid); } }) .start(); if (LeautoCameraAppLication.CheckUDPServiceIsOk) { // mActivity.stopService(new Intent(mActivity, CheckUDPService.class)); } }
@Override public void onResume() { super.onResume(); showPhoto(); if (LeautoCameraAppLication.isConnectCamera) { startReFreshAnimation(); DeviceDiscovery.getInstance().startDiscovery(); if (mPlayer != null) { mPlayer.start(); if (TextUtils.isEmpty(cameraStatus)) { getCameraStatus(); } else { initRecordedIcon(); } } } else { mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); if (mPlayer != null) { mPlayer.stop(); } } Logger.e("onResume ------------->"); }
@Override public void onPrepared() { Logger.e(TAG, "onPrepared...."); initRecordedIcon(); }
public void onEventMainThread(AutoConnectToCameraEvent event) { Logger.e("onEventMainThread isConnectCamera=" + event.isConnectCamera()); if (event.isConnectCamera() == 0) { // admin.closeWifi(); } }
@Override public void onInfo(int what, long extra) { hideReFreshAnimation(); Logger.e(TAG, "onInfo...."); }
@Override public void onResume() { super.onResume(); Logger.e(TAG, "onResume"); StatisticsUtil.getInstance().recordActivityStart(this.getClass().getSimpleName()); }
/** * 密码错误 * * @param event */ public void onEventMainThread(ConnectionAuthenticateEvent event) { Logger.e("debug_wifi", "密码错误 , 认证失败"); creatInputDialog(tempSSID, getResources().getString(R.string.passwork_incorrect)); }