From 514f53477bd3b92cf6bbe85956077615ef5e95af Mon Sep 17 00:00:00 2001 From: mu7220 <80700814+mu7220@users.noreply.github.com> Date: Tue, 13 Feb 2024 11:28:36 +0800 Subject: [PATCH] fix: CustomWatermark hook failed (by StarVoyager) Signed-off-by: mu7220 <80700814+mu7220@users.noreply.github.com> --- .../hook/mediaeditor/CustomWatermark.kt | 39 ++++++++++++++----- .../mediaeditor/UnlockCustomPhotoFrames.kt | 13 ++----- .../hook/systemui/lockscreen/BlurButton.kt | 1 + 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/CustomWatermark.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/CustomWatermark.kt index e4640ed9ae..355ace4677 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/CustomWatermark.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/CustomWatermark.kt @@ -1,6 +1,6 @@ /* * This file is part of HyperCeiler. - + * HyperCeiler is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the @@ -18,23 +18,42 @@ */ package com.sevtinge.hyperceiler.module.hook.mediaeditor -import android.annotation.SuppressLint -import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks -import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder +import com.github.kyuubiran.ezxhelper.EzXHelper +import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.sevtinge.hyperceiler.module.base.BaseHook -import com.sevtinge.hyperceiler.utils.api.LazyClass.SystemProperties +import com.sevtinge.hyperceiler.module.base.dexkit.DexKit.dexKitBridge +import org.luckypray.dexkit.query.enums.StringMatchType +import java.lang.reflect.Modifier -@SuppressLint("StaticFieldLeak") object CustomWatermark : BaseHook() { + private val name by lazy { + mPrefsMap.getString("mediaeditor_custom_watermark", "") + } override fun init(){ - SystemProperties.methodFinder() + // by StarVoyager + val search = dexKitBridge.findMethod { + matcher { + addUsingString("K30 Pro Zoom E", StringMatchType.Equals) + modifiers = Modifier.FINAL + returnType = "java.lang.String" + paramCount = 2 + } + }.single().getMethodInstance(EzXHelper.classLoader) + + logE(TAG, "[CustomWatermark] search method is $search") + search.createHook { + // 当前只能修改后缀 + returnConstant(name) + } + + /*SystemProperties.methodFinder() .filterByParamCount(2) .filterByParamTypes(String::class.java, String::class.java) .toList().createHooks { before { if (it.args[0] == "ro.product.marketname") { - it.args[1] = mPrefsMap.getString("mediaeditor_custom_watermark", "") + it.args[1] = name } } } @@ -45,9 +64,9 @@ object CustomWatermark : BaseHook() { .toList().createHooks { before { if (it.args[0] == "ro.product.marketname") { - it.result = mPrefsMap.getString("mediaeditor_custom_watermark", "") + it.result = name } } - } + }*/ } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt index 5dc98f3845..e606b51cdf 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/mediaeditor/UnlockCustomPhotoFrames.kt @@ -42,7 +42,7 @@ object UnlockCustomPhotoFrames : BaseHook() { dexKitBridge.findMethod { matcher { // find 徕卡定制画框 && redmi 定制画框 && poco 定制画框 && 迪斯尼定制画框 && 新春定制画框 - // 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() b() d() f() g() i()) + // 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() b() d() f() h() i()) // b() 是新春定制画框,前置条件需要符合定制画框类型(徕卡定制画框 或 redmi 定制画框) // h() 是 Redmi 中的 其中一个联名定制画框 // 如果都返回 true 的话,按照原代码逻辑,只会解锁徕卡定制画框 @@ -64,7 +64,7 @@ object UnlockCustomPhotoFrames : BaseHook() { private val publicA by lazy { dexKitBridge.findMethod { matcher { - // 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() d() f() h() i()) + // 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() d() f() h()) addCall { declaredClass { modifiers = Modifier.FINAL or Modifier.PUBLIC @@ -128,7 +128,7 @@ object UnlockCustomPhotoFrames : BaseHook() { differentItems.forEach { method -> // debug 用 logI(TAG, "Public Spring name is $method") - springFestival(method) + other(method) // 1.6.0.5.2 新增限时新春定制画框 } } @@ -173,11 +173,4 @@ object UnlockCustomPhotoFrames : BaseHook() { returnConstant(true) } } - - private fun springFestival(name: Method) { - // 1.6.0.5.2 新增限时新春定制画框 - name.createHook { - returnConstant(true) - } - } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/lockscreen/BlurButton.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/lockscreen/BlurButton.kt index 260f0d0763..d25b0558d8 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/lockscreen/BlurButton.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/lockscreen/BlurButton.kt @@ -45,6 +45,7 @@ object BlurButton : BaseHook() { @RequiresApi(Build.VERSION_CODES.S) override fun init() { + // by StarVoyager if (isMoreHyperOSVersion(1f)) { loadClassOrNull( "com.android.keyguard.injector.KeyguardBottomAreaInjector"