From afdde7ad904483f8a11703b6ca7393eae637d1a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=80=E6=BC=93=E4=B8=A8Sevtinge?= <89193494+Sevtinge@users.noreply.github.com> Date: Wed, 5 Jun 2024 01:16:35 +0800 Subject: [PATCH] fix: systemui - control center - hide delimiter, display default value when choose show device name --- .../systemui/controlcenter/HideDelimiter.java | 32 ++++++++++++++ .../hook/systemui/plugin/PluginHelper.java | 3 +- .../hook/systemui/plugin/ShowDeviceName.java | 43 +++++++++++++++++++ .../statusbar/model/DualRowSignalHook.java | 6 +-- ...ystem_ui_status_bar_doubleline_network.xml | 10 +++-- 5 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/ShowDeviceName.java diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java index 55fb2b32c6..a0f344b378 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java @@ -20,6 +20,7 @@ import static com.sevtinge.hyperceiler.utils.PropUtils.getProp; +import android.telephony.SubscriptionInfo; import android.view.View; import android.widget.TextView; @@ -32,6 +33,7 @@ public class HideDelimiter extends BaseHook { boolean operator = mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 1; int prefs = mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0); String deviceName = getProp("persist.sys.device_name"); + String[] deviceNameList = {deviceName}; @Override public void init() { @@ -83,12 +85,41 @@ protected void before(MethodHookParam param) throws Throwable { } }); + findAndHookMethod("com.android.keyguard.CarrierText$1", "onCarrierTextChanged", String.class, new MethodHook() { + @Override + protected void before(MethodHookParam param) throws Throwable { + param.args[0] = deviceName; + } + }); + findAndHookMethod("com.android.systemui.statusbar.policy.MiuiCarrierTextControllerImpl", "updateCarrierText", new MethodHook() { @Override protected void before(MethodHookParam param) throws Throwable { XposedHelpers.setObjectField(param.thisObject, "mCurrentCarrier", deviceName); + XposedHelpers.setObjectField(param.thisObject, "mCustomCarrier", deviceNameList); + XposedHelpers.setObjectField(param.thisObject, "mCarrier", deviceNameList); } }); + + findAndHookMethod(SubscriptionInfo.class, "getCarrierName", new MethodHook(){ + @Override + protected void before(MethodHookParam param) throws Throwable { + param.setResult(deviceName); + } + }); + + findAndHookMethod("com.android.systemui.statusbar.policy.MiuiCarrierTextControllerImpl", "onCarrierChanged", String[].class, new MethodHook() { + @Override + protected void before(MethodHookParam param) throws Throwable { + String[] deviceNameList = new String[deviceName.length()]; + for (int i = 0; i < deviceName.length(); i++){ + deviceNameList[i] = String.valueOf(deviceName.charAt(i)); + } + param.args[0] = deviceNameList; + XposedHelpers.setObjectField(param.thisObject, "mRealCarrier", deviceNameList); + } + }); + } else { findAndHookMethod("androidx.constraintlayout.core.PriorityGoalRow$GoalVariableAccessor$$ExternalSyntheticOutline0", "m", String.class, String.class, new MethodHook() { @@ -154,3 +185,4 @@ protected void after(MethodHookParam param) throws Throwable { } } } + diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java index 6d10f35392..a86ba35c5b 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/PluginHelper.java @@ -150,11 +150,12 @@ public void setClassLoader(ClassLoader classLoader) { if (mPrefsMap.getBoolean("system_ui_control_center_qs_open_color") || mPrefsMap.getBoolean("system_ui_control_center_qs_big_open_color")) QSColor.pluginHook(classLoader); - List mCardStyleTiles = getTileList(); if (mPrefsMap.getBoolean("systemui_plugin_card_tiles_enabled") && !mPrefsMap.getString("systemui_plugin_card_tiles", "").isEmpty()) { CustomCardTiles.initCustomCardTiles(classLoader, mCardStyleTiles); } + if(mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 3) + ShowDeviceName.initShowDeviceName(classLoader); } private static List getTileList() { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/ShowDeviceName.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/ShowDeviceName.java new file mode 100644 index 0000000000..73c12475eb --- /dev/null +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/ShowDeviceName.java @@ -0,0 +1,43 @@ +package com.sevtinge.hyperceiler.module.hook.systemui.plugin; + +import static com.sevtinge.hyperceiler.module.base.tool.HookTool.hookMethod; +import static com.sevtinge.hyperceiler.utils.PropUtils.getProp; + +import com.sevtinge.hyperceiler.module.base.dexkit.DexKit; +import com.sevtinge.hyperceiler.module.base.dexkit.IDexKit; +import com.sevtinge.hyperceiler.module.base.tool.HookTool; + +import org.luckypray.dexkit.DexKitBridge; +import org.luckypray.dexkit.query.FindMethod; +import org.luckypray.dexkit.query.matchers.MethodMatcher; +import org.luckypray.dexkit.result.MethodData; + +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; + +import de.robv.android.xposed.XC_MethodHook; + +public class ShowDeviceName { + + static String deviceName = getProp("persist.sys.device_name"); + + public static void initShowDeviceName(ClassLoader classLoader) { + Method method = (Method) DexKit.getDexKitBridge("OnCarrierTextChanged", new IDexKit() { + @Override + public AnnotatedElement dexkit(DexKitBridge bridge) throws ReflectiveOperationException { + MethodData methodData = bridge.findMethod(FindMethod.create() + .matcher(MethodMatcher.create() + .name("onCarrierTextChanged") + )).singleOrNull(); + return methodData.getMethodInstance(classLoader); + } + }); + hookMethod(method, new HookTool.MethodHook() { + @Override + protected void before(XC_MethodHook.MethodHookParam param) throws Throwable { + param.args[0] = deviceName; + } + }); + } +} + diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHook.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHook.java index db449bb30f..bd874afba3 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHook.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHook.java @@ -41,8 +41,8 @@ import de.robv.android.xposed.XposedHelpers; public class DualRowSignalHook extends BaseHook { - private final int rightMargin = mPrefsMap.getInt("system_ui_statusbar_mobile_network_icon_right_margin", 0); - private final int leftMargin = mPrefsMap.getInt("system_ui_statusbar_mobile_network_icon_left_margin", 0); + private final int rightMargin = mPrefsMap.getInt("system_ui_statusbar_mobile_network_icon_right_margin", 8) - 8; + private final int leftMargin = mPrefsMap.getInt("system_ui_statusbar_mobile_network_icon_left_margin", 8) - 8; private final int iconScale = mPrefsMap.getInt("system_ui_statusbar_mobile_network_icon_size", 10); // 图标缩放 private final int verticalOffset = mPrefsMap.getInt("system_ui_statusbar_mobile_network_icon_vertical_offset", 8); private final boolean mobileTypeSingle = mPrefsMap.getBoolean("system_ui_statusbar_mobile_type_enable"); // 移动网络类型单独显示 @@ -302,7 +302,7 @@ private void getDualRowView(XC_MethodHook.MethodHookParam param) { } private void setDualRowStyle() { - if (rightMargin > 0 || leftMargin > 0 || iconScale != 10 || verticalOffset != 8) { + if (rightMargin != 0 || leftMargin != 0 || iconScale != 10 || verticalOffset != 8) { MethodHook styleHook = new MethodHook() { @Override protected void after(final MethodHookParam param) { diff --git a/app/src/main/res/xml/system_ui_status_bar_doubleline_network.xml b/app/src/main/res/xml/system_ui_status_bar_doubleline_network.xml index 3d4ea10ff4..1d07f8e2bc 100644 --- a/app/src/main/res/xml/system_ui_status_bar_doubleline_network.xml +++ b/app/src/main/res/xml/system_ui_status_bar_doubleline_network.xml @@ -35,25 +35,27 @@ app:stepValue="1" />