use of edu.berkeley.cs.amplab.carat.thrift.Registration 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;
}
use of edu.berkeley.cs.amplab.carat.thrift.Registration in project carat by amplab.
the class CommunicationManager method registerMe.
private void registerMe(CaratService.Client instance, String uuId, String os, String model) throws TException {
if (uuId == null || os == null || model == null) {
Log.e("registerMe", "Null uuId, os, or model given to registerMe!");
System.exit(1);
return;
}
Registration registration = new Registration(uuId);
registration.setPlatformId(model);
registration.setSystemVersion(os);
registration.setTimestamp(System.currentTimeMillis() / 1000.0);
registration.setKernelVersion(SamplingLibrary.getKernelVersion());
registration.setSystemDistribution(SamplingLibrary.getManufacturer() + ";" + SamplingLibrary.getBrand());
FlurryAgent.logEvent("Registering " + uuId + "," + model + "," + os);
instance.registerMe(registration);
}
Aggregations