Ejemplo n.º 1
0
  public ResPackage loadMainPkg(ResTable resTable, ExtFile apkFile) throws AndrolibException {
    LOGGER.info("Loading resource table...");
    ResPackage[] pkgs = getResPackagesFromApk(apkFile, resTable, sKeepBroken);
    ResPackage pkg = null;

    switch (pkgs.length) {
      case 1:
        pkg = pkgs[0];
        break;
      case 2:
        if (pkgs[0].getName().equals("android")) {
          LOGGER.warning("Skipping \"android\" package group");
          pkg = pkgs[1];
        } else if (pkgs[0].getName().equals("com.htc")) {
          LOGGER.warning("Skipping \"htc\" stupid package group");
          pkg = pkgs[1];
        }
        break;
    }

    if (pkg == null) {
      throw new AndrolibException("Arsc files with zero or multiple packages");
    }

    resTable.addPackage(pkg, true);
    LOGGER.info("Loaded.");
    return pkg;
  }
Ejemplo n.º 2
0
  public ResPackage loadFrameworkPkg(ResTable resTable, int id, String frameTag)
      throws AndrolibException {
    File apk = getFrameworkApk(id, frameTag);

    LOGGER.info("Loading resource table from file: " + apk);
    ResPackage[] pkgs = getResPackagesFromApk(new ExtFile(apk), resTable, true);

    if (pkgs.length != 1) {
      throw new AndrolibException("Arsc files with zero or multiple packages");
    }

    ResPackage pkg = pkgs[0];
    if (pkg.getId() != id) {
      throw new AndrolibException(
          "Expected pkg of id: " + String.valueOf(id) + ", got: " + pkg.getId());
    }

    resTable.addPackage(pkg, false);
    LOGGER.info("Loaded.");
    return pkg;
  }