コード例 #1
0
ファイル: AdbUtility.java プロジェクト: Jogi1977/Flashtool
 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) {
   }
 }
コード例 #2
0
ファイル: AdbUtility.java プロジェクト: Jogi1977/Flashtool
 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;
 }
コード例 #3
0
ファイル: AdbUtility.java プロジェクト: Jogi1977/Flashtool
 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 "";
   }
 }
コード例 #4
0
ファイル: AdbUtility.java プロジェクト: Jogi1977/Flashtool
 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 "";
   }
 }
コード例 #5
0
ファイル: AdbUtility.java プロジェクト: Jogi1977/Flashtool
 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;
 }