public void store(String packageName) { Log.d("HarvestJournal", "store"); HashMap sessions; if (data.containsKey(packageName)) { sessions = (HashMap) data.get(packageName); } else { sessions = new HashMap(); data.put(packageName, sessions); } Long started = settings.getStarted(null); HarvestEntry entry; if (sessions.containsKey(started)) { entry = (HarvestEntry) sessions.get(started); } else { entry = new HarvestEntry(packageName); entry.started = started; sessions.put(started, entry); } Long delta = settings.getRealNowSeconds() - lastStored; if (delta > HarvestSettings.INTERVAL) { delta = HarvestSettings.INTERVAL; } entry.increment(delta); Log.d( "HarvestJournal", String.format("%s %d %d", entry.packageName, entry.started, entry.duration)); display(); }
public List<HarvestEntry> getEntries() { Log.d("HarvestJournal", "getEntries"); dump(); Long started = settings.getStarted(settings.getLastReported()); return storage.retrieve(started); }