Ejemplo n.º 1
0
  public void installcomplete()
      throws IOException, InterruptedException, TimeoutException, RootDeniedException {
    recovery();
    File file = new File("/system/etc/dreamnarae.sh");
    if (file.length() > 0) {
      RootTools.remount("/system/", "RW");
      CommandCapture command =
          new CommandCapture(
              0,
              "busybox touch /system/98banner_dreamnarae_prev",
              "echo check > /system/98banner_dreamnarae_prev",
              "chmod 755 /system/98banner_dreamnarae_prev");
      RootTools.getShell(true).add(command).waitForFinish();
      Log.d("Install", "Install Success!");
      success_dn();
      if (new File("/system/98banner_dreamnarae_prev").exists()) {
        apply.setEnabled(false);
        apply.setFocusable(false);
        imageview.setImageResource(R.drawable.apply);
      } else {
      }

    } else {
      fail_dn();
    }
  }
Ejemplo n.º 2
0
 public String exec(String command) {
   final StringBuffer radare_output = new StringBuffer();
   Command command_out =
       new Command(0, command) {
         @Override
         public void output(int id, String line) {
           radare_output.append(line);
         }
       };
   try {
     RootTools.getShell(RootTools.useRoot);
     RootTools.getShell(RootTools.useRoot).add(command_out).waitForFinish();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return radare_output.toString();
 }
Ejemplo n.º 3
0
 public void Install_Prev()
     throws InterruptedException, IOException, TimeoutException, RootDeniedException {
   Delete_File();
   RootTools.remount("/system/", "rw");
   RootTools.copyFile(
       this.getExternalFilesDir(null) + "/prev_set.sh", "/system/etc/dreamnarae.sh", true, false);
   CommandCapture command = new CommandCapture(0, "chmod 755 /system/etc/dreamnarae.sh");
   RootTools.getShell(true).add(command).waitForFinish();
   installcomplete();
 }
  private void makeScreenshot() {
    if (FileUtil.isExternalStorageAvailable() && FileUtil.hasExternalStorageFreeMemory()) {
      if (RootTools.isAccessGiven()) {
        try {
          String path = FileUtil.getExternalFullPath(mContext, "screenshot.jpg");
          MakeScreenshotCommand command = new MakeScreenshotCommand(path);
          RootTools.getShell(true).add(command);

        } catch (Exception e) {
          ACRA.getErrorReporter().handleSilentException(e);
        }
      }
    }

    if (mSettings.isScreenshotEnabled()) {
      mHandler.sendEmptyMessageDelayed(0, mSettings.screenshotInterval());
    }
  }
Ejemplo n.º 5
0
  public static JobResult execute(AsyncJob j) {
    Context context = j.getContext();
    JobResult result = new JobResult();

    // Make sure we support their device
    String arch = App.getInstance().getArch();

    if (!arch.equals(Constants.ARM) && !arch.equals(Constants.X86)) {
      result.setSuccess(false);
      result.setError(context.getString(R.string.device_unsupported) + " " + arch);
      return result;
    }

    try {
      RootTools.getShell(true);
    } catch (Exception e) {
      result.setSuccess(false);
      result.setError(context.getString(R.string.shell_error));
      return result;
    }

    if (!RootTools.isRootAvailable()) {
      result.setError(context.getString(R.string.noroot2));
    } else {
      try {
        if (!RootTools.isAccessGiven()) {
          result.setError(context.getString(R.string.noAccess));
        }

        App.getInstance().setSpace((float) (RootTools.getSpace("/system") / 1000));

      } catch (Exception e) {
        result.setError(context.getString(R.string.accessUndetermined));
      }
    }

    App.getInstance().setInstalled(RootTools.isBusyboxAvailable());

    Common.extractBusybox(context, "");

    return result;
  }
Ejemplo n.º 6
0
  @Override
  protected ShellCommandResult doInBackground(Void... params) {

    String umountCommand = String.format("umount %s", mMountPoint);
    CommandCapture unmountCommand = new CommandCapture(0, umountCommand);
    ShellCommandResult result = null;

    try {
      RootTools.getShell(true).add(unmountCommand);
      unmountCommand.waitForFinish();
      Log.d(
          CLASS,
          String.format("umount [%d] %s", unmountCommand.exitCode(), unmountCommand.toString()));
      result = new ShellCommandResult(unmountCommand.exitCode(), unmountCommand.toString());
    } catch (Exception exception) {
      mError = exception;
      cancel(false);
    }

    return result;
  }
Ejemplo n.º 7
0
  public String sendCommand(String commandString) {
    String result = "";

    if (checkRoot()) {
      CommandCapture command = new CommandCapture(0, commandString);
      try {
        RootTools.getShell(true).add(command).waitForFinish();
        result = command.toString();
        LAST_COMMAND_OUTPUT = result;
        LAST_EXIT_CODE = command.exitCode();
      } catch (InterruptedException e) {
        // TODO: Do something useful with the exceptions
        // e.printStackTrace();
      } catch (IOException e) {
        // e.printStackTrace();
      } catch (TimeoutException e) {
        // e.printStackTrace();
      } catch (RootDeniedException e) {
        // e.printStackTrace();
      }
    }
    return result;
  }
Ejemplo n.º 8
0
    public void run() {
      visualUpdate(TestHandler.ACTION_SHOW, null);

      // First test: Install a binary file for future use
      // if it wasn't already installed.
      /*
      visualUpdate(TestHandler.ACTION_PDISPLAY, "Installing binary if needed");
      if(false == RootTools.installBinary(mContext, R.raw.nes, "nes_binary")) {
          visualUpdate(TestHandler.ACTION_HIDE, "ERROR: Failed to install binary. Please see log file.");
          return;
      }
      */

      boolean result;

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing getPath");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ getPath ]\n");

      try {
        List<String> paths = RootTools.getPath();

        for (String path : paths) {
          visualUpdate(TestHandler.ACTION_DISPLAY, path + " k\n\n");
        }

      } catch (Exception e) {
        e.printStackTrace();
      }

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing A ton of commands");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Ton of Commands ]\n");

      for (int i = 0; i < 100; i++) {
        RootTools.exists("/system/xbin/busybox");
      }

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing Find Binary");
      result = RootTools.isRootAvailable();
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking Root ]\n");
      visualUpdate(TestHandler.ACTION_DISPLAY, result + " k\n\n");

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing file exists");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking Exists() ]\n");
      visualUpdate(TestHandler.ACTION_DISPLAY, RootTools.exists("/system/sbin/[") + " k\n\n");

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing Is Access Given");
      result = RootTools.isAccessGiven();
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking for Access to Root ]\n");
      visualUpdate(TestHandler.ACTION_DISPLAY, result + " k\n\n");

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing Remount");
      result = RootTools.remount("/system", "rw");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Remounting System as RW ]\n");
      visualUpdate(TestHandler.ACTION_DISPLAY, result + " k\n\n");

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing CheckUtil");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking busybox is setup ]\n");
      visualUpdate(TestHandler.ACTION_DISPLAY, RootTools.checkUtil("busybox") + " k\n\n");

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing getBusyBoxVersion");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking busybox version ]\n");
      visualUpdate(
          TestHandler.ACTION_DISPLAY, RootTools.getBusyBoxVersion("/system/bin/") + " k\n\n");

      try {
        visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing fixUtils");
        visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking Utils ]\n");
        visualUpdate(
            TestHandler.ACTION_DISPLAY,
            RootTools.fixUtils(new String[] {"ls", "rm", "ln", "dd", "chmod", "mount"}) + " k\n\n");
      } catch (Exception e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
      }

      try {
        visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing getSymlink");
        visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking [[ for symlink ]\n");
        visualUpdate(TestHandler.ACTION_DISPLAY, RootTools.getSymlink("/system/bin/[[") + " k\n\n");
      } catch (Exception e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
      }

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing getInode");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking Inodes ]\n");
      visualUpdate(
          TestHandler.ACTION_DISPLAY, RootTools.getInode("/system/bin/busybox") + " k\n\n");

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing GetBusyBoxapplets");
      try {

        visualUpdate(TestHandler.ACTION_DISPLAY, "[ Getting all available Busybox applets ]\n");
        for (String applet :
            RootTools.getBusyBoxApplets("/data/data/stericson.busybox.donate/files/bb")) {
          visualUpdate(TestHandler.ACTION_DISPLAY, applet + " k\n\n");
        }

      } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing getFilePermissionsSymlinks");
      Permissions permissions = RootTools.getFilePermissionsSymlinks("/system/bin/busybox");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking busybox permissions and symlink ]\n");

      if (permissions != null) {
        visualUpdate(TestHandler.ACTION_DISPLAY, "Symlink: " + permissions.getSymlink() + " k\n\n");
        visualUpdate(
            TestHandler.ACTION_DISPLAY,
            "Group Permissions: " + permissions.getGroupPermissions() + " k\n\n");
        visualUpdate(
            TestHandler.ACTION_DISPLAY,
            "Owner Permissions: " + permissions.getOtherPermissions() + " k\n\n");
        visualUpdate(
            TestHandler.ACTION_DISPLAY, "Permissions: " + permissions.getPermissions() + " k\n\n");
        visualUpdate(TestHandler.ACTION_DISPLAY, "Type: " + permissions.getType() + " k\n\n");
        visualUpdate(
            TestHandler.ACTION_DISPLAY,
            "User Permissions: " + permissions.getUserPermissions() + " k\n\n");
      } else {
        visualUpdate(TestHandler.ACTION_DISPLAY, "Permissions == null k\n\n");
      }

      visualUpdate(TestHandler.ACTION_PDISPLAY, "JAVA");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Running some Java code ]\n");

      Shell shell;
      try {
        shell = RootTools.getShell(true);
        JavaCommandCapture cmd =
            new JavaCommandCapture(
                43,
                false,
                SanityCheckRootTools.this,
                "com.stericson.RootToolsTests.NativeJavaClass") {

              @Override
              public void commandOutput(int id, String line) {
                super.commandOutput(id, line);
                visualUpdate(TestHandler.ACTION_DISPLAY, line + "\n");
              }
            };
        shell.add(cmd);

      } catch (Exception e) {
        // Oops. Say, did you run RootClass and move the resulting anbuild.dex " file to res/raw?
        // If you don't you will not be able to check root mode Java.
        e.printStackTrace();
      }

      visualUpdate(TestHandler.ACTION_PDISPLAY, "Testing df");
      long spaceValue = RootTools.getSpace("/data");
      visualUpdate(TestHandler.ACTION_DISPLAY, "[ Checking /data partition size]\n");
      visualUpdate(TestHandler.ACTION_DISPLAY, spaceValue + "k\n\n");

      try {
        shell = RootTools.getShell(true);

        CommandCapture cmd =
            new CommandCapture(42, false, "find /") {

              boolean _catch = false;

              @Override
              public void commandOutput(int id, String line) {
                super.commandOutput(id, line);

                if (_catch) {
                  RootTools.log("CAUGHT!!!");
                }
              }

              @Override
              public void commandTerminated(int id, String reason) {
                synchronized (SanityCheckRootTools.this) {
                  _catch = true;
                  visualUpdate(TestHandler.ACTION_PDISPLAY, "All tests complete.");
                  visualUpdate(TestHandler.ACTION_HIDE, null);

                  try {
                    RootTools.closeAllShells();
                  } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
                }
              }

              @Override
              public void commandCompleted(int id, int exitCode) {
                synchronized (SanityCheckRootTools.this) {
                  _catch = true;

                  visualUpdate(TestHandler.ACTION_PDISPLAY, "All tests complete.");
                  visualUpdate(TestHandler.ACTION_HIDE, null);

                  try {
                    RootTools.closeAllShells();
                  } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
                }
              }
            };

        shell.add(cmd);

      } catch (Exception e) {
        e.printStackTrace();
      }
    }