use of org.flyve.mdm.agent.data.database.PoliciesData in project android-mdm-agent by flyve-mdm.
the class FragmentFeedback method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_feedback, container, false);
HashMap<String, Boolean> map = new HashMap<>();
PoliciesData cache = new PoliciesData(FragmentFeedback.this.getContext());
map.put("Ping", false);
map.put("Geolocate", false);
map.put("Inventory", false);
map.put("Lock", false);
map.put("Wipe", false);
map.put("Unenroll", false);
map.put("Deploy app", false);
map.put("Remove app", false);
map.put("Deploy file", false);
map.put("Remove file", false);
map.put("Password enabled", Helpers.boolFromString(cache.getValue(PasswordEnablePolicy.POLICY_NAME).value));
map.put("Password quality", emptyValue(cache.getValue(PasswordQualityPolicy.POLICY_NAME).value));
map.put("Password minimum length", Helpers.moreThanZero(cache.getValue(PasswordMinLengthPolicy.POLICY_NAME).value));
map.put("Password minimum lower case", Helpers.moreThanZero(cache.getValue(PasswordMinLowerCasePolicy.POLICY_NAME).value));
map.put("Password minimum upper case", Helpers.moreThanZero(cache.getValue(PasswordMinUpperCasePolicy.POLICY_NAME).value));
map.put("Password minimum non letter", Helpers.moreThanZero(cache.getValue(PasswordMinNonLetterPolicy.POLICY_NAME).value));
map.put("Password minimum letters", Helpers.moreThanZero(cache.getValue(PasswordMinLetterPolicy.POLICY_NAME).value));
map.put("Password minimum numeric", Helpers.moreThanZero(cache.getValue(PasswordMinNumericPolicy.POLICY_NAME).value));
map.put("Password minimum symbols", Helpers.moreThanZero(cache.getValue(PasswordMinSymbolsPolicy.POLICY_NAME).value));
map.put("Maximum failed passwords for wipe", Helpers.moreThanZero(cache.getValue(MaximumFailedPasswordForWipePolicy.POLICY_NAME).value));
map.put("Maximum time to lock", Helpers.moreThanZero(cache.getValue(MaximumTimeToLockPolicy.POLICY_NAME).value));
map.put("Storage encryption", Helpers.boolFromString(cache.getValue(StorageEncryptionPolicy.POLICY_NAME).value));
map.put("Disable camera", Helpers.boolFromString(cache.getValue(CameraPolicy.POLICY_NAME).value));
map.put("Disable bluetooth", Helpers.boolFromString(cache.getValue(BluetoothPolicy.POLICY_NAME).value));
map.put("Disable screen capture", Helpers.boolFromString(cache.getValue(ScreenCapturePolicy.POLICY_NAME).value));
map.put("Disable airplane mode", Helpers.boolFromString(cache.getValue(AirplaneModePolicy.POLICY_NAME).value));
map.put("Disable GPS", Helpers.boolFromString(cache.getValue(GPSPolicy.POLICY_NAME).value));
map.put("Disable Hostpot/Tethering", Helpers.boolFromString(cache.getValue(HostpotTetheringPolicy.POLICY_NAME).value));
map.put("Disable roaming", Helpers.boolFromString(cache.getValue(RoamingPolicy.POLICY_NAME).value));
map.put("Disable wifi", Helpers.boolFromString(cache.getValue(WifiPolicy.POLICY_NAME).value));
// map.put("Use TLS", cache.getUseTLS());
map.put("Disable mobile line", Helpers.boolFromString(cache.getValue(MobileLinePolicy.POLICY_NAME).value));
map.put("Disable NFC", Helpers.boolFromString(cache.getValue(NFCPolicy.POLICY_NAME).value));
map.put("Disable statusbar", Helpers.boolFromString(cache.getValue(StatusBarPolicy.POLICY_NAME).value));
// map.put("ResetPassword",false);
map.put("Disable Usb Mtp", Helpers.boolFromString(cache.getValue(UsbMtpPolicy.POLICY_NAME).value));
map.put("Disable Usb Ptp", Helpers.boolFromString(cache.getValue(UsbPtpPolicy.POLICY_NAME).value));
map.put("Disable Usb Adb", Helpers.boolFromString(cache.getValue(UsbAdbPolicy.POLICY_NAME).value));
map.put("Disable speakerphone", Helpers.boolFromString(cache.getValue(SpeakerphonePolicy.POLICY_NAME).value));
map.put("Disable create VPN Profiles", Helpers.boolFromString(cache.getValue(VPNPolicy.POLICY_NAME).value));
LinearLayout ln = v.findViewById(R.id.lnFields);
editMessage = v.findViewById(R.id.editMessage);
Map<String, Boolean> treeMap = new TreeMap<>(map);
createField(FragmentFeedback.this.getContext(), treeMap, ln);
Button btnSend = v.findViewById(R.id.btnSend);
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sendFeedbackChollima(createFeedbackJSON(swPolicy));
}
});
return v;
}
use of org.flyve.mdm.agent.data.database.PoliciesData in project android-mdm-agent by flyve-mdm.
the class FragmentPolicies method loadData.
private void loadData(ListView lst) {
List<Policies> arrPolicies = new PoliciesData(FragmentPolicies.this.getContext()).getAllPolicies();
ArrayList arr = new ArrayList<HashMap<String, Boolean>>();
if (arrPolicies.isEmpty()) {
HashMap<String, String> map = new HashMap<>();
map.put("description", "0 policies");
map.put("value", "");
map.put("taskId", "");
arr.add(map);
} else {
for (int i = 0; i < arrPolicies.size(); i++) {
HashMap<String, String> map = new HashMap<>();
map.put("description", Helpers.splitCapitalized(arrPolicies.get(i).policyName));
map.put("value", String.valueOf(arrPolicies.get(i).value));
map.put("taskId", String.valueOf(arrPolicies.get(i).taskId));
arr.add(map);
}
}
lst.setAdapter(new PoliciesAdapter(FragmentPolicies.this.getActivity(), arr));
}
use of org.flyve.mdm.agent.data.database.PoliciesData in project android-mdm-agent by flyve-mdm.
the class CustomPhoneStateListener method onCallStateChanged.
public void onCallStateChanged(int state, String incomingNumber) {
// 0 = CALL_STATE_IDLE (close or no activity)
// 1 = CALL_STATE_RINGING
// 2 = CALL_STATE_OFFHOOK (At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.)
FlyveLog.d("Status: " + state);
final Context context = MDMAgent.getInstance();
Boolean disable = Boolean.parseBoolean(new PoliciesData(context).getValue(SpeakerphonePolicy.POLICY_NAME).value);
if (state == 2) {
// Disable Speaker Phone
CustomPolicies customPolicies = new CustomPolicies(context);
customPolicies.disableSpeakerphone(disable);
}
}
use of org.flyve.mdm.agent.data.database.PoliciesData in project android-mdm-agent by flyve-mdm.
the class MessagePolicies method messageArrived.
public void messageArrived(final Context context, String topic, String message) {
// Delete policy information if message contains default
if (message.contains("default")) {
try {
String taskId = new JSONObject(message).getString("taskId");
new PoliciesData(context).removeValue(taskId);
FlyveLog.i("Deleting policy " + message + " - " + topic);
} catch (Exception ex) {
FlyveLog.e("fcm", "error deleting policy " + message + " - " + topic, ex.getMessage());
}
return;
}
// Command/Policies
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.POLICIES, topic, message);
// Command/Ping
if (topic.toLowerCase().contains("ping")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.PING, topic, message);
}
// Command/Geolocate
if (topic.toLowerCase().contains("geolocate")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.GEOLOCATE, topic, message);
}
// Command/Inventory
if (topic.toLowerCase().contains("inventory")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.INVENTORY, topic, message);
}
// Command/Wipe
if (topic.toLowerCase().contains("wipe")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.WIPE, topic, message);
}
// Command/Lock
if (topic.toLowerCase().contains("lock")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.LOCK, topic, message);
}
// Command/Unenroll
if (topic.toLowerCase().contains("unenroll")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.UNENROLL, topic, message);
}
}
use of org.flyve.mdm.agent.data.database.PoliciesData in project android-mdm-agent by flyve-mdm.
the class MqttModel method messageArrived.
public void messageArrived(Context context, String topic, MqttMessage message) {
int priority = topic.contains("fleet") ? 0 : 1;
String messageBody = new String(message.getPayload());
MqttController mqttController = new MqttController(context, getMqttClient());
if (topic.isEmpty()) {
// exit if the topic if empty
return;
}
// Delete policy information
if (messageBody.contains("default")) {
try {
String taskId = new JSONObject(messageBody).getString("taskId");
new PoliciesData(context).removeValue(taskId);
FlyveLog.i("Deleting policy " + message + " - " + topic);
} catch (Exception ex) {
FlyveLog.e("fcm", "error deleting policy " + message + " - " + topic, ex.getMessage());
}
return;
}
// Command/Policies
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.POLICIES, topic, messageBody, this.client);
// Command/Ping
if (topic.toLowerCase().contains("ping")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.PING, topic, messageBody, this.client);
}
// Command/Geolocate
if (topic.toLowerCase().contains("geolocate")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.GEOLOCATE, topic, messageBody, this.client);
}
// Command/Inventory
if (topic.toLowerCase().contains("inventory")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.INVENTORY, topic, messageBody, this.client);
}
// Command/Wipe
if (topic.toLowerCase().contains("wipe")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.WIPE, topic, messageBody);
}
// Command/Unenroll
if (topic.toLowerCase().contains("unenroll")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.UNENROLL, topic, messageBody);
}
// Command/Lock
if (topic.toLowerCase().contains("lock")) {
new PoliciesAsyncTask().execute(context, PoliciesAsyncTask.LOCK, topic, messageBody);
}
// Command/Subscribe
if (topic.toLowerCase().contains("subscribe")) {
try {
JSONObject jsonObj = new JSONObject(messageBody);
if (jsonObj.has("subscribe")) {
JSONArray jsonTopics = jsonObj.getJSONArray("subscribe");
for (int i = 0; i < jsonTopics.length(); i++) {
JSONObject jsonTopic = jsonTopics.getJSONObject(i);
String channel = jsonTopic.getString("topic") + "/#";
if (channel == null || channel.contains("null")) {
mqttController.unsubscribe();
} else {
mqttController.subscribe(channel);
}
}
}
} catch (Exception ex) {
showDetailError(context, CommonErrorType.MQTT_SUBSCRIBE, ex.getMessage());
}
}
}
Aggregations