Exemplo n.º 1
0
 public void decodeSourcesSmali(
     File apkFile,
     File outDir,
     String filename,
     boolean debug,
     String debugLinePrefix,
     boolean bakdeb,
     int api)
     throws AndrolibException {
   try {
     File smaliDir;
     if (filename.equalsIgnoreCase("classes.dex")) {
       smaliDir = new File(outDir, SMALI_DIRNAME);
     } else {
       smaliDir =
           new File(outDir, SMALI_DIRNAME + "_" + filename.substring(0, filename.indexOf(".")));
     }
     OS.rmdir(smaliDir);
     smaliDir.mkdirs();
     LOGGER.info("Baksmaling " + filename + "...");
     SmaliDecoder.decode(apkFile, smaliDir, filename, debug, debugLinePrefix, bakdeb, api);
   } catch (BrutException ex) {
     throw new AndrolibException(ex);
   }
 }
Exemplo n.º 2
0
 public void buildLib(File appDir) throws AndrolibException {
   File working = new File(appDir, "lib");
   if (!working.exists()) {
     return;
   }
   File stored = new File(appDir, APK_DIRNAME + "/lib");
   if (apkOptions.forceBuildAll || isModified(working, stored)) {
     LOGGER.info("Copying libs...");
     try {
       OS.rmdir(stored);
       OS.cpdir(working, stored);
     } catch (BrutException ex) {
       throw new AndrolibException(ex);
     }
   }
 }
 @BeforeClass
 public static void beforeClass() throws Exception, BrutException {
   sTmpDir = new ExtFile(OS.createTempDirectory());
   sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
   sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
   LOGGER.info("Unpacking testapp...");
   TestUtils.copyResourceDir(BuildAndDecodeTest.class, "brut/apktool/testapp/", sTestOrigDir);
 }
Exemplo n.º 4
0
  @BeforeClass
  public static void beforeClass() throws Exception, BrutException {
    sTmpDir = new ExtFile(OS.createTempDirectory());
    sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
    sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
    LOGGER.info("Unpacking testapp...");
    TestUtils.copyResourceDir(BuildAndDecodeTest.class, "brut/apktool/testapp/", sTestOrigDir);

    LOGGER.info("Building testapp.apk...");
    File testApk = new File(sTmpDir, "testapp.apk");
    new Androlib().build(sTestOrigDir, testApk);

    LOGGER.info("Decoding testapp.apk...");
    ApkDecoder apkDecoder = new ApkDecoder(testApk);
    apkDecoder.setOutDir(sTestNewDir);
    apkDecoder.decode();
  }
  @BeforeClass
  public static void beforeClass() throws Exception, BrutException {
    sTmpDir = new ExtFile(OS.createTempDirectory());
    sTestOrigDir = new ExtFile(sTmpDir, "testjar-orig");
    sTestNewDir = new ExtFile(sTmpDir, "testjar-new");
    LOGGER.info("Unpacking testjar...");
    TestUtils.copyResourceDir(BuildAndDecodeJarTest.class, "brut/apktool/testjar/", sTestOrigDir);

    LOGGER.info("Building testjar.jar...");
    File testJar = new File(sTmpDir, "testjar.jar");
    new Androlib().build(sTestOrigDir, testJar, TestUtils.returnStockHashMap(), "");

    LOGGER.info("Decoding testjar.jar...");
    ApkDecoder apkDecoder = new ApkDecoder(testJar);
    apkDecoder.setOutDir(sTestNewDir);
    apkDecoder.decode();
  }
Exemplo n.º 6
0
 @AfterClass
 public static void afterClass() throws BrutException {
   OS.rmdir(sTmpDir);
 }
Exemplo n.º 7
0
  public void aaptPackage(
      File apkFile,
      File manifest,
      File resDir,
      File rawDir,
      File assetDir,
      File[] include,
      boolean update,
      boolean framework)
      throws AndrolibException {
    List<String> cmd = new ArrayList<String>();

    cmd.add("aapt");
    cmd.add("p");
    cmd.add("-v"); // mega debug mode.@todo REMOVE ON FINAL
    if (update) {
      cmd.add("-u");
    }
    if (mMinSdkVersion != null) {
      cmd.add("--min-sdk-version");
      cmd.add(mMinSdkVersion);
    }
    if (mTargetSdkVersion != null) {
      cmd.add("--target-sdk-version");
      cmd.add(mTargetSdkVersion);
    }
    if (mMaxSdkVersion != null) {
      cmd.add("--max-sdk-version");
      cmd.add(mMaxSdkVersion);
    }
    cmd.add("-F");
    cmd.add(apkFile.getAbsolutePath());

    if (framework) {
      cmd.add("-x");
      //            cmd.add("-0");
      //            cmd.add("arsc");
    }

    if (include != null) {
      for (File file : include) {
        cmd.add("-I");
        cmd.add(file.getPath());
      }
    }
    if (resDir != null) {
      cmd.add("-S");
      cmd.add(resDir.getAbsolutePath());
    }
    if (manifest != null) {
      cmd.add("-M");
      cmd.add(manifest.getAbsolutePath());
    }
    if (assetDir != null) {
      cmd.add("-A");
      cmd.add(assetDir.getAbsolutePath());
    }
    if (rawDir != null) {
      cmd.add(rawDir.getAbsolutePath());
    }

    try {
      OS.exec(cmd.toArray(new String[0]));
    } catch (BrutException ex) {
      throw new AndrolibException(ex);
    }
  }