|
19 | 19 | package com.sevtinge.hyperceiler.hook.module.hook.systemui.plugin |
20 | 20 |
|
21 | 21 | import android.view.View |
| 22 | +import com.sevtinge.hyperceiler.hook.utils.callMethodAs |
22 | 23 | import com.sevtinge.hyperceiler.hook.utils.devicesdk.isMoreHyperOSVersion |
| 24 | +import com.sevtinge.hyperceiler.hook.utils.getObjectFieldAs |
| 25 | +import com.sevtinge.hyperceiler.hook.utils.replaceMethod |
23 | 26 | import de.robv.android.xposed.XC_MethodHook |
24 | 27 | import de.robv.android.xposed.XposedHelpers |
| 28 | +import io.github.kyuubiran.ezxhelper.core.finder.MethodFinder.`-Static`.methodFinder |
25 | 29 | import io.github.kyuubiran.ezxhelper.core.util.ClassUtil.loadClass |
26 | 30 |
|
27 | 31 | object HideCollpasedFootButton { |
28 | 32 | 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 | | - } |
53 | 33 |
|
| 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 |
54 | 51 | } |
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 | + } |
70 | 53 |
|
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 | | - }) |
110 | 54 | } |
111 | 55 | } |
0 commit comments