示例#1
0
 public static void doBLUnlock() {
   try {
     Devices.waitForReboot(false);
     PluginInterface po = (PluginInterface) plugins.get("Bootloader Unlock");
     po.run();
   } catch (Exception e) {
     MyLogger.getLogger().error("The BootLoader Unlock plugin is not loaded");
   }
 }
示例#2
0
  public static void registerPlugin(String type, String classname, String workdir) {
    try {

      Class<?> pluginClass = Class.forName(classname);
      Constructor<?> constr = pluginClass.getConstructor();
      PluginInterface pluginObject = (PluginInterface) constr.newInstance();
      pluginObject.setWorkdir(workdir);
      boolean aenabled = false;
      String aversion = Devices.getCurrent().getVersion();
      Enumeration<String> e1 = pluginObject.getCompatibleAndroidVersions();
      while (e1.hasMoreElements()) {
        String pversion = e1.nextElement();
        if (aversion.startsWith(pversion) || pversion.equals("any")) aenabled = true;
      }

      boolean kenabled = false;
      String kversion = Devices.getCurrent().getKernelVersion();
      Enumeration<String> e2 = pluginObject.getCompatibleKernelVersions();
      while (e2.hasMoreElements()) {
        String pversion = e2.nextElement();
        if (kversion.equals(pversion) || pversion.equals("any")) kenabled = true;
      }

      boolean denabled = false;
      if (type.equals("generic")) {
        String currdevid = Devices.getCurrent().getId();
        Enumeration<String> e3 = pluginObject.getCompatibleDevices();
        while (e3.hasMoreElements()) {
          String pversion = e3.nextElement();
          if (currdevid.equals(pversion) || pversion.equals("any")) denabled = true;
        }
      } else denabled = true;

      boolean hasroot = false;
      if (pluginObject.isRootNeeded()) hasroot = Devices.getCurrent().hasRoot();

      if (type.equals("device") && aenabled && kenabled && denabled && hasroot) {
        plugins.put(pluginObject.getName(), pluginObject);
      } else if (aenabled && kenabled && denabled && hasroot)
        plugins.put(pluginObject.getName(), pluginObject);
      Enumeration e = plugins.keys();
      while (e.hasMoreElements()) {
        String pname = (String) e.nextElement();
      }
    } catch (Exception e) {
      MyLogger.getLogger().error(e.getMessage());
    }
  }