Example #1
0
 public static void antiRic() {
   try {
     Scanner scan = new Scanner(AdbUtility.run("ps"));
     String path = "";
     String pid = "";
     while (scan.hasNextLine()) {
       String line = scan.nextLine();
       if (line.contains("bin/ric")) {
         String[] fields = line.split("\\s+");
         pid = fields[1];
         path = fields[fields.length - 1];
       }
     }
     scan.close();
     if (path.length() > 0) {
       MyLogger.getLogger().info("Stopping ric service");
       AdbUtility.run(
           "su -c 'mount -o remount,rw / && mv "
               + path
               + " "
               + path
               + "c && mount -o remount,ro / && kill -9 "
               + pid
               + "'");
       MyLogger.getLogger().info("ric service stopped successfully");
     }
   } catch (Exception e) {
   }
 }
Example #2
0
 public static long rawBackup(String source, String destination) {
   String md5source = getMD5(source);
   String result = "";
   long transferred = 0L;
   try {
     result =
         AdbUtility.run(
             "su -c 'dd if="
                 + source
                 + " of="
                 + destination
                 + " && sync && sync && sync && sync'");
   } catch (Exception e) {
   }
   if (!result.contains("bytes transferred")) return 0L;
   Scanner sc = new Scanner(result);
   while (sc.hasNextLine()) {
     String line = sc.nextLine();
     if (line.contains("bytes")) {
       transferred = Long.parseLong(line.split(" ")[0]);
     }
   }
   String md5destination = getMD5(destination);
   if (!md5source.equals(md5destination)) return 0L;
   return transferred;
 }
Example #3
0
 public static String getMD5(String source) {
   try {
     String md5 =
         AdbUtility.run("su -c 'busybox md5sum " + source + "'")
             .split(" ")[0]
             .toUpperCase()
             .trim();
     if (md5 == null) return "";
     if (md5.length() != 32) md5 = "";
     return md5;
   } catch (Exception e) {
     return "";
   }
 }
Example #4
0
 public static String getKernelVersion(boolean hasbusybox) {
   try {
     String result = "";
     if (!hasbusybox) {
       AdbUtility.push(
           Devices.getCurrent().getBusybox(false),
           GlobalConfig.getProperty("deviceworkdir") + "/busybox1",
           false);
       AdbUtility.run("chmod 755 " + GlobalConfig.getProperty("deviceworkdir") + "/busybox1");
       result = run(GlobalConfig.getProperty("deviceworkdir") + "/busybox1 uname -r");
       run("rm -r " + GlobalConfig.getProperty("deviceworkdir") + "/busybox1");
     } else result = run("busybox uname -r");
     return result;
   } catch (Exception e) {
     return "";
   }
 }
Example #5
0
 public static long getSizeOf(String source) {
   String result = "";
   try {
     result = AdbUtility.run("su -c 'busybox stat " + source + "'");
   } catch (Exception e) {
     result = "";
   }
   if (!result.contains("Size")) return 0L;
   Scanner sc = new Scanner(result);
   while (sc.hasNextLine()) {
     String line = sc.nextLine();
     if (line.contains("Size")) {
       return Long.parseLong(
           line.substring(line.indexOf("Size"), line.indexOf("Blocks"))
               .replace("Size:", "")
               .trim());
     }
   }
   return 0L;
 }