use of org.flyve.mdm.agent.core.enrollment.EnrollmentHelper in project android-mdm-agent by flyve-mdm.
the class DeployFilePolicy method process.
@Override
protected boolean process() {
try {
JSONObject jsonObj = new JSONObject(message);
if (jsonObj.has(POLICY_NAME)) {
final String deployFile = jsonObj.getString(POLICY_NAME);
final String id = jsonObj.getString("id");
final String versionCode = jsonObj.getString("version");
final String taskId = jsonObj.getString("taskId");
// execute the policy
EnrollmentHelper sToken = new EnrollmentHelper(this.context);
sToken.getActiveSessionToken(new EnrollmentHelper.EnrollCallBack() {
@Override
public void onSuccess(String sessionToken) {
FlyveLog.d("Install file: " + deployFile + " id: " + id);
PoliciesFiles policiesFiles = new PoliciesFiles(context);
policiesFiles.execute("file", deployFile, id, sessionToken, taskId);
}
@Override
public void onError(int type, String error) {
FlyveLog.e(this.getClass().getName() + ", downloadFile", error);
}
});
}
return true;
} catch (Exception ex) {
FlyveLog.e(this.getClass().getName() + ", process", ex.getMessage());
return false;
}
}
use of org.flyve.mdm.agent.core.enrollment.EnrollmentHelper in project android-mdm-agent by flyve-mdm.
the class DeployAppPolicy method process.
@Override
protected boolean process() {
try {
JSONObject jsonObj = new JSONObject(message);
final String deployApp = jsonObj.getString("deployApp");
final String id = jsonObj.getString("id");
final String versionCode = jsonObj.getString("versionCode");
final String taskId = jsonObj.getString("taskId");
ApplicationData apps = new ApplicationData(context);
Application[] appsArray = apps.getApplicationsById(id);
// check if the app exists with same version or older
Boolean bDownload = true;
if (appsArray.length > 0 && Integer.parseInt(versionCode) <= Integer.parseInt(appsArray[0].appVersionCode)) {
bDownload = false;
}
if (bDownload) {
EnrollmentHelper sToken = new EnrollmentHelper(this.context);
sToken.getActiveSessionToken(new EnrollmentHelper.EnrollCallBack() {
@Override
public void onSuccess(String sessionToken) {
try {
FlyveLog.d("Download package: " + deployApp + " id: " + id);
PoliciesFiles policiesFiles = new PoliciesFiles(context);
policiesFiles.execute("package", deployApp, id, sessionToken, taskId, versionCode);
} catch (Exception ex) {
FlyveLog.e(this.getClass().getName() + ", installPackage", ex.getMessage());
}
}
@Override
public void onError(int type, String error) {
FlyveLog.e(this.getClass().getName() + ", installPackage", error);
}
});
}
return true;
} catch (Exception ex) {
FlyveLog.e(this.getClass().getName() + ", process", ex.getMessage());
return false;
}
}
use of org.flyve.mdm.agent.core.enrollment.EnrollmentHelper in project android-mdm-agent by flyve-mdm.
the class DeeplinkModel method openEnrollment.
@Override
public void openEnrollment(final Activity activity, final int request) {
EnrollmentHelper sessionToken = new EnrollmentHelper(activity);
sessionToken.getActiveSessionTokenEnrollment(new EnrollmentHelper.EnrollCallBack() {
@Override
public void onSuccess(String data) {
// Active EnrollmentHelper Token is stored on cache
openEnrollmentActivity(activity, request);
presenter.openEnrollSuccess();
}
@Override
public void onError(int type, String error) {
presenter.showSnackError(type, error);
presenter.openEnrollFail();
}
});
}
Aggregations