Showing
8 changed files
with
320 additions
and
62 deletions
| 1 | +package com.gimi.common.cinema.utils; | |
| 2 | + | |
| 3 | +import java.io.InputStream; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by wugian on 2017/6/7. | |
| 7 | + */ | |
| 8 | + | |
| 9 | +public class CompressUtils { | |
| 10 | + /** | |
| 11 | + * 取得压缩包中的 文件列表(文件夹,文件自选) | |
| 12 | + * | |
| 13 | + * @param zipFileString 压缩包名字 | |
| 14 | + * @param bContainFolder 是否包括 文件夹 | |
| 15 | + * @param bContainFile 是否包括 文件 | |
| 16 | + * @return | |
| 17 | + * @throws Exception | |
| 18 | + */ | |
| 19 | + public static java.util.List<java.io.File> getFileList(String zipFileString, boolean bContainFolder, | |
| 20 | + boolean bContainFile) throws Exception { | |
| 21 | + java.util.List<java.io.File> fileList = new java.util.ArrayList<java.io.File>(); | |
| 22 | + java.util.zip.ZipInputStream inZip = | |
| 23 | + new java.util.zip.ZipInputStream(new java.io.FileInputStream(zipFileString)); | |
| 24 | + java.util.zip.ZipEntry zipEntry; | |
| 25 | + String szName = ""; | |
| 26 | + while ((zipEntry = inZip.getNextEntry()) != null) { | |
| 27 | + szName = zipEntry.getName(); | |
| 28 | + if (zipEntry.isDirectory()) { | |
| 29 | + // get the folder name of the widget | |
| 30 | + szName = szName.substring(0, szName.length() - 1); | |
| 31 | + java.io.File folder = new java.io.File(szName); | |
| 32 | + if (bContainFolder) { | |
| 33 | + fileList.add(folder); | |
| 34 | + } | |
| 35 | + } else { | |
| 36 | + java.io.File file = new java.io.File(szName); | |
| 37 | + if (bContainFile) { | |
| 38 | + fileList.add(file); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + }//end of while | |
| 42 | + inZip.close(); | |
| 43 | + return fileList; | |
| 44 | + } | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 返回压缩包中的文件InputStream | |
| 48 | + * | |
| 49 | + * @param zipFilePath 压缩文件的名字 | |
| 50 | + * @param fileString 解压文件的名字 | |
| 51 | + * @return InputStream | |
| 52 | + * @throws Exception | |
| 53 | + */ | |
| 54 | + public static java.io.InputStream upZip(String zipFilePath, String fileString) throws Exception { | |
| 55 | + java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(zipFilePath); | |
| 56 | + java.util.zip.ZipEntry zipEntry = zipFile.getEntry(fileString); | |
| 57 | + | |
| 58 | + return zipFile.getInputStream(zipEntry); | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 解压一个压缩文档 到指定位置 | |
| 63 | + * | |
| 64 | + * @param input 压缩包的名字 | |
| 65 | + * @param outPathString 指定的路径 | |
| 66 | + * @throws Exception | |
| 67 | + */ | |
| 68 | + public static void unZipFolder(InputStream input, String outPathString) throws Exception { | |
| 69 | + java.util.zip.ZipInputStream inZip = new java.util.zip.ZipInputStream(input); | |
| 70 | + java.util.zip.ZipEntry zipEntry = null; | |
| 71 | + String szName = ""; | |
| 72 | + | |
| 73 | + while ((zipEntry = inZip.getNextEntry()) != null) { | |
| 74 | + szName = zipEntry.getName(); | |
| 75 | + | |
| 76 | + if (zipEntry.isDirectory()) { | |
| 77 | + // get the folder name of the widget | |
| 78 | + szName = szName.substring(0, szName.length() - 1); | |
| 79 | + java.io.File folder = new java.io.File(outPathString + java.io.File.separator + szName); | |
| 80 | + folder.mkdirs(); | |
| 81 | + } else { | |
| 82 | + java.io.File file = new java.io.File(outPathString + java.io.File.separator + szName); | |
| 83 | + file.createNewFile(); | |
| 84 | + // get the output stream of the file | |
| 85 | + java.io.FileOutputStream out = new java.io.FileOutputStream(file); | |
| 86 | + int len; | |
| 87 | + byte[] buffer = new byte[1024]; | |
| 88 | + // read (len) bytes into buffer | |
| 89 | + while ((len = inZip.read(buffer)) != -1) { | |
| 90 | + // write (len) byte from buffer at the position 0 | |
| 91 | + out.write(buffer, 0, len); | |
| 92 | + out.flush(); | |
| 93 | + } | |
| 94 | + out.close(); | |
| 95 | + } | |
| 96 | + }//end of while | |
| 97 | + inZip.close(); | |
| 98 | + } | |
| 99 | + | |
| 100 | + /** | |
| 101 | + * 解压一个压缩文档 到指定位置 | |
| 102 | + * | |
| 103 | + * @param zipFileString 压缩包的名字 | |
| 104 | + * @param outPathString 指定的路径 | |
| 105 | + * @throws Exception | |
| 106 | + */ | |
| 107 | + public static void unZipFolder(String zipFileString, String outPathString) throws Exception { | |
| 108 | + unZipFolder(new java.io.FileInputStream(zipFileString), outPathString); | |
| 109 | + }//end of func | |
| 110 | + | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * 压缩文件,文件夹 | |
| 114 | + * | |
| 115 | + * @param srcFilePath 要压缩的文件/文件夹名字 | |
| 116 | + * @param zipFilePath 指定压缩的目的和名字 | |
| 117 | + * @throws Exception | |
| 118 | + */ | |
| 119 | + public static void zipFolder(String srcFilePath, String zipFilePath) throws Exception { | |
| 120 | + //创建Zip包 | |
| 121 | + java.util.zip.ZipOutputStream outZip = | |
| 122 | + new java.util.zip.ZipOutputStream(new java.io.FileOutputStream(zipFilePath)); | |
| 123 | + | |
| 124 | + //打开要输出的文件 | |
| 125 | + java.io.File file = new java.io.File(srcFilePath); | |
| 126 | + | |
| 127 | + //压缩 | |
| 128 | + zipFiles(file.getParent() + java.io.File.separator, file.getName(), outZip); | |
| 129 | + | |
| 130 | + //完成,关闭 | |
| 131 | + outZip.finish(); | |
| 132 | + outZip.close(); | |
| 133 | + | |
| 134 | + }//end of func | |
| 135 | + | |
| 136 | + /** | |
| 137 | + * 压缩文件 | |
| 138 | + * | |
| 139 | + * @param folderPath | |
| 140 | + * @param filePath | |
| 141 | + * @param zipOut | |
| 142 | + * @throws Exception | |
| 143 | + */ | |
| 144 | + private static void zipFiles(String folderPath, String filePath, | |
| 145 | + java.util.zip.ZipOutputStream zipOut) throws Exception { | |
| 146 | + if (zipOut == null) { | |
| 147 | + return; | |
| 148 | + } | |
| 149 | + | |
| 150 | + java.io.File file = new java.io.File(folderPath + filePath); | |
| 151 | + | |
| 152 | + //判断是不是文件 | |
| 153 | + if (file.isFile()) { | |
| 154 | + java.util.zip.ZipEntry zipEntry = new java.util.zip.ZipEntry(filePath); | |
| 155 | + java.io.FileInputStream inputStream = new java.io.FileInputStream(file); | |
| 156 | + zipOut.putNextEntry(zipEntry); | |
| 157 | + | |
| 158 | + int len; | |
| 159 | + byte[] buffer = new byte[4096]; | |
| 160 | + | |
| 161 | + while ((len = inputStream.read(buffer)) != -1) { | |
| 162 | + zipOut.write(buffer, 0, len); | |
| 163 | + } | |
| 164 | + | |
| 165 | + zipOut.closeEntry(); | |
| 166 | + } else { | |
| 167 | + //文件夹的方式,获取文件夹下的子文件 | |
| 168 | + String fileList[] = file.list(); | |
| 169 | + | |
| 170 | + //如果没有子文件, 则添加进去即可 | |
| 171 | + if (fileList.length <= 0) { | |
| 172 | + java.util.zip.ZipEntry zipEntry = | |
| 173 | + new java.util.zip.ZipEntry(filePath + java.io.File.separator); | |
| 174 | + zipOut.putNextEntry(zipEntry); | |
| 175 | + zipOut.closeEntry(); | |
| 176 | + } | |
| 177 | + | |
| 178 | + //如果有子文件, 遍历子文件 | |
| 179 | + for (int i = 0; i < fileList.length; i++) { | |
| 180 | + zipFiles(folderPath, filePath + java.io.File.separator + fileList[i], zipOut); | |
| 181 | + }//end of for | |
| 182 | + | |
| 183 | + }//end of if | |
| 184 | + | |
| 185 | + }//end of func | |
| 186 | +} | |
| \ No newline at end of file | ... | ... |
| ... | ... | @@ -23,6 +23,8 @@ import java.lang.annotation.Retention; |
| 23 | 23 | import java.lang.annotation.RetentionPolicy; |
| 24 | 24 | import java.text.Format; |
| 25 | 25 | import java.text.SimpleDateFormat; |
| 26 | +import java.util.Arrays; | |
| 27 | +import java.util.Calendar; | |
| 26 | 28 | import java.util.Date; |
| 27 | 29 | import java.util.Formatter; |
| 28 | 30 | import java.util.Locale; |
| ... | ... | @@ -468,6 +470,55 @@ public final class LogUtils { |
| 468 | 470 | } |
| 469 | 471 | } |
| 470 | 472 | |
| 473 | + /** | |
| 474 | + * 系统时间问题导致经常性删除失败在管理开门时进行日志清除 | |
| 475 | + */ | |
| 476 | + public static void delLog() { | |
| 477 | + try { | |
| 478 | + deleteOldLog(); | |
| 479 | + } catch (Exception e) { | |
| 480 | + e.printStackTrace(); | |
| 481 | + Log.d("cinema", e.getMessage()); | |
| 482 | + } | |
| 483 | + } | |
| 484 | + | |
| 485 | + private static void deleteOldLog() { | |
| 486 | + long start = System.currentTimeMillis(); | |
| 487 | + Calendar cal = Calendar.getInstance(); | |
| 488 | + int day = cal.get(Calendar.DAY_OF_MONTH); | |
| 489 | + int mouth = cal.get(Calendar.MONTH); | |
| 490 | + String[] newestName = new String[5]; | |
| 491 | + if (day > 4) { | |
| 492 | + newestName[0] = String.format("%02d-%02d", mouth + 1, day--); | |
| 493 | + newestName[1] = String.format("%02d-%02d", mouth + 1, day--); | |
| 494 | + newestName[2] = String.format("%02d-%02d", mouth + 1, day--); | |
| 495 | + } | |
| 496 | + //不删除1月1,2日的日志 | |
| 497 | + newestName[3] = String.format("%02d-%02d", 1, 1); | |
| 498 | + newestName[4] = String.format("%02d-%02d", 1, 2); | |
| 499 | + Log.d("delete-log", Arrays.toString(newestName)); | |
| 500 | + Log.d("cinema", Arrays.toString(newestName)); | |
| 501 | + File[] files = new File(dir == null ? defaultDir : dir).listFiles(); | |
| 502 | + if (files != null && files.length > 0) { | |
| 503 | + for (File file : files) { | |
| 504 | + boolean delete = true; | |
| 505 | + for (String s : newestName) { | |
| 506 | + if (file.getPath().contains(s)) { | |
| 507 | + delete = false; | |
| 508 | + break; | |
| 509 | + } | |
| 510 | + } | |
| 511 | + Log.d("delete-log", (delete ? "delete:" : "keep:") + file.getPath()); | |
| 512 | + Log.d("cinema", (delete ? "delete:" : "keep:") + file.getPath()); | |
| 513 | + if (delete) { | |
| 514 | + file.delete(); | |
| 515 | + } | |
| 516 | + } | |
| 517 | + } | |
| 518 | + Log.d("delete-log", "total time:" + (System.currentTimeMillis() - start)); | |
| 519 | + | |
| 520 | + } | |
| 521 | + | |
| 471 | 522 | private static boolean createOrExistsDir(File file) { |
| 472 | 523 | return file != null && (file.exists() ? file.isDirectory() : file.mkdirs()); |
| 473 | 524 | } | ... | ... |
| ... | ... | @@ -7,6 +7,7 @@ import com.gimi.common.cinema.model.RoomInfo; |
| 7 | 7 | import com.gimi.common.cinema.model.RoomQrCodeInfo; |
| 8 | 8 | import com.gimi.common.cinema.model.RoomStatusInfo; |
| 9 | 9 | import com.gimi.common.cinema.model.WrongMsg; |
| 10 | +import com.gimi.common.cinema.utils.LogUtils; | |
| 10 | 11 | import com.gimi.common.cinema.utils.SystemUtils; |
| 11 | 12 | import com.telink.bluetooth.light.model.Mesh; |
| 12 | 13 | import com.xgimi.gimicinema.BuildConfig; |
| ... | ... | @@ -127,13 +128,13 @@ public class SmartControlPresenter implements SmartControlContract.Presenter { |
| 127 | 128 | @Override |
| 128 | 129 | public void onOpenDoorSuccess() { |
| 129 | 130 | mainView.reportResult(true); |
| 130 | - Log.d("room-info", "report success"); | |
| 131 | + LogUtils.i("room-info", "report success"); | |
| 131 | 132 | } |
| 132 | 133 | |
| 133 | 134 | @Override |
| 134 | 135 | public void onOpenDoorFailure() { |
| 135 | 136 | mainView.reportResult(false); |
| 136 | - Log.d("room-info", "report failure"); | |
| 137 | + LogUtils.i("room-info", "report failure"); | |
| 137 | 138 | } |
| 138 | 139 | }); |
| 139 | 140 | } |
| ... | ... | @@ -143,13 +144,13 @@ public class SmartControlPresenter implements SmartControlContract.Presenter { |
| 143 | 144 | roomInfoModel.getRoomQrCode(orderSn, roomSn, new RoomInfoModelImpl.GetRoomQrCodeListener() { |
| 144 | 145 | @Override |
| 145 | 146 | public void onGetRoomQrCodeSuccess(RoomQrCodeInfo info) { |
| 146 | - Log.d("room-info", "getCleanQrCode#onGetRoomQrCodeSuccess:" + info.toString()); | |
| 147 | + LogUtils.i("room-info", "getCleanQrCode#onGetRoomQrCodeSuccess:" + info.toString()); | |
| 147 | 148 | mainView.prepareRoomQrCodeInfo(info); |
| 148 | 149 | } |
| 149 | 150 | |
| 150 | 151 | @Override |
| 151 | 152 | public void onGetRoomQrCodeFailure(WrongMsg wrongMsg) { |
| 152 | - Log.d("room-info", "onGetRoomQrCodeFailure:" + wrongMsg.toString()); | |
| 153 | + LogUtils.i("room-info", "onGetRoomQrCodeFailure:" + wrongMsg.toString()); | |
| 153 | 154 | } |
| 154 | 155 | }); |
| 155 | 156 | } | ... | ... |
| ... | ... | @@ -201,7 +201,7 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 201 | 201 | private void openDoor() { |
| 202 | 202 | updateLastCompleteMovieInfo(); |
| 203 | 203 | presenter.getSysTime(this); |
| 204 | - LogUtils.d("room-info", "openDoor called"); | |
| 204 | + LogUtils.i("room-info", "openDoor called"); | |
| 205 | 205 | bleBroadcastReceiver.setResponseObj(new GREENCITYBLEProtocolFactory.GREENCITYBleDataWritten() { |
| 206 | 206 | @Override |
| 207 | 207 | public void writeSuccess() { |
| ... | ... | @@ -209,14 +209,14 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 209 | 209 | Toast.makeText(SmartControlService.this, "开门成功", Toast.LENGTH_SHORT).show(); |
| 210 | 210 | if (needReport) { |
| 211 | 211 | mHandler.postDelayed(reportRunnable, 10 * 1000); |
| 212 | - LogUtils.d("room-info", "user open door ,report the open success status"); | |
| 212 | + LogUtils.i("room-info", "user open door ,report the open success status"); | |
| 213 | 213 | } |
| 214 | - LogUtils.d("room-info", "open success"); | |
| 214 | + LogUtils.i("room-info", "open success"); | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | @Override |
| 218 | 218 | public void writeFailure(String error) { |
| 219 | - LogUtils.d("room-info", "open failure," + error.toString()); | |
| 219 | + LogUtils.i("room-info", "open failure," + error.toString()); | |
| 220 | 220 | bleBroadcastReceiver.setResponseObj(null); |
| 221 | 221 | Toast.makeText(SmartControlService.this, "开门失败," + error, Toast.LENGTH_SHORT).show(); |
| 222 | 222 | } |
| ... | ... | @@ -237,13 +237,14 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 237 | 237 | || !TextUtils.isEmpty(((FangTangApplication) FangTangApplication.getInstance()).getCurrentPlayUrl())) { |
| 238 | 238 | break; |
| 239 | 239 | } |
| 240 | - Log.d("event bus", "open door" + messageEvent.getMessage()); | |
| 240 | + Log.i("event bus", "open door" + messageEvent.getMessage()); | |
| 241 | 241 | //异常2清理时段管理扫码进入,没有显示清洁码 |
| 242 | 242 | if (messageEvent.getMessage().startsWith("administrator")) { |
| 243 | 243 | if (roomStatusInfo != null) { |
| 244 | 244 | int spaceTime = openDoorServerTime - roomStatusInfo.getData().getEnd_time(); |
| 245 | 245 | if (spaceTime < 20 && spaceTime > 0) { |
| 246 | 246 | if (!ActivityCollector.isActivityExist(QrCodeShowActivity.class)) { |
| 247 | + Log.i("event bus", "admin open door show qr code activity"); | |
| 247 | 248 | Intent intent = new Intent(this, QrCodeShowActivity.class) |
| 248 | 249 | .putExtra("room_sn", roomInfo.getData().getRoom_sn()) |
| 249 | 250 | .putExtra("order_sn", roomStatusInfo.getData().getOrder_sn()); |
| ... | ... | @@ -255,11 +256,11 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 255 | 256 | break; |
| 256 | 257 | } |
| 257 | 258 | //异常3 观景时段内 没有放电影 |
| 258 | - if (roomStatusInfo.getData().getEnd_time() > openDoorServerTime | |
| 259 | - && openDoorServerTime > roomStatusInfo.getData().getBegin_time() | |
| 260 | - && TextUtils.isEmpty(((FangTangApplication) FangTangApplication.getInstance()).getCurrentPlayUrl())) { | |
| 261 | - presenter.getOrderInfo(this); | |
| 262 | - } | |
| 259 | +// if (roomStatusInfo.getData().getEnd_time() > openDoorServerTime | |
| 260 | +// && openDoorServerTime > roomStatusInfo.getData().getBegin_time() | |
| 261 | +// && TextUtils.isEmpty(((FangTangApplication) FangTangApplication.getInstance()).getCurrentPlayUrl())) { | |
| 262 | +// presenter.getOrderInfo(this); | |
| 263 | +// } | |
| 263 | 264 | } |
| 264 | 265 | } |
| 265 | 266 | } |
| ... | ... | @@ -268,11 +269,12 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 268 | 269 | needReport = true; |
| 269 | 270 | openDoor(); |
| 270 | 271 | presenter.getOrderInfo(this); |
| 271 | - Log.d("event bus", "open door" + messageEvent.getMessage()); | |
| 272 | + Log.i("event bus", "user open door" + messageEvent.getMessage()); | |
| 272 | 273 | break; |
| 273 | 274 | case SocketService.USER_OPEN_DOOR: |
| 274 | 275 | needReport = true; |
| 275 | 276 | openDoor(); |
| 277 | + Log.i("event bus", "user open door" + messageEvent.getMessage()); | |
| 276 | 278 | // if (rightSn) { |
| 277 | 279 | // down(); |
| 278 | 280 | // } |
| ... | ... | @@ -292,7 +294,7 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 292 | 294 | if (!TextUtils.isEmpty(roomStatusInfo.getData().getFilm_hash())) { |
| 293 | 295 | LocalMovieMessage lmm = new NewDBManager(this).queryPlayMovie(roomStatusInfo.getData().getFilm_hash()); |
| 294 | 296 | if (lmm == null) { |
| 295 | - Log.d("room-info", "movie not exits"); | |
| 297 | + Log.e("room-info", "movie not exits"); | |
| 296 | 298 | break; |
| 297 | 299 | } |
| 298 | 300 | if (!roomStatusInfo.getData().getFilm_hash().equals(lmm.getMd5())) { |
| ... | ... | @@ -310,6 +312,7 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 310 | 312 | // if (info == null || info.getData() == null) { |
| 311 | 313 | // break; |
| 312 | 314 | // } |
| 315 | + Log.i("room-info", "COUNT_DOWN_ZERO stop polling finish some activity,jump to qr code activity"); | |
| 313 | 316 | try { |
| 314 | 317 | PollingUtils.stopPollingService(this, CountService.class, CountService.STATUS_ACTION); |
| 315 | 318 | } catch (Exception e) { |
| ... | ... | @@ -318,7 +321,6 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 318 | 321 | if (ActivityCollector.isActivityExist(SimpleAdsPlayer2.class)) { |
| 319 | 322 | ActivityCollector.getActivity(SimpleAdsPlayer2.class).finish(); |
| 320 | 323 | } |
| 321 | -// cc | |
| 322 | 324 | Intent intent = new Intent(this, QrCodeShowActivity.class) |
| 323 | 325 | // .putExtra("qr", info.getData().getCode()) |
| 324 | 326 | .putExtra("room_sn", roomInfo.getData().getRoom_sn()) |
| ... | ... | @@ -329,7 +331,6 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 329 | 331 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 330 | 332 | startActivity(intent); |
| 331 | 333 | roomStatusInfo = null; |
| 332 | - Log.d("room-info", "into clean activity clear oder info"); | |
| 333 | 334 | // if (roomStatusInfo != null && roomStatusInfo.getData() != null & roomInfo != null && roomInfo.getData() != null) { |
| 334 | 335 | // if (System.currentTimeMillis() - lastRequest > 3000) { |
| 335 | 336 | // lastRequest = System.currentTimeMillis(); |
| ... | ... | @@ -344,7 +345,7 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 344 | 345 | // } |
| 345 | 346 | break; |
| 346 | 347 | case ORDER_PLAY_COMPLETE: |
| 347 | - LogUtils.d("room-info", messageEvent.getMessage()); | |
| 348 | + LogUtils.i("room-info", messageEvent.getMessage()); | |
| 348 | 349 | Utils.saveString(this, "oder-play-completed", new Gson().toJson(roomStatusInfo)); |
| 349 | 350 | playEndAds(); |
| 350 | 351 | break; |
| ... | ... | @@ -575,8 +576,7 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 575 | 576 | int offset = data.getNow_time() - data.getBegin_time(); |
| 576 | 577 | |
| 577 | 578 | int durationMinutes = data.getEnd_time() - data.getNow_time(); |
| 578 | - Log.d("CountService", "durationMinutes:" + durationMinutes); | |
| 579 | - LogUtils.d("room-info", orderInfo.toString()); | |
| 579 | + LogUtils.i("room-info", orderInfo.toString()); | |
| 580 | 580 | if (durationMinutes <= 1) { |
| 581 | 581 | return; |
| 582 | 582 | } |
| ... | ... | @@ -598,7 +598,7 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 598 | 598 | localMovieMessages = new NewDBManager(this).queryPlayMovie(data.getFilm_hash()); |
| 599 | 599 | if (localMovieMessages == null) { |
| 600 | 600 | show("电影信息出错,找不到相关电影"); |
| 601 | - LogUtils.d("room-info", "file not exists:" + orderInfo.getData().getFilm_hash()); | |
| 601 | + LogUtils.e("room-info", "file not exists:" + orderInfo.toString()); | |
| 602 | 602 | if (offset > 3) { |
| 603 | 603 | CToast.makeText(this, "您已迟到" + offset + "分钟,请注意把握时间,没有找到电影信息,请联系客服", 90 * 1000).show(); |
| 604 | 604 | } else { |
| ... | ... | @@ -610,8 +610,10 @@ public class SmartControlService extends BaseService implements EventListener<St |
| 610 | 610 | if (offset > 3) { |
| 611 | 611 | CToast.makeText(this, "您已迟到" + offset + "分钟,请注意把握时间", 100 * 1000).show(); |
| 612 | 612 | } |
| 613 | + LogUtils.i("room-info", "play movie" + localMovieMessages.toString()); | |
| 613 | 614 | OpenMMUtils.openMMWithAds(this, localMovieMessages.getPlayPath(), null); |
| 614 | 615 | } else { |
| 616 | + LogUtils.e("room-info", "file not exists:" + orderInfo.toString()); | |
| 615 | 617 | show("没有找到电影"); |
| 616 | 618 | } |
| 617 | 619 | } | ... | ... |
| ... | ... | @@ -121,7 +121,7 @@ public class SocketService1 extends BaseService { |
| 121 | 121 | new SocketSendMsg().contractHeartBeatMsg(testRoomSn)); |
| 122 | 122 | boolean isSuccess = sendMsg(s + END_SYMBOL); |
| 123 | 123 | if (!isSuccess) { |
| 124 | - LogUtils.d(TAG, "send heart beat error restart"); | |
| 124 | + LogUtils.i(TAG, "send heart beat error restart"); | |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | }; |
| ... | ... | @@ -130,12 +130,12 @@ public class SocketService1 extends BaseService { |
| 130 | 130 | @Override |
| 131 | 131 | public void run() { |
| 132 | 132 | if (ActivityCollector.getActivity(MainActivity.class) == null) { |
| 133 | - LogUtils.d(TAG, "do start main activity"); | |
| 133 | + LogUtils.i(TAG, "do start main activity"); | |
| 134 | 134 | Intent intent = new Intent(context, MainActivity.class); |
| 135 | 135 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 136 | 136 | startActivity(intent); |
| 137 | 137 | } else { |
| 138 | - LogUtils.d(TAG, "already start main activity"); | |
| 138 | + LogUtils.i(TAG, "already start main activity"); | |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | }; |
| ... | ... | @@ -150,13 +150,13 @@ public class SocketService1 extends BaseService { |
| 150 | 150 | @Override |
| 151 | 151 | public void onCreate() { |
| 152 | 152 | super.onCreate(); |
| 153 | - LogUtils.d(TAG, "onCreate"); | |
| 153 | + LogUtils.i(TAG, "onCreate"); | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | @Override |
| 157 | 157 | public int onStartCommand(Intent intent, int flags, int startId) { |
| 158 | 158 | super.onStartCommand(intent, flags, startId); |
| 159 | - LogUtils.d(TAG, "onStartCommand"); | |
| 159 | + LogUtils.i(TAG, "onStartCommand"); | |
| 160 | 160 | int ftTest = Utils.getInt(this, "ft-test", 0); |
| 161 | 161 | switch (ftTest) { |
| 162 | 162 | case 0: |
| ... | ... | @@ -175,19 +175,19 @@ public class SocketService1 extends BaseService { |
| 175 | 175 | |
| 176 | 176 | String roomInfoStr = Utils.getString(this, "room-info"); |
| 177 | 177 | if (TextUtils.isEmpty(roomInfoStr)) { |
| 178 | - LogUtils.d("room-info", "room info not exist"); | |
| 178 | + LogUtils.i("room-info", "room info not exist"); | |
| 179 | 179 | Toast.makeText(this, "没有获取到房间信息,请查看后台配置", Toast.LENGTH_SHORT).show(); |
| 180 | 180 | return super.onStartCommand(intent, flags, startId); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - LogUtils.d("room-info", "room info not null"); | |
| 183 | + LogUtils.i("room-info", "room info not null"); | |
| 184 | 184 | RoomInfo roomInfo = null; |
| 185 | 185 | try { |
| 186 | 186 | roomInfo = gson.fromJson(roomInfoStr, RoomInfo.class); |
| 187 | - LogUtils.d("room-info", "room info room_sn update"); | |
| 187 | + LogUtils.i("room-info", "room info room_sn update"); | |
| 188 | 188 | testRoomSn = roomInfo.getData().getRoom_sn(); |
| 189 | 189 | } catch (JsonSyntaxException e) { |
| 190 | - LogUtils.d("room-info", "room gson parse exception return"); | |
| 190 | + LogUtils.i("room-info", "room gson parse exception return"); | |
| 191 | 191 | Toast.makeText(this, "房间信息配置出错,请重新进入应用获取", Toast.LENGTH_SHORT).show(); |
| 192 | 192 | e.printStackTrace(); |
| 193 | 193 | return super.onStartCommand(intent, flags, startId); |
| ... | ... | @@ -206,8 +206,8 @@ public class SocketService1 extends BaseService { |
| 206 | 206 | boolean availableByPing = NetStatusUtils.isAvailableByPing("www.baidu.com"); |
| 207 | 207 | boolean availableByPing1 = NetStatusUtils.isAvailableByPing(serverHost); |
| 208 | 208 | boolean availableByPing2 = NetStatusUtils.isAvailableByPing("192.168.200.241"); |
| 209 | - LogUtils.d(TAG, "initsocket serverHost:serverPort:" + serverHost + ":" + serverPort); | |
| 210 | - LogUtils.d(TAG, "networkConnected:" + networkConnected + ":baidu:" + availableByPing + ",serverHost:" + availableByPing1 + ",serverIp:" + availableByPing2); | |
| 209 | + LogUtils.i(TAG, "initsocket serverHost:serverPort:" + serverHost + ":" + serverPort); | |
| 210 | + LogUtils.i(TAG, "networkConnected:" + networkConnected + ":baidu:" + availableByPing + ",serverHost:" + availableByPing1 + ",serverIp:" + availableByPing2); | |
| 211 | 211 | mHandler.post(new Runnable() { |
| 212 | 212 | @Override |
| 213 | 213 | public void run() { |
| ... | ... | @@ -225,7 +225,7 @@ public class SocketService1 extends BaseService { |
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | if (!msg.contains("20025")) { |
| 228 | - LogUtils.d(TAG, "send msg:" + msg); | |
| 228 | + LogUtils.i(TAG, "send msg:" + msg); | |
| 229 | 229 | } else { |
| 230 | 230 | if (heartBeatErrorCount.getAndDecrement() > 3) { |
| 231 | 231 | clearConnect(); |
| ... | ... | @@ -242,7 +242,7 @@ public class SocketService1 extends BaseService { |
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | } catch (IOException e) { |
| 245 | - LogUtils.d(TAG, "error" + e.getMessage()); | |
| 245 | + LogUtils.e(TAG, "error" + e.getMessage()); | |
| 246 | 246 | e.printStackTrace(); |
| 247 | 247 | clearConnect(); |
| 248 | 248 | return false; |
| ... | ... | @@ -256,7 +256,7 @@ public class SocketService1 extends BaseService { |
| 256 | 256 | socket.close(); |
| 257 | 257 | } |
| 258 | 258 | } catch (IOException e) { |
| 259 | - LogUtils.d(TAG, "error" + e.getMessage()); | |
| 259 | + LogUtils.e(TAG, "error" + e.getMessage()); | |
| 260 | 260 | e.printStackTrace(); |
| 261 | 261 | } finally { |
| 262 | 262 | socket = null; |
| ... | ... | @@ -290,7 +290,7 @@ public class SocketService1 extends BaseService { |
| 290 | 290 | return false; |
| 291 | 291 | } catch (IOException e) { |
| 292 | 292 | e.printStackTrace(); |
| 293 | - LogUtils.d(TAG, e.getMessage()); | |
| 293 | + LogUtils.e(TAG, e.getMessage()); | |
| 294 | 294 | clearConnect(); |
| 295 | 295 | return false; |
| 296 | 296 | } |
| ... | ... | @@ -298,7 +298,7 @@ public class SocketService1 extends BaseService { |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | private synchronized void clearConnect() { |
| 301 | - LogUtils.d(TAG, "clearConnect"); | |
| 301 | + LogUtils.i(TAG, "clearConnect"); | |
| 302 | 302 | mHandler.removeCallbacks(heartBeatRunnable); |
| 303 | 303 | sendRegister.set(false); |
| 304 | 304 | heartBeatErrorCount.set(0); |
| ... | ... | @@ -314,13 +314,13 @@ public class SocketService1 extends BaseService { |
| 314 | 314 | initSocket(); |
| 315 | 315 | } catch (IOException e) { |
| 316 | 316 | e.printStackTrace(); |
| 317 | - LogUtils.d(TAG, "init socket thread error,restart again after " + HEART_BEAT_RATE / 1000 + " seconds"); | |
| 317 | + LogUtils.e(TAG, "init socket thread error,restart again after " + HEART_BEAT_RATE / 1000 + " seconds"); | |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | try { |
| 321 | 321 | Thread.sleep(1000); |
| 322 | 322 | } catch (InterruptedException e1) { |
| 323 | - LogUtils.d(TAG, "error" + e1.getMessage()); | |
| 323 | + LogUtils.e(TAG, "error" + e1.getMessage()); | |
| 324 | 324 | e1.printStackTrace(); |
| 325 | 325 | } |
| 326 | 326 | } |
| ... | ... | @@ -336,9 +336,9 @@ public class SocketService1 extends BaseService { |
| 336 | 336 | StringBuilder message = new StringBuilder(); |
| 337 | 337 | while (!isInterrupted()) { |
| 338 | 338 | if (!sendRegister.get()) { |
| 339 | - LogUtils.d(TAG, "send register mes"); | |
| 340 | 339 | SocketSendMsg ssm = new SocketSendMsg().contractRegisterMsg(testRoomSn); |
| 341 | 340 | String msg = gson.toJson(ssm) + END_SYMBOL; |
| 341 | + LogUtils.i(TAG, "send register mes:" + msg); | |
| 342 | 342 | if (!sendMsg(msg)) { |
| 343 | 343 | try { |
| 344 | 344 | Thread.sleep(READ_THREAD_DEFAULT_SLEEP_MTIME); |
| ... | ... | @@ -347,7 +347,6 @@ public class SocketService1 extends BaseService { |
| 347 | 347 | } |
| 348 | 348 | continue; |
| 349 | 349 | } |
| 350 | - LogUtils.d(TAG, "" + msg); | |
| 351 | 350 | sendRegister.set(true); |
| 352 | 351 | } |
| 353 | 352 | |
| ... | ... | @@ -362,44 +361,47 @@ public class SocketService1 extends BaseService { |
| 362 | 361 | try { |
| 363 | 362 | socketResponse = gson.fromJson(message.toString(), |
| 364 | 363 | SocketResponse.class); |
| 364 | + if (socketResponse.getCode() != HEART_BEAT_SUCCESS) { | |
| 365 | + LogUtils.i(TAG, "recv msg:" + message); | |
| 366 | + } | |
| 365 | 367 | } catch (JsonSyntaxException e) { |
| 366 | 368 | LogUtils.e(TAG, "invalid msg:", message + e.getMessage()); |
| 367 | 369 | e.printStackTrace(); |
| 368 | 370 | clearConnect(); |
| 369 | 371 | break; |
| 370 | 372 | } |
| 371 | - | |
| 372 | 373 | switch (socketResponse.getCode()) { |
| 373 | 374 | case SUCCESS_MESSAGE: |
| 374 | 375 | heartBeatErrorCount.set(0); |
| 375 | 376 | Log.d(TAG, "SUCCESS_MESSAGE"); |
| 376 | 377 | break; |
| 377 | 378 | case VERIFY_SUCCESS: |
| 378 | - LogUtils.d(TAG, "VERIFY_SUCCESS"); | |
| 379 | 379 | mHandler.post(heartBeatRunnable); |
| 380 | - LogUtils.d(TAG, "verify success start heart beat"); | |
| 380 | + LogUtils.i(TAG, "verify success start heart beat"); | |
| 381 | 381 | break; |
| 382 | 382 | case HEART_BEAT_SUCCESS: |
| 383 | + LogUtils.d(TAG, "HEART_BEAT_SUCCESS,MainActivity Launched:" + ActivityCollector.isActivityExist(MainActivity.class)); | |
| 383 | 384 | heartBeatErrorCount.set(0); |
| 384 | 385 | //每成功5次心跳判定是否启动main activity |
| 385 | 386 | if (++mainChargeCount == 5) { |
| 386 | 387 | mainChargeCount = 0; |
| 387 | - if (ActivityCollector.getActivity(MainActivity.class) == null) { | |
| 388 | - LogUtils.d(TAG, "charge start main activity"); | |
| 388 | + if (heartBeatErrorCount.get() < 3) { | |
| 389 | + LogUtils.i(TAG, "heart beat regular"); | |
| 390 | + } | |
| 391 | + if (!ActivityCollector.isActivityExist(MainActivity.class)) { | |
| 392 | + LogUtils.i(TAG, "charge start main activity"); | |
| 389 | 393 | mHandler.postDelayed(startMainRunnable, 3 * 1000); |
| 390 | 394 | } |
| 391 | 395 | } |
| 392 | - boolean serviceLaunched = ActivityCollector.getActivity(MainActivity.class) != null; | |
| 393 | - Log.d(TAG, "HEART_BEAT_SUCCESS,MainActivity Launched:" + serviceLaunched); | |
| 394 | 396 | break; |
| 395 | 397 | case HEART_BEAT_ERROR_SYMBOL: |
| 396 | 398 | case ROOM_SN_CONNECTED: |
| 397 | 399 | String msg1 = socketResponse.getCode() == HEART_BEAT_ERROR_SYMBOL ? "HEART_BEAT_ERROR_SYMBOL" : "ROOM_SN_CONNECTED"; |
| 398 | - LogUtils.d(TAG, msg1); | |
| 400 | + LogUtils.e(TAG, msg1); | |
| 399 | 401 | clearConnect(); |
| 400 | 402 | break; |
| 401 | 403 | case RETURN_VERIFY_CODE: |
| 402 | - LogUtils.d(TAG, "RETURN_VERIFY_CODE"); | |
| 404 | + LogUtils.i(TAG, "RETURN_VERIFY_CODE"); | |
| 403 | 405 | if (!TextUtils.isEmpty(socketResponse.getData().getVerify())) { |
| 404 | 406 | String verifyMsg = AuthCode.getDecodeStr(socketResponse.getData().getVerify()); |
| 405 | 407 | SocketSendMsg ssm = new SocketSendMsg().contractVerifyMsg(testRoomSn, verifyMsg); |
| ... | ... | @@ -409,7 +411,7 @@ public class SocketService1 extends BaseService { |
| 409 | 411 | break; |
| 410 | 412 | case CONTAIN_MESSAGE: |
| 411 | 413 | heartBeatErrorCount.set(0); |
| 412 | - LogUtils.d(TAG, "CONTAIN_MESSAGE"); | |
| 414 | + LogUtils.i(TAG, "CONTAIN_MESSAGE"); | |
| 413 | 415 | if (socketResponse.getData() != null) { |
| 414 | 416 | if (socketResponse.getCmd() == OPEN_DOOR) { |
| 415 | 417 | switch (socketResponse.getData().getUser()) { |
| ... | ... | @@ -428,8 +430,10 @@ public class SocketService1 extends BaseService { |
| 428 | 430 | } |
| 429 | 431 | break; |
| 430 | 432 | case 20: |
| 433 | + LogUtils.i(TAG, "admin open the door,del the log"); | |
| 434 | + LogUtils.delLog(); | |
| 431 | 435 | if (TextUtils.isEmpty(((FangTangApplication) getApplication()).getCurrentPlayUrl())) { |
| 432 | - LogUtils.d("LightOperationUtils", "admin open light"); | |
| 436 | + LogUtils.i("LightOperationUtils", "admin open light"); | |
| 433 | 437 | LightOperationUtils.open(); |
| 434 | 438 | LightOperationUtils.setLightValue(Utils.getInt(context, "brightness", 50)); |
| 435 | 439 | } |
| ... | ... | @@ -443,7 +447,7 @@ public class SocketService1 extends BaseService { |
| 443 | 447 | break; |
| 444 | 448 | } |
| 445 | 449 | } else if (socketResponse.getCmd() == CLEAN_OVER) { |
| 446 | - LogUtils.d("LightOperationUtils", "admin clean over close light"); | |
| 450 | + LogUtils.i("LightOperationUtils", "admin clean over close light"); | |
| 447 | 451 | LightOperationUtils.setLightValue(5); |
| 448 | 452 | LightOperationUtils.close(); |
| 449 | 453 | new SystemUtils().closeFtLed(context.getApplicationContext()); |
| ... | ... | @@ -467,9 +471,8 @@ public class SocketService1 extends BaseService { |
| 467 | 471 | break; |
| 468 | 472 | default: |
| 469 | 473 | clearConnect(); |
| 470 | - LogUtils.d(TAG, "default msg clearConnect:" + socketResponse.toString()); | |
| 474 | + LogUtils.i(TAG, "default msg clearConnect:" + socketResponse.toString()); | |
| 471 | 475 | } |
| 472 | - LogUtils.d(TAG, "recv msg:" + message); | |
| 473 | 476 | } |
| 474 | 477 | try { |
| 475 | 478 | Thread.sleep(sleepTime); |
| ... | ... | @@ -489,7 +492,7 @@ public class SocketService1 extends BaseService { |
| 489 | 492 | |
| 490 | 493 | @Override |
| 491 | 494 | public void onDestroy() { |
| 492 | - LogUtils.d(TAG, "socket service destroy"); | |
| 495 | + LogUtils.i(TAG, "socket service destroy"); | |
| 493 | 496 | super.onDestroy(); |
| 494 | 497 | } |
| 495 | 498 | } |
| \ No newline at end of file | ... | ... |
| ... | ... | @@ -25,6 +25,7 @@ import android.widget.ListView; |
| 25 | 25 | import android.widget.Toast; |
| 26 | 26 | import com.gimi.common.cinema.model.RoomInfo; |
| 27 | 27 | import com.gimi.common.cinema.model.SambaMsg; |
| 28 | +import com.gimi.common.cinema.utils.CompressUtils; | |
| 28 | 29 | import com.gimi.common.cinema.utils.LogUtils; |
| 29 | 30 | import com.gimi.common.cinema.utils.NetStatusUtils; |
| 30 | 31 | import com.gimi.common.cinema.utils.ShellUtils; |
| ... | ... | @@ -34,6 +35,7 @@ import com.gimi.common.cinema.utils.Utils; |
| 34 | 35 | import com.google.gson.Gson; |
| 35 | 36 | import com.google.gson.JsonSyntaxException; |
| 36 | 37 | import com.xgimi.gimicinema.R; |
| 38 | +import com.xgimi.gimicinema.application.FangTangApplication; | |
| 37 | 39 | |
| 38 | 40 | import java.io.File; |
| 39 | 41 | import java.io.FileInputStream; |
| ... | ... | @@ -58,6 +60,14 @@ public class CheckActivity extends ListActivity { |
| 58 | 60 | setListAdapter(adapter); |
| 59 | 61 | } |
| 60 | 62 | |
| 63 | + void compres() { | |
| 64 | + try { | |
| 65 | + CompressUtils.zipFolder("/sdcard/ft_log/", "/sdcard/log.zip"); | |
| 66 | + } catch (Exception e) { | |
| 67 | + e.printStackTrace(); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + | |
| 61 | 71 | private List<String> getData() { |
| 62 | 72 | List<String> data = new ArrayList<>(); |
| 63 | 73 | data.add("网络状况");//0 |
| ... | ... | @@ -67,6 +77,7 @@ public class CheckActivity extends ListActivity { |
| 67 | 77 | data.add("结束log"); |
| 68 | 78 | data.add("考出log到服务器"); |
| 69 | 79 | data.add("考出日志文件到服务器"); |
| 80 | + data.add("生成全部日志"); | |
| 70 | 81 | return data; |
| 71 | 82 | } |
| 72 | 83 | |
| ... | ... | @@ -157,6 +168,10 @@ public class CheckActivity extends ListActivity { |
| 157 | 168 | } |
| 158 | 169 | } |
| 159 | 170 | break; |
| 171 | + case 7: | |
| 172 | + FangTangApplication.initLog(LogUtils.D); | |
| 173 | + msg = "保存日志已重置,重启后失效"; | |
| 174 | + break; | |
| 160 | 175 | } |
| 161 | 176 | Toast.makeText(this, msg, Toast.LENGTH_LONG).show(); |
| 162 | 177 | } | ... | ... |
| ... | ... | @@ -22,7 +22,7 @@ public class FangTangApplication extends TelinkApplication { |
| 22 | 22 | AdvanceStrategy.setDefault(new MySampleAdvanceStrategy()); |
| 23 | 23 | // CrashHandler crashHandler = CrashHandler.getInstance(); |
| 24 | 24 | // crashHandler.init(getApplicationContext());initLog\\ |
| 25 | - initLog(); | |
| 25 | + initLog(LogUtils.I); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | @Override |
| ... | ... | @@ -76,7 +76,7 @@ public class FangTangApplication extends TelinkApplication { |
| 76 | 76 | this.currentPlayUrl = currentPlayUrl; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public static void initLog() { | |
| 79 | + public static void initLog(int logLever) { | |
| 80 | 80 | LogUtils.Builder builder = new LogUtils.Builder() |
| 81 | 81 | .setLogSwitch(true)// 设置log总开关,包括输出到控制台和文件,默认开 |
| 82 | 82 | .setConsoleSwitch(true)// 设置是否输出到控制台开关,默认开 |
| ... | ... | @@ -88,7 +88,7 @@ public class FangTangApplication extends TelinkApplication { |
| 88 | 88 | .setDir("/sdcard/ft_log/")// 当自定义路径为空时,写入应用的/cache/log/目录中 |
| 89 | 89 | .setBorderSwitch(false)// 输出日志是否带边框开关,默认开 |
| 90 | 90 | .setConsoleFilter(LogUtils.V)// log的控制台过滤器,和logcat过滤器同理,默认Verbose |
| 91 | - .setFileFilter(LogUtils.V);// log文件过滤器,和logcat过滤器同理,默认Verbose | |
| 91 | + .setFileFilter(logLever);// log文件过滤器,和logcat过滤器同理,默认Verbose | |
| 92 | 92 | LogUtils.d(builder.toString()); |
| 93 | 93 | } |
| 94 | 94 | ... | ... |
| ... | ... | @@ -348,9 +348,9 @@ public class CinemaControlService extends Service { |
| 348 | 348 | messageEvent.setEventId(SmartControlService.ORDER_PLAY_COMPLETE); |
| 349 | 349 | messageEvent.setMessage("电影播放完成,记录完成订单信息"); |
| 350 | 350 | EventBus.getDefault().post(messageEvent); |
| 351 | - LogUtils.d("room-info", "stop media completed"); | |
| 351 | + LogUtils.i("room-info", "stop media completed:" + currentPath); | |
| 352 | 352 | } else { |
| 353 | - LogUtils.d("room-info", "stop media but not completed"); | |
| 353 | + LogUtils.i("room-info", "stop media but not completed:" + currentPath); | |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | } | ... | ... |
Please
register
or
login
to post a comment