Command Line Interface and APIs for Surelock

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());

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);

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);

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);

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);

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);

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);

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);

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);

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);

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

sendBroadcast(intent);

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);

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);

sendBroadcast(intent);

SureLock Command Line Options

Examples:

To add an application – 

am broadcast -a com.gears42.surelock.COMMUNICATOR -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>

To remove an application – 

am broadcast -a com.gears42.surelock.COMMUNICATOR -e password <0000> -e command remove_application -e package_name <package name>

To configure Wi-Fi Settings –

am broadcast -a com.gears42.surelock.COMMUNICATOR -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>

To password change –

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "command" "change_password" -e "password" "0000" -e "new_password" "1111"

To exit SureLock –

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "password" "0000" -e "command" "exit_surelock"

To force apply changes –

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "command" "force_apply_settings" -e "password" "0000" -e "settings_path" "/sdcard/SureLock.settings"

To reset Idle Timeout

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "command" "reset_idletimeout" -e "password" "0000"

To activate SureLock License

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "command" "activate" -e "password" "0000"  -e "activation_code" "Enter Code Here"

To deactivate SureLock License

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "command" "deactivate" -e "password" "0000"

To force the user to activate KNOX

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "password"  "0000" -e "command" "force_knox"

To hide bottom bar of the device

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "command" "hidebottombar" -e "password" "0000"

To show bottom bar of the device

am broadcast -a com.gears42.surelock.COMMUNICATOR -e "command" "showbottombar" -e "password" "0000"

 

To know more, visit http://www.42gears.com or contact us on info@42gears.com

 

3 Comments

  1. Markus on Friday April 10th, 2015 at 06:12 PM

    Please update your documentation. Note to extra spaces.
    It’s intent.putExtra(“command”, “force_apply_settings”); and NOT intent.putExtra(“command”, ” force_apply_settings “);
    Same for intent.putExtra(“command”, ” change_password “);

  2. Markus on Monday February 16th, 2015 at 02:43 PM

    Does the Intent “force_apply_settings” also work when SureLock currently not running? This is possible if the Intent is registered in SureLock’s AndroidManifest, but as I can’t look into your code, I can’t know about that. In my case, SureLock is not running on BootUp on my Samsung Galaxy Camera. We talked about that earlier.

    • bishal on Tuesday February 17th, 2015 at 09:00 AM

      Hi Markus,
      We would be more than happy to help you with your question. Please do write to us at techsupport@42gears.com or use chat option from our website’s contact page.
      Thank you.

Leave a Comment