Example #1
0
 private static void load() {
   if (props == null) props = new Properties();
   else props.clear();
   File[] list = (new File(OS.getWorkDir() + OS.getFileSeparator() + "devices")).listFiles();
   if (list == null) return;
   for (int i = 0; i < list.length; i++) {
     if (list[i].isDirectory()) {
       PropertiesFile p = new PropertiesFile();
       String device =
           list[i].getPath().substring(list[i].getPath().lastIndexOf(OS.getFileSeparator()) + 1);
       try {
         if (!device.toLowerCase().equals("busybox")) {
           p.open(
               "",
               new File(list[i].getPath() + OS.getFileSeparator() + device + ".properties")
                   .getAbsolutePath());
           DeviceEntry entry = new DeviceEntry(p);
           if (device.equals(entry.getId())) props.put(device, entry);
           else MyLogger.getLogger().error(device + " : this bundle is not valid");
         }
       } catch (Exception fne) {
         MyLogger.getLogger().error(device + " : this bundle is not valid");
       }
     }
   }
 }
Example #2
0
 public static String identFromRecognition() {
   Enumeration<Object> e = Devices.listDevices(true);
   if (!e.hasMoreElements()) {
     MyLogger.getLogger().error("No device is registered in Flashtool.");
     MyLogger.getLogger().error("You can only flash devices.");
     return "";
   }
   boolean found = false;
   Properties founditems = new Properties();
   founditems.clear();
   Properties buildprop = new Properties();
   buildprop.clear();
   while (e.hasMoreElements()) {
     DeviceEntry current = Devices.getDevice((String) e.nextElement());
     String prop = current.getBuildProp();
     if (!buildprop.containsKey(prop)) {
       String readprop = DeviceProperties.getProperty(prop);
       buildprop.setProperty(prop, readprop);
     }
     Iterator<String> i = current.getRecognitionList().iterator();
     String localdev = buildprop.getProperty(prop);
     while (i.hasNext()) {
       String pattern = i.next().toUpperCase();
       if (localdev.toUpperCase().equals(pattern)) {
         founditems.put(current.getId(), current.getName());
       }
     }
   }
   if (founditems.size() == 1) {
     return (String) founditems.keys().nextElement();
   } else return "";
 }
Example #3
0
 public static String getVariantName(String dev) {
   Enumeration<Object> e = Devices.listDevices(true);
   while (e.hasMoreElements()) {
     DeviceEntry current = Devices.getDevice((String) e.nextElement());
     if (current.getVariantList().contains(dev)) return current.getName() + " (" + dev + ")";
   }
   return dev;
 }
Example #4
0
 public static void doIdent() {
   Enumeration<Object> e = Devices.listDevices(true);
   if (!e.hasMoreElements()) {
     MyLogger.getLogger().error("No device is registered in Flashtool.");
     MyLogger.getLogger().error("You can only flash devices.");
     return;
   }
   boolean found = false;
   Properties founditems = new Properties();
   founditems.clear();
   Properties buildprop = new Properties();
   buildprop.clear();
   while (e.hasMoreElements()) {
     DeviceEntry current = Devices.getDevice((String) e.nextElement());
     String prop = current.getBuildProp();
     if (!buildprop.containsKey(prop)) {
       String readprop = DeviceProperties.getProperty(prop);
       buildprop.setProperty(prop, readprop);
     }
     Iterator<String> i = current.getRecognitionList().iterator();
     String localdev = buildprop.getProperty(prop);
     while (i.hasNext()) {
       String pattern = i.next().toUpperCase();
       if (localdev.toUpperCase().contains(pattern)) {
         founditems.put(current.getId(), current.getName());
       }
     }
   }
   if (founditems.size() == 1) {
     found = true;
     Devices.setCurrent((String) founditems.keys().nextElement());
     if (!Devices.isWaitingForReboot())
       MyLogger.getLogger().info("Connected device : " + Devices.getCurrent().getId());
   } else {
     MyLogger.getLogger().error("Cannot identify your device.");
     MyLogger.getLogger().error("You can only flash devices.");
   }
   if (found) {
     if (!Devices.isWaitingForReboot()) {
       MyLogger.getLogger()
           .info(
               "Installed version of busybox : "
                   + Devices.getCurrent().getInstalledBusyboxVersion());
       MyLogger.getLogger()
           .info(
               "Android version : "
                   + Devices.getCurrent().getVersion()
                   + " / kernel version : "
                   + Devices.getCurrent().getKernelVersion());
     }
     if (Devices.getCurrent().isRecovery()) {
       MyLogger.getLogger().info("Phone in recovery mode");
       if (!Devices.isWaitingForReboot()) MyLogger.getLogger().info("Root Access Allowed");
     } else {
       boolean hasSU = Devices.getCurrent().hasSU();
       if (hasSU) {
         boolean hasRoot = Devices.getCurrent().hasRoot();
         if (hasRoot)
           if (!Devices.isWaitingForReboot()) MyLogger.getLogger().info("Root Access Allowed");
       }
     }
     plugins.clear();
     addDevicesPlugins();
     addGenericPlugins();
     MyLogger.getLogger().debug("Stop waiting for device");
     if (Devices.isWaitingForReboot()) Devices.stopWaitForReboot();
     MyLogger.getLogger().debug("End of identification");
   }
 }
