Search in sources :

Example 1 with Registration

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;
}
Also used : CaratService(edu.berkeley.cs.amplab.carat.thrift.CaratService) HogBugReport(edu.berkeley.cs.amplab.carat.thrift.HogBugReport) Registration(edu.berkeley.cs.amplab.carat.thrift.Registration) ArrayList(java.util.ArrayList) ProcessInfo(edu.berkeley.cs.amplab.carat.thrift.ProcessInfo)

Example 2 with Registration

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);
}
Also used : Registration(edu.berkeley.cs.amplab.carat.thrift.Registration)

Aggregations

Registration (edu.berkeley.cs.amplab.carat.thrift.Registration)2 CaratService (edu.berkeley.cs.amplab.carat.thrift.CaratService)1 HogBugReport (edu.berkeley.cs.amplab.carat.thrift.HogBugReport)1 ProcessInfo (edu.berkeley.cs.amplab.carat.thrift.ProcessInfo)1 ArrayList (java.util.ArrayList)1