mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
...
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
<!-- 最低xposed版本号 -->
|
||||
<meta-data
|
||||
android:name="xposedminversion"
|
||||
android:value="82" />
|
||||
android:value="93" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
@@ -30,10 +30,12 @@
|
||||
package com.highcapable.yukihookapi.demo
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.Keep
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
||||
|
||||
@Keep
|
||||
@@ -46,9 +48,18 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
// for test
|
||||
findViewById<Button>(R.id.main_button).setOnClickListener {
|
||||
modulePrefs.apply {
|
||||
putString("data", "这是存储的数据")
|
||||
putBoolean("test_key", true)
|
||||
putString("test_key_name", "存储数据成功,包名:$packageName")
|
||||
}
|
||||
Toast.makeText(this, "存储完成", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
// for test
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("Hook 方法返回值测试")
|
||||
.setMessage(test() + "\n变量:$a\n模块是否已激活:${YukiHookModuleStatus.isActive()}")
|
||||
.setMessage(test() + "\n变量:$a\n模块数据:${xptest()}\n模块是否已激活:${YukiHookModuleStatus.isActive()}")
|
||||
.setPositiveButton("下一个") { _, _ ->
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle("Hook 方法参数测试")
|
||||
@@ -90,6 +101,10 @@ class MainActivity : AppCompatActivity() {
|
||||
@Keep
|
||||
private fun test() = "正常显示的一行文字"
|
||||
|
||||
// for test
|
||||
@Keep
|
||||
private fun xptest() = "这里是正常的文字"
|
||||
|
||||
// for test
|
||||
@Keep
|
||||
private fun test(string: String) = string
|
||||
|
@@ -70,6 +70,13 @@ class MainInjecter : YukiHookXposedInitProxy {
|
||||
}.set(instance, "这段文字被修改成功了")
|
||||
}
|
||||
}
|
||||
injectMember {
|
||||
method {
|
||||
name = "xptest"
|
||||
returnType = StringType
|
||||
}
|
||||
replaceTo(prefs.getString(key = "data", default = "获取 Hook:没数据"))
|
||||
}
|
||||
injectMember {
|
||||
method {
|
||||
name = "toast"
|
||||
@@ -150,7 +157,11 @@ class MainInjecter : YukiHookXposedInitProxy {
|
||||
AlertDialog.Builder(instance())
|
||||
.setCancelable(false)
|
||||
.setTitle("测试 Hook")
|
||||
.setMessage("Hook 已成功")
|
||||
.setMessage(
|
||||
"Hook 已成功\n" +
|
||||
"test_key:${prefs.getBoolean("test_key")}\n" +
|
||||
"test_key_name:${prefs.getString("test_key_name", "默认值")}"
|
||||
)
|
||||
.setPositiveButton("OK") { _, _ ->
|
||||
Toast.makeText(instance(), "Hook Success", Toast.LENGTH_SHORT).show()
|
||||
}.show()
|
||||
|
@@ -1,18 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_marginBottom="10dp"
|
||||
android:text="Hello World!" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<Button
|
||||
android:id="@+id/main_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="存储模块数据" />
|
||||
</LinearLayout>
|
Reference in New Issue
Block a user