示例#1
0
 public static boolean runRootCommand(String command) {
   Log.d(TAG, "Root-Command ==> su -c \"" + command + "\"");
   int returncode = NativeTask.runCommand("su -c \"" + command + "\"");
   if (returncode == 0) {
     return true;
   }
   Log.d(TAG, "Root-Command error, return code: " + returncode);
   return false;
 }
示例#2
0
 public static boolean runStandardCommand(String command) {
   Log.d(TAG, "Standard-Command ==> \"" + command + "\"");
   int returncode = NativeTask.runCommand(command);
   if (returncode == 0) {
     return true;
   }
   Log.d(TAG, "Standard-Command error, return code: " + returncode);
   return false;
 }
  /** Corresponds to <element name="nativeExecutable"> */
  private Element createNativeExecutableElement(Document doc, NativeTask t) {
    Element nativeExecE =
        doc.createElementNS(
            Schemas.SCHEMA_LATEST.namespace, XMLTags.NATIVE_EXECUTABLE.getXMLName());

    // <choice>
    // <ref name="staticCommand"/>
    // <ref name="dynamicCommand"/>
    // </choice>
    String[] cmd = t.getCommandLine();
    if (cmd != null && cmd.length > 0) {
      // <element name="staticCommand">
      Element staticCmdE =
          doc.createElementNS(
              Schemas.SCHEMA_LATEST.namespace, XMLTags.NATIVE_TASK_STATIC_COMMAND.getXMLName());
      setAttribute(staticCmdE, XMLAttributes.TASK_COMMAND_VALUE, cmd[0], true);

      // <ref name="commandArguments"/>
      if (cmd.length > 1) {
        // <element name="arguments">
        Element argsE =
            doc.createElementNS(
                Schemas.SCHEMA_LATEST.namespace, XMLTags.NATIVE_TASK_ARGUMENTS.getXMLName());
        for (int i = 1; i < cmd.length; i++) {
          // <element name="argument">
          Element argE =
              doc.createElementNS(
                  Schemas.SCHEMA_LATEST.namespace, XMLTags.NATIVE_TASK_ARGUMENT.getXMLName());
          setAttribute(argE, XMLAttributes.COMMON_VALUE, cmd[i], true);
          argsE.appendChild(argE);
        }
        staticCmdE.appendChild(argsE);
      }
      nativeExecE.appendChild(staticCmdE);
    } else {
      logger.error("The task " + t.getName() + " does not define a command");
    }

    return nativeExecE;
  }
示例#4
0
 /**
  * *********************************************************************** Static methods
  * **********************************************************************
  */
 public static boolean chmod(String file, String mode) {
   if (NativeTask.runCommand("chmod " + mode + " " + file) == 0) {
     return true;
   }
   return false;
 }
示例#5
0
 public static String getProp(String property) {
   return NativeTask.getProp(property);
 }