Skip to content

Commit

Permalink
[tinker] Copy pre-generated patch dex to tempPatchedDexes directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
tys282000 committed Oct 14, 2016
1 parent 8883448 commit 49cab9e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.tencent.tinker.build.decoder;


import com.google.common.io.Files;

import com.tencent.tinker.android.dex.ClassDef;
import com.tencent.tinker.android.dex.Dex;
import com.tencent.tinker.android.dex.DexFormat;
Expand Down Expand Up @@ -69,7 +71,7 @@
*/
public class DexDiffDecoder extends BaseDecoder {
private static final String TEST_DEX_NAME = "test.dex";
private static final String STUBMODE_PATCH_DEX_NAME = "changed_classes.dex";
private static final String PREGENERATED_PATCH_DEX_NAME = "changed_classes.dex";

private final InfoWriter logWriter;
private final InfoWriter metaWriter;
Expand Down Expand Up @@ -282,14 +284,18 @@ private void generateStubModePatchDex() throws IOException {

// Write constructed stub mode patch dex to file and record it in meta file.
final String dexMode = config.mDexRaw ? "raw" : "jar";
final File dest = new File(config.mTempResultDir + "/" + STUBMODE_PATCH_DEX_NAME);
final File dest = new File(config.mTempResultDir + "/" + PREGENERATED_PATCH_DEX_NAME);

FileDataStore fileDataStore = new FileDataStore(dest);
dexBuilder.writeTo(fileDataStore);

final File tempPreGeneratedPatchDexPath = new File(config.mOutFolder + File.separator + TypedValue.DEX_TEMP_PATCH_DIR + File.separator + "pre-generated");
ensureDirectoryExist(tempPreGeneratedPatchDexPath);
Files.copy(dest, new File(tempPreGeneratedPatchDexPath, PREGENERATED_PATCH_DEX_NAME));

final String md5 = MD5.getMD5(dest);

String meta = STUBMODE_PATCH_DEX_NAME + "," + "" + "," + md5 + "," + md5 + "," + 0
String meta = PREGENERATED_PATCH_DEX_NAME + "," + "" + "," + md5 + "," + md5 + "," + 0
+ "," + 0 + "," + dexMode;

Logger.d("\nPre-generated patch dex: %s, size:%d", dest.getAbsolutePath(), dest.length());
Expand Down

0 comments on commit 49cab9e

Please sign in to comment.