package net.heartshield.control;

import android.content.Context;

import net.heartshield.data.AppInfo;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Supplies AppInfo with appId and other device-related meta-data.
 *
 * @author David Madl (git@abanbytes.eu)
 * @date 2017-04-07
 */
public class Device implements IDevice {
    private AppInfo mAppInfo;

    public Device(Context context) {
        mAppInfo = AppInfo.getInstance(context);
    }

    @Override
    public String getAppId() {
        JSONObject appInfo = mAppInfo.getAppInfo();
        String appId;
        try {
            appId = appInfo.getString("id");
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        return appId;
    }
}
