mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-10-22 19:42:49 +08:00
Revert "putIfAbsent" method in YukiMemberHookCreater、YukiResourcesHookCreater、PackageParam
This commit is contained in:
@@ -42,7 +42,6 @@ import com.highcapable.yukihookapi.hook.param.HookParam
|
|||||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
||||||
import com.highcapable.yukihookapi.hook.param.wrapper.HookParamWrapper
|
import com.highcapable.yukihookapi.hook.param.wrapper.HookParamWrapper
|
||||||
import com.highcapable.yukihookapi.hook.utils.putIfAbsentCompat
|
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
|
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import java.lang.reflect.Member
|
import java.lang.reflect.Member
|
||||||
@@ -100,8 +99,7 @@ class YukiMemberHookCreater(@PublishedApi internal val packageParam: PackagePara
|
|||||||
* @return [MemberHookCreater.Result]
|
* @return [MemberHookCreater.Result]
|
||||||
*/
|
*/
|
||||||
inline fun injectMember(priority: Int = PRIORITY_DEFAULT, tag: String = "Default", initiate: MemberHookCreater.() -> Unit) =
|
inline fun injectMember(priority: Int = PRIORITY_DEFAULT, tag: String = "Default", initiate: MemberHookCreater.() -> Unit) =
|
||||||
MemberHookCreater(priority, tag, packageParam.exhibitName)
|
MemberHookCreater(priority, tag, packageParam.exhibitName).apply(initiate).apply { preHookMembers[toString()] = this }.build()
|
||||||
.apply(initiate).apply { preHookMembers.putIfAbsentCompat(toString(), this) }.build()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook 执行入口
|
* Hook 执行入口
|
||||||
|
@@ -36,7 +36,6 @@ import com.highcapable.yukihookapi.hook.log.yLoggerE
|
|||||||
import com.highcapable.yukihookapi.hook.log.yLoggerI
|
import com.highcapable.yukihookapi.hook.log.yLoggerI
|
||||||
import com.highcapable.yukihookapi.hook.param.PackageParam
|
import com.highcapable.yukihookapi.hook.param.PackageParam
|
||||||
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
||||||
import com.highcapable.yukihookapi.hook.utils.putIfAbsentCompat
|
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
|
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiResources
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ class YukiResourcesHookCreater(private val packageParam: PackageParam, @Publishe
|
|||||||
* @return [ResourcesHookCreater.Result]
|
* @return [ResourcesHookCreater.Result]
|
||||||
*/
|
*/
|
||||||
inline fun injectResource(tag: String = "Default", initiate: ResourcesHookCreater.() -> Unit) =
|
inline fun injectResource(tag: String = "Default", initiate: ResourcesHookCreater.() -> Unit) =
|
||||||
ResourcesHookCreater(tag).apply(initiate).apply { preHookResources.putIfAbsentCompat(toString(), this) }.build()
|
ResourcesHookCreater(tag).apply(initiate).apply { preHookResources[toString()] = this }.build()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook 执行入口
|
* Hook 执行入口
|
||||||
|
@@ -47,7 +47,6 @@ import com.highcapable.yukihookapi.hook.factory.hasClass
|
|||||||
import com.highcapable.yukihookapi.hook.factory.hookClass
|
import com.highcapable.yukihookapi.hook.factory.hookClass
|
||||||
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
import com.highcapable.yukihookapi.hook.param.type.HookEntryType
|
||||||
import com.highcapable.yukihookapi.hook.param.wrapper.PackageParamWrapper
|
import com.highcapable.yukihookapi.hook.param.wrapper.PackageParamWrapper
|
||||||
import com.highcapable.yukihookapi.hook.utils.putIfAbsentCompat
|
|
||||||
import com.highcapable.yukihookapi.hook.utils.value
|
import com.highcapable.yukihookapi.hook.utils.value
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
|
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge
|
||||||
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiModuleResources
|
import com.highcapable.yukihookapi.hook.xposed.bridge.dummy.YukiModuleResources
|
||||||
@@ -467,8 +466,7 @@ open class PackageParam internal constructor(@PublishedApi internal var wrapper:
|
|||||||
* @param initiate 回调 - ([Context] 当前上下文,[Intent] 当前 Intent)
|
* @param initiate 回调 - ([Context] 当前上下文,[Intent] 当前 Intent)
|
||||||
*/
|
*/
|
||||||
fun registerReceiver(vararg action: String, initiate: (context: Context, intent: Intent) -> Unit) {
|
fun registerReceiver(vararg action: String, initiate: (context: Context, intent: Intent) -> Unit) {
|
||||||
if (action.isNotEmpty())
|
if (action.isNotEmpty()) YukiHookBridge.AppLifecycleCallback.onReceiversCallback[action.value()] = Pair(action, initiate)
|
||||||
YukiHookBridge.AppLifecycleCallback.onReceiversCallback.putIfAbsentCompat(action.value(), Pair(action, initiate))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置创建生命周期监听回调 */
|
/** 设置创建生命周期监听回调 */
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.highcapable.yukihookapi.hook.utils
|
package com.highcapable.yukihookapi.hook.utils
|
||||||
|
|
||||||
import android.os.Build
|
|
||||||
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
import com.highcapable.yukihookapi.annotation.YukiPrivateApi
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@@ -60,20 +59,6 @@ inline fun <reified T> Array<out T>.value() = if (isNotEmpty()) {
|
|||||||
"[${value.trim().let { it.substring(0, it.lastIndex) }}]"
|
"[${value.trim().let { it.substring(0, it.lastIndex) }}]"
|
||||||
} else "[]"
|
} else "[]"
|
||||||
|
|
||||||
/**
|
|
||||||
* 不重复写入 [HashMap]
|
|
||||||
*
|
|
||||||
* 兼容旧版本 Android
|
|
||||||
* @param key Key
|
|
||||||
* @param value Value
|
|
||||||
*/
|
|
||||||
@YukiPrivateApi
|
|
||||||
inline fun <reified K, V> HashMap<K, V>.putIfAbsentCompat(key: K, value: V) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
||||||
putIfAbsent(key, value)
|
|
||||||
else get(key) ?: put(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算方法执行耗时
|
* 计算方法执行耗时
|
||||||
* @param block 方法块
|
* @param block 方法块
|
||||||
|
Reference in New Issue
Block a user