| | |
| | | |
| | | private static final String TAG = "AppStatusWorker"; |
| | | private AppStatusDao appStatusDao; |
| | | private int lastSatNum = 0; |
| | | private int lastQf = 0; |
| | | |
| | | |
| | | public AppStatusWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) { |
| | | super(context, workerParams); |
| | | MyLog.d(TAG,"初始化AppStatusWorker"); |
| | | MyLog.i("初始化AppStatusWorker"); |
| | | appStatusDao = WorkRoomDataBase.getWorkRoomDataBase(getApplicationContext()).getAppStatusDao(); |
| | | } |
| | | |
| | |
| | | public Result doWork() { |
| | | String[] str = getInputData().getStringArray(Constant.APP_STATUS); |
| | | JSONObject jsonObject = null; |
| | | MyLog.i(PlatFormConstant.TAG,"AppStatusWorker:"+str[0]+": "+str[1]); |
| | | MyLog.i("AppStatusWorker:"+str[0]+": "+str[1]); |
| | | try { |
| | | jsonObject = new JSONObject(str[1]); |
| | | switch (str[0]) { |
| | |
| | | case Constant.RTK_INFO_SAT_QF: |
| | | int qf = jsonObject.getInt("qf"); |
| | | int satNum = jsonObject.getInt("sat_num"); |
| | | if (qf==lastQf){ |
| | | Log.i(TAG,"解状态和上次的一样,不保存数据库"+qf); |
| | | }else{ |
| | | lastQf = qf; |
| | | |
| | | appStatusDao.updatedQf(qf); |
| | | } |
| | | if (satNum==lastSatNum){ |
| | | Log.i(TAG,"卫星颗数和上次的一样,不保存数据库"+lastSatNum); |
| | | }else{ |
| | | |
| | | appStatusDao.updatedSatNum(satNum); |
| | | lastSatNum = satNum; |
| | | } |
| | | |
| | | |
| | | break; |