Skip to content

Commit 03d9a39

Browse files
YunZiAlingqiqi5211
authored andcommitted
* opt: 重写侧边音量条隐藏静音勿扰功能
(cherry picked from commit 552a145)
1 parent 927efd2 commit 03d9a39

1 file changed

Lines changed: 22 additions & 78 deletions

File tree

library/hook/src/main/java/com/sevtinge/hyperceiler/hook/module/hook/systemui/plugin/HideCollpasedFootButton.kt

Lines changed: 22 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -19,93 +19,37 @@
1919
package com.sevtinge.hyperceiler.hook.module.hook.systemui.plugin
2020

2121
import android.view.View
22+
import com.sevtinge.hyperceiler.hook.utils.callMethodAs
2223
import com.sevtinge.hyperceiler.hook.utils.devicesdk.isMoreHyperOSVersion
24+
import com.sevtinge.hyperceiler.hook.utils.getObjectFieldAs
25+
import com.sevtinge.hyperceiler.hook.utils.replaceMethod
2326
import de.robv.android.xposed.XC_MethodHook
2427
import de.robv.android.xposed.XposedHelpers
28+
import io.github.kyuubiran.ezxhelper.core.finder.MethodFinder.`-Static`.methodFinder
2529
import io.github.kyuubiran.ezxhelper.core.util.ClassUtil.loadClass
2630

2731
object HideCollpasedFootButton {
2832
fun initLoaderHook(classLoader: ClassLoader) {
29-
val mRingerButtonHelper by lazy {
30-
loadClass("com.android.systemui.miui.volume.MiuiRingerModeLayout\$RingerButtonHelper", classLoader)
31-
}
32-
val mTimerItem by lazy {
33-
loadClass("com.android.systemui.miui.volume.TimerItem", classLoader)
34-
}
35-
36-
XposedHelpers.findAndHookMethod(
37-
mRingerButtonHelper, "updateState",
38-
object : XC_MethodHook() {
39-
override fun afterHookedMethod(param: MethodHookParam?) {
40-
val thisObj = param?.thisObject
41-
val mIcon = XposedHelpers.getObjectField(thisObj, "mIcon") as View
42-
val mStandardView =
43-
XposedHelpers.getObjectField(thisObj, "mStandardView") as View
44-
val mExpanded = XposedHelpers.getBooleanField(thisObj, "mExpanded")
45-
if (mExpanded) {
46-
mIcon.visibility = View.VISIBLE
47-
mStandardView.visibility = View.VISIBLE
48-
} else {
49-
mIcon.visibility = View.GONE
50-
mStandardView.visibility = View.GONE
51-
52-
}
5333

34+
loadClass(
35+
"com.android.systemui.miui.volume.MiuiVolumeDialogView",
36+
classLoader
37+
).methodFinder()
38+
.filterByName("updateFooterVisibility")
39+
.filterByParamTypes { it[0] == Boolean::class.java }
40+
.first().replaceMethod {
41+
val thisObj = it.thisObject
42+
val mRingerModeLayout = thisObj.getObjectFieldAs<View>("mRingerModeLayout")
43+
val mExpandButton = thisObj.getObjectFieldAs<View>("mExpandButton")
44+
val mExpanded = thisObj.callMethodAs<Boolean>("isExpanded")
45+
if (mExpanded){
46+
mRingerModeLayout.visibility = View.VISIBLE
47+
mExpandButton.visibility = View.GONE
48+
}else{
49+
mRingerModeLayout.visibility = View.GONE
50+
mExpandButton.visibility = if (it.args[0] as Boolean) View.VISIBLE else View.GONE
5451
}
55-
})
56-
57-
58-
if (isMoreHyperOSVersion(2f)) {
59-
XposedHelpers.findAndHookMethod(
60-
mRingerButtonHelper, "onExpanded", Boolean::class.java, Boolean::class.java,
61-
object : XC_MethodHook() {
62-
override fun afterHookedMethod(param: MethodHookParam?) {
63-
val thisObj = param?.thisObject
64-
val z1 = param?.args?.get(0) as Boolean
65-
val z2 = param.args?.get(1) as Boolean
66-
67-
val mStandardView =
68-
XposedHelpers.getObjectField(thisObj, "mStandardView") as View
69-
val mExpanded = XposedHelpers.getBooleanField(thisObj, "mExpanded")
52+
}
7053

71-
if (mExpanded != z1 || z2) {
72-
mStandardView.visibility = View.GONE
73-
} else {
74-
mStandardView.visibility = View.VISIBLE
75-
}
76-
77-
}
78-
})
79-
} else {
80-
XposedHelpers.findAndHookMethod(
81-
mRingerButtonHelper, "onExpanded", Boolean::class.java,
82-
object : XC_MethodHook() {
83-
override fun afterHookedMethod(param: MethodHookParam?) {
84-
val thisObj = param?.thisObject
85-
val z1 = param?.args?.get(0) as Boolean
86-
val mStandardView =
87-
XposedHelpers.getObjectField(thisObj, "mStandardView") as View
88-
val mExpanded = XposedHelpers.getBooleanField(thisObj, "mExpanded")
89-
90-
if (mExpanded != z1) {
91-
mStandardView.visibility = View.GONE
92-
} else {
93-
mStandardView.visibility = View.VISIBLE
94-
}
95-
}
96-
})
97-
}
98-
99-
XposedHelpers.findAndHookMethod(
100-
mTimerItem, "updateExpanded", Boolean::class.java,
101-
object : XC_MethodHook() {
102-
override fun afterHookedMethod(param: MethodHookParam?) {
103-
val thisObj = param?.thisObject
104-
val mCountDownProgressBar =
105-
XposedHelpers.getObjectField(thisObj, "mCountDownProgressBar") as View
106-
107-
mCountDownProgressBar.visibility = View.GONE
108-
}
109-
})
11054
}
11155
}

0 commit comments

Comments
 (0)