Skip to content

Commit 1162871

Browse files
committed
Merge branch 'dev_1_9_14_26' into dev
2 parents 836ca8b + 4b56163 commit 1162871

File tree

12 files changed

+342
-329
lines changed

12 files changed

+342
-329
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ext {
3636
javaVersion = JavaVersion.VERSION_1_8
3737

3838
GROUP = 'com.tencent.tinker'
39-
VERSION_NAME = '1.9.14.25.3'
39+
VERSION_NAME = '1.9.14.26'
4040

4141
POM_DESCRIPTION = 'Tinker is a hot-fix solution library for Android, it supports dex, library and resources update without reinstalling apk.'
4242
POM_URL = 'https://github.com/Tencent/tinker'

tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/patch/BasePatchInternal.java

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.tencent.tinker.lib.patch;
1818

1919
import com.tencent.tinker.commons.util.IOHelper;
20+
import com.tencent.tinker.loader.shareutil.ShareTinkerInternals;
2021
import com.tencent.tinker.loader.shareutil.ShareTinkerLog;
2122
import com.tencent.tinker.loader.shareutil.ShareConstants;
2223
import com.tencent.tinker.loader.shareutil.SharePatchFileUtil;
@@ -66,6 +67,7 @@ public static boolean extract(ZipFile zipFile, ZipEntry entryFile, File extractT
6667
try {
6768
is = new BufferedInputStream(zipFile.getInputStream(entryFile));
6869
os = new BufferedOutputStream(new FileOutputStream(extractTo));
70+
extractTo.setReadOnly();
6971
byte[] buffer = new byte[ShareConstants.BUFFER_SIZE];
7072
int length = 0;
7173
while ((length = is.read(buffer)) > 0) {

tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/patch/DexDiffPatchInternal.java

+8
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ private static boolean mergeClassNDexFiles(final Context context, final File pat
280280
AlignedZipOutputStream out = null;
281281
try {
282282
out = new AlignedZipOutputStream(new BufferedOutputStream(new FileOutputStream(classNFile)));
283+
classNFile.setReadOnly();
283284
for (ShareDexDiffPatchInfo info : classNDexInfo.keySet()) {
284285
File dexFile = classNDexInfo.get(info);
285286
if (info.isJarMode) {
@@ -648,6 +649,10 @@ private static boolean extractDexToJar(ZipFile zipFile, ZipEntry entryFile, File
648649
try {
649650
zos = new ZipOutputStream(new
650651
BufferedOutputStream(new FileOutputStream(extractTo)));
652+
if (ShareTinkerInternals.isNewerOrEqualThanVersion(33, true)) {
653+
extractTo.setReadOnly();
654+
}
655+
651656
bis = new BufferedInputStream(zipFile.getInputStream(entryFile));
652657

653658
byte[] buffer = new byte[ShareConstants.BUFFER_SIZE];
@@ -719,6 +724,9 @@ private static void patchDexFile(
719724
try {
720725
oldDexStream = new BufferedInputStream(baseApk.getInputStream(oldDexEntry));
721726
patchFileStream = (patchFileEntry != null ? new BufferedInputStream(patchPkg.getInputStream(patchFileEntry)) : null);
727+
if (ShareTinkerInternals.isNewerOrEqualThanVersion(33, true)) {
728+
patchedDexFile.setReadOnly();
729+
}
722730

723731
final boolean isRawDexFile = SharePatchFileUtil.isRawDexFile(patchInfo.rawName);
724732
if (!isRawDexFile || patchInfo.isJarMode) {

tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/patch/ResDiffPatchInternal.java

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ private static boolean extractResourceDiffInternals(Context context, String dir,
135135
int totalEntryCount = 0;
136136
try {
137137
out = new TinkerZipOutputStream(new BufferedOutputStream(new FileOutputStream(resOutput)));
138+
resOutput.setReadOnly();
138139
oldApk = new TinkerZipFile(apkPath);
139140
newApk = new TinkerZipFile(patchFile);
140141
final Enumeration<? extends TinkerZipEntry> entries = oldApk.entries();

tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/patch/UpgradePatch.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,15 @@ public boolean tryPatch(Context context, String tempPatchPath, boolean useEmerge
126126
// if it is interpret now, use changing flag to wait main process
127127
final String finalOatDir = usingInterpret ? ShareConstants.CHANING_DEX_OPTIMIZE_PATH : oldInfo.oatDir;
128128
if (!patchMd5.equals(oldInfo.newVersion) && !oldInfo.newVersion.equals(oldInfo.oldVersion)) {
129+
// Mark previous new version to old one before delete current new version so that all processes can stay at the
130+
// same version after restart but before the latest new version finish applying.
131+
final String lastNewVersion = oldInfo.newVersion;
132+
oldInfo.newVersion = oldInfo.oldVersion;
133+
SharePatchInfo.rewritePatchInfoFileWithLock(patchInfoFile, oldInfo, patchInfoLockFile);
134+
129135
// Currently applied patch is not the same as last applied one and the last applied one is not loaded,
130136
// so we can delete the last applied patch to avoid patch artifacts accumulating.
131-
final String patchName = SharePatchFileUtil.getPatchVersionDirectory(oldInfo.newVersion);
137+
final String patchName = SharePatchFileUtil.getPatchVersionDirectory(lastNewVersion);
132138
SharePatchFileUtil.deleteDir(new File(patchDirectory, patchName));
133139
}
134140
final String versionToRemove;

tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/ShareConstants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public class ShareConstants {
102102
public static final String PATCH_TEMP_DIRECTORY_NAME = "tinker_temp";
103103
public static final String PATCH_TEMP_LAST_CRASH_NAME = "tinker_last_crash";
104104

105-
public static final String PATCH_INFO_NAME = "patch.info";
105+
public static final String PATCH_INFO_NAME = "patch_meta.info";
106106
public static final String PATCH_INFO_LOCK_NAME = "info.lock";
107107

108108
public static final String META_SUFFIX = "meta.txt";

tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/AppInfoChangedBlocker.java

-107
This file was deleted.

0 commit comments

Comments
 (0)