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(); } }
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(); }
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(); } }