use of org.flyve.mdm.agent.data.database.MqttData in project android-mdm-agent by flyve-mdm.
the class SplashActivity method onCreate.
/**
* Called when the activity is starting
* It shows the UI with the Splash screen
* @param savedInstanceState if the activity is being re-initialized, it contains the data it most recently supplied
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MqttData cache = new MqttData(SplashActivity.this);
// if broker is on cache open the main activity
String broker = cache.getBroker();
if (!broker.isEmpty()) {
// if user is enrolled show landing screen
FlyveLog.d(cache.getSessionToken());
setContentView(R.layout.activity_splash_enrolled);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
openMain();
}
}, TIME);
return;
}
// if user is not enrolled show help
setContentView(R.layout.activity_splash);
setupUI();
FloatingActionButton btnScan = findViewById(R.id.btnScan);
btnScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SplashActivity.this.startActivityForResult(new Intent(SplashActivity.this, ScanActivity.class), REQUEST_CODE_SCAN);
}
});
TextView txtVersion = findViewById(R.id.txtVersion);
txtVersion.setText(MDMAgent.getCompleteVersion());
}
use of org.flyve.mdm.agent.data.database.MqttData in project android-mdm-agent by flyve-mdm.
the class Inventory method getJSONInventory.
public void getJSONInventory(Context context, InventoryTask.OnTaskCompleted callback) {
InventoryTask inventoryTask = new InventoryTask(context, APP_VERSION, true);
MqttData cache = new MqttData(context);
String invitationToken = cache.getInvitationToken();
if (!invitationToken.isEmpty()) {
String tag = "invitation_" + invitationToken;
FlyveLog.i(tag);
inventoryTask.setTag(tag);
}
inventoryTask.getJSON(callback);
}
use of org.flyve.mdm.agent.data.database.MqttData in project android-mdm-agent by flyve-mdm.
the class Inventory method getXMLInventory.
public void getXMLInventory(Context context, InventoryTask.OnTaskCompleted callback) {
InventoryTask inventoryTask = new InventoryTask(context, APP_VERSION, true);
MqttData cache = new MqttData(context);
String invitationToken = cache.getInvitationToken();
if (!invitationToken.isEmpty()) {
String tag = "invitation_" + invitationToken;
FlyveLog.i(tag);
inventoryTask.setTag(tag);
}
inventoryTask.getXML(callback);
}
use of org.flyve.mdm.agent.data.database.MqttData in project android-mdm-agent by flyve-mdm.
the class ConnectionHTTP method killSession.
public static void killSession(final Context context, final String sessionToken) {
Thread t = new Thread(new Runnable() {
public void run() {
try {
Routes routes = new Routes(context);
MqttData cache = new MqttData(context);
String url = routes.pluginFlyvemdmAgent(cache.getAgentId());
URL dataURL = new URL(url);
HttpURLConnection conn = (HttpURLConnection) dataURL.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(timeout);
conn.setReadTimeout(readtimeout);
HashMap<String, String> header = new HashMap();
header.put("Accept", "application/octet-stream");
header.put("Content-Type", "application/json");
header.put("Session-Token", sessionToken);
StringBuilder logHeader = new StringBuilder();
if (header != null) {
for (Map.Entry<String, String> entry : header.entrySet()) {
logHeader.append("- " + entry.getKey() + " : " + entry.getValue() + "\n");
conn.setRequestProperty(entry.getKey(), entry.getValue());
}
} else {
logHeader.append("Empty");
}
if (conn.getResponseCode() >= 400) {
InputStream is = conn.getErrorStream();
String result = inputStreamToString(is);
Log(result);
return;
}
InputStream is = conn.getInputStream();
final String requestResponse = inputStreamToString(is);
String response = "\n URL:\n" + url + "\n\n Method:\n" + conn.getRequestMethod() + "\n\n Code:\n" + conn.getResponseCode() + " " + conn.getResponseMessage() + "\n\n Header:\n" + logHeader + "\n\n Response:\n" + requestResponse + "\n\n";
LogDebug(response);
} catch (final Exception ex) {
ConnectionHTTP.runOnUI(new Runnable() {
public void run() {
FlyveLog.e(ConnectionHTTP.class.getClass().getName() + ", getWebData", ex.getClass() + " : " + ex.getMessage());
}
});
}
}
});
t.start();
}
Aggregations