mobicontrol.agent

This namespace provides access to the functionality of the SOTI MobiControl agent, like restarting the agent or the agent's interaction with the Deployment server.
Since:
  • Version 1.0 (API level 1)

Members

static, readonly ConnectionStatusCode :object

This enumeration represents a return status code of mobicontrol.agent.connect.
Properties:
Name Type Description
NONE object No specific status code.
ALREADY_CONNECTED object The agent is already connected.
NO_NETWORK object There are no networks the agent can connect to.

This might happen if one of the following conditions exists:

  • The device is out of the coverage area for any allowed network.
  • The device is outside its home network and data roaming has been disabled.
  • The device's radio is turned off, for example, because airplane mode is enabled.
SERVER_UNREACHABLE object The agent cannot establish network connection to the deployment server.
SERVER_BUSY object The network connection to the deployment server was established, but the server didn't acknowledge connection.
NOT_CONFIGURED object The agent is not configured to connect.
Since:
  • Version 1.0 (API level 1)

static, readonly Mode :object

This enumeration represents an agent mode.
Properties:
Name Type Description
ADMIN_MODE object Administrator mode of the agent.
USER_MODE object User mode of the agent.
Since:
  • Version 1.0 (API level 1)

static, readonly packageName :string

Agent package name.
Since:
  • Version 1.0 (API level 1)

static, readonly version :string

Agent version name.
Since:
  • Version 1.0 (API level 1)

static, readonly versionCode :number

Agent version code.

This number determines which version is more recent. It has no other meaning than that higher numbers are more recent.

Since:
  • Version 1.0 (API level 1)
Example
var VERSION_KNOWN_TO_HAVE_THE_NEW_FEATURE = 137501042;
if (mobicontrol.agent.versionCode >= VERSION_KNOWN_TO_HAVE_THE_NEW_FEATURE) {
    mobicontrol.log.info("The agent has the new feature!");
}

Methods

async, static checkIn()

Force the agent to check in with the deployment server.
Since:
  • Version 1.0 (API level 1)

async, static connect(callbackFunctionopt, invocationTimeoutInMillisopt) → {boolean}

Connect the agent to the deployment server.

If the agent is already connected, no action is taken, and the function returns true. If connection isn't possible, the function returns false. Connection might not be possible if one of the following conditions exists:

  • The device is out of the coverage area for any allowed network.
  • The device is outside its home network and data roaming has been disabled.
  • The device's radio is turned off, for example, because airplane mode is enabled.
Otherwise, the function returns true, and the connection process is asynchronously launched. Note that the connection might still fail, even if the function has returned true.

Note: The agent will try to connect even if its current active network is not allowed by the agent's configuration.

If a callback function parameter is supplied, it will be called when the connection attempt completes, with an argument describing the result of the connection attempt.

Parameters:
Name Type Attributes Default Description
callbackFunction mobicontrol.agent.connectCallback <optional>
JavaScript function which is called when the connection attempt completes.
invocationTimeoutInMillis number <optional>
300000 Invocation timeout in milliseconds. If the callback function isn't invoked before the timeout expires, it will be called with the timed-out result.
Returns:
boolean - false if the connection isn't possible, true otherwise.
Since:
  • Version 1.0 (API level 1)
Example
// Provide a callback function with simple logging of successful invocation
mobicontrol.agent.connect(onFinish);

function onFinish(result) {
    if (result.isSuccessful) {
        mobicontrol.log.info('OK');
    }
    if (result.statusCode == mobicontrol.agent.ConnectionStatusCode.ALREADY_CONNECTED) {
        mobicontrol.log.info('Already connected');
    }
}

async, static disconnect() → {boolean}

Disconnect the agent from the deployment server.
Returns:
boolean - true if the disconnection process was successfully launched, false otherwise.
Since:
  • Version 1.0 (API level 1)

static enterAdminMode() → {boolean}

Enter administrator mode.

If the agent is already in the administrator mode, no action is taken, and the function returns true.

Returns:
boolean - false if the agent failed to enter the administrator mode, true otherwise.
Since:
  • Version 1.0 (API level 1)

static enterUserMode() → {boolean}

Enter user mode.

If the agent is already in the user mode, no action is taken, and the function returns true.

Returns:
boolean - false if the agent failed to enter the user mode, true otherwise.
Since:
  • Version 1.0 (API level 1)

static getCustomAttribute(key)nullable {string}

Retrieve custom attribute value for a given key.
Parameters:
Name Type Description
key string Custom attribute key.
Returns:
string - Custom attribute value or null if such an attribute doesn't exist.
Since:
  • Version 1.5 (API level 6)
Example
var myCustomValue = mobicontrol.agent.getCustomAttribute("myCustomKey");
if (myCustomValue != null) {
    mobicontrol.log.info("Custom attribute for key myCustomKey: " + myCustomValue);
} else {
    mobicontrol.log.info("Custom attribute for key myCustomKey is not found");
}

static getMode() → {mobicontrol.agent.Mode}

Retrieve the current agent mode.
Returns:
mobicontrol.agent.Mode - The current agent mode.
Since:
  • Version 1.0 (API level 1)
Example
var agentMode = mobicontrol.agent.getMode();
switch (agentMode) {
    case mobicontrol.agent.Mode.ADMIN_MODE:
        mobicontrol.log.info("The agent is in Admin mode");
        break;
    case mobicontrol.agent.Mode.USER_MODE:
        mobicontrol.log.info("The agent is in User mode");
        break;
    default:
        mobicontrol.log.error("Unexpected mode: " + agentMode);
}

static isAdminMode() → {boolean}

Detect if the agent is in administrator mode.
Returns:
boolean - true if the agent is in the administrator mode, false otherwise.
Since:
  • Version 1.0 (API level 1)

static isUserMode() → {boolean}

Detect if the agent is in user mode.
Returns:
boolean - true if the agent is in the user mode, false otherwise.
Since:
  • Version 1.0 (API level 1)

static restart() → {boolean}

Restart the agent.
Returns:
boolean - false if the agent failed to restart. The function only returns if the agent failed to restart, so it will never return true.
Since:
  • Version 1.0 (API level 1)

async, static sendDebugReport() → {boolean}

Send a debug report to the deployment server.
Returns:
boolean - true if the debug report generation process was successfully launched, false otherwise.
Since:
  • Version 1.0 (API level 1)

Type Definitions

connectCallback(result)

Callback function for mobicontrol.agent.connect.
Parameters:
Name Type Description
result object Result of the connection attempt.
Properties
Name Type Description
statusCode mobicontrol.agent.ConnectionStatusCode The detailed status code of the callback.

Follow the link in the Type column to see all the possible values.

isSuccessful boolean Success status of the callback.

true if the callback completed successfully, false otherwise.

isTimedOut boolean Timeout status of the callback.

true if the callback was timed out, false otherwise.

Note: A timeout is considered a failure, so if the timeout status is true, failure status is true as well, and success status is false.

isFailed boolean Failure status of the callback.

true if the callback failed, false otherwise.

Since:
  • Version 1.0 (API level 1)