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

Commit

Permalink
类搜索日志
Browse files Browse the repository at this point in the history
  • Loading branch information
GangJust committed Sep 16, 2023
1 parent e63343a commit 0f95ca6
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 131 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
applicationId "com.freegang.fplus"
minSdk 24
targetSdk 34
versionCode 55
versionCode 57
versionName "1.2.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/update.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
v1.2.0
增加视频类型、文案关键字过滤
增加相关表情长按保存
增加视频类型、文案关键字过滤
调整表情包保存逻辑
修复旧版本抖音兼容性
修复部分已知问题
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0-55
1.2.0-57
11 changes: 11 additions & 0 deletions core/src/main/java/com/freegang/config/ConfigV1.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.freegang.ktutils.json.getStringOrDefault
import com.freegang.ktutils.json.parseJSON
import com.freegang.webdav.WebDav
import com.tencent.mmkv.MMKV
import org.json.JSONObject
import java.io.File

class ConfigV1 private constructor() {
Expand Down Expand Up @@ -303,4 +304,14 @@ class ConfigV1 private constructor() {
mmkv.putString("dyVersionName", value.dyVersionName)
mmkv.putLong("dyVersionCode", value.dyVersionCode)
}

/// 类名存储
var classes: JSONObject = JSONObject()
get() {
return mmkv.getString("classes", "")!!.parseJSON()
}
set(value) {
field = value
mmkv.putString("classes", value.toString())
}
}
125 changes: 88 additions & 37 deletions core/src/main/java/com/freegang/hook/DouYinMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,32 @@ import com.freegang.ktutils.app.KActivityUtils
import com.freegang.ktutils.app.KAppCrashUtils
import com.freegang.ktutils.app.KAppUtils
import com.freegang.ktutils.app.KToastUtils
import com.freegang.ktutils.app.appVersionCode
import com.freegang.ktutils.app.appVersionName
import com.freegang.ktutils.io.hasOperationStorage
import com.freegang.ktutils.json.getIntOrDefault
import com.freegang.ktutils.json.getStringOrDefault
import com.freegang.ktutils.json.parseJSONArray
import com.freegang.ktutils.log.KLogCat
import com.freegang.ktutils.text.ifNotEmpty
import com.freegang.plugin.PluginBridge
import com.freegang.xpler.HookPackages
import com.freegang.xpler.core.findClass
import com.freegang.xpler.core.lpparam
import com.freegang.xpler.loader.hostClassloader
import com.freegang.xpler.loader.injectClassLoader
import org.json.JSONObject
import org.luckypray.dexkit.DexKitBridge
import org.luckypray.dexkit.query.enums.StringMatchType
import java.lang.reflect.Modifier
import kotlin.system.exitProcess