Example #5
0
 public static void setCurrent(String device) {
   AdbUtility.init();
   _current = (DeviceEntry) props.get(device);
   _current.queryAll();
 }
Example #6
0
 protected IStatus run(IProgressMonitor monitor) {
   try {
     DeviceEntry ent = new DeviceEntry(platform);
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + "cert.properties")
         .exists()) throw new Exception("cert.properties is missing");
     Properties p = new Properties();
     try {
       p.load(
           new FileInputStream(
               new File(
                   ent.getDeviceDir()
                       + File.separator
                       + "blu"
                       + File.separator
                       + "files"
                       + File.separator
                       + "cert.properties")));
     } catch (Exception ex) {
     }
     String bootwrite = "";
     Enumeration<Object> e = p.keys();
     while (e.hasMoreElements()) {
       String key = (String) e.nextElement();
       if (p.getProperty(key).equals(phonecert)) {
         bootwrite = key;
         break;
       }
     }
     if (bootwrite.length() == 0) throw new Exception("Phone certificate not identified");
     bootwrite = "bootwrite_" + bootwrite + "SL";
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + bootwrite)
         .exists()) throw new Exception(bootwrite + " is missing");
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + "fixPart")
         .exists()) throw new Exception("fixPart is missing");
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + "mapper_2.6.29.ko")
         .exists()) throw new Exception("mapper_2.6.29.ko is missing");
     if (platform.equals("X10"))
       if (!new File(
               ent.getDeviceDir()
                   + File.separator
                   + "blu"
                   + File.separator
                   + "files"
                   + File.separator
                   + "mapper_2.6.29-00054-g5f01537.ko")
           .exists()) throw new Exception("mapper_2.6.29-00054-g5f01537.ko is missing");
     MyLogger.getLogger().info("Waiting for device to reboot");
     Devices.waitForReboot(false);
     if (!Devices.getCurrent().getKernelVersion().equals("2.6.29-00054-g5f01537")
         && !Devices.getCurrent().getKernelVersion().equals("2.6.29"))
       throw new Exception("Kernel does not match a compatible one");
     if (!Devices.getCurrent().hasRoot()) throw new Exception("Device must be rooted first");
     String mapper = "mapper_" + Devices.getCurrent().getKernelVersion() + ".ko";
     AdbUtility.push(
         ent.getDeviceDir()
             + File.separator
             + "blu"
             + File.separator
             + "files"
             + File.separator
             + "fixPart",
         GlobalConfig.getProperty("deviceworkdir"));
     FTShell fixpart =
         new FTShell(
             new File(
                 ent.getDeviceDir()
                     + File.separator
                     + "blu"
                     + File.separator
                     + "shells"
                     + File.separator
                     + "runfixPart"));
     String output = fixpart.runRoot();
     if (!output.contains("success")) throw new Exception("Error applying fixpart: " + output);
     MyLogger.getLogger().info("Successfully applied fixPart. Rebooting");
     Devices.getCurrent().reboot();
     Devices.waitForReboot(false);
     AdbUtility.push(
         ent.getDeviceDir()
             + File.separator
             + "blu"
             + File.separator
             + "files"
             + File.separator
             + mapper,
         GlobalConfig.getProperty("deviceworkdir"));
     AdbUtility.push(
         ent.getDeviceDir()
             + File.separator
             + "blu"
             + File.separator
             + "files"
             + File.separator
             + bootwrite,
         GlobalConfig.getProperty("deviceworkdir"));
     FTShell runbootwrite =
         new FTShell(
             new File(
                 ent.getDeviceDir()
                     + File.separator
                     + "blu"
                     + File.separator
                     + "shells"
                     + File.separator
                     + "runbootwrite"));
     runbootwrite.setProperty("KVER", Devices.getCurrent().getKernelVersion());
     runbootwrite.setProperty("BOOTWRITEBIN", bootwrite);
     output = runbootwrite.runRoot();
     if (!output.contains("success")) throw new Exception("Error applying fixpart: " + output);
     MyLogger.getLogger()
         .info("Successfully applied bootwrite. Bootloader should be unlocked. Rebooting");
     Devices.getCurrent().reboot();
     return Status.OK_STATUS;
   } catch (Exception e) {
     e.printStackTrace();
     MyLogger.getLogger().error(e.getMessage());
     return Status.CANCEL_STATUS;
   }
 }