예제 #1
0
 public void startUICenterLog(String action, String resid, String packageName) {
   String logText = action + "#" + resid + "#" + packageName;
   boolean isFind = false;
   if (mContext == null) {
     if (enable_Statistics_LOG)
       Log.v(
           "UICenter - StatisticsNew",
           LOG_TAG
               + "\n=packageOnEvent"
               + "\n--[(mContext == null)] --------------------- return");
     return;
   }
   if (enable_Statistics_LOG)
     Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=packageOnEvent" + "\n--order:" + logText);
   LogDB logDB = new LogDB(mContext);
   logDB.open();
   Cursor cursor = logDB.getAllLogText();
   while (cursor.moveToNext()) {
     String text = cursor.getString(cursor.getColumnIndexOrThrow("logtext"));
     if (text.equals(logText)) {
       isFind = true;
       break;
     }
   }
   cursor.close();
   if (!isFind) {
     logDB.insertRecord(logText);
   }
   logDB.close();
   if (mHandler != null) {
     if (enable_Statistics_LOG)
       Log.v(
           "UICenter - StatisticsNew",
           LOG_TAG + "\n=packageOnEvent" + "\n--存在上传线程 ---------------------return");
     return;
   }
   checkThread();
   if (!exitErrTime()) {
     if (enable_Statistics_LOG)
       Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=packageOnEvent" + "\n--不存在错误时间");
     if (SuccessTimeTransfinite()) {
       if (enable_Statistics_LOG)
         Log.v(
             "UICenter - StatisticsNew",
             LOG_TAG + "\n=packageOnEvent" + "\n--成功时间超过时间间隔 ==========================");
       // 上传数据
       mHandler.post(UploadRun);
     } else {
       exitThread();
       if (enable_Statistics_LOG)
         Log.v(
             "UICenter - StatisticsNew",
             LOG_TAG
                 + "\n=packageOnEvent"
                 + "\n--exitThread成功时间没有超过时间间隔 ---------------------exitThread--------------------");
     }
   } else {
     if (enable_Statistics_LOG)
       Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=packageOnEvent" + "\n--存在错误时间");
     if (getErrTimes() > 3 && ErrTimeTransfinite(TYPE.ONEDAYINTERVAL)) {
       if (enable_Statistics_LOG)
         Log.v(
             "UICenter - StatisticsNew",
             LOG_TAG + "\n=packageOnEvent" + "\n--错误时间超过一小时 ==========================");
       // 更新失败次数&失败时间
       recordErrCount(1);
       recordErrTime();
       // 上传数据
       mHandler.post(UploadRun);
     } else if (getErrTimes() <= 3 && ErrTimeTransfinite(TYPE.RETRYINTERVAL)) {
       if (enable_Statistics_LOG)
         Log.v(
             "UICenter - StatisticsNew",
             LOG_TAG + "\n=packageOnEvent" + "\n--错误时间间隔超过1分钟 ========================== ");
       // 上传数据
       mHandler.post(UploadRun);
     } else {
       exitThread();
       if (enable_Statistics_LOG)
         Log.v(
             "UICenter - StatisticsNew",
             LOG_TAG
                 + "\n=packageOnEvent"
                 + "\n--exitThread错误时间没有超过时间间隔 ---------------------exitThread-------------------- ");
     }
   }
 }