Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
GangJust committed May 31, 2024
1 parent d7acc42 commit 49d7e0a
Show file tree
Hide file tree
Showing 42 changed files with 114 additions and 48 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/io/github/fplus/core/base/BaseHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlin.coroutines.CoroutineContext

abstract class BaseHook<T> : HookEntity<T>() {
abstract class BaseHook : HookEntity() {
protected val handler: Handler = Handler(Looper.getMainLooper())
private val mainScope: CoroutineScope = CoroutineScope(Dispatchers.Main)
private var singleMainJob: MutableMap<String, Job?> = mutableMapOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog
import kotlinx.coroutines.delay

class HAbstractFeedAdapter : BaseHook<Any>() {
class HAbstractFeedAdapter : BaseHook() {
companion object {
const val TAG = "HAbstractFeedAdapter"
}
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/io/github/fplus/core/hook/HActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisActivity

class HActivity : BaseHook<Activity>() {
class HActivity : BaseHook() {
companion object {
const val TAG = "HActivity"
}

private val config get() = ConfigV1.get()

override fun setTargetClass(): Class<*> {
return Activity::class.java
}

@OnBefore("dispatchTouchEvent")
fun dispatchTouchEventBefore(params: XC_MethodHook.MethodHookParam, event: MotionEvent) {
hookBlockRunning(params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisViewGroup

class HBottomCtrlBar : BaseHook<Any>() {
class HBottomCtrlBar : BaseHook() {
companion object {
const val TAG = "HBottomCtrlBar"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import io.github.xpler.core.entity.Param
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HChatListRecalledHint : BaseHook<Any>() {
class HChatListRecalledHint : BaseHook() {
companion object {
const val TAG = "HChatListRecalledHint"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HChatListRecyclerViewAdapter : BaseHook<Any>() {
class HChatListRecyclerViewAdapter : BaseHook() {
companion object {
const val TAG = "HChatListRecyclerViewAdapter"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import io.github.xpler.core.thisView
import io.github.xpler.core.wrapper.CallMethods

@Deprecated("暂存区, 评论区语音保存")
class HCommentAudioView : BaseHook<Any>(), CallMethods {
class HCommentAudioView : BaseHook(), CallMethods {
companion object {
const val TAG = "HCommentAudioView"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import io.github.xpler.core.entity.ReturnType
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HCommentListPageFragment : BaseHook<Any>() {
class HCommentListPageFragment : BaseHook() {
companion object {
const val TAG = "HCommentListPageFragment"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HConversationFragment : BaseHook<Any>() {
class HConversationFragment : BaseHook() {
companion object {
const val TAG = "HConversationFragment"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HCornerExtensionsPopupWindow : BaseHook<Any>() {
class HCornerExtensionsPopupWindow : BaseHook() {
companion object {
const val TAG = "HCornerExtensionsPopupWindow"
}
Expand Down
12 changes: 8 additions & 4 deletions core/src/main/java/io/github/fplus/core/hook/HCrashTolerance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.wrapper.CallMethods

/// 崩溃容错,处理官方可能造成的系列崩溃问题
class HCrashTolerance : BaseHook<EmptyHook>() {
class HCrashTolerance : BaseHook() {
companion object {
const val TAG = "HCrashTolerance"
}

val config get() = ConfigV1.get()

override fun setTargetClass(): Class<*> {
return EmptyHook::class.java
}

override fun onInit() {
if (!config.isCrashTolerance)
return
Expand All @@ -31,7 +35,7 @@ class HCrashTolerance : BaseHook<EmptyHook>() {
HTabLanding()
}

inner class HPoiFeed : BaseHook<EmptyHook>(), CallMethods {
inner class HPoiFeed : BaseHook(), CallMethods {
override fun setTargetClass(): Class<*> {
return findClass("com.ss.android.ugc.aweme.poi.anchor.poi.flavor.PoiFeedAnchor")
}
Expand All @@ -50,7 +54,7 @@ class HCrashTolerance : BaseHook<EmptyHook>() {
}
}

inner class HLivePhoto : BaseHook<EmptyHook>() {
inner class HLivePhoto : BaseHook() {

override fun setTargetClass(): Class<*> {
return DexkitBuilder.livePhotoClazz ?: NoneHook::class.java
Expand All @@ -67,7 +71,7 @@ class HCrashTolerance : BaseHook<EmptyHook>() {
}
}

inner class HTabLanding : BaseHook<EmptyHook>() {
inner class HTabLanding : BaseHook() {

override fun setTargetClass(): Class<*> {
return DexkitBuilder.tabLandingClazz ?: NoneHook::class.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisActivity

class HDetailActivity : BaseHook<DetailActivity>() {
class HDetailActivity : BaseHook() {
companion object {
const val TAG = "HDetailActivity"
}
Expand All @@ -25,6 +25,10 @@ class HDetailActivity : BaseHook<DetailActivity>() {

private val clipboardLogic = ClipboardLogic(this)

override fun setTargetClass(): Class<*> {
return DetailActivity::class.java
}

@OnAfter("onResume")
fun onResumeAfter(params: XC_MethodHook.MethodHookParam) {
hookBlockRunning(params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HDetailPageFragment : BaseHook<Any>() {
class HDetailPageFragment : BaseHook() {
companion object {
const val TAG = "HDetailPageFragment"

Expand All @@ -37,7 +37,9 @@ class HDetailPageFragment : BaseHook<Any>() {

private val config get() = ConfigV1.get()

override fun setTargetClass(): Class<*> = DexkitBuilder.detailPageFragmentClazz ?: NoneHook::class.java
override fun setTargetClass(): Class<*> {
return DexkitBuilder.detailPageFragmentClazz ?: NoneHook::class.java
}

@OnAfter("onViewCreated")
fun onViewCreatedAfter(param: XC_MethodHook.MethodHookParam, view: View, bundle: Bundle?) {
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/io/github/fplus/core/hook/HDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HDialog : BaseHook<Dialog>() {
class HDialog : BaseHook() {
companion object {
const val TAG = "HDialog"
}
Expand All @@ -30,6 +30,10 @@ class HDialog : BaseHook<Dialog>() {
.toRegex()
}

override fun setTargetClass(): Class<*> {
return Dialog::class.java
}

@OnAfter("show")
fun showAfter(params: XC_MethodHook.MethodHookParam) {
hookBlockRunning(params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisViewGroup
import io.github.xpler.core.wrapper.CallConstructors

class HDisallowInterceptRelativeLayout : BaseHook<Any>(),
class HDisallowInterceptRelativeLayout : BaseHook(),
CallConstructors {
companion object {
const val TAG = "HDisallowInterceptRelativeLayout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.wrapper.CallMethods
import kotlinx.coroutines.delay

class HEmojiDetailDialog : BaseHook<EmojiDetailDialog>(), CallMethods {
class HEmojiDetailDialog : BaseHook(), CallMethods {
companion object {
const val TAG = "HEmojiDetailDialog"
}
Expand All @@ -28,12 +28,16 @@ class HEmojiDetailDialog : BaseHook<EmojiDetailDialog>(), CallMethods {

private var urlList: List<String> = emptyList()

override fun setTargetClass(): Class<*> {
return EmojiDetailDialog::class.java
}

override fun onInit() {
lpparam.hookClass(EmojiBottomSheetDialog::class.java)
.method("onCreate", Bundle::class.java) {
onAfter {
if (!config.isEmojiDownload) return@onAfter
if (!targetClazz.isInstance(thisObject)) return@onAfter // 非 EmojiDetailDialog, 直接结束
if (!targetClass.isInstance(thisObject)) return@onAfter // 非 EmojiDetailDialog, 直接结束

singleLaunchMain {
delay(500L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import io.github.fplus.core.hook.logic.SaveEmojiLogic
import io.github.xpler.core.argsOrEmpty
import io.github.xpler.core.hookClass

class HEmojiDetailDialogNew : BaseHook<EmojiDetailDialogNew>() {
class HEmojiDetailDialogNew : BaseHook() {
companion object {
const val TAG = "HEmojiDetailDialogNew"
}
Expand All @@ -25,6 +25,10 @@ class HEmojiDetailDialogNew : BaseHook<EmojiDetailDialogNew>() {

private var urlList: List<String> = emptyList()

override fun setTargetClass(): Class<*> {
return EmojiDetailDialogNew::class.java
}

override fun onInit() {

lpparam.hookClass(EmojiDetailDialogNew::class.java)
Expand All @@ -44,7 +48,7 @@ class HEmojiDetailDialogNew : BaseHook<EmojiDetailDialogNew>() {
if (!config.isEmojiDownload) return@onAfter

// 非 EmojiDetailDialogNew, 直接结束
if (!targetClazz.isInstance(thisObject)) {
if (!targetClass.isInstance(thisObject)) {
return@onAfter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.github.xpler.core.entity.ReturnType
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HEmojiPopupWindow : BaseHook<Any>() {
class HEmojiPopupWindow : BaseHook() {
companion object {
const val TAG = "HEmojiPopupWindow"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import io.github.xpler.core.entity.OnBefore
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HFeedAvatarPresenter : BaseHook<Any>() {
class HFeedAvatarPresenter : BaseHook() {
companion object {
const val TAG = "HFeedAvatarPresenter"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import io.github.xpler.core.entity.OnBefore
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HFlippableViewPager : BaseHook<FlippableViewPager>() {
class HFlippableViewPager : BaseHook() {
companion object {
const val TAG = "HFlippableViewPager"
}

private val config get() = ConfigV1.get()

override fun setTargetClass(): Class<*> {
return FlippableViewPager::class.java
}

@OnBefore("onInterceptTouchEvent", "onTouchEvent", "dispatchTouchEvent")
fun onTouchEventBefore(params: XC_MethodHook.MethodHookParam, event: MotionEvent) {
hookBlockRunning(params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisActivity
import kotlinx.coroutines.delay

class HGifEmojiDetailActivity : BaseHook<GifEmojiDetailActivity>() {
class HGifEmojiDetailActivity : BaseHook() {
companion object {
const val TAG = "HGifEmojiDetailActivity"
}
Expand All @@ -29,6 +29,10 @@ class HGifEmojiDetailActivity : BaseHook<GifEmojiDetailActivity>() {

private var urlList: List<String> = emptyList()

override fun setTargetClass(): Class<*> {
return GifEmojiDetailActivity::class.java
}

@OnBefore("onCreate")
fun onCreate(params: XC_MethodHook.MethodHookParam, bundle: Bundle?) {
hookBlockRunning(params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import io.github.xpler.core.entity.OnBefore
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog

class HHomeBottomTabServiceImpl : BaseHook<Any>() {
class HHomeBottomTabServiceImpl : BaseHook() {
companion object {
const val TAG = "HHomeBottomTabServiceImpl"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisViewGroup
import io.github.xpler.core.wrapper.CallConstructors

class HInteractStickerParent : BaseHook<InteractStickerParent>(), CallConstructors {
class HInteractStickerParent : BaseHook(), CallConstructors {
companion object {
const val TAG = "HInteractStickerParent"
}

private val config get() = ConfigV1.get()

override fun setTargetClass(): Class<*> {
return InteractStickerParent::class.java
}

override fun callOnBeforeConstructors(params: XC_MethodHook.MethodHookParam) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisActivity

class HLandscapeFeedActivity : BaseHook<LandscapeFeedActivity>() {
class HLandscapeFeedActivity : BaseHook() {
companion object {
const val TAG = "HLandscapeFeedActivity"
}
Expand All @@ -25,6 +25,10 @@ class HLandscapeFeedActivity : BaseHook<LandscapeFeedActivity>() {

private val clipboardLogic = ClipboardLogic(this)

override fun setTargetClass(): Class<*> {
return LandscapeFeedActivity::class.java
}

@OnAfter("onResume")
fun onResumeAfter(params: XC_MethodHook.MethodHookParam) {
hookBlockRunning(params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisActivity

class HLivePlayActivity : BaseHook<LivePlayActivity>() {
class HLivePlayActivity : BaseHook() {

companion object {
const val TAG = "HLivePlayActivity"
}

private val config get() = ConfigV1.get()

override fun setTargetClass(): Class<*> {
return LivePlayActivity::class.java
}

@OnBefore("onWindowFocusChanged")
@OnAfter("onWindowFocusChanged")
fun onWindowFocusChangedAfter(params: XC_MethodHook.MethodHookParam, boolean: Boolean) {
Expand Down
Loading

0 comments on commit 49d7e0a

Please sign in to comment.