public void executeShellCommand(org.wso2.emm.agent.beans.Operation operation) throws AndroidAgentException {
  JSONObject result=new JSONObject();
  try {
    String status=resources.getString(R.string.shared_pref_default_status);
    result.put(resources.getString(R.string.operation_status),status);
    operation.setPayLoad(result.toString());
    if (status.equals(resources.getString(R.string.shared_pref_default_status))) {
      operation.setStatus(resources.getString(R.string.operation_value_completed));
      resultBuilder.build(operation);
      if (Constants.DEBUG_MODE_ENABLED) {
        Log.d(TAG,"Shell command received.");
      }
    }
 else {
      operation.setStatus(resources.getString(R.string.operation_value_error));
      operation.setOperationResponse("Device reboot failed due to insufficient privileges.");
      resultBuilder.build(operation);
    }
  }
 catch (  JSONException e) {
    operation.setStatus(resources.getString(R.string.operation_value_error));
    operation.setOperationResponse("Error in processing result payload.");
    resultBuilder.build(operation);
    throw new AndroidAgentException("Invalid JSON format.",e);
  }
}

public void executeShellCommand ( org . wso2 . emm . agent . beans . Operation operation ) throws AndroidAgentException { JSONObject result = new JSONObject ( ) ; try { String status = resources . getString ( R . string . shared_pref_default_status ) ; result . put ( resources . getString ( R . string . operation_status ) , status ) ; operation . setPayLoad ( result . toString ( ) ) ; if ( status . equals ( resources . getString ( R . string . shared_pref_default_status ) ) ) { operation . setStatus ( resources . getString ( R . string . operation_value_completed ) ) ; resultBuilder . build ( operation ) ; if ( Constants . DEBUG_MODE_ENABLED ) { Log . d ( TAG , "Shell command received." ) ; } } else { operation . setStatus ( resources . getString ( R . string . operation_value_error ) ) ; operation . setOperationResponse ( "Device reboot failed due to insufficient privileges." ) ; resultBuilder . build ( operation ) ; } } catch ( JSONException e ) { operation . setStatus ( resources . getString ( R . string . operation_value_error ) ) ; operation . setOperationResponse ( "Error in processing result payload." ) ; resultBuilder . build ( operation ) ; throw new AndroidAgentException ( "Invalid JSON format." , e ) ; } }
execute shell commands as the super user .
