mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-05 18:25:28 +08:00
Update hook demo
This commit is contained in:
@@ -43,7 +43,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
setContentView(root)
|
setContentView(root)
|
||||||
appDemoFirstText.text = getFirstText()
|
appDemoFirstText.text = getFirstText()
|
||||||
appDemoSecondText.text = secondText
|
appDemoSecondText.text = secondText
|
||||||
appDemoThirdText.text = Main(string = "Feel real").getString()
|
appDemoThirdText.text = Main(content = "Feel real").getString()
|
||||||
appDemoFourthText.text = getRegularText(string = "Have fun day")
|
appDemoFourthText.text = getRegularText(string = "Have fun day")
|
||||||
appDemoFifthText.text = getDataText()
|
appDemoFifthText.text = getDataText()
|
||||||
appDemoSixthText.text = getArray(arrayOf("apple", "banana")).let { "${it[0]}, ${it[1]}" }
|
appDemoSixthText.text = getArray(arrayOf("apple", "banana")).let { "${it[0]}, ${it[1]}" }
|
||||||
@@ -51,6 +51,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
appDemoEighthText.text = Main().getTestResultFirst(string = "Find something interesting")
|
appDemoEighthText.text = Main().getTestResultFirst(string = "Find something interesting")
|
||||||
appDemoNinthText.text = Main().getTestResultLast()
|
appDemoNinthText.text = Main().getTestResultLast()
|
||||||
appDemoTenthText.text = Main().getTestResultLast(string = "This is the last sentence")
|
appDemoTenthText.text = Main().getTestResultLast(string = "This is the last sentence")
|
||||||
|
appDemoEleventhText.text = Main().getSuperString()
|
||||||
appDemoButton.setOnClickListener { toast() }
|
appDemoButton.setOnClickListener { toast() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,9 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.highcapable.yukihookapi.demo_app.utils
|
package com.highcapable.yukihookapi.demo_app.utils
|
||||||
|
|
||||||
class Main(private val string: String = "") {
|
class Main(override val content: String = "") : SuperMain(content) {
|
||||||
|
|
||||||
fun getString() = string
|
|
||||||
|
|
||||||
fun getTestResultFirst() = "The world is beautiful"
|
fun getTestResultFirst() = "The world is beautiful"
|
||||||
|
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* YukiHookAPI - An efficient Kotlin version of the Xposed Hook API.
|
||||||
|
* Copyright (C) 2019-2022 HighCapable
|
||||||
|
* https://github.com/fankes/YukiHookAPI
|
||||||
|
*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
* This file is Created by fankes on 2022/4/29.
|
||||||
|
*/
|
||||||
|
package com.highcapable.yukihookapi.demo_app.utils
|
||||||
|
|
||||||
|
open class SuperMain(open val content: String = "") {
|
||||||
|
|
||||||
|
fun getSuperString() = "The sea is blue"
|
||||||
|
|
||||||
|
fun getString() = content
|
||||||
|
}
|
@@ -1,96 +1,132 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:fillViewport="true"
|
||||||
android:orientation="vertical"
|
android:scrollbars="none"
|
||||||
tools:ignore="HardcodedText">
|
tools:ignore="HardcodedText,ContentDescription">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/app_demo_first_text"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginTop="20dp"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:text="sample"
|
android:gravity="center"
|
||||||
android:textSize="18sp" />
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/app_demo_second_text"
|
android:layout_width="50dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="50dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginBottom="15dp"
|
||||||
android:layout_marginBottom="15dp"
|
android:src="@mipmap/ic_face_unhappy" />
|
||||||
android:text="sample"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_third_text"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginBottom="25dp"
|
||||||
android:layout_marginBottom="15dp"
|
android:text="@string/test_string"
|
||||||
android:text="sample"
|
android:textSize="17.5sp" />
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_fourth_text"
|
android:id="@+id/app_demo_first_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="sample"
|
android:text="sample"
|
||||||
android:textSize="18sp" />
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_seventh_text"
|
android:id="@+id/app_demo_second_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="sample"
|
android:text="sample"
|
||||||
android:textSize="18sp" />
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_eighth_text"
|
android:id="@+id/app_demo_eleventh_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="sample"
|
android:text="sample"
|
||||||
android:textSize="18sp" />
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_ninth_text"
|
android:id="@+id/app_demo_third_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="sample"
|
android:text="sample"
|
||||||
android:textSize="18sp" />
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_tenth_text"
|
android:id="@+id/app_demo_fourth_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="sample"
|
android:text="sample"
|
||||||
android:textSize="18sp" />
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_sixth_text"
|
android:id="@+id/app_demo_seventh_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="sample"
|
android:text="sample"
|
||||||
android:textSize="18sp" />
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app_demo_fifth_text"
|
android:id="@+id/app_demo_eighth_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:text="sample"
|
android:text="sample"
|
||||||
android:textSize="18sp" />
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
<Button
|
<TextView
|
||||||
android:id="@+id/app_demo_button"
|
android:id="@+id/app_demo_ninth_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Click Me!"
|
android:layout_marginBottom="15dp"
|
||||||
android:textAllCaps="false" />
|
android:text="sample"
|
||||||
</LinearLayout>
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_demo_tenth_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_demo_sixth_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_demo_fifth_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="17.5sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:src="@android:mipmap/sym_def_app_icon" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/app_demo_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Click Me!"
|
||||||
|
android:textAllCaps="false" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
BIN
demo-app/src/main/res/mipmap-xxhdpi/ic_face_unhappy.png
Normal file
BIN
demo-app/src/main/res/mipmap-xxhdpi/ic_face_unhappy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@@ -1,3 +1,4 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">YukiHookDemoApp</string>
|
<string name="app_name">YukiHookDemoApp</string>
|
||||||
|
<string name="test_string">I am feel not good</string>
|
||||||
</resources>
|
</resources>
|
@@ -25,16 +25,23 @@
|
|||||||
*
|
*
|
||||||
* This file is Created by fankes on 2022/2/9.
|
* This file is Created by fankes on 2022/2/9.
|
||||||
*/
|
*/
|
||||||
|
@file:Suppress("SetTextI18n")
|
||||||
|
|
||||||
package com.highcapable.yukihookapi.demo_module.hook
|
package com.highcapable.yukihookapi.demo_module.hook
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.widget.Button
|
||||||
import com.highcapable.yukihookapi.YukiHookAPI
|
import com.highcapable.yukihookapi.YukiHookAPI
|
||||||
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
import com.highcapable.yukihookapi.annotation.xposed.InjectYukiHookWithXposed
|
||||||
|
import com.highcapable.yukihookapi.demo_module.R
|
||||||
import com.highcapable.yukihookapi.demo_module.data.DataConst
|
import com.highcapable.yukihookapi.demo_module.data.DataConst
|
||||||
|
import com.highcapable.yukihookapi.hook.type.android.ActivityClass
|
||||||
import com.highcapable.yukihookapi.hook.type.android.BundleClass
|
import com.highcapable.yukihookapi.hook.type.android.BundleClass
|
||||||
import com.highcapable.yukihookapi.hook.type.java.StringArrayClass
|
import com.highcapable.yukihookapi.hook.type.java.StringArrayClass
|
||||||
import com.highcapable.yukihookapi.hook.type.java.StringType
|
import com.highcapable.yukihookapi.hook.type.java.StringType
|
||||||
import com.highcapable.yukihookapi.hook.type.java.UnitType
|
import com.highcapable.yukihookapi.hook.type.java.UnitType
|
||||||
|
import com.highcapable.yukihookapi.hook.xposed.bridge.event.YukiXposedEvent
|
||||||
import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit
|
import com.highcapable.yukihookapi.hook.xposed.proxy.IYukiHookXposedInit
|
||||||
|
|
||||||
@InjectYukiHookWithXposed
|
@InjectYukiHookWithXposed
|
||||||
@@ -51,6 +58,10 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
// 请注意 - 若作为发布版本请务必关闭调试功能防止对用户设备造成大量日志填充
|
// 请注意 - 若作为发布版本请务必关闭调试功能防止对用户设备造成大量日志填充
|
||||||
isDebug = true
|
isDebug = true
|
||||||
// 是否启用调试日志的输出功能
|
// 是否启用调试日志的输出功能
|
||||||
|
// 一旦关闭后除手动日志外 API 将停止全部日志的输出 - 建议不要随意关掉这个选项
|
||||||
|
// 虽然说对用户的设备写入大量日志是不正确的 - 但是没有日志你将无法调试
|
||||||
|
// 关于日志是否会影响设备的流畅度一直是一个伪命题
|
||||||
|
// 但是不设置这个选项可能会引起一些非议 - 建议不要关闭就是了
|
||||||
isAllowPrintingLogs = true
|
isAllowPrintingLogs = true
|
||||||
// 是否启用 [YukiHookModulePrefs] 的键值缓存功能
|
// 是否启用 [YukiHookModulePrefs] 的键值缓存功能
|
||||||
// 若无和模块频繁交互数据在宿主重新启动之前建议开启
|
// 若无和模块频繁交互数据在宿主重新启动之前建议开启
|
||||||
@@ -67,6 +78,36 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
// 开始你的 Hook
|
// 开始你的 Hook
|
||||||
// 可简写为 encase {}
|
// 可简写为 encase {}
|
||||||
YukiHookAPI.encase {
|
YukiHookAPI.encase {
|
||||||
|
// 装载到系统框架
|
||||||
|
loadZygote {
|
||||||
|
// 得到需要 Hook 的 Class
|
||||||
|
ActivityClass.hook {
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "onCreate"
|
||||||
|
param(BundleClass)
|
||||||
|
}
|
||||||
|
afterHook {
|
||||||
|
// 在 [Activity] 标题后方加入文字
|
||||||
|
instance<Activity>().apply { title = "$title [Active]" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 得到需要 Hook 的 Resources
|
||||||
|
resources().hook {
|
||||||
|
// 注入要 Hook 的 Resources
|
||||||
|
injectResource {
|
||||||
|
// 设置条件
|
||||||
|
conditions {
|
||||||
|
name = "sym_def_app_icon"
|
||||||
|
mipmap()
|
||||||
|
}
|
||||||
|
// 替换为当前模块的 Resources
|
||||||
|
// 模块的 Resources 可以使用 R8 混淆 - 结果不受影响
|
||||||
|
replaceToModuleResource(R.mipmap.ic_icon)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 装载需要 Hook 的 APP
|
// 装载需要 Hook 的 APP
|
||||||
loadApp(name = "com.highcapable.yukihookapi.demo_app") {
|
loadApp(name = "com.highcapable.yukihookapi.demo_app") {
|
||||||
// 得到需要 Hook 的 Class
|
// 得到需要 Hook 的 Class
|
||||||
@@ -169,19 +210,93 @@ class HookEntry : IYukiHookXposedInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 注入要 Hook 的方法
|
// 注入要 Hook 的方法
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "getSuperString"
|
||||||
|
emptyParam()
|
||||||
|
// 这个方法不在当前的 Class
|
||||||
|
// 只需要设置此查找条件即可自动前往当前 Class 的父类查找
|
||||||
|
// 由于演示的方法只会在父类存在 - 所以可以设置仅查找父类 isOnlySuperClass = true 节省时间
|
||||||
|
// 如果想继续尝试查找当前 Class - 请删除 isOnlySuperClass = true
|
||||||
|
superClass(isOnlySuperClass = true)
|
||||||
|
}
|
||||||
|
// 执行替换 Hook
|
||||||
|
replaceTo(any = "I am hook super class method")
|
||||||
|
}
|
||||||
|
// 注入要 Hook 的方法
|
||||||
injectMember {
|
injectMember {
|
||||||
allMethods(name = "getTestResultFirst")
|
allMethods(name = "getTestResultFirst")
|
||||||
// 执行替换 Hook
|
// 执行替换 Hook
|
||||||
replaceTo("I am hook all methods first")
|
replaceTo(any = "I am hook all methods first")
|
||||||
}
|
}
|
||||||
// 注入要 Hook 的方法
|
// 注入要 Hook 的方法
|
||||||
injectMember {
|
injectMember {
|
||||||
allMethods(name = "getTestResultLast")
|
allMethods(name = "getTestResultLast")
|
||||||
// 执行替换 Hook
|
// 执行替换 Hook
|
||||||
replaceTo("I am hook all methods last")
|
replaceTo(any = "I am hook all methods last")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 得到需要 Hook 的 Resources
|
||||||
|
resources().hook {
|
||||||
|
// 注入要 Hook 的 Resources
|
||||||
|
injectResource {
|
||||||
|
// 设置条件
|
||||||
|
conditions {
|
||||||
|
name = "activity_main"
|
||||||
|
layout()
|
||||||
|
}
|
||||||
|
// Hook 布局装载器
|
||||||
|
injectAsLayout {
|
||||||
|
// 替换布局中指定 Id 的按钮文本
|
||||||
|
findViewByIdentifier<Button>(name = "app_demo_button")?.text = "Touch Me!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 注入要 Hook 的 Resources
|
||||||
|
injectResource {
|
||||||
|
// 设置条件
|
||||||
|
conditions {
|
||||||
|
name = "test_string"
|
||||||
|
string()
|
||||||
|
}
|
||||||
|
// 替换为指定的 Resources
|
||||||
|
replaceTo(any = "I am hook to make your Happy")
|
||||||
|
}
|
||||||
|
// 注入要 Hook 的 Resources
|
||||||
|
injectResource {
|
||||||
|
// 设置条件
|
||||||
|
conditions {
|
||||||
|
name = "ic_face_unhappy"
|
||||||
|
mipmap()
|
||||||
|
}
|
||||||
|
// 替换为当前模块的 Resources
|
||||||
|
// 模块的 Resources 可以使用 R8 混淆 - 结果不受影响
|
||||||
|
replaceToModuleResource(R.mipmap.ic_face_happy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 可选的监听功能 - 如不需要你可以不重写这个方法
|
||||||
|
// Demo 中实现这个方法仅为了介绍它的功能
|
||||||
|
override fun onXposedEvent() {
|
||||||
|
// (可选) 监听原生 Xposed API 的装载事件
|
||||||
|
// 若你的 Hook 事件中存在需要兼容的原生 Xposed 功能 - 可在这里实现
|
||||||
|
// 不要在这里处理任何 YukiHookAPI 的事件 - 请在 onHook 中完成
|
||||||
|
YukiXposedEvent.events {
|
||||||
|
onInitZygote {
|
||||||
|
// 实现监听 initZygote 事件
|
||||||
|
}
|
||||||
|
onHandleLoadPackage {
|
||||||
|
// 实现监听 handleLoadPackage 事件
|
||||||
|
// 可调用原生 Xposed API 方法
|
||||||
|
// XposedHelpers.findAndHookMethod("className", it.classLoader, "methodName", object : XC_MethodHook())
|
||||||
|
}
|
||||||
|
onHandleInitPackageResources {
|
||||||
|
// 实现监听 handleInitPackageResources 事件
|
||||||
|
// 可调用原生 Xposed API 方法
|
||||||
|
// it.res.setReplacement(0x7f060001, "replaceMent")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -37,6 +37,7 @@ import com.highcapable.yukihookapi.YukiHookAPI
|
|||||||
import com.highcapable.yukihookapi.demo_module.data.DataConst
|
import com.highcapable.yukihookapi.demo_module.data.DataConst
|
||||||
import com.highcapable.yukihookapi.demo_module.databinding.ActivityMainBinding
|
import com.highcapable.yukihookapi.demo_module.databinding.ActivityMainBinding
|
||||||
import com.highcapable.yukihookapi.hook.factory.isModuleActive
|
import com.highcapable.yukihookapi.hook.factory.isModuleActive
|
||||||
|
import com.highcapable.yukihookapi.hook.factory.isSupportResourcesHook
|
||||||
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
import com.highcapable.yukihookapi.hook.factory.modulePrefs
|
||||||
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
import com.highcapable.yukihookapi.hook.xposed.YukiHookModuleStatus
|
||||||
|
|
||||||
@@ -47,10 +48,17 @@ class MainActivity : AppCompatActivity() {
|
|||||||
ActivityMainBinding.inflate(layoutInflater).apply {
|
ActivityMainBinding.inflate(layoutInflater).apply {
|
||||||
setContentView(root)
|
setContentView(root)
|
||||||
moduleDemoActiveText.text = "Module is Active:$isModuleActive"
|
moduleDemoActiveText.text = "Module is Active:$isModuleActive"
|
||||||
|
moduleDemoActiveZhText.text = "Xposed 模块激活状态"
|
||||||
moduleDemoFrameworkText.text = "Hook Framework:${YukiHookModuleStatus.executorName}"
|
moduleDemoFrameworkText.text = "Hook Framework:${YukiHookModuleStatus.executorName}"
|
||||||
moduleDemoApiVersionText.text = "API Version:${YukiHookModuleStatus.executorVersion}"
|
moduleDemoFrameworkZhText.text = "当前的 Hook 框架"
|
||||||
|
moduleDemoApiVersionText.text = "Xposed API Version:${YukiHookModuleStatus.executorVersion}"
|
||||||
|
moduleDemoApiVersionZhText.text = "Xposed API 版本"
|
||||||
moduleDemoYukiHookApiVersionText.text = "YukiHookAPI Version:${YukiHookAPI.API_VERSION_NAME}(${YukiHookAPI.API_VERSION_CODE})"
|
moduleDemoYukiHookApiVersionText.text = "YukiHookAPI Version:${YukiHookAPI.API_VERSION_NAME}(${YukiHookAPI.API_VERSION_CODE})"
|
||||||
|
moduleDemoYukiHookApiVersionZhText.text = "YukiHookAPI 版本"
|
||||||
moduleDemoNewXshareText.text = "New XShare Mode:${modulePrefs.isRunInNewXShareMode}"
|
moduleDemoNewXshareText.text = "New XShare Mode:${modulePrefs.isRunInNewXShareMode}"
|
||||||
|
moduleDemoNewXshareZhText.text = "New XShare 模式支持状态"
|
||||||
|
moduleDemoResHookText.text = "Support Resources Hook:$isSupportResourcesHook"
|
||||||
|
moduleDemoResHookZhText.text = "资源钩子支持状态"
|
||||||
moduleDemoEditText.also {
|
moduleDemoEditText.also {
|
||||||
it.setText(modulePrefs.get(DataConst.TEST_KV_DATA))
|
it.setText(modulePrefs.get(DataConst.TEST_KV_DATA))
|
||||||
moduleDemoButton.setOnClickListener { _ ->
|
moduleDemoButton.setOnClickListener { _ ->
|
||||||
|
@@ -1,109 +1,201 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:fillViewport="true"
|
||||||
android:orientation="vertical"
|
android:scrollbars="none"
|
||||||
tools:ignore="HardcodedText">
|
tools:ignore="HardcodedText">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginLeft="50dp"
|
android:layout_marginTop="20dp"
|
||||||
android:layout_marginRight="50dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:layout_marginBottom="15dp"
|
android:gravity="center"
|
||||||
android:gravity="center|start"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/module_demo_active_text"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="50dp"
|
||||||
|
android:layout_marginRight="50dp"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_active_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_active_zh_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:alpha="0.85"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_framework_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_framework_zh_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:alpha="0.85"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_api_version_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_api_version_zh_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:alpha="0.85"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_yuki_hook_api_version_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_yuki_hook_api_version_zh_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:alpha="0.85"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_new_xshare_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_new_xshare_zh_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:alpha="0.85"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_res_hook_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_demo_res_hook_zh_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:alpha="0.85"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="sample"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center|start"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="Leave something in there"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/module_demo_edit_text"
|
||||||
|
android:layout_width="250dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="Please enter the text"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textSize="18sp"
|
||||||
|
tools:ignore="Autofill,LabelFor,TextFields" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/module_demo_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
android:ellipsize="end"
|
android:text="Save Test Data"
|
||||||
android:gravity="center|start"
|
android:textAllCaps="false" />
|
||||||
android:singleLine="true"
|
|
||||||
android:text="sample"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<TextView
|
<Button
|
||||||
android:id="@+id/module_demo_framework_text"
|
android:id="@+id/module_demo_frg_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:text="Open PreferenceFragment"
|
||||||
android:ellipsize="end"
|
android:textAllCaps="false" />
|
||||||
android:gravity="center|start"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="sample"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/module_demo_api_version_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="15dp"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center|start"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="sample"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/module_demo_yuki_hook_api_version_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="15dp"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center|start"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="sample"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/module_demo_new_xshare_text"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="25dp"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center|start"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="sample"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:layout_marginBottom="15dp"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center|start"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="Leave something in there"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/module_demo_edit_text"
|
|
||||||
android:layout_width="250dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="Please enter the text"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:textSize="18sp"
|
|
||||||
tools:ignore="Autofill,LabelFor,TextFields" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
<Button
|
|
||||||
android:id="@+id/module_demo_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="15dp"
|
|
||||||
android:text="Save Test Data"
|
|
||||||
android:textAllCaps="false" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/module_demo_frg_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Open PreferenceFragment"
|
|
||||||
android:textAllCaps="false" />
|
|
||||||
</LinearLayout>
|
|
BIN
demo-module/src/main/res/mipmap-xxhdpi/ic_face_happy.png
Normal file
BIN
demo-module/src/main/res/mipmap-xxhdpi/ic_face_happy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Reference in New Issue
Block a user