Command Line Interface and APIs for Surelock
okt 22, 2013 | 42Gears Team
Applies to: | |
Product | SureLock |
Platform | Android |
Surelock uses a BroadcastReceiver to allow 3rd party applications to send specific commands to SureLock. Commands can be send using Intent (See examples below). To execute any command, Administrator password is necessary.
SureLock API
exit_surelock – This command exits the device from lock down mode.
public synchronized void exitSurelock() { /* Intent Action MUST be 'com.gears42.surelock.COMMUNICATOR' */ final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); /* the command to execute is 'exit_surelock' */ intent.putExtra("command","exit_surelock"); /* optional parameter to identify the sender application */ intent.putExtra("sender", "com.gears42.test.kill_surelock"); /* SureLock's password. Command will NOT execute if password mismatches */ intent.putExtra("password", editText.getText().toString()); intent.setPackage("com.gears42.surelock"); this.sendBroadcast(intent); }
apply_settings – Apply SureLock settings using XML data.
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","apply_settings"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.putExtra("setting_xml", surelockSettingFileContents); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
change_password – Change SureLock password required to enter into Admin Settings.
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","change_password"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.putExtra("new_password", newSureLockPassword); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
force_apply_settings – force applies SureLock settings.
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","force_apply_settings"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.putExtra("settings_path", pathToSurelockSettingsFile); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
reset_idletimeout – resets idle timeout.
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","reset_idletimeout"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
activate – activates SureLock license.
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","activate"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("activation_code",activationcode); intent.putExtra("password", surelockPassword); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
deactivate – deactivates SureLock license.
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","deactivate"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
forceknox – forces the user to activate KNOX
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","force_knox"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
hidebottombar – hides bottom bar of the device
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","hidebottombar"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
showbottombar – shows bottom bar of the device
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","showbottombar"); intent.putExtra("sender", context.getPackageName()); // optional intent.putExtra("password", surelockPassword); intent.setPackage("com.gears42.surelock"); context.sendBroadcast(intent);
add_application – adds a new application to the allowed list (application should already be installed on the device)
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","add_application"); intent.putExtra("sender",context.getPackageName()); intent.putExtra("password",surelockPassword); intent.putExtra("package_name",applicationPackageName); intent.putExtra("label",applicationLabel); // optional intent.putExtra("icon",applicationIcon); // optional intent.putExtra("app_password",applicationPassword); // optional intent.putExtra("hide_icon",True/False); // optional intent.putExtra("launch_at_startup",True/False); // optional intent.putExtra("restart_app_on_relaunch",True/False); // optional intent.putExtra("clear_app_data",True/False); // optional intent.putExtra("idle_timeout",value); // optional intent.setPackage("com.gears42.surelock"); sendBroadcast(intent); intent.putExtra("blocked_windows",childwindow1,childwindow2,childwindow3); // optional intent.putExtra("landscape_position",0/1); // optional intent.putExtra("portrait_position",0/1); // optional
remove_ application – removes application from the allowed list
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","remove_application"); intent.putExtra("sender",context.getPackageName()); intent.putExtra("password",surelockPassword); intent.putExtra("package_name",applicationPackageName); intent.setPackage("com.gears42.surelock"); sendBroadcast(intent);
wifi_settings – applies WiFi settings on the device
final Intent intent = new Intent("com.gears42.surelock.COMMUNICATOR"); intent.putExtra("command","wifi_settings"); intent.putExtra("sender",context.getPackageName()); intent.putExtra("password",surelockPassword); intent.putExtra("ssid",wifiSSID); intent.putExtra("wifi_password",wifiPassword); intent.putExtra("security_type",securityType); intent.setPackage("com.gears42.surelock"); sendBroadcast(intent);
SureLock Command Line Options
Examples:
To add an application –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e password 0000 -e command add_application -e package_name <package name>-e label<app name>-e icon </sdcard/images/image1.png>-e app_password <0000>-e hide_icon <false> -e launch_at_startup <true> -e restart_app_on_relaunch <true> -e blocked_windows <childwindow1,childwindow2> -e idle_timeout <milliseconds> com.gears42.surelock
To remove an application –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e password <0000> -e command remove_application -e package_name <package name> com.gears42.surelock
To configure Wi-Fi Settings –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e password <0000> -e command wifi_settings -e clear_saved_network <true> -e ssid <SSID name> -e wifi_password <wifi password>-e security_type <wpa> com.gears42.surelock
To change Password –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "command" "change_password" -e "password" "0000" -e "new_password" "1111" com.gears42.surelock
To exit SureLock –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "password" "0000" -e "command" "exit_surelock" com.gears42.surelock
To force apply changes –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "command" "force_apply_settings" -e "password" "0000" -e "settings_path" "/sdcard/SureLock.settings" com.gears42.surelock
To reset Idle Timeout –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "command" "reset_idletimeout" -e "password" "0000" com.gears42.surelock
To activate SureLock License –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "command" "activate" -e "password" "0000" -e "activation_code" "Enter Code Here" com.gears42.surelock
To deactivate SureLock License –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "command" "deactivate" -e "password" "0000" com.gears42.surelock
To force the user to activate KNOX –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "password" "0000" -e "command" "force_knox" com.gears42.surelock
To hide bottom bar of the device –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "command" "hidebottombar" -e "password" "0000" com.gears42.surelock
To show Bottom bar of the device –
am broadcast -a com.gears42.surelock.COMMUNICATOR -n com.gears42.surelock/com.gears42.surelock.service.SureLockCommunicator -e "command" "showbottombar" -e "password" "0000" com.gears42.surelock
To know more, visit https://www.42gears.com or contact us on info@42gears.com