private boolean isNewDay() { int lastRecordTime = Integer.parseInt(ConfigDataUtils.getLastRecordTime(cr)); int dateOfToday = Integer.parseInt(ConfigDataUtils.getDateOfToday()); Log.v( "MonitorService", "lastRecordTime is " + lastRecordTime + " dateOfToday is " + dateOfToday); if (lastRecordTime >= dateOfToday) { return false; } return true; }
private boolean isNewMonth() { int lastRecordMonth = Integer.parseInt( ConfigDataUtils.getLastRecordTime(cr).equals("0") ? "0" : ConfigDataUtils.getLastRecordTime(cr).substring(0, 6)); int monthOfToday = Integer.parseInt(ConfigDataUtils.getDateOfToday().substring(0, 6)); Log.v( "MonitorService", "lastRecordMonth is " + lastRecordMonth + " monthOfToday is " + monthOfToday); if (lastRecordMonth >= monthOfToday) { return false; } return true; }
private void handleNewMonth() { Log.v("MonitorService", "handleNewMonth"); monthlyTrafficBytesUpload.resetTrafficBytes(); monthlyTrafficBytesDownload.resetTrafficBytes(); ConfigDataUtils.setMonthlyUsedCorrect( 0, NETWORK_TRAFFIC_MONTHLY_USED_CORRECT_DOWNLOAD, NETWORK_TRAFFIC_MONTHLY_USED_CORRECT_DOWNLOAD_ID, getContentResolver()); ConfigDataUtils.setMonthlyUsedCorrect( 0, NETWORK_TRAFFIC_MONTHLY_USED_CORRECT_UPLOAD, NETWORK_TRAFFIC_MONTHLY_USED_CORRECT_UPLOAD_ID, getContentResolver()); }
private void restoreData() { Log.v("MonitorService", "Begin to restore Data"); dailyTrafficBytesUpload.restoreTrafficBytes(); dailyTrafficBytesDownload.restoreTrafficBytes(); monthlyTrafficBytesUpload.restoreTrafficBytes(); monthlyTrafficBytesDownload.restoreTrafficBytes(); ConfigDataUtils.setLastRecordTime(cr); Intent intent = new Intent(); intent.setAction("com.dylangao.updateUI"); sendBroadcast(intent); }
private void checkNetworkTrafficLimits() { long limitBytesForDay = Long.parseLong(ConfigDataUtils.getLimitBytesForDay(cr)); long monthlyPlanBytes = Long.parseLong(ConfigDataUtils.getMonthlyPlanBytes(cr)); long dayBytes = dailyTrafficBytesUpload.getTrafficData(COLUMNS_MOBILE, cr) + dailyTrafficBytesDownload.getTrafficData(COLUMNS_MOBILE, cr); long monthBytes = monthlyTrafficBytesUpload.getTrafficData(COLUMNS_MOBILE, cr) + monthlyTrafficBytesDownload.getTrafficData(COLUMNS_MOBILE, cr); Log.v("MonitorService", "limitBytesForDay is " + limitBytesForDay + "dayBytes is " + dayBytes); if (limitBytesForDay > 0 && limitBytesForDay < dayBytes) { Log.v("MonitorService", "send day alert"); } Log.v( "MonitorService", "mMonthlyPlanBytes is " + monthlyPlanBytes + "monthBytes is " + monthBytes); if (monthlyPlanBytes > 0 && monthlyPlanBytes < monthBytes) { Log.v("MonitorService", "send month alert"); } }