Skip to content
This repository was archived by the owner on Aug 10, 2025. It is now read-only.

Commit ce6a706

Browse files
committed
fix: NetworkSpeedSpacing hook failed by HyperOS2.0.200+
1 parent 5742f27 commit ce6a706

File tree

2 files changed

+67
-88
lines changed

2 files changed

+67
-88
lines changed

app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/icon/v/HideFakeStatusBar.kt

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,25 @@ import android.graphics.Rect
2828
import android.service.notification.StatusBarNotification
2929
import android.view.View
3030
import android.widget.TextView
31-
import cn.lyric.getter.api.data.*
31+
import cn.lyric.getter.api.data.LyricData
3232
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
3333
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createAfterHook
3434
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createBeforeHook
3535
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
3636
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
37-
import com.sevtinge.hyperceiler.module.base.*
38-
import com.sevtinge.hyperceiler.module.base.MusicBaseHook.Companion.CHANNEL_ID
39-
import com.sevtinge.hyperceiler.utils.*
37+
import com.sevtinge.hyperceiler.module.base.MusicBaseHook
4038
import com.sevtinge.hyperceiler.utils.api.LazyClass.miuiConfigs
41-
import de.robv.android.xposed.*
42-
import kotlinx.coroutines.flow.*
39+
import com.sevtinge.hyperceiler.utils.callMethod
40+
import com.sevtinge.hyperceiler.utils.callStaticMethod
41+
import com.sevtinge.hyperceiler.utils.getBooleanFieldOrNull
42+
import com.sevtinge.hyperceiler.utils.getObjectField
43+
import com.sevtinge.hyperceiler.utils.getObjectFieldAs
44+
import com.sevtinge.hyperceiler.utils.getObjectFieldOrNull
45+
import com.sevtinge.hyperceiler.utils.getObjectFieldOrNullAs
46+
import com.sevtinge.hyperceiler.utils.invokeOriginalMethod
47+
import com.sevtinge.hyperceiler.utils.replaceMethod
48+
import de.robv.android.xposed.XC_MethodHook
49+
import kotlinx.coroutines.flow.MutableStateFlow
4350

