Skip to content

Commit 987e4f2

Browse files
author
tangyinsheng
committed
Merge branch 'hotfix/1.9.14.25' into dev
# Conflicts: # build.gradle
2 parents ec41878 + f56358d commit 987e4f2

File tree

5 files changed

+109
-57
lines changed

5 files changed

+109
-57
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
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.27'
39+
VERSION_NAME = '1.9.14.25.1'
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'

gradle/WeChatPublish.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class WeChatPublishExtension {
166166
}
167167

168168
private void checkVersion() {
169-
if (!(fullVersion ==~ /\d+\.\d+(?:\.\d+)?(?:\.\d+)?(?:-[\w-]+)?/)) {
169+
if (!(fullVersion ==~ /\d+\.\d+(?:\.\d+)?(?:\.\d+)?(?:\.\d+)?(?:-[\w-]+)?/)) {
170170
def message = "Invalid version: ${fullVersion}"
171171
if (!isSnapshot)
172172
throw new GradleException(message)

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

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@
2828
import android.text.TextUtils;
2929

3030
import java.io.BufferedInputStream;
31+
import java.io.BufferedReader;
3132
import java.io.ByteArrayOutputStream;
3233
import java.io.File;
3334
import java.io.FileInputStream;
3435
import java.io.IOException;
3536
import java.io.InputStream;
37+
import java.io.InputStreamReader;
3638
import java.io.PrintStream;
3739
import java.lang.reflect.InvocationTargetException;
3840
import java.lang.reflect.Method;
@@ -104,14 +106,41 @@ public static boolean isAfterAndroidO() {
104106
return Build.VERSION.SDK_INT > 25;
105107
}
106108

107-
public static String getCurrentInstructionSet() throws Exception {
109+
public static String getCurrentInstructionSet() {
108110
if (currentInstructionSet != null) {
109111
return currentInstructionSet;
110112
}
111-
Class<?> clazz = Class.forName("dalvik.system.VMRuntime");
112-
Method currentGet = clazz.getDeclaredMethod("getCurrentInstructionSet");
113113

114-
currentInstructionSet = (String) currentGet.invoke(null);
114+
try {
115+
Class<?> clazz = Class.forName("dalvik.system.VMRuntime");
116+
Method currentGet = clazz.getDeclaredMethod("getCurrentInstructionSet");
117+
currentGet.setAccessible(true);
118+
currentInstructionSet = (String) currentGet.invoke(null);
119+
} catch (Throwable ignored) {
120+
switch (Build.CPU_ABI) {
121+
case "armeabi":
122+
case "armeabi-v7a":
123+
currentInstructionSet = "arm";
124+
break;
125+
case "arm64-v8a":
126+
currentInstructionSet = "arm64";
127+
break;
128+
case "x86":
129+
currentInstructionSet = "x86";
130+
break;
131+
case "x86_64":
132+
currentInstructionSet = "x86_64";
133+
break;
134+
case "mips":
135+
currentInstructionSet = "mips";
136+
break;
137+
case "mips64":
138+
currentInstructionSet = "mips64";
139+
break;
140+
default:
141+
throw new IllegalStateException("Unsupported abi: " + Build.CPU_ABI);
142+
}
143+
}
115144
ShareTinkerLog.d(TAG, "getCurrentInstructionSet:" + currentInstructionSet);
116145
return currentInstructionSet;
117146
}
@@ -484,13 +513,44 @@ public static String getProcessName(Context context) {
484513

485514
@SuppressLint("NewApi")
486515
private static String getProcessNameInternal(final Context context) {
487-
if (ShareTinkerInternals.isNewerOrEqualThanVersion(28, true)) {
516+
if (isNewerOrEqualThanVersion(28, true)) {
488517
final String result = Application.getProcessName();
489518
if (!TextUtils.isEmpty(result)) {
490519
return result;
491520
}
492521
}
493522

523+
// The 'currentProcess' method only exists on api 18 and newer systems.
524+
if (isNewerOrEqualThanVersion(18, true)) {
525+
try {
526+
final Class<?> activityThreadClazz = Class.forName("android.app.ActivityThread");
527+
final Method currentProcessMethod = ShareReflectUtil.findMethod(activityThreadClazz, "currentProcessName");
528+
currentProcessMethod.setAccessible(true);
529+
final String result = (String) currentProcessMethod.invoke(null);
530+
if (result != null && !result.isEmpty()) {
531+
return result;
532+
}
533+
} catch (Throwable thr) {
534+
ShareTinkerLog.e(TAG, "getProcessNameInternal reflect activity thread exception:" + thr.getMessage());
535+
}
536+
}
537+
538+
BufferedReader br = null;
539+
try {
540+
br = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/self/cmdline"), StandardCharsets.US_ASCII));
541+
String result = br.readLine();
542+
if (result != null) {
543+
result = result.trim();
544+
if (!result.isEmpty()) {
545+
return result;
546+
}
547+
}
548+
} catch (Throwable thr) {
549+
ShareTinkerLog.e(TAG, "getProcessNameInternal parse cmdline exception:" + thr.getMessage());
550+
} finally {
551+
SharePatchFileUtil.closeQuietly(br);
552+
}
553+
494554
if (context != null) {
495555
try {
496556
final int myPid = android.os.Process.myPid();
@@ -506,26 +566,11 @@ private static String getProcessNameInternal(final Context context) {
506566
}
507567
}
508568
}
509-
} catch (Throwable ignored) {
510-
// Ignored.
569+
} catch (Throwable thr) {
570+
ShareTinkerLog.e(TAG, "getProcessNameInternal getRunningAppProcesses exception:" + thr.getMessage());
511571
}
512572
}
513573

514-
final byte[] buf = new byte[2048];
515-
InputStream in = null;
516-
try {
517-
in = new BufferedInputStream(new FileInputStream("/proc/self/cmdline"));
518-
int len = in.read(buf);
519-
while (len > 0 && (buf[len - 1] <= 0 || buf[len - 1] == 10 || buf[len - 1] == 13)) --len;
520-
if (len > 0) {
521-
return new String(buf, StandardCharsets.US_ASCII);
522-
}
523-
} catch (Throwable thr) {
524-
ShareTinkerLog.e(TAG, "getProcessNameInternal parse cmdline exception:" + thr.getMessage());
525-
} finally {
526-
SharePatchFileUtil.closeQuietly(in);
527-
}
528-
529574
return null;
530575
}
531576

tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
import android.content.pm.ApplicationInfo;
2626
import android.content.pm.PackageManager;
2727
import android.os.Build;
28+
import android.os.Build.VERSION;
2829
import android.text.TextUtils;
2930

3031
import com.tencent.tinker.loader.TinkerRuntimeException;
3132

3233
import java.io.BufferedInputStream;
34+
import java.io.BufferedReader;
3335
import java.io.ByteArrayOutputStream;
3436
import java.io.DataInputStream;
3537
import java.io.DataOutputStream;
@@ -38,6 +40,7 @@
3840
import java.io.FileOutputStream;
3941
import java.io.IOException;
4042
import java.io.InputStream;
43+
import java.io.InputStreamReader;
4144
import java.io.PrintStream;
4245
import java.lang.reflect.InvocationTargetException;
4346
import java.lang.reflect.Method;
@@ -122,10 +125,10 @@ public static String getCurrentInstructionSet() {
122125
} catch (Throwable ignored) {
123126
switch (Build.CPU_ABI) {
124127
case "armeabi":
125-
case "armeabi_v7a":
128+
case "armeabi-v7a":
126129
currentInstructionSet = "arm";
127130
break;
128-
case "arm64_v8a":
131+
case "arm64-v8a":
129132
currentInstructionSet = "arm64";
130133
break;
131134
case "x86":
@@ -555,13 +558,44 @@ public static String getProcessName(Context context) {
555558

556559
@SuppressLint("NewApi")
557560
private static String getProcessNameInternal(final Context context) {
558-
if (ShareTinkerInternals.isNewerOrEqualThanVersion(28, true)) {
561+
if (isNewerOrEqualThanVersion(28, true)) {
559562
final String result = Application.getProcessName();
560563
if (!TextUtils.isEmpty(result)) {
561564
return result;
562565
}
563566
}
564567

568+
// The 'currentProcess' method only exists on api 18 and newer systems.
569+
if (isNewerOrEqualThanVersion(18, true)) {
570+
try {
571+
final Class<?> activityThreadClazz = Class.forName("android.app.ActivityThread");
572+
final Method currentProcessMethod = ShareReflectUtil.findMethod(activityThreadClazz, "currentProcessName");
573+
currentProcessMethod.setAccessible(true);
574+
final String result = (String) currentProcessMethod.invoke(null);
575+
if (result != null && !result.isEmpty()) {
576+
return result;
577+
}
578+
} catch (Throwable thr) {
579+
ShareTinkerLog.e(TAG, "getProcessNameInternal reflect activity thread exception:" + thr.getMessage());
580+
}
581+
}
582+
583+
BufferedReader br = null;
584+
try {
585+
br = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/self/cmdline"), StandardCharsets.US_ASCII));
586+
String result = br.readLine();
587+
if (result != null) {
588+
result = result.trim();
589+
if (!result.isEmpty()) {
590+
return result;
591+
}
592+
}
593+
} catch (Throwable thr) {
594+
ShareTinkerLog.e(TAG, "getProcessNameInternal parse cmdline exception:" + thr.getMessage());
595+
} finally {
596+
SharePatchFileUtil.closeQuietly(br);
597+
}
598+
565599
if (context != null) {
566600
try {
567601
final int myPid = android.os.Process.myPid();
@@ -577,24 +611,9 @@ private static String getProcessNameInternal(final Context context) {
577611
}
578612
}
579613
}
580-
} catch (Throwable ignored) {
581-
// Ignored.
582-
}
583-
}
584-
585-
final byte[] buf = new byte[2048];
586-
InputStream in = null;
587-
try {
588-
in = new BufferedInputStream(new FileInputStream("/proc/self/cmdline"));
589-
int len = in.read(buf);
590-
while (len > 0 && (buf[len - 1] <= 0 || buf[len - 1] == 10 || buf[len - 1] == 13)) --len;
591-
if (len > 0) {
592-
return new String(buf, StandardCharsets.US_ASCII);
614+
} catch (Throwable thr) {
615+
ShareTinkerLog.e(TAG, "getProcessNameInternal getRunningAppProcesses exception:" + thr.getMessage());
593616
}
594-
} catch (Throwable thr) {
595-
ShareTinkerLog.e(TAG, "getProcessNameInternal parse cmdline exception:" + thr.getMessage());
596-
} finally {
597-
SharePatchFileUtil.closeQuietly(in);
598617
}
599618

600619
return null;

tinker-build/tinker-patch-lib/src/main/java/com/tencent/tinker/build/decoder/ResDiffDecoder.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -404,19 +404,7 @@ public void onAllPatchesEnd() throws IOException, TinkerPatchException {
404404
private void checkIfSpecificResWasAnimRes(Collection<String> specificFileNames) {
405405
final Set<String> changedAnimResNames = new HashSet<>();
406406
for (String resFileName : specificFileNames) {
407-
String resName = resFileName;
408-
int lastPathSepPos = resFileName.lastIndexOf('/');
409-
if (lastPathSepPos < 0) {
410-
lastPathSepPos = resFileName.lastIndexOf('\\');
411-
}
412-
if (lastPathSepPos >= 0) {
413-
resName = resName.substring(lastPathSepPos + 1);
414-
}
415-
final int firstDotPos = resName.indexOf('.');
416-
if (firstDotPos >= 0) {
417-
resName = resName.substring(0, firstDotPos);
418-
}
419-
if (newApkAnimResNames.contains(resName)) {
407+
if (newApkAnimResNames.contains(resFileName)) {
420408
if (Utils.isStringMatchesPatterns(resFileName, config.mResIgnoreChangeWarningPattern)) {
421409
Logger.d("\nAnimation resource: " + resFileName
422410
+ " was changed, but it's filtered by ignoreChangeWarning pattern, just ignore.\n");

0 commit comments

Comments
 (0)