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 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 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"); } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { cr = getContentResolver(); dailyTrafficBytesUpload = new TrafficDataUtils(NETWORK_TRAFFIC_TYPE_UPLOAD, URI_TYPE_NETWORK_TRAFFIC_FOR_DAY, cr); dailyTrafficBytesUpload.initialTrafficBytes(); dailyTrafficBytesDownload = new TrafficDataUtils(NETWORK_TRAFFIC_TYPE_DOWNLOAD, URI_TYPE_NETWORK_TRAFFIC_FOR_DAY, cr); dailyTrafficBytesDownload.initialTrafficBytes(); monthlyTrafficBytesUpload = new TrafficDataUtils(NETWORK_TRAFFIC_TYPE_UPLOAD, URI_TYPE_NETWORK_TRAFFIC_FOR_MONTH, cr); monthlyTrafficBytesUpload.initialTrafficBytes(); monthlyTrafficBytesDownload = new TrafficDataUtils(NETWORK_TRAFFIC_TYPE_DOWNLOAD, URI_TYPE_NETWORK_TRAFFIC_FOR_MONTH, cr); monthlyTrafficBytesDownload.initialTrafficBytes(); handler.sendEmptyMessage(STARTMONITOR); checkNetworkTrafficLimits(); return super.onStartCommand(intent, flags, startId); }
private void handleNewDay() { Log.v("MonitorService", "handleNewDay"); dailyTrafficBytesUpload.resetTrafficBytes(); dailyTrafficBytesDownload.resetTrafficBytes(); }