Skip to content

Commit 4d07fb8

Browse files
committed
Minor changes. Release 1.0.8.
1 parent 47b856c commit 4d07fb8

File tree

17 files changed

+68
-56
lines changed

17 files changed

+68
-56
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ByteHook
22

33
![](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)
4-
![](https://img.shields.io/badge/release-1.0.7-red.svg?style=flat)
4+
![](https://img.shields.io/badge/release-1.0.8-red.svg?style=flat)
55
![](https://img.shields.io/badge/Android-4.1%20--%2013-blue.svg?style=flat)
66
![](https://img.shields.io/badge/arch-armeabi--v7a%20%7C%20arm64--v8a%20%7C%20x86%20%7C%20x86__64-blue.svg?style=flat)
77

@@ -39,14 +39,6 @@ There is a sample app in the [bytehook-sample](bytehook_sample) you can refer to
3939

4040
ByteHook is published on [Maven Central](https://search.maven.org/), and uses [Prefab](https://google.github.io/prefab/) package format for [native dependencies](https://developer.android.com/studio/build/native-dependencies), which is supported by [Android Gradle Plugin 4.0+](https://developer.android.com/studio/releases/gradle-plugin?buildsystem=cmake#native-dependencies).
4141

42-
```Gradle
43-
allprojects {
44-
repositories {
45-
mavenCentral()
46-
}
47-
}
48-
```
49-
5042
```Gradle
5143
android {
5244
buildFeatures {
@@ -55,10 +47,16 @@ android {
5547
}
5648
5749
dependencies {
58-
implementation 'com.bytedance:bytehook:1.0.7'
50+
implementation 'com.bytedance:bytehook:1.0.8'
5951
}
6052
```
6153

54+
**Note**: ByteHook uses the [prefab package schema v2](https://github.com/google/prefab/releases/tag/v2.0.0), which is configured by default since [Android Gradle Plugin 7.1.0](https://developer.android.com/studio/releases/gradle-plugin?buildsystem=cmake#7-1-0). If you are using Android Gradle Plugin earlier than 7.1.0, please add the following configuration to `gradle.properties`:
55+
56+
```
57+
android.prefabVersion=2.0.0
58+
```
59+
6260
### 2. Add dependency in CMakeLists.txt or Android.mk
6361

6462
> CMakeLists.txt

README.zh-CN.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ByteHook
22

33
![](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)
4-
![](https://img.shields.io/badge/release-1.0.7-red.svg?style=flat)
4+
![](https://img.shields.io/badge/release-1.0.8-red.svg?style=flat)
55
![](https://img.shields.io/badge/Android-4.1%20--%2013-blue.svg?style=flat)
66
![](https://img.shields.io/badge/arch-armeabi--v7a%20%7C%20arm64--v8a%20%7C%20x86%20%7C%20x86__64-blue.svg?style=flat)
77

@@ -39,14 +39,6 @@ ByteHook 现在被用于 TikTok,抖音,今日头条,西瓜视频,飞书
3939

4040
ByteHook 发布在 [Maven Central](https://search.maven.org/) 上。为了使用 [native 依赖项](https://developer.android.com/studio/build/native-dependencies),ByteHook 使用了从 [Android Gradle Plugin 4.0+](https://developer.android.com/studio/releases/gradle-plugin?buildsystem=cmake#native-dependencies) 开始支持的 [Prefab](https://google.github.io/prefab/) 包格式。
4141

42-
```Gradle
43-
allprojects {
44-
repositories {
45-
mavenCentral()
46-
}
47-
}
48-
```
49-
5042
```Gradle
5143
android {
5244
buildFeatures {
@@ -55,10 +47,16 @@ android {
5547
}
5648
5749
dependencies {
58-
implementation 'com.bytedance:bytehook:1.0.7'
50+
implementation 'com.bytedance:bytehook:1.0.8'
5951
}
6052
```
6153

54+
**注意**:ByteHook 使用 [prefab package schema v2](https://github.com/google/prefab/releases/tag/v2.0.0),它是从 [Android Gradle Plugin 7.1.0](https://developer.android.com/studio/releases/gradle-plugin?buildsystem=cmake#7-1-0) 开始作为默认配置的。如果你使用的是 Android Gradle Plugin 7.1.0 之前的版本,请在 `gradle.properties` 中加入以下配置:
55+
56+
```
57+
android.prefabVersion=2.0.0
58+
```
59+
6260
### 2. 在 CMakeLists.txt 或 Android.mk 中增加依赖
6361

6462
> CMakeLists.txt

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
2-
id 'com.android.application' version '7.2.2' apply false
3-
id 'com.android.library' version '7.2.2' apply false
2+
id 'com.android.application' version '7.4.2' apply false
3+
id 'com.android.library' version '7.4.2' apply false
44
}
55

66
task clean(type: Delete) {
@@ -21,7 +21,7 @@ ext {
2121

2222
POM_GROUP_ID = "com.bytedance"
2323
POM_ARTIFACT_ID = "bytehook"
24-
POM_VERSION_NAME = "1.0.7"
24+
POM_VERSION_NAME = "1.0.8"
2525

2626
POM_NAME = "bytehook"
2727
POM_DESCRIPTION = "ByteHook is an Android PLT hook library which supports armeabi-v7a, arm64-v8a, x86 and x86_64."

bytehook/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
}
44

55
android {
6+
namespace 'com.bytedance.android.bytehook'
67
compileSdkVersion rootProject.ext.compileSdkVersion
78
buildToolsVersion rootProject.ext.buildToolsVersion
89
ndkVersion rootProject.ext.ndkVersion
@@ -48,6 +49,12 @@ android {
4849
headers "src/main/cpp/include"
4950
}
5051
}
52+
publishing {
53+
singleVariant('release') {
54+
withSourcesJar()
55+
withJavadocJar()
56+
}
57+
}
5158
}
5259

5360
apply from: rootProject.file('gradle/check.gradle')
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.bytedance.android.bytehook">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
</manifest>

bytehook/src/main/cpp/bh_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bh_core_t *bh_core_global(void) {
5656
int bh_core_init(int mode, bool debug) {
5757
// Do not repeat the initialization.
5858
if (BYTEHOOK_STATUS_CODE_UNINIT != bh_core.init_status) {
59-
BH_LOG_SHOW("bytehook already inited, return %d", bh_core.init_status);
59+
BH_LOG_SHOW("bytehook already inited, return: %d", bh_core.init_status);
6060
return bh_core.init_status;
6161
}
6262

@@ -106,7 +106,9 @@ int bh_core_init(int mode, bool debug) {
106106
}
107107
pthread_mutex_unlock(&lock);
108108

109-
BH_LOG_SHOW("bytehook init, mode %d, debug %d, return %d", mode, debug ? 1 : 0, bh_core.init_status);
109+
BH_LOG_SHOW("%s: bytehook init(mode: %s, debug: %s), return: %d", bytehook_get_version(),
110+
BYTEHOOK_MODE_AUTOMATIC == mode ? "AUTOMATIC" : "MANUAL", debug ? "true" : "false",
111+
bh_core.init_status);
110112
return bh_core.init_status;
111113
}
112114

bytehook/src/main/cpp/bh_jni.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#define BH_JNI_VERSION JNI_VERSION_1_6
3030
#define BH_JNI_CLASS_NAME "com/bytedance/android/bytehook/ByteHook"
3131

32+
static jstring bh_jni_get_version(JNIEnv *env, jobject thiz) {
33+
(void)thiz;
34+
return (*env)->NewStringUTF(env, bytehook_get_version());
35+
}
36+
3237
static jint bh_jni_init(JNIEnv *env, jobject thiz, jint mode, jboolean debug) {
3338
(void)env;
3439
(void)thiz;
@@ -125,7 +130,8 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
125130
jclass cls;
126131
if (__predict_false(NULL == (cls = (*env)->FindClass(env, BH_JNI_CLASS_NAME)))) return JNI_ERR;
127132

128-
JNINativeMethod m[] = {{"nativeInit", "(IZ)I", (void *)bh_jni_init},
133+
JNINativeMethod m[] = {{"nativeGetVersion", "()Ljava/lang/String;", (void *)bh_jni_get_version},
134+
{"nativeInit", "(IZ)I", (void *)bh_jni_init},
129135
{"nativeAddIgnore", "(Ljava/lang/String;)I", (void *)bh_jni_add_ignore},
130136
{"nativeGetMode", "()I", (void *)bh_jni_get_mode},
131137
{"nativeGetDebug", "()Z", (void *)bh_jni_get_debug},

bytehook/src/main/cpp/bytehook.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "bh_core.h"
3333
#include "bh_recorder.h"
3434

35+
const char *bytehook_get_version(void) {
36+
return "bytehook version " BYTEHOOK_VERSION;
37+
}
38+
3539
int bytehook_init(int mode, bool debug) {
3640
return bh_core_init(mode, debug);
3741
}

bytehook/src/main/cpp/bytehook.map.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
global:
33
JNI_OnLoad;
4+
bytehook_get_version;
45
bytehook_init;
56
bytehook_hook_single;
67
bytehook_hook_all;

bytehook/src/main/cpp/include/bytehook.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include <stdbool.h>
4949
#include <stdint.h>
5050

51+
#define BYTEHOOK_VERSION "1.0.8"
52+
5153
#define BYTEHOOK_STATUS_CODE_OK 0
5254
#define BYTEHOOK_STATUS_CODE_UNINIT 1
5355
#define BYTEHOOK_STATUS_CODE_INITERR_INVALID_ARG 2
@@ -83,6 +85,8 @@
8385
extern "C" {
8486
#endif
8587

88+
const char *bytehook_get_version(void);
89+
8690
typedef void *bytehook_stub_t;
8791

8892
typedef void (*bytehook_hooked_t)(bytehook_stub_t task_stub, int status_code, const char *caller_path_name,

0 commit comments

Comments
 (0)