use of edu.berkeley.cs.amplab.carat.thrift.HogBugReport in project carat by amplab.
the class CommunicationManager method refreshBugReports.
private boolean refreshBugReports(String uuid, String model) {
if (System.currentTimeMillis() - CaratApplication.storage.getFreshness() < Constants.FRESHNESS_TIMEOUT)
return false;
CaratService.Client instance = null;
try {
instance = ProtocolClient.open(a.getApplicationContext());
HogBugReport r = instance.getHogOrBugReport(uuid, getFeatures("ReportType", "Bug", "Model", model));
// ProtocolClient.close();
if (r != null) {
CaratApplication.storage.writeBugReport(r);
Log.d("CommunicationManager.refreshBugReports()", "got the bug list: " + r.getHbList().toString());
} else {
Log.d("CommunicationManager.refreshBugReports()", "the fetched bug report is null");
}
safeClose(instance);
return true;
} catch (Throwable th) {
Log.e(TAG, "Error refreshing bug reports.", th);
safeClose(instance);
}
return false;
}
use of edu.berkeley.cs.amplab.carat.thrift.HogBugReport in project carat by amplab.
the class CommunicationManager method refreshHogReports.
private boolean refreshHogReports(String uuid, String model) {
if (System.currentTimeMillis() - CaratApplication.storage.getFreshness() < Constants.FRESHNESS_TIMEOUT)
return false;
CaratService.Client instance = null;
try {
instance = ProtocolClient.open(a.getApplicationContext());
HogBugReport r = instance.getHogOrBugReport(uuid, getFeatures("ReportType", "Hog", "Model", model));
// ProtocolClient.close();
if (r != null) {
CaratApplication.storage.writeHogReport(r);
Log.d("CommunicationManager.refreshHogReports()", "got the hog list: " + r.getHbList().toString());
} else {
Log.d("CommunicationManager.refreshHogReports()", "the fetched hog report is null");
}
// Assume freshness written by caller.
// s.writeFreshness();
safeClose(instance);
return true;
} catch (Throwable th) {
Log.e(TAG, "Error refreshing hog reports.", th);
safeClose(instance);
}
return false;
}
use of edu.berkeley.cs.amplab.carat.thrift.HogBugReport in project carat by amplab.
the class CommunicationManager method getQuickHogsAndMaybeRegister.
private boolean getQuickHogsAndMaybeRegister(String uuid, String os, String model) {
if (System.currentTimeMillis() - CaratApplication.storage.getQuickHogsFreshness() < Constants.FRESHNESS_TIMEOUT_QUICKHOGS)
return false;
CaratService.Client instance = null;
try {
instance = ProtocolClient.open(a.getApplicationContext());
Registration registration = new Registration(uuid);
registration.setPlatformId(model);
registration.setSystemVersion(os);
registration.setTimestamp(System.currentTimeMillis() / 1000.0);
List<ProcessInfo> pi = SamplingLibrary.getRunningAppInfo(a.getApplicationContext());
List<String> processList = new ArrayList<String>();
for (ProcessInfo p : pi) processList.add(p.pName);
HogBugReport r = instance.getQuickHogsAndMaybeRegister(registration, processList);
// ProtocolClient.close();
if (r != null) {
CaratApplication.storage.writeHogReport(r);
CaratApplication.storage.writeQuickHogsFreshness();
}
// Assume freshness written by caller.
// s.writeFreshness();
safeClose(instance);
return true;
} catch (Throwable th) {
Log.e(TAG, "Error refreshing main reports.", th);
safeClose(instance);
}
return false;
}
Aggregations