class DouYinMain(private val app: Application) {
companion object {
val awemeHostApplication get() = "com.ss.android.ugc.aweme.app.host.AwemeHostApplication".findClass(lpparam.classLoader)!!
val awemeHostApplication
get() = "com.ss.android.ugc.aweme.app.host.AwemeHostApplication".findClass(
lpparam.classLoader
)!!
var detailPageFragmentClazz: Class<*>? = null
var videoPinchClazz: Class<*>? = null
var videoPagerAdapterClazz: Class<*>? = null
Expand Down Expand Up @@ -61,13 +69,17 @@ class DouYinMain(private val app: Application) {

//插件化注入
if (!ConfigV1.get().isDisablePlugin) {
val subClazz = hostClassloader!!.loadClass("com.ss.android.ugc.aweme.bullet.ui.BulletContainerActivity")
val subClazz =
hostClassloader!!.loadClass("com.ss.android.ugc.aweme.bullet.ui.BulletContainerActivity")
PluginBridge.init(app, subClazz)
}

//全局异常捕获工具
val intent = Intent()
intent.setClassName(HookPackages.modulePackageName, "${HookPackages.modulePackageName}.activity.ErrorActivity")
intent.setClassName(
HookPackages.modulePackageName,
"${HookPackages.modulePackageName}.activity.ErrorActivity"
)
KAppCrashUtils.instance.init(app, intent, "抖音异常退出!")

//初始化DexKit
Expand Down Expand Up @@ -97,7 +109,44 @@ class DouYinMain(private val app: Application) {
}
}

private fun readClasses(): Boolean {
val classes = ConfigV1.get().classes
val targetVersion = classes.getStringOrDefault("targetVersion")
val detailPageFragment = classes.getStringOrDefault("detailPageFragment")
val videoPinch = classes.getStringOrDefault("videoPinch")
val videoPagerAdapter = classes.getStringOrDefault("videoPagerAdapter")
val emojiApiProxy = classes.getStringOrDefault("emojiApiProxy")
val emojiPopupWindow = classes.getStringOrDefault("emojiPopupWindow")
val ripsChatRoomFragment = classes.getStringOrDefault("ripsChatRoomFragment")

if (targetVersion != "${app.appVersionName}_${app.appVersionCode}") {
return false
}

detailPageFragmentClazz = detailPageFragment.ifNotEmpty { it.findClass(lpparam.classLoader) }
videoPinchClazz = videoPinch.ifNotEmpty { it.findClass(lpparam.classLoader) }
videoPagerAdapterClazz = videoPagerAdapter.ifNotEmpty { it.findClass(lpparam.classLoader) }
emojiApiProxyClazz = emojiApiProxy.ifNotEmpty { it.findClass(lpparam.classLoader) }
emojiPopupWindowClazz = emojiPopupWindow.ifNotEmpty { it.findClass(lpparam.classLoader) }
ripsChatRoomFragmentClazz = ripsChatRoomFragment.ifNotEmpty { it.findClass(lpparam.classLoader) }

return true
}

private fun saveClasses() {
val classJson = JSONObject()
classJson.put("targetVersion", "${app.appVersionName}_${app.appVersionCode}")
classJson.put("detailPageFragment", "${detailPageFragmentClazz?.name}")
classJson.put("videoPinch", "${videoPinchClazz?.name}")
classJson.put("videoPagerAdapter", "${videoPagerAdapterClazz?.name}")
classJson.put("emojiApiProxy", "${emojiApiProxyClazz?.name}")
classJson.put("emojiPopupWindow", "${emojiPopupWindowClazz?.name}")
classJson.put("ripsChatRoomFragment", "${ripsChatRoomFragmentClazz?.name}")
ConfigV1.get().classes = classJson
}

private fun initDexKit() {
if (readClasses()) return
System.loadLibrary("dexkit")
DexKitBridge.create(lpparam.appInfo.sourceDir)?.use { bridge ->
if (detailPageFragmentClazz == null) {
Expand All @@ -118,7 +167,8 @@ class DouYinMain(private val app: Application) {
matcher {
fields {
add {
type = "com.ss.android.ugc.aweme.feed.ui.seekbar.CustomizedUISeekBar"
type =
"com.ss.android.ugc.aweme.feed.ui.seekbar.CustomizedUISeekBar"
}
}
methods {
Expand Down Expand Up @@ -148,7 +198,8 @@ class DouYinMain(private val app: Application) {
returnType = "com.ss.android.ugc.aweme.feed.model.Aweme"
}
add {
returnType = "com.ss.android.ugc.aweme.feed.adapter.FeedImageViewHolder"
returnType =
"com.ss.android.ugc.aweme.feed.adapter.FeedImageViewHolder"
}
}
}
Expand Down Expand Up @@ -201,12 +252,7 @@ class DouYinMain(private val app: Application) {
ripsChatRoomFragmentClazz = finds.firstOrNull()?.getInstance(lpparam.classLoader)
}
}
KLogCat.d("detailPageFragmentClazz: $detailPageFragmentClazz")
KLogCat.d("videoPinchClazz: $videoPinchClazz")
KLogCat.d("videoPagerAdapterClazz: $videoPagerAdapterClazz")
KLogCat.d("emojiApiProxyClazz: $emojiApiProxyClazz")
KLogCat.d("emojiPopupWindowClazz: $emojiPopupWindowClazz")
KLogCat.d("ripsChatRoomFragmentClazz: $ripsChatRoomFragmentClazz")
saveClasses()
}

@Synchronized
Expand All @@ -218,38 +264,43 @@ class DouYinMain(private val app: Application) {
val timedExit = timedExitValue.getIntOrDefault(0, 0) * 60 * 1000L
val freeExit = timedExitValue.getIntOrDefault(1, 0) * 60 * 1000L

timedExitCountDown = object : CountDownTimer(timedExit, 1000) {
override fun onTick(millisUntilFinished: Long) {
val second = millisUntilFinished / 1000
if (second == 30L) {
KToastUtils.show(app, "抖音将在30秒后定时退出")
}
if (second <= 5) {
KToastUtils.show(app, "定时退出倒计时${second}s")
if (timedExit >= 60 * 1000 * 3) {
timedExitCountDown = object : CountDownTimer(timedExit, 1000) {
override fun onTick(millisUntilFinished: Long) {
val second = millisUntilFinished / 1000
if (second == 30L) {
KToastUtils.show(app, "抖音将在30秒后定时退出")
}
if (second <= 5) {
KToastUtils.show(app, "定时退出倒计时${second}s")
}
}
}

override fun onFinish() {
KActivityUtils.getActivities().forEach { it.finishAndRemoveTask() }
Process.killProcess(Process.myPid())
exitProcess(1)
override fun onFinish() {
KActivityUtils.getActivities().forEach { it.finishAndRemoveTask() }
Process.killProcess(Process.myPid())
exitProcess(1)
}
}
}
freeExitCountDown = object : CountDownTimer(freeExit, 1000) {
override fun onTick(millisUntilFinished: Long) {
val second = millisUntilFinished / 1000
if (second == 30L) {
KToastUtils.show(app, "长时间无操作, 抖音将在30秒后空闲退出")
}
if (second <= 5) {
KToastUtils.show(app, "空闲退出倒计时${second}s")

if (freeExit >= 60 * 1000 * 3) {
freeExitCountDown = object : CountDownTimer(freeExit, 1000) {
override fun onTick(millisUntilFinished: Long) {
val second = millisUntilFinished / 1000
if (second == 30L) {
KToastUtils.show(app, "长时间无操作, 抖音将在30秒后空闲退出")
}
if (second <= 5) {
KToastUtils.show(app, "空闲退出倒计时${second}s")
}
}
}

override fun onFinish() {
KActivityUtils.getActivities().forEach { it.finishAndRemoveTask() }
Process.killProcess(Process.myPid())
exitProcess(1)
override fun onFinish() {
KActivityUtils.getActivities().forEach { it.finishAndRemoveTask() }
Process.killProcess(Process.myPid())
exitProcess(1)
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/com/freegang/hook/HEmojiDetailDialogNew.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class HEmojiDetailDialogNew(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook
}
}

//表情弹层
// 表情弹层
if (DouYinMain.emojiPopupWindowClazz != null) {
lpparam.hookClass(DouYinMain.emojiPopupWindowClazz!!)
.methodAll {
Expand All @@ -61,9 +61,9 @@ class HEmojiDetailDialogNew(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook
?: emoji?.detailEmoji?.staticUrl?.urlList ?: emptyList()
}

if (result !is View && popUrlList.isEmpty()) return@onAfter
if (popUrlList.isEmpty()) return@onAfter

val view = result as View
val view = result.asOrNull<View>() ?: return@onAfter
if (view is TextView) {
if (view.text == "添加到表情") {
view.text = "添加到表情 (长按保存)"
Expand All @@ -80,10 +80,10 @@ class HEmojiDetailDialogNew(lpparam: XC_LoadPackage.LoadPackageParam) : BaseHook
}
}

//重构表情布局
// 重构表情布局
private fun rebuildView(params: XC_MethodHook.MethodHookParam) {
hookBlock(params) {
if (!targetClazz.isInstance(thisObject)) return //非 EmojiDetailDialogNew, 直接结束
if (!targetClazz.isInstance(thisObject)) return // 非 EmojiDetailDialogNew, 直接结束

launch {
delay(500L)
Expand Down
Loading

0 comments on commit 0f95ca6

Please sign in to comment.