All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eg.agent.android.harvest.crash.ApplicationInfo Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package com.eg.agent.android.harvest.crash;

/*import com.newrelic.agent.android.analytics.AnalyticAttribute;
import com.newrelic.agent.android.harvest.ApplicationInformation1;
import com.newrelic.agent.android.harvest.type.HarvestableObject;
import com.newrelic.agent.android.util.SafeJsonPrimitive;
import com.newrelic.com.google.gson.JsonObject;*/

import com.eg.agent.android.analytics.AnalyticAttribute;
import com.eg.agent.android.ApplicationInformation;
import com.eg.agent.android.harvest.type.HarvestableObject;
import com.eg.agent.android.util.SafeJsonPrimitive;
import com.eg.google.gson.JsonObject;

public class ApplicationInfo extends HarvestableObject {
    private String applicationBuild = "";
    private String applicationName = "";
    private String applicationVersion = "";
    private String bundleId = "";
    private int processId = 0;

    public ApplicationInfo(ApplicationInformation applicationInformation) {
        this.applicationName = applicationInformation.getAppName();
        this.applicationVersion = applicationInformation.getAppVersion();
        this.applicationBuild = applicationInformation.getAppBuild();
        this.bundleId = applicationInformation.getPackageId();
    }

    public ApplicationInfo() {
    }

    public JsonObject asJsonObject() {
        JsonObject data = new JsonObject();
        data.add(AnalyticAttribute.APP_NAME_ATTRIBUTE, SafeJsonPrimitive.factory(this.applicationName));
        data.add("appVersion", SafeJsonPrimitive.factory(this.applicationVersion));
        data.add("appBuild", SafeJsonPrimitive.factory(this.applicationBuild));
        data.add("bundleId", SafeJsonPrimitive.factory(this.bundleId));
        data.add("processId", SafeJsonPrimitive.factory(Integer.valueOf(this.processId)));
        return data;
    }

    public static ApplicationInfo newFromJson(JsonObject jsonObject) {
        ApplicationInfo info = new ApplicationInfo();
        info.applicationName = jsonObject.get(AnalyticAttribute.APP_NAME_ATTRIBUTE).getAsString();
        info.applicationVersion = jsonObject.get("appVersion").getAsString();
        info.applicationBuild = jsonObject.get("appBuild").getAsString();
        info.bundleId = jsonObject.get("bundleId").getAsString();
        info.processId = jsonObject.get("processId").getAsInt();
        return info;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy