@Override
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
    super.execute(arguments);
    @SuppressWarnings("unchecked")
    List<String> optionNames = (List<String>) arguments.get("optionNames");
    ;
    UiScrollable optionsMenu =
        new UiScrollable(
            new UiSelector()
                .className("android.widget.ListView")
                .packageName("com.android.settings")
                .focused(false));

    if (!isUiObjectAvailable(optionsMenu, arguments)) {
      return Result.FAILURE;
    }

    for (String optionName : optionNames) {
      UiObject option =
          optionsMenu.getChildByText(
              new UiSelector().className(TextView.class.getName()), optionName);
      if (!isUiObjectAvailable(option, arguments) && !enabled.equals(option.isEnabled())) {
        return Result.FAILURE;
      }
    }
    return Result.OK;
  }
  private void loadXPrivacyConfig(String actionCommand) {
    // There is an intent to open the import configuration screen,
    // however there is a bug on XPrivacy, when that intent is called,
    // after a file is selected its contents are not displayed and no
    // operation is performed
    Log.d(uiaDaemon_logcatTag, "Loading XPrivacy configuration file.");

    // Extract the configuration file name
    String fileName = actionCommand.split("=")[1];
    Log.d(uiaDaemon_logcatTag, "Filename = " + fileName);

    try {
      // launchApp("XPrivacy");

      String XPrivacy = "biz.bokhorst.xprivacy";
      String XPrivacyToolbar = XPrivacy + ":id/widgetToolbar";
      String XPrivacyOkButton = XPrivacy + ":id/btnOk";
      UiObject toolbar = this.device.findObject(new UiSelector().resourceId(XPrivacyToolbar));

      // Locate the toolbar
      UiObject buttonSet = toolbar.getChild(new UiSelector().index(2));
      UiObject menuButton = buttonSet.getChild(new UiSelector().index(1));
      // Click to open the menu
      menuButton.click();
      waitForGuiToStabilize();

      // Select "Operations …" item from menu
      UiObject operationsButton = this.device.findObject(new UiSelector().text("Operations …"));
      operationsButton.click();
      waitForGuiToStabilize();

      // Select "Import"
      UiObject importButton = this.device.findObject(new UiSelector().text("Import"));
      importButton.click();
      waitForGuiToStabilize();

      // Select configuration file
      UiObject fileManagerButton = this.device.findObject(new UiSelector().text("OI File Manager"));
      fileManagerButton.click();
      waitForGuiToStabilize();

      UiObject textInput = this.device.findObject(new UiSelector().text("File name"));
      textInput.setText(fileName);

      UiObject pickFileButton = this.device.findObject(new UiSelector().text("Pick file"));
      pickFileButton.click();
      waitForGuiToStabilize();

      UiObject okButton = this.device.findObject(new UiSelector().resourceId(XPrivacyOkButton));
      okButton.click();

      do {
        okButton = this.device.findObject(new UiSelector().resourceId(XPrivacyOkButton));
        waitForGuiToStabilize();
      } while (!okButton.isEnabled());

      waitForGuiToStabilize();

      okButton.click();
      this.device.waitForIdle();
      waitForGuiToStabilize();

      // Return to home
      this.device.pressHome();
      this.device.waitForIdle();
    } catch (UiObjectNotFoundException ex) {
      Log.e(uiaDaemon_logcatTag, "Failed to import XPrivacy configuration.");
    }
    // catch (UiAutomatorDaemonException ex)
    // {
    //  Log.e(uiaDaemon_logcatTag, "Failed to start XPrivacy.");
    // }

    Log.d(uiaDaemon_logcatTag, "XPrivacy configuration file loaded.");
  }