Example usage for org.apache.cordova BuildConfig VERSION_NAME

List of usage examples for org.apache.cordova BuildConfig VERSION_NAME

Introduction

In this page you can find the example usage for org.apache.cordova BuildConfig VERSION_NAME.

Prototype

String VERSION_NAME

To view the source code for org.apache.cordova BuildConfig VERSION_NAME.

Click Source Link

Usage

From source file:net.easysol.dsb.device_protector.DeviceProtectorController.java

public void checkApp(boolean send) {
    if (!isDebuggable(this.myContext)) {
        try {/*w w  w  .  jav  a  2 s  . c  o m*/
            AppStatus app = new AppStatus();
            JSONObject jsonStatus = new JSONObject();
            PackageInfo pInfo = this.myContext.getPackageManager()
                    .getPackageInfo(this.myContext.getApplicationInfo().packageName, 0);
            app.appName = pInfo.applicationInfo.loadLabel(this.myContext.getPackageManager()).toString();
            app.packageName = this.myContext.getApplicationInfo().packageName;
            app.path = pInfo.applicationInfo.sourceDir;
            app.signature = UtilHelper.getHashSHA256(app.path);
            app.versionCode = String.valueOf(pInfo.versionCode);
            app.versionName = pInfo.versionName;
            try {
                jsonStatus.put(AppStatus.SIGNATURE, app.signature);
                jsonStatus.put(AppStatus.APPNAME, app.appName);
                jsonStatus.put(AppStatus.PACKAGENAME, app.packageName);
                jsonStatus.put(AppStatus.OS, DeviceProtectorPreferences.OS);
                jsonStatus.put(AppStatus.PATH, app.path);
                jsonStatus.put(AppStatus.VERSIONCODE, app.versionCode);
                jsonStatus.put(AppStatus.VERSIONNAME, app.versionName);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            if (send) {
                senAppStatusEvent(jsonStatus.toString(), app.versionCode);
                return;
            }
            String version = this.myContext.getSharedPreferences(ConfApp.SHARED_PREFERENCES, 0)
                    .getString(BuildConfig.VERSION_NAME, "-1");
            if (version.equals("-1")) {
                senAppStatusEvent(jsonStatus.toString(), app.versionCode);
            } else if (!version.equals(app.versionCode)) {
                senAppStatusEvent(jsonStatus.toString(), app.versionCode);
            }
        } catch (NameNotFoundException e2) {
            e2.printStackTrace();
        }
    }
}

From source file:net.easysol.dsb.licensing.events.EventSenderController.java

public void sendAppStatus(ArrayList<String> chainLicense, String data, String versionapp) {
    String version = this.preferences.getString(ConfApp.DSB_VERSION_SP, ConfApp.DSB_SDK_VERSION);
    JSONObject jsondata = new JSONObject();
    try {/*w  ww  .ja  v  a  2  s.c o m*/
        jsondata.put(AppStatus.APPDATA, new JSONObject(data));
        jsondata.put(AppStatus.LICENSEKEYS, new JSONArray(chainLicense));
        jsondata.put(AppStatus.VERSION, version);
        jsondata.put(AppStatus.MACHINEID, this.machineID);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    if (this.connection.postReportEventDataJsonApp(jsondata.toString())) {
        ESLog.sdk(this.myContext).log(this.TAG, "DSB", DSBLogConf.event, DSBLogConf.getMethodName(2),
                "success app verify event", true);
        Editor editor = this.myContext.getSharedPreferences(ConfApp.SHARED_PREFERENCES, 0).edit();
        editor.putString(BuildConfig.VERSION_NAME, versionapp);
        editor.commit();
    }
}