Skip to content

Commit 400615e

Browse files
authored
Merge pull request #709 from Tencent/feature/dev
Matrix 2.0.5 for Android
2 parents 87688f4 + f95d172 commit 400615e

File tree

168 files changed

+9912
-1934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+9912
-1934
lines changed

matrix/matrix-android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
1414
# org.gradle.parallel=true
1515
#Tue Jun 20 10:24:33 CST 2017
1616

17-
VERSION_NAME_PREFIX=2.0.2
17+
VERSION_NAME_PREFIX=2.0.5
1818
VERSION_NAME_SUFFIX=
1919
## two options: Internal (for wechat), External (for public repo)
2020
PUBLISH_CHANNEL=Internal

matrix/matrix-android/gradle/Arguments.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ gradle.ext.gonnaPublish = {
2323
}
2424

2525
return false
26+
}
27+
28+
gradle.ext.staticLinkCXX = {
29+
return gradle.startParameter.projectProperties.containsKey("publishStaticLinkCXXFlavor" as String)
2630
}

matrix/matrix-android/matrix-android-commons/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 3.4.1)
22
project(android-commons C)
33

44
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/libsemi_dlfcn)
5+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/libenhance_dlsym)
56
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/libxhook)

matrix/matrix-android/matrix-android-commons/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ android {
1818

1919
externalNativeBuild {
2020
cmake {
21-
targets = ['xhook', 'semi_dlfcn']
21+
targets = ['xhook', 'semi_dlfcn', 'enhance_dlsym']
2222
}
2323
exportHeaders {
2424
from('src/main/cpp/libxhook') {
@@ -27,6 +27,9 @@ android {
2727
from('src/main/cpp/libsemi_dlfcn') {
2828
include '**/*.h'
2929
}
30+
from('src/main/cpp/libenhance_dlsym') {
31+
include '**/*.h'
32+
}
3033
}
3134
}
3235
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.4.1)
2+
project(libenhance_dlsym CXX)
3+
4+
set(enhance_dlsym_source_dir ${CMAKE_CURRENT_SOURCE_DIR})
5+
6+
set(enhance_dlsym_source
7+
${enhance_dlsym_source_dir}/EnhanceDlsym.cpp)
8+
9+
add_library(enhance_dlsym STATIC ${enhance_dlsym_source})
10+
11+
target_include_directories(
12+
enhance_dlsym
13+
PUBLIC ${enhance_dlsym_source_dir}
14+
)
15+
16+
target_link_libraries(
17+
enhance_dlsym
18+
PUBLIC ${log-lib}
19+
)

matrix/matrix-android/matrix-jectl/src/main/cpp/jectl/EnhanceDlsym.cpp renamed to matrix/matrix-android/matrix-android-commons/src/main/cpp/libenhance_dlsym/EnhanceDlsym.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <dlfcn.h>
3333
#include <set>
3434
#include "EnhanceDlsym.h"
35-
#include "JeLog.h"
35+
#include "../../../../../matrix-jectl/src/main/cpp/jectl/JeLog.h"
3636

3737
#define TAG "Matrix.EnhanceDl"
3838

@@ -283,8 +283,7 @@ namespace enhance {
283283
if (__handle) {
284284
auto info = static_cast<DlInfo *>(__handle);
285285
m_opened_info.erase(info);
286-
free(info->strtab);
287-
free(info);
286+
delete info;
288287

289288
std::map<void *, ElfW(Sym) *> empty;
290289
empty.swap(m_founded_symtab);

matrix/matrix-android/matrix-jectl/src/main/cpp/jectl/EnhanceDlsym.h renamed to matrix/matrix-android/matrix-android-commons/src/main/cpp/libenhance_dlsym/EnhanceDlsym.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ namespace enhance {
3535
struct DlInfo {
3636

3737
DlInfo() {}
38-
~DlInfo() {}
38+
~DlInfo() {
39+
if (strtab) {
40+
free(strtab);
41+
}
42+
if (symtab) {
43+
free(symtab);
44+
}
45+
}
3946

4047
std::string pathname;
4148

@@ -45,10 +52,10 @@ namespace enhance {
4552
ElfW(Ehdr) *ehdr; // pointing to loaded mem
4653
ElfW(Phdr) *phdr; // pointing to loaded mem
4754

48-
char *strtab; // strtab
55+
char *strtab = nullptr; // strtab
4956
ElfW(Word) strtab_size; // size in bytes
5057

51-
ElfW(Sym) *symtab;
58+
ElfW(Sym) *symtab = nullptr;
5259
ElfW(Word) symtab_num;
5360

5461
};

matrix/matrix-android/matrix-backtrace/build.gradle

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,7 @@ android {
6262

6363
}
6464

65-
dependencies {
66-
implementation fileTree(dir: 'libs', include: ['*.jar'])
67-
68-
implementation 'androidx.annotation:annotation:1.0.0'
69-
testImplementation 'junit:junit:4.12'
70-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
71-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
72-
// implementation "com.tencent.stubs:logger:${rootProject.LOGGER_VERSION}"
73-
implementation project(':matrix-android-lib')
74-
}
65+
apply from: project.file('dependencies.gradle')
7566

7667
group = rootProject.GROUP
7768
version = rootProject.VERSION_NAME
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
apply plugin: 'com.android.library'
2+
3+
apply from: rootProject.file('gradle/WeChatNativeDepend.gradle')
4+
5+
android {
6+
compileSdkVersion rootProject.compileSdkVersion
7+
8+
defaultConfig {
9+
minSdkVersion rootProject.MIN_SDK_VERSION_FOR_HOOK
10+
targetSdkVersion rootProject.targetSdkVersion
11+
versionCode rootProject.VERSION_CODE
12+
versionName rootProject.VERSION_NAME
13+
14+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
15+
16+
ndk {
17+
abiFilters rootProject.ABI_FILTERS as String[]
18+
}
19+
20+
externalNativeBuild {
21+
cmake {
22+
targets = ['wechatbacktrace', 'unwindstack']
23+
arguments = ['-DANDROID_STL=c++_static',
24+
"-DEnableLOG=${gradle.enableLog() ? "ON" : "OFF"}" as String,
25+
"-DQUT_STATISTIC_ENABLE=${gradle.enableLog() ? "ON" : "OFF"}" as String]
26+
}
27+
28+
exportHeaders {
29+
from('../src/main/cpp') {
30+
include 'common/*.h'
31+
moveToDir 'backtrace'
32+
}
33+
from('../src/main/cpp/libwechatbacktrace/include') {
34+
include '**/*.h'
35+
moveToDir 'backtrace'
36+
}
37+
from('../src/main/cpp/external/libunwindstack/include') {
38+
include '**/*.h'
39+
moveToDir 'backtrace'
40+
}
41+
from('../src/main/cpp/dexfile/include') {
42+
include '**/*.h'
43+
moveToDir 'backtrace'
44+
}
45+
}
46+
}
47+
}
48+
49+
buildTypes {
50+
51+
release {
52+
minifyEnabled false
53+
}
54+
}
55+
56+
externalNativeBuild {
57+
cmake {
58+
path "../CMakeLists.txt"
59+
}
60+
}
61+
62+
sourceSets {
63+
main {
64+
java.srcDirs = ['../src/main/java']
65+
res.srcDirs = ['../src/main/res']
66+
manifest.srcFile '../src/main/AndroidManifest.xml'
67+
}
68+
}
69+
70+
}
71+
72+
apply from: project.file('../dependencies.gradle')
73+
74+
group = rootProject.GROUP
75+
version = "${rootProject.VERSION_NAME}-STATIC"
76+
77+
if("External" == rootProject.ext.PUBLISH_CHANNEL) {
78+
apply from: rootProject.file('gradle/android-publish.gradle')
79+
}
80+
else {
81+
apply from: rootProject.file('gradle/WeChatPublish.gradle')
82+
wechatPublish {
83+
artifactId = POM_ARTIFACT_ID
84+
}
85+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
dependencies {
2+
implementation fileTree(dir: 'libs', include: ['*.jar'])
3+
4+
implementation 'androidx.annotation:annotation:1.0.0'
5+
testImplementation 'junit:junit:4.12'
6+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
7+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
8+
// implementation "com.tencent.stubs:logger:${rootProject.LOGGER_VERSION}"
9+
implementation project(':matrix-android-lib')
10+
}

0 commit comments

Comments
 (0)