4451
@SuppressLint("StaticFieldLeak")
4552
// author git@wuyou-123
@@ -126,15 +133,19 @@ object HideFakeStatusBar : MusicBaseHook() {
126133
// 大时钟布局
127134
mBigTime = it.thisObject.getObjectFieldOrNullAs<TextView>("mBigTime") ?: return@createAfterHook
128135
}
129-
miuiNotificationClass.methodFinder()
130-
.filterByName("updateBigTimeColor").first().replaceMethod {
131-
if (isShowingFocusedLyric) {
132-
// 显示歌词的时候取消设置大时钟颜色(假时钟动画会设置颜色,显示歌词的时候取消了假时钟动画,所以可能会下拉通知栏之后时间是黑色)
133-
null
134-
} else {
135-
it.invokeOriginalMethod()
136+
137+
runCatching {
138+
miuiNotificationClass.methodFinder()
139+
.filterByName("updateBigTimeColor").first().replaceMethod {
140+
if (isShowingFocusedLyric) {
141+
// 显示歌词的时候取消设置大时钟颜色(假时钟动画会设置颜色,显示歌词的时候取消了假时钟动画,所以可能会下拉通知栏之后时间是黑色)
142+
null
143+
} else {
144+
it.invokeOriginalMethod()
145+
}
136146
}
137-
}
147+
}
148+
138149
var unhook0: XC_MethodHook.Unhook? = null
139150
loadClass("com.android.systemui.controlcenter.shade.NotificationHeaderExpandController\$notificationCallback\$1").methodFinder()
140151
.filterByName("onExpansionChanged").first().createHook {

app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/network/NetworkSpeedSpacing.java

Lines changed: 42 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
/*
2-
* This file is part of HyperCeiler.
2+
* This file is part of HyperCeiler.
33
4-
* HyperCeiler is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU Affero General Public License as
6-
* published by the Free Software Foundation, either version 3 of the
7-
* License.
4+
* HyperCeiler is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License.
88
9-
* This program is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU Affero General Public License for more details.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
1313
14-
* You should have received a copy of the GNU Affero General Public License
15-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
* You should have received a copy of the GNU Affero General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
17-
* Copyright (C) 2023-2025 HyperCeiler Contributions
18-
*/
17+
* Copyright (C) 2023-2025 HyperCeiler Contributions
18+
*/
1919
package com.sevtinge.hyperceiler.module.hook.systemui.statusbar.network;
2020

21-
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isAndroidVersion;
22-
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion;
23-
24-
import android.os.Build;
2521
import android.os.Message;
2622

2723
import com.sevtinge.hyperceiler.module.base.BaseHook;
@@ -33,10 +29,9 @@ public class NetworkSpeedSpacing extends BaseHook {
3329

3430
@Override
3531
public void init() {
36-
if (isMoreAndroidVersion(Build.VERSION_CODES.S)) {
37-
try {
38-
findClass("com.android.systemui.statusbar.policy.NetworkSpeedController").getDeclaredMethod("postUpdateNetworkSpeedDelay", long.class);
39-
findAndHookMethod("com.android.systemui.statusbar.policy.NetworkSpeedController",
32+
try {
33+
findClass("com.android.systemui.statusbar.policy.NetworkSpeedController").getDeclaredMethod("postUpdateNetworkSpeedDelay", long.class);
34+
findAndHookMethod("com.android.systemui.statusbar.policy.NetworkSpeedController",
4035
"postUpdateNetworkSpeedDelay", long.class, new MethodHook() {
4136
@Override
4237
protected void before(MethodHookParam param) {
@@ -50,68 +45,41 @@ protected void before(MethodHookParam param) {
5045
}
5146
}
5247
}
53-
);
54-
} catch (NoSuchMethodException e) {
48+
);
49+
} catch (NoSuchMethodException e) {
50+
try {
51+
findClass("com.android.systemui.statusbar.policy.NetworkSpeedController$4").getDeclaredMethod("handleMessage", Message.class);
5552
findAndHookMethod("com.android.systemui.statusbar.policy.NetworkSpeedController$4",
56-
"handleMessage", Message.class, new MethodHook() {
57-
/* @Override
58-
protected void before(MethodHookParam param) {
59-
Message message = (Message) param.args[0];
60-
// Object handleMessage = XposedHelpers.getObjectField(param.thisObject, "this$0");
61-
switch (message.what) {
62-
case 100001, 100002 -> {
63-
handler = true;
64-
logE(TAG, "handleMessage before: " + handler);
53+
"handleMessage", Message.class, new MethodHook() {
54+
@Override
55+
protected void after(MethodHookParam param) {
56+
Message message = (Message) param.args[0];
57+
Object handleMessage = XposedHelpers.getObjectField(param.thisObject, "this$0");
58+
Object mBgHandler = XposedHelpers.getObjectField(handleMessage, "mBgHandler");
59+
if (message.what == 200001) {
60+
handleMessage(mBgHandler, true);
61+
// logE(TAG, "200001: " + mBgHandler);
6562
}
6663
}
67-
}*/
68-
69-
@Override
70-
protected void after(MethodHookParam param) {
71-
Message message = (Message) param.args[0];
72-
Object handleMessage = XposedHelpers.getObjectField(param.thisObject, "this$0");
73-
Object mBgHandler = XposedHelpers.getObjectField(handleMessage, "mBgHandler");
74-
if (message.what == 200001) {
75-
handleMessage(mBgHandler, true);
76-
// logE(TAG, "200001: " + mBgHandler);
77-
}
7864
}
79-
}
8065
);
81-
82-
/*findAndHookMethod("android.os.Handler",
83-
"sendEmptyMessageDelayed", int.class, long.class,
84-
new MethodHook() {
85-
@Override
86-
protected void before(MethodHookParam param) {
87-
if (handler) {
88-
param.setResult(true);
89-
logE(TAG, "sendEmptyMessageDelayed im run");
90-
handler = false;
66+
} catch (NoSuchMethodException t) {
67+
findAndHookMethod("com.android.systemui.statusbar.policy.NetworkSpeedController$2",
68+
"handleMessage", Message.class, new MethodHook() {
69+
@Override
70+
protected void after(MethodHookParam param) {
71+
Message message = (Message) param.args[0];
72+
Object handleMessage = XposedHelpers.getObjectField(param.thisObject, "this$0");
73+
Object mBgHandler = XposedHelpers.getObjectField(handleMessage, "mBgHandler");
74+
if (message.what == 200001) {
75+
handleMessage(mBgHandler, true);
76+
// logE(TAG, "200001: " + mBgHandler);
77+
}
9178
}
9279
}
93-
}
94-
);*/
80+
);
9581
}
9682
}
97-
98-
if (isAndroidVersion(30)) {
99-
findAndHookMethod("com.android.systemui.statusbar.NetworkSpeedController",
100-
"postUpdateNetworkSpeedDelay", long.class, new MethodHook() {
101-
@Override
102-
protected void before(MethodHookParam param) {
103-
long originInterval = (long) param.args[0];
104-
if (originInterval != 0L) {
105-
originInterval = mPrefsMap.getInt(
106-
"system_ui_statusbar_network_speed_update_spacing",
107-
4
108-
) * 1000L;
109-
param.args[0] = originInterval;
110-
}
111-
}
112-
}
113-
);
114-
}
11583
}
11684

11785
public void handleMessage(Object mBgHandler, boolean z) {

0 commit comments

Comments
 (0)