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