diff --git a/app/src/main/java/com/bytedance/shadowhook/sample/MainActivity.java b/app/src/main/java/com/bytedance/shadowhook/sample/MainActivity.java
index 90c3219..22c9f5b 100644
--- a/app/src/main/java/com/bytedance/shadowhook/sample/MainActivity.java
+++ b/app/src/main/java/com/bytedance/shadowhook/sample/MainActivity.java
@@ -25,10 +25,16 @@
import androidx.appcompat.app.AppCompatActivity;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
import com.bytedance.shadowhook.ShadowHook;
import com.bytedance.shadowhook.systest.SysTest;
@@ -62,8 +68,31 @@ public void onUnitTestUnhookClick(View view) {
public void onUnitTestLoadClick(View view) {
if(!hookee2Loaded) {
- hookee2Loaded = true;
- System.loadLibrary("hookee2");
+ try {
+ System.loadLibrary("hookee2");
+ hookee2Loaded = true;
+ if (view instanceof Button) {
+ Button button = (Button) view;
+ button.setEnabled(false);
+ button.setText(R.string.libhookee2_loaded);
+ }
+ Toast.makeText(this, R.string.libhookee2_loaded_toast, Toast.LENGTH_SHORT).show();
+ } catch (Throwable t) {
+ Log.e(tag, "loadLibrary hookee2 failed", t);
+ Toast.makeText(this, "Load failed: " + t.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ }
+ }
+
+ public void onAdbCommandClick(View view) {
+ if (view instanceof TextView) {
+ CharSequence text = ((TextView) view).getText();
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText("adb command", text);
+ if (clipboard != null) {
+ clipboard.setPrimaryClip(clip);
+ Toast.makeText(this, R.string.adb_command_copied, Toast.LENGTH_SHORT).show();
+ }
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index c74fc8e..1b1fccc 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -16,6 +16,11 @@
android:orientation="vertical">
shadowhook
-
\ No newline at end of file
+ libhookee2.so loaded
+ libhookee2.so loaded successfully
+ Adb command copied to clipboard
+
diff --git a/build.gradle b/build.gradle
index 606ebdd..940fa6c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,10 +1,10 @@
plugins {
- id 'com.android.application' version '7.4.2' apply false
- id 'com.android.library' version '7.4.2' apply false
+ id 'com.android.application' version '8.2.2' apply false
+ id 'com.android.library' version '8.2.2' apply false
}
task clean(type: Delete) {
- delete rootProject.buildDir
+ delete rootProject.layout.buildDirectory
}
ext {
@@ -12,7 +12,7 @@ ext {
compileSdkVersion = 34
targetSdkVersion = 34
buildToolsVersion = '34.0.0'
- javaVersion = JavaVersion.VERSION_1_7
+ javaVersion = JavaVersion.VERSION_1_8
ndkVersion = "23.2.8568313"
cmakeVersion = "3.22.1"
abiFilters = "armeabi-v7a,arm64-v8a"
diff --git a/gradle.properties b/gradle.properties
index f06ddf7..30cef6f 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -20,4 +20,3 @@ android.useAndroidX=true
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
#android.prefabVersion=2.0.0
-android.disableAutomaticComponentCreation=true
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 927b535..2fdb227 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Thu Dec 30 21:41:31 CST 2021
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME