mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 01:35:17 +08:00
Modify change some HashMap to ArrayMap to save memory
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core
|
||||
|
||||
import android.util.ArrayMap
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.annotation.CauseProblemsApi
|
||||
import com.highcapable.yukihookapi.hook.bean.HookClass
|
||||
@@ -96,7 +97,7 @@ class YukiMemberHookCreator @PublishedApi internal constructor(
|
||||
|
||||
/** 设置要 Hook 的 [Method]、[Constructor] */
|
||||
@PublishedApi
|
||||
internal var preHookMembers = HashMap<String, MemberHookCreator>()
|
||||
internal var preHookMembers = ArrayMap<String, MemberHookCreator>()
|
||||
|
||||
/**
|
||||
* 更新当前 [YukiMemberHookCreator] 禁止执行 Hook 操作的条件
|
||||
|
@@ -30,6 +30,7 @@
|
||||
package com.highcapable.yukihookapi.hook.core
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.util.ArrayMap
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.hook.bean.HookResources
|
||||
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper
|
||||
@@ -53,7 +54,7 @@ class YukiResourcesHookCreator @PublishedApi internal constructor(
|
||||
|
||||
/** 设置要 Hook 的 Resources */
|
||||
@PublishedApi
|
||||
internal var preHookResources = HashMap<String, ResourcesHookCreator>()
|
||||
internal var preHookResources = ArrayMap<String, ResourcesHookCreator>()
|
||||
|
||||
/**
|
||||
* 注入要 Hook 的 Resources
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
package com.highcapable.yukihookapi.hook.core.finder.base.rules
|
||||
|
||||
import android.util.ArrayMap
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Member
|
||||
import java.lang.reflect.Method
|
||||
@@ -47,7 +48,7 @@ class ModifierRules private constructor(private val instance: Any) {
|
||||
internal companion object {
|
||||
|
||||
/** 当前实例数组 */
|
||||
private val instances = HashMap<Long, ModifierRules>()
|
||||
private val instances = ArrayMap<Long, ModifierRules>()
|
||||
|
||||
/**
|
||||
* 获取模板字符串数组
|
||||
|
@@ -27,6 +27,7 @@
|
||||
*/
|
||||
package com.highcapable.yukihookapi.hook.core.finder.store
|
||||
|
||||
import android.util.ArrayMap
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.Field
|
||||
@@ -45,22 +46,22 @@ import java.lang.reflect.Method
|
||||
internal object ReflectsCacheStore {
|
||||
|
||||
/** 缓存的 [Class] 列表 */
|
||||
private val dexClassListData = HashMap<Int, List<String>>()
|
||||
private val dexClassListData = ArrayMap<Int, List<String>>()
|
||||
|
||||
/** 缓存的 [Class] 对象 */
|
||||
private val classData = HashMap<Int, Class<*>?>()
|
||||
private val classData = ArrayMap<Int, Class<*>?>()
|
||||
|
||||
/** 缓存的 [Class] 数组 */
|
||||
private val classesData = HashMap<Int, HashSet<Class<*>>>()
|
||||
private val classesData = ArrayMap<Int, HashSet<Class<*>>>()
|
||||
|
||||
/** 缓存的 [Method] 数组 */
|
||||
private val methodsData = HashMap<Int, HashSet<Method>>()
|
||||
private val methodsData = ArrayMap<Int, HashSet<Method>>()
|
||||
|
||||
/** 缓存的 [Constructor] 数组 */
|
||||
private val constructorsData = HashMap<Int, HashSet<Constructor<*>>>()
|
||||
private val constructorsData = ArrayMap<Int, HashSet<Constructor<*>>>()
|
||||
|
||||
/** 缓存的 [Field] 数组 */
|
||||
private val fieldsData = HashMap<Int, HashSet<Field>>()
|
||||
private val fieldsData = ArrayMap<Int, HashSet<Field>>()
|
||||
|
||||
/**
|
||||
* 查找缓存中的 [Class] 列表
|
||||
|
@@ -30,6 +30,7 @@
|
||||
package com.highcapable.yukihookapi.hook.param
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.ArrayMap
|
||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
|
||||
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator.MemberHookCreator
|
||||
import com.highcapable.yukihookapi.hook.core.api.helper.YukiHookHelper
|
||||
@@ -55,7 +56,7 @@ class HookParam internal constructor(
|
||||
internal companion object {
|
||||
|
||||
/** 每个回调方法体的数据存储实例数据 */
|
||||
private val dataExtras = HashMap<String, Bundle>()
|
||||
private val dataExtras = ArrayMap<String, Bundle>()
|
||||
|
||||
/** [HookParam] 是否已经执行首次回调事件 */
|
||||
internal var isCallbackCalled = false
|
||||
|
@@ -30,6 +30,7 @@ package com.highcapable.yukihookapi.hook.xposed.bridge
|
||||
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.res.Resources
|
||||
import android.util.ArrayMap
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper
|
||||
import com.highcapable.yukihookapi.hook.factory.hasClass
|
||||
@@ -58,13 +59,13 @@ internal object YukiXposedModule : IYukiXposedModuleLifecycle {
|
||||
private var isInitializingZygote = false
|
||||
|
||||
/** 当前 [PackageParam] 实例数组 */
|
||||
private val packageParams = HashMap<String, PackageParam>()
|
||||
private val packageParams = ArrayMap<String, PackageParam>()
|
||||
|
||||
/** 已在 [PackageParam] 中被装载的 APP 包名 */
|
||||
private val loadedPackageNames = HashSet<String>()
|
||||
|
||||
/** 当前 [PackageParamWrapper] 实例数组 */
|
||||
private val packageParamWrappers = HashMap<String, PackageParamWrapper>()
|
||||
private val packageParamWrappers = ArrayMap<String, PackageParamWrapper>()
|
||||
|
||||
/** 当前 [PackageParam] 方法体回调 */
|
||||
internal var packageParamCallback: (PackageParam.() -> Unit)? = null
|
||||
|
@@ -38,6 +38,7 @@ import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.util.ArrayMap
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiProperty
|
||||
@@ -79,7 +80,7 @@ internal object AppParasitics {
|
||||
private var isClassLoaderHooked = false
|
||||
|
||||
/** [ClassLoader] 监听回调数组 */
|
||||
private var classLoaderCallbacks = HashMap<Int, (Class<*>) -> Unit>()
|
||||
private var classLoaderCallbacks = ArrayMap<Int, (Class<*>) -> Unit>()
|
||||
|
||||
/**
|
||||
* 当前 Hook APP (宿主) 的全局生命周期 [Application]
|
||||
@@ -435,9 +436,9 @@ internal object AppParasitics {
|
||||
internal var onConfigurationChangedCallback: ((Application, Configuration) -> Unit)? = null
|
||||
|
||||
/** 系统广播监听回调 */
|
||||
internal val onReceiverActionsCallbacks = HashMap<String, Pair<Array<out String>, (Context, Intent) -> Unit>>()
|
||||
internal val onReceiverActionsCallbacks = ArrayMap<String, Pair<Array<out String>, (Context, Intent) -> Unit>>()
|
||||
|
||||
/** 系统广播监听回调 */
|
||||
internal val onReceiverFiltersCallbacks = HashMap<String, Pair<IntentFilter, (Context, Intent) -> Unit>>()
|
||||
internal val onReceiverFiltersCallbacks = ArrayMap<String, Pair<IntentFilter, (Context, Intent) -> Unit>>()
|
||||
}
|
||||
}
|
@@ -31,6 +31,7 @@ package com.highcapable.yukihookapi.hook.xposed.prefs
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.util.ArrayMap
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.highcapable.yukihookapi.YukiHookAPI
|
||||
import com.highcapable.yukihookapi.hook.log.yLoggerE
|
||||
@@ -65,10 +66,10 @@ class YukiHookPrefsBridge private constructor(private var context: Context? = nu
|
||||
private val isXposedEnvironment = YukiXposedModule.isXposedEnvironment
|
||||
|
||||
/** 当前缓存的 [XSharedPreferencesDelegate] 实例数组 */
|
||||
private val xPrefs = HashMap<String, XSharedPreferencesDelegate>()
|
||||
private val xPrefs = ArrayMap<String, XSharedPreferencesDelegate>()
|
||||
|
||||
/** 当前缓存的 [SharedPreferences] 实例数组 */
|
||||
private val sPrefs = HashMap<String, SharedPreferences>()
|
||||
private val sPrefs = ArrayMap<String, SharedPreferences>()
|
||||
|
||||
/**
|
||||
* 创建 [YukiHookPrefsBridge] 对象
|
||||
@@ -122,22 +123,22 @@ class YukiHookPrefsBridge private constructor(private var context: Context? = nu
|
||||
private object XSharedPreferencesCaches {
|
||||
|
||||
/** 缓存的 [String] 键值数据 */
|
||||
var stringData = HashMap<String, String>()
|
||||
var stringData = ArrayMap<String, String>()
|
||||
|
||||
/** 缓存的 [Set]<[String]> 键值数据 */
|
||||
var stringSetData = HashMap<String, Set<String>>()
|
||||
var stringSetData = ArrayMap<String, Set<String>>()
|
||||
|
||||
/** 缓存的 [Boolean] 键值数据 */
|
||||
var booleanData = HashMap<String, Boolean>()
|
||||
var booleanData = ArrayMap<String, Boolean>()
|
||||
|
||||
/** 缓存的 [Int] 键值数据 */
|
||||
var intData = HashMap<String, Int>()
|
||||
var intData = ArrayMap<String, Int>()
|
||||
|
||||
/** 缓存的 [Long] 键值数据 */
|
||||
var longData = HashMap<String, Long>()
|
||||
var longData = ArrayMap<String, Long>()
|
||||
|
||||
/** 缓存的 [Float] 键值数据 */
|
||||
var floatData = HashMap<String, Float>()
|
||||
var floatData = ArrayMap<String, Float>()
|
||||
|
||||
/** 清除所有缓存的键值数据 */
|
||||
fun clear() {
|
||||
|
Reference in New Issue
Block a user