コード例 #1
1
  public void publicizeResources(File arscFile) throws AndrolibException {
    byte[] data = new byte[(int) arscFile.length()];

    InputStream in = null;
    OutputStream out = null;
    try {
      in = new FileInputStream(arscFile);
      in.read(data);

      publicizeResources(data);

      out = new FileOutputStream(arscFile);
      out.write(data);
    } catch (IOException ex) {
      throw new AndrolibException(ex);
    } finally {
      if (in != null) {
        try {
          in.close();
        } catch (IOException ex) {
        }
      }
      if (out != null) {
        try {
          out.close();
        } catch (IOException ex) {
        }
      }
    }
  }
コード例 #2
0
  private void generatePublicXml(ResPackage pkg, Directory out, XmlSerializer serial)
      throws AndrolibException {
    try {
      OutputStream outStream = out.getFileOutput("values/public.xml");
      serial.setOutput(outStream, null);
      serial.startDocument(null, null);
      serial.startTag(null, "resources");

      for (ResResSpec spec : pkg.listResSpecs()) {
        serial.startTag(null, "public");
        serial.attribute(null, "type", spec.getType().getName());
        serial.attribute(null, "name", spec.getName());
        serial.attribute(null, "id", String.format("0x%08x", spec.getId().id));
        serial.endTag(null, "public");
      }

      serial.endTag(null, "resources");
      serial.endDocument();
      serial.flush();
      outStream.close();
    } catch (IOException ex) {
      throw new AndrolibException("Could not generate public.xml file", ex);
    } catch (DirectoryException ex) {
      throw new AndrolibException("Could not generate public.xml file", ex);
    }
  }
コード例 #3
0
  private void generateValuesFile(ResValuesFile valuesFile, Directory out, ExtXmlSerializer serial)
      throws AndrolibException {
    try {
      OutputStream outStream = out.getFileOutput(valuesFile.getPath());
      serial.setOutput((outStream), null);
      serial.startDocument(null, null);
      serial.startTag(null, "resources");

      for (ResResource res : valuesFile.listResources()) {
        if (valuesFile.isSynthesized(res)) {
          continue;
        }
        ((ResValuesXmlSerializable) res.getValue()).serializeToResValuesXml(serial, res);
      }

      serial.endTag(null, "resources");
      serial.newLine();
      serial.endDocument();
      serial.flush();
      outStream.close();
    } catch (IOException ex) {
      throw new AndrolibException("Could not generate: " + valuesFile.getPath(), ex);
    } catch (DirectoryException ex) {
      throw new AndrolibException("Could not generate: " + valuesFile.getPath(), ex);
    }
  }
コード例 #4
0
  public File getFrameworkApk(int id, String frameTag) throws AndrolibException {
    File dir = getFrameworkDir();
    File apk;

    if (frameTag != null) {
      apk = new File(dir, String.valueOf(id) + '-' + frameTag + ".apk");
      if (apk.exists()) {
        return apk;
      }
    }

    apk = new File(dir, String.valueOf(id) + ".apk");
    if (apk.exists()) {
      return apk;
    }

    if (id == 1) {
      InputStream in = null;
      OutputStream out = null;
      try {
        in = AndrolibResources.class.getResourceAsStream("/brut/androlib/android-framework.jar");
        out = new FileOutputStream(apk);
        IOUtils.copy(in, out);
        return apk;
      } catch (IOException ex) {
        throw new AndrolibException(ex);
      } finally {
        if (in != null) {
          try {
            in.close();
          } catch (IOException ex) {
          }
        }
        if (out != null) {
          try {
            out.close();
          } catch (IOException ex) {
          }
        }
      }
    }

    throw new CantFindFrameworkResException(id);
  }