Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
fix: systemui - control center - hide delimiter, display default valu…
Browse files Browse the repository at this point in the history
…e when choose show device name
  • Loading branch information
Sevtinge committed Jun 4, 2024
1 parent 5a8bc82 commit afdde7a
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static com.sevtinge.hyperceiler.utils.PropUtils.getProp;

import android.telephony.SubscriptionInfo;
import android.view.View;
import android.widget.TextView;

Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -154,3 +185,4 @@ protected void after(MethodHookParam param) throws Throwable {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> getTileList() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
});
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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"); // 移动网络类型单独显示
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/res/xml/system_ui_status_bar_doubleline_network.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,27 @@
app:stepValue="1" />

<SeekBarPreferenceEx
android:defaultValue="0"
android:defaultValue="8"
android:key="prefs_key_system_ui_statusbar_mobile_network_icon_left_margin"
android:title="@string/left_margin"
app:defaultValueText="@string/array_default"
app:displayDividerValue="2"
app:format="%s dp"
app:maxValue="10"
app:maxValue="16"
app:minValue="0"
app:negativeShift="8"
app:stepValue="1" />

<SeekBarPreferenceEx
android:defaultValue="0"
android:defaultValue="8"
android:key="prefs_key_system_ui_statusbar_mobile_network_icon_right_margin"
android:title="@string/right_margin"
app:defaultValueText="@string/array_default"
app:displayDividerValue="2"
app:format="%s dp"
app:maxValue="10"
app:maxValue="16"
app:minValue="0"
app:negativeShift="8"
app:stepValue="1" />

<SeekBarPreferenceEx
Expand Down

0 comments on commit afdde7a

Please sign in to comment.