Skip to content

Commit

Permalink
fix duplicate scheduled backend
Browse files Browse the repository at this point in the history
  • Loading branch information
GangJust committed Feb 22, 2024
1 parent c5f3209 commit ec8a4fe
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "io.github.fplus"
minSdk 24
targetSdk 33
versionCode 121
versionName "1.2.7"
versionCode 122
versionName "1.2.8"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/assets/update.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.2.8
修复定时、空闲后台重复退出问题
移除启动时底部提示

v1.2.7
增加聊天消息防止撤回
增加视频下载自定义编码格式
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.7-121
1.2.8-122
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.freegang.ktutils.text.KTextUtils
import io.github.fplus.core.config.ConfigV1
import io.github.xpler.core.findClass
import io.github.xpler.core.findMethod
import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.lpparam
import org.json.JSONArray
import org.json.JSONObject
Expand Down Expand Up @@ -631,6 +632,7 @@ object DexkitBuilder {
private fun ClassDataList.singleInstance(label: String): Class<*>? {
val classData = this.singleOrNull()
KLogCat.tagI(TAG, "found-class[$label]: ${classData?.name}")
if (classData == null) XplerLog.d("not found class: $label")
classCacheJson.put(label, "${classData?.name}")
return classData?.getInstance(lpparam.classLoader)
}
Expand Down
14 changes: 11 additions & 3 deletions core/src/main/java/io/github/fplus/core/hook/DouYinMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DouYinMain(private val app: Application) {
KActivityUtils.register(app)

// 日志工具
XplerLog.setTag("Freedom+")
KLogCat.init(app)
// KLogCat.silence() //静默

Expand All @@ -55,7 +56,7 @@ class DouYinMain(private val app: Application) {
// search and hook
DexkitBuilder.running(
app = app,
version = 15,
version = 16,
searchBefore = {
HActivity()
HMainActivity()
Expand Down Expand Up @@ -122,7 +123,11 @@ class DouYinMain(private val app: Application) {
timedExitCountDown = object : CountDownTimer(timedExit, 1000) {
override fun onTick(millisUntilFinished: Long) {
val second = millisUntilFinished / 1000
// KLogCat.d("定时倒计时: ${second}秒")
KLogCat.d("定时倒计时: ${second}")
if (!KAppUtils.isAppInForeground(app)) {
inBackend = true
cancel()
}
if (second == 30L) {
KToastUtils.show(app, "抖音将在30秒后定时退出")
}
Expand All @@ -144,7 +149,10 @@ class DouYinMain(private val app: Application) {
freeExitCountDown = object : CountDownTimer(freeExit, 1000) {
override fun onTick(millisUntilFinished: Long) {
val second = millisUntilFinished / 1000
// KLogCat.d("空闲倒计时: ${second}秒")
KLogCat.d("空闲倒计时: ${second}")
if (!KAppUtils.isAppInForeground(app)) {
cancel()
}
if (second == 30L) {
KToastUtils.show(app, "长时间无操作, 抖音将在30秒后空闲退出")
}
Expand Down
45 changes: 29 additions & 16 deletions core/src/main/java/io/github/fplus/core/hook/HActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.github.fplus.core.base.BaseHook
import io.github.fplus.core.config.ConfigV1
import io.github.fplus.core.helper.ImmersiveHelper
import io.github.fplus.core.ui.activity.FreedomSettingActivity
import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.entity.OnBefore
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.thisActivity
Expand Down Expand Up @@ -48,29 +49,41 @@ class HActivity : BaseHook<Activity>() {
fun onResumeBefore(params: XC_MethodHook.MethodHookParam) {
hookBlockRunning(params) {
DouYinMain.freeExitCountDown?.restart()
if (DouYinMain.inBackend) {
DouYinMain.inBackend = false
DouYinMain.timedExitCountDown?.restart()
}
}.onFailure {
KLogCat.tagE(TAG, it)
}
}

if (thisActivity is FreedomSettingActivity) return
@OnAfter("onWindowFocusChanged")
fun onWindowFocusChangedAfter(params: XC_MethodHook.MethodHookParam, boolean: Boolean) {
hookBlockRunning(params) {
launch {
if (thisActivity is FreedomSettingActivity) return@launch

if (config.isImmersive) {
ImmersiveHelper.immersive(
activity = thisActivity,
hideStatusBar = config.systemControllerValue[0],
hideNavigationBars = config.systemControllerValue[1],
)
if (config.isImmersive) {
ImmersiveHelper.immersive(
activity = thisActivity,
hideStatusBar = config.systemControllerValue[0],
hideNavigationBars = config.systemControllerValue[1],
)

// 底部三键导航
val activity = thisObject as Activity
if (activity.navBarInteractionMode == 0 && !config.systemControllerValue[1]) {
activity.contentView.apply {
updatePadding(bottom = context.navigationBarHeight)
}
ImmersiveHelper.systemBarColor(activity, navigationBarColor = null)
} else {
// 底部三键导航
val activity = thisObject as Activity
ImmersiveHelper.systemBarColor(activity)
if (activity.navBarInteractionMode == 0 && !config.systemControllerValue[1]) {
activity.contentView.apply {
updatePadding(bottom = context.navigationBarHeight)
}
ImmersiveHelper.systemBarColor(activity, navigationBarColor = null)
}
}
}
}.onFailure {
KLogCat.tagE(TAG, it)
KLogCat.tagE(HLivePlayActivity.TAG, it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import de.robv.android.xposed.XC_MethodHook
import io.github.fplus.core.base.BaseHook
import io.github.fplus.core.config.ConfigV1
import io.github.fplus.core.helper.ImmersiveHelper
import io.github.xpler.core.entity.FutureHook
import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.entity.OnBefore
import io.github.xpler.core.hookBlockRunning
Expand All @@ -23,7 +22,6 @@ class HLivePlayActivity : BaseHook<Any>() {
return findClass("com.ss.android.ugc.aweme.live.LivePlayActivity")
}

@FutureHook
@OnBefore("onWindowFocusChanged")
@OnAfter("onWindowFocusChanged")
fun onWindowFocusChangedAfter(params: XC_MethodHook.MethodHookParam, boolean: Boolean) {
Expand Down
9 changes: 4 additions & 5 deletions core/src/main/java/io/github/fplus/core/hook/HMainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ import io.github.fplus.core.helper.DexkitBuilder
import io.github.fplus.core.hook.logic.ClipboardLogic
import io.github.fplus.core.hook.logic.DownloadLogic
import io.github.fplus.core.ui.activity.FreedomSettingActivity
import io.github.xpler.core.KtXposedHelpers
import io.github.xpler.core.entity.OnAfter
import io.github.xpler.core.entity.OnBefore
import io.github.xpler.core.hookBlockRunning
import io.github.xpler.core.log.XplerLog
import io.github.xpler.core.thisActivity
import io.github.xpler.core.thisContext
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -84,7 +86,8 @@ class HMainActivity : BaseHook<MainActivity>() {
@OnAfter("onCreate")
fun onCreateAfter(params: XC_MethodHook.MethodHookParam, savedInstanceState: Bundle?) {
hookBlockRunning(params) {
showToast(thisContext, "Freedom+ Attach!")
val activity = thisActivity
XplerLog.d("version: ${KtXposedHelpers.moduleVersionName(activity)} - ${activity.appVersionName}(${activity.appVersionCode})")
DouYinMain.timedExitCountDown?.restart()
}.onFailure {
KLogCat.tagE(TAG, it)
Expand All @@ -94,10 +97,6 @@ class HMainActivity : BaseHook<MainActivity>() {
@OnAfter("onResume")
fun onResume(params: XC_MethodHook.MethodHookParam) {
hookBlockRunning(params) {
if (DouYinMain.inBackend) {
DouYinMain.inBackend = false
DouYinMain.timedExitCountDown?.restart()
}
addClipboardListener(thisActivity)
initView(thisActivity)
is32BisTips(thisActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ class DownloadLogic(
// 构建视频文件名
mPureFileName = mPureFileName.secureFilename(".mp4")
if (config.isNotification) {
showDownloadByNotification(videoUrlList, mVideoParent.need(), mPureFileName, isWebDav)
showDownloadByNotification(videoUrlList, mVideoParent, mPureFileName, isWebDav)
} else {
showDownloadByDialog(videoUrlList, mVideoParent.need(), mPureFileName, isWebDav)
showDownloadByDialog(videoUrlList, mVideoParent, mPureFileName, isWebDav)
}
}

Expand All @@ -202,9 +202,9 @@ class DownloadLogic(
// 构建视频文件名
mPureFileName = mPureFileName.secureFilename(".mp3")
if (config.isNotification) {
showDownloadByNotification(musicUrlList, mMusicParent.need(), mPureFileName, isWebDav)
showDownloadByNotification(musicUrlList, mMusicParent, mPureFileName, isWebDav)
} else {
showDownloadByDialog(musicUrlList, mMusicParent.need(), mPureFileName, isWebDav)
showDownloadByDialog(musicUrlList, mMusicParent, mPureFileName, isWebDav)
}
}

Expand Down

0 comments on commit ec8a4fe

Please sign in to comment.