diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java index e4eb9e5fc..6fc650930 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiU.java @@ -62,6 +62,7 @@ import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaControlPanelTimeViewTextSize; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaSeekBarColor; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MuteVisibleNotifications; +import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NewBrightnessPct; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationImportanceHyperOSFix; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationRowMenu; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationWeather; @@ -101,8 +102,6 @@ import com.sevtinge.hyperceiler.module.hook.systemui.navigation.HideNavigationBar; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.NavigationCustom; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.RotationButton; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.FocusNotifLyricPluginHelper; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelper; import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelperKt; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.BlurEnable; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.DoubleTapToSleep; @@ -349,6 +348,7 @@ public void handleLoadPackage() { initHook(DisableBottomBar.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_bottombar")); initHook(UnlockClipboard.INSTANCE, mPrefsMap.getBoolean("system_ui_unlock_clipboard")); initHook(new VolumeTimerValuesHook(), mPrefsMap.getBoolean("system_ui_volume_timer")); + initHook(NewBrightnessPct.INSTANCE, mPrefsMap.getBoolean("system_showpct_title")); // 锁屏 initHook(new ScramblePIN(), mPrefsMap.getBoolean("system_ui_lock_screen_scramble_pin")); diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java index 207458ffd..a444964e5 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Pad/SystemUiV.java @@ -59,6 +59,7 @@ import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaControlPanelTimeViewTextSize; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaSeekBarColor; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MuteVisibleNotifications; +import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NewBrightnessPct; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NewFlashLight; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationImportanceHyperOSFix; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationRowMenu; @@ -97,8 +98,6 @@ import com.sevtinge.hyperceiler.module.hook.systemui.navigation.HideNavigationBar; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.NavigationCustom; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.RotationButton; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.FocusNotifLyricPluginHelper; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelper; import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelperKt; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.BlurEnable; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.DoubleTapToSleep; @@ -269,6 +268,7 @@ public void handleLoadPackage() { initHook(DisableInfinitymodeGesture.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_infinitymode_gesture")); initHook(DisableBottomBar.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_bottombar")); initHook(UnlockClipboard.INSTANCE, mPrefsMap.getBoolean("system_ui_unlock_clipboard")); + initHook(NewBrightnessPct.INSTANCE, mPrefsMap.getBoolean("system_showpct_title")); // 锁屏 initHook(new ScramblePIN(), mPrefsMap.getBoolean("system_ui_lock_screen_scramble_pin")); diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java index 3506a2570..80fa839a0 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiU.java @@ -62,6 +62,7 @@ import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaControlPanelTimeViewTextSize; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaSeekBarColor; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MuteVisibleNotifications; +import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NewBrightnessPct; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationImportanceHyperOSFix; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationRowMenu; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationWeather; @@ -101,8 +102,6 @@ import com.sevtinge.hyperceiler.module.hook.systemui.navigation.HideNavigationBar; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.NavigationCustom; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.RotationButton; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.FocusNotifLyricPluginHelper; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelper; import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelperKt; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.BlurEnable; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.DoubleTapToSleep; @@ -349,6 +348,7 @@ public void handleLoadPackage() { initHook(DisableBottomBar.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_bottombar")); initHook(UnlockClipboard.INSTANCE, mPrefsMap.getBoolean("system_ui_unlock_clipboard")); initHook(new VolumeTimerValuesHook(), mPrefsMap.getBoolean("system_ui_volume_timer")); + initHook(NewBrightnessPct.INSTANCE, mPrefsMap.getBoolean("system_showpct_title")); // 锁屏 initHook(new ScramblePIN(), mPrefsMap.getBoolean("system_ui_lock_screen_scramble_pin")); diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java index 922611d0e..0a5e0535f 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUiV.java @@ -59,6 +59,7 @@ import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaControlPanelTimeViewTextSize; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MediaSeekBarColor; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.MuteVisibleNotifications; +import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NewBrightnessPct; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NewFlashLight; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationImportanceHyperOSFix; import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.NotificationRowMenu; @@ -97,8 +98,6 @@ import com.sevtinge.hyperceiler.module.hook.systemui.navigation.HideNavigationBar; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.NavigationCustom; import com.sevtinge.hyperceiler.module.hook.systemui.navigation.RotationButton; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.FocusNotifLyricPluginHelper; -import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelper; import com.sevtinge.hyperceiler.module.hook.systemui.plugin.NewPluginHelperKt; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.BlurEnable; import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.DoubleTapToSleep; @@ -285,6 +284,7 @@ public void handleLoadPackage() { initHook(DisableInfinitymodeGesture.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_infinitymode_gesture")); initHook(DisableBottomBar.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_bottombar")); initHook(UnlockClipboard.INSTANCE, mPrefsMap.getBoolean("system_ui_unlock_clipboard")); + initHook(NewBrightnessPct.INSTANCE, mPrefsMap.getBoolean("system_showpct_title")); // 锁屏 initHook(new ScramblePIN(), mPrefsMap.getBoolean("system_ui_lock_screen_scramble_pin")); diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/base/tool/OtherTool.java b/app/src/main/java/com/sevtinge/hyperceiler/module/base/tool/OtherTool.java index 384251a6b..5e39a8451 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/base/tool/OtherTool.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/base/tool/OtherTool.java @@ -22,6 +22,7 @@ import static com.sevtinge.hyperceiler.utils.devicesdk.DeviceSDKKt.isDarkMode; import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logE; +import android.annotation.SuppressLint; import android.app.Application; import android.content.Context; import android.content.pm.PackageManager; @@ -53,19 +54,10 @@ public class OtherTool { // 获取 Android 系统 public static final int FlAG_ONLY_ANDROID = ContextUtils.FlAG_ONLY_ANDROID; - // public static TextView mPct = null; - public static WeakReference mPct; + public static TextView mPct = null; // public Context mModuleContext = null; - public static void setTextView(TextView textView) { - mPct = new WeakReference<>(textView); - } - - public static TextView getTextView() { - return mPct != null ? mPct.get() : null; - } - public static Resources getModuleRes(Context context) throws PackageManager.NameNotFoundException { return ResourcesTool.loadModuleRes(context); @@ -155,25 +147,25 @@ public static int getPackageVersionCode(XC_LoadPackage.LoadPackageParam lpparam) } } - public static void initPct(ViewGroup container, int source, Context context) { - Resources res = context.getResources(); - if (getTextView() == null) { - setTextView(new TextView(container.getContext())); - getTextView().setTextSize(TypedValue.COMPLEX_UNIT_SP, 40); - getTextView().setGravity(Gravity.CENTER); + public static void initPct(ViewGroup container, int source) { + Resources res = container.getContext().getResources(); + if (mPct == null) { + mPct = new TextView(container.getContext()); + mPct.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40); + mPct.setGravity(Gravity.CENTER); float density = res.getDisplayMetrics().density; FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); lp.topMargin = Math.round(mPrefsMap.getInt("system_ui_others_showpct_top", 54) * density); // lp.topMargin = Math.round(54 * density); lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; - getTextView().setPadding(Math.round(20 * density), Math.round(10 * density), Math.round(18 * density), Math.round(12 * density)); - getTextView().setLayoutParams(lp); + mPct.setPadding(Math.round(20 * density), Math.round(10 * density), Math.round(18 * density), Math.round(12 * density)); + mPct.setLayoutParams(lp); try { - Resources modRes = getModuleRes(context); - getTextView().setTextColor(ColorStateList.valueOf(Color.parseColor("#FFFFFFFF"))); - getTextView().setBackground(modRes.getDrawable(R.drawable.input_background, context.getTheme())); + Resources modRes = getModuleRes(container.getContext()); + mPct.setTextColor(ColorStateList.valueOf(Color.parseColor("#FFFFFFFF"))); + mPct.setBackground(modRes.getDrawable(R.drawable.input_background, container.getContext().getTheme())); } catch (Throwable err) { - logE("ShowVolumePct", err); + logE("ShowPct", err); } if (mPrefsMap.getBoolean("system_showpct_use_blur")) { try { @@ -183,18 +175,18 @@ public static void initPct(ViewGroup container, int source, Context context) { int a; if (isDarkMode()) a = 120; else a = 140; - MiBlurUtils.setContainerPassBlur(getTextView(), i, true); - MiBlurUtils.setMiViewBlurMode(getTextView(), 1); - MiBlurUtils.clearMiBackgroundBlendColor(getTextView()); - MiBlurUtils.addMiBackgroundBlendColor(getTextView(), Color.argb(a, 0, 0, 0), 101); + MiBlurUtils.setContainerPassBlur(mPct, i, true); + MiBlurUtils.setMiViewBlurMode(mPct, 1); + MiBlurUtils.clearMiBackgroundBlendColor(mPct); + MiBlurUtils.addMiBackgroundBlendColor(mPct, Color.argb(a, 0, 0, 0), 101); } catch (Throwable e) { - logE("ShowVolumePct", e); + logE("ShowPct", e); } } - container.addView(getTextView()); + container.addView(mPct); } - getTextView().setTag(source); - getTextView().setVisibility(View.GONE); + mPct.setTag(source); + mPct.setVisibility(View.GONE); } public static void removePct(TextView mPctText) { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/BrightnessPct.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/BrightnessPct.java index cc717f497..389f7d050 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/BrightnessPct.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/BrightnessPct.java @@ -18,13 +18,12 @@ */ package com.sevtinge.hyperceiler.module.hook.systemui; -import static com.sevtinge.hyperceiler.module.base.tool.OtherTool.getTextView; import static com.sevtinge.hyperceiler.module.base.tool.OtherTool.initPct; +import static com.sevtinge.hyperceiler.module.base.tool.OtherTool.mPct; import static com.sevtinge.hyperceiler.module.base.tool.OtherTool.removePct; import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion; import android.annotation.SuppressLint; -import android.content.Context; import android.view.View; import android.view.ViewGroup; @@ -34,8 +33,6 @@ import de.robv.android.xposed.XposedHelpers; public class BrightnessPct extends BaseHook { - public boolean isHooked = false; - @Override @SuppressLint("SetTextI18n") public void init() throws NoSuchMethodException { @@ -48,15 +45,15 @@ protected void after(MethodHookParam param) { logE(TAG, lpparam.packageName, "mStatusBarWindow is null"); return; } - initPct(mStatusBarWindow, 1, mStatusBarWindow.getContext()); - getTextView().setVisibility(View.VISIBLE); + initPct(mStatusBarWindow, 1); + mPct.setVisibility(View.VISIBLE); } }); findAndHookMethod("com.android.systemui.statusbar.policy.BrightnessMirrorController", "hideMirror", new MethodHook() { @Override protected void after(MethodHookParam param) { - removePct(getTextView()); + removePct(mPct); } } ); @@ -65,21 +62,20 @@ protected void after(MethodHookParam param) { hookAllMethods("com.android.systemui.controlcenter.policy.MiuiBrightnessController", "onStart", new MethodHook() { @Override protected void before(MethodHookParam param) { - Context mContext = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext"); Object windowView = getObject(param); if (windowView == null) { logE(TAG, lpparam.packageName, "mControlPanelContentView is null"); return; } - initPct((ViewGroup) windowView, 2, mContext); - getTextView().setVisibility(View.VISIBLE); + initPct((ViewGroup) windowView, 2); + mPct.setVisibility(View.VISIBLE); } }); hookAllMethods("com.android.systemui.controlcenter.policy.MiuiBrightnessController", "onStop", new MethodHook() { @Override protected void after(MethodHookParam param) { - removePct(getTextView()); + removePct(mPct); } }); @@ -88,14 +84,14 @@ protected void after(MethodHookParam param) { @Override protected void after(MethodHookParam param) { int pctTag = 0; - if (getTextView() != null && getTextView().getTag() != null) { - pctTag = (int) getTextView().getTag(); + if (mPct != null && mPct.getTag() != null) { + pctTag = (int) mPct.getTag(); } - if (pctTag == 0 || getTextView() == null) return; + if (pctTag == 0 || mPct == null) return; int currentLevel = (int) param.args[3]; if (brightnessUtils != null) { int maxLevel = (int) XposedHelpers.getStaticObjectField(brightnessUtils, "GAMMA_SPACE_MAX"); - getTextView().setText(((currentLevel * 100) / maxLevel) + "%"); + mPct.setText(((currentLevel * 100) / maxLevel) + "%"); } } }); diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NewBrightnessPct.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NewBrightnessPct.kt new file mode 100644 index 000000000..3f39e31de --- /dev/null +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NewBrightnessPct.kt @@ -0,0 +1,85 @@ +package com.sevtinge.hyperceiler.module.hook.systemui.controlcenter + +import android.annotation.* +import android.view.* +import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass +import com.github.kyuubiran.ezxhelper.ClassUtils.loadClassOrNull +import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createBeforeHook +import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder +import com.sevtinge.hyperceiler.module.base.* +import com.sevtinge.hyperceiler.module.base.tool.* +import com.sevtinge.hyperceiler.utils.* +import de.robv.android.xposed.* + +object NewBrightnessPct : BaseHook() { + private val MiuiBrightnessController by lazy { + loadClass("com.android.systemui.controlcenter.policy.MiuiBrightnessController") + } + private val brightnessUtils by lazy { + loadClassOrNull("com.android.systemui.controlcenter.policy.BrightnessUtils") + } + + fun initLoaderHook(classLoader: ClassLoader) { + loadClass("miui.systemui.controlcenter.panel.main.brightness.BrightnessSliderController\$seekBarListener\$1", classLoader) + .methodFinder().filterByName("onStartTrackingTouch") + .first().createBeforeHook { + startPct(it) + } + + loadClass("miui.systemui.controlcenter.panel.main.brightness.BrightnessPanelSliderController\$seekBarListener\$1") + .methodFinder().filterByName("onStartTrackingTouch") + .first().createBeforeHook { + startPct(it) + } + } + + private fun startPct(it: XC_MethodHook.MethodHookParam) { + val windowView = getView("miui.systemui.dagger.PluginComponentFactory", it.thisObject.javaClass.classLoader) + if (windowView == null) { + logE(TAG, lpparam.packageName, "ControlCenterWindowViewImpl is null") + return + } + OtherTool.initPct(windowView as ViewGroup, 2) + OtherTool.mPct.visibility = View.VISIBLE + } + + @SuppressLint("SetTextI18n") + override fun init() { + hookAllMethods( + MiuiBrightnessController, "onStop", + object : MethodHook() { + override fun after(param: MethodHookParam) { + OtherTool.removePct(OtherTool.mPct) + } + }) + + hookAllMethods( + MiuiBrightnessController, "onChanged", + object : MethodHook() { + override fun after(param: MethodHookParam) { + var pctTag = 0 + if (OtherTool.mPct != null && OtherTool.mPct.tag != null) { + pctTag = OtherTool.mPct.tag as Int + } + if (pctTag == 0 || OtherTool.mPct == null) return + val currentLevel = param.args[3] as Int + if (brightnessUtils != null) { + val maxLevel = + brightnessUtils!!.getStaticObjectField("GAMMA_SPACE_MAX") as Int + OtherTool.mPct.text = + ((currentLevel * 100) / maxLevel).toString() + "%" + } + } + }) + } + + private fun getView(str: String, cl: ClassLoader?): Any? { + val cl2 = loadClass(str, cl) + val controlCenterWindowView = cl2.callStaticMethod("getInstance")!! + .callMethod("getPluginComponent")!! + .getObjectField("controlCenterWindowViewCreatorProvider")!! + .callMethod("get")!! + .getObjectField("windowView") + return controlCenterWindowView + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelper.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelper.java deleted file mode 100644 index c81882fea..000000000 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelper.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This file is part of HyperCeiler. - * - * HyperCeiler is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * Copyright (C) 2023-2024 HyperCeiler Contributions - */ - -package com.sevtinge.hyperceiler.module.hook.systemui.plugin; - -import android.content.Context; - -import com.sevtinge.hyperceiler.module.base.BaseHook; -import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.CCGridForHyperOS; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import de.robv.android.xposed.XposedHelpers; - -import com.sevtinge.hyperceiler.module.hook.systemui.*; -import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.*; - -public class NewPluginHelper extends BaseHook { - @Override - public void init() throws NoSuchMethodException { - // from hyperstar2.0 - findAndHookConstructor("com.android.systemui.shared.plugins.PluginActionManager$PluginContextWrapper", Context.class, ClassLoader.class, new MethodHook(){ - @Override - protected void after(MethodHookParam param) throws Throwable { - ClassLoader classLoader = (ClassLoader) XposedHelpers.getObjectField(param.thisObject,"mClassLoader"); - onPluginLoaded(classLoader); - } - }); - } - - private void onPluginLoaded(ClassLoader classLoader) { - List mCardStyleTiles = null; - try { - mCardStyleTiles = getTileList(); - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_ui_plugin_enable_volume_blur")) { - EnableVolumeBlur.initEnableVolumeBlur(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_cc_volume_showpct_title")) { - NewShowVolumePct.initLoader(classLoader); // 音量百分比 - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_ui_unlock_super_volume")) { - NewSuperVolume.initSuperVolume(classLoader); // 超大音量 - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_framework_volume_separate_control") && - mPrefsMap.getBoolean("system_framework_volume_separate_slider")) { - NotificationVolumeSeparateSlider.initHideDeviceControlEntry(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getStringAsInt("system_ui_control_center_mi_play_entry", 0) != 0) { - HideMiPlayEntry.initHideMiPlayEntry(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("systemui_plugin_card_tiles_enabled") && - !mPrefsMap.getString("systemui_plugin_card_tiles", "").isEmpty()) { - CustomCardTiles.initCustomCardTiles(classLoader, mCardStyleTiles); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_ui_control_center_qs_open_color") || - mPrefsMap.getBoolean("system_ui_control_center_qs_big_open_color")) { - QSColor.pluginHook(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_ui_control_center_hide_edit_botton")) { - HideEditButton.initHideEditButton(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect")) { - CCGridForHyperOS.initCCGridForHyperOS(classLoader); // 控制中心磁贴圆角 - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getStringAsInt("system_ui_control_center_mi_smart_hub_entry", 0) != 0) { - HideMiSmartHubEntry.initHideMiSmartHubEntry(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getStringAsInt("system_ui_control_center_device_ctrl_entry", 0) != 0) { - HideDeviceControlEntry.initHideDeviceControlEntry(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getStringAsInt("system_ui_control_center_cc_bluetooth_tile_style", 1) > 1) { - BluetoothTileStyle.initHideDeviceControlEntry(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 3) { - ShowDeviceName.initShowDeviceName(classLoader); - } - } catch (Exception ignored) {} - try { - if (mPrefsMap.getBoolean("system_ui_control_center_disable_device_managed")) { - DisableDeviceManaged.initDisableDeviceManaged(classLoader); - } - } catch (Exception ignored) {} - } - - private List getTileList() { - String cardTiles = mPrefsMap.getString("systemui_plugin_card_tiles", "").replace("List_", ""); - if (cardTiles.isEmpty()) { - return new ArrayList<>(); - } else { - return Arrays.asList(cardTiles.split("\\|")); - } - } - -} diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelperKt.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelperKt.kt index 26ed30bd8..8ca3c050c 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelperKt.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelperKt.kt @@ -28,18 +28,32 @@ import com.sevtinge.hyperceiler.module.hook.systemui.* import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.* import com.sevtinge.hyperceiler.module.hook.systemui.other.* import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.icon.v.* -import com.sevtinge.hyperceiler.utils.api.* +import com.sevtinge.hyperceiler.utils.api.PluginFactory import java.lang.ref.* -// https://github.com/buffcow/Hyper5GSwitch/blob/master/app/src/main/kotlin/cn/buffcow/hyper5g/hooker/PluginLoader.kt object NewPluginHelperKt : BaseHook() { override fun init() { + // from hyperstar2.0 + /*loadClass("com.android.systemui.shared.plugins.PluginActionManager\$PluginContextWrapper") + .constructors.first().createAfterHook { + val classLoader = it.thisObject.getObjectFieldAs("mClassLoader") + runCatching { + onPluginLoadedAll(classLoader) + }.onFailure { + logE(TAG, lpparam.packageName, "Failed to create plugin context.") + return@createAfterHook + } + }*/ + + // https://github.com/buffcow/Hyper5GSwitch/blob/master/app/src/main/kotlin/cn/buffcow/hyper5g/hooker/PluginLoader.kt loadClass("com.android.systemui.shared.plugins.PluginInstance\$PluginFactory") .methodFinder().filterByName("createPluginContext") .first().createAfterHook { runCatching { val wrapper = it.result as ContextWrapper - onPluginLoaded(PluginFactory(it.thisObject).also { it.pluginCtxRef = WeakReference(wrapper) }) + onPluginLoaded(PluginFactory(it.thisObject).also { + it.pluginCtxRef = WeakReference(wrapper) + }) }.onFailure { logE(TAG, lpparam.packageName, "Failed to create plugin context.") return@createAfterHook @@ -48,97 +62,83 @@ object NewPluginHelperKt : BaseHook() { } private fun onPluginLoaded(factory: PluginFactory) { - try { - onPluginLoadedAll(factory) - - when (factory.mComponentName) { - factory.componentNames("miui.systemui.volume.VolumeDialogPlugin") -> { - val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader - logD(TAG, lpparam.packageName, "Plugin for sysui volume loaded.") - - if (mPrefsMap.getBoolean("system_ui_plugin_enable_volume_blur")) - EnableVolumeBlur.initEnableVolumeBlur(classLoader) - if (mPrefsMap.getBoolean("system_cc_volume_showpct_title")) - NewShowVolumePct.initLoader(classLoader) // 声音百分比 - if (mPrefsMap.getBoolean("system_ui_unlock_super_volume")) - NewSuperVolume.initSuperVolume(classLoader) // 超大音量 - if (mPrefsMap.getBoolean("system_framework_volume_separate_control") && - mPrefsMap.getBoolean("system_framework_volume_separate_slider")) - NotificationVolumeSeparateSlider.initHideDeviceControlEntry(classLoader) - } - - factory.componentNames("miui.systemui.miplay.MiPlayPluginImpl") -> { - val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader - logD(TAG, lpparam.packageName, "Plugin for sysui mipay loaded.") + val mCardStyleTiles = getTileList() - if (mPrefsMap.getStringAsInt("system_ui_control_center_mi_play_entry", 0) != 0) - HideMiPlayEntry.initHideMiPlayEntry(classLoader) - } + when (factory.mComponentName) { + factory.componentNames("miui.systemui.volume.VolumeDialogPlugin") -> { + val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader + logD(TAG, lpparam.packageName, "Plugin for sysui volume loaded.") + + if (mPrefsMap.getBoolean("system_ui_plugin_enable_volume_blur")) + EnableVolumeBlur.initEnableVolumeBlur(classLoader) + if (mPrefsMap.getBoolean("system_cc_volume_showpct_title")) + NewShowVolumePct.initLoader(classLoader) // 声音百分比 + if (mPrefsMap.getBoolean("system_ui_unlock_super_volume")) + NewSuperVolume.initSuperVolume(classLoader) // 超大音量 + if (mPrefsMap.getBoolean("system_framework_volume_separate_control") && + mPrefsMap.getBoolean("system_framework_volume_separate_slider") + ) + NotificationVolumeSeparateSlider.initHideDeviceControlEntry(classLoader) + if (mPrefsMap.getBoolean("system_ui_other_default_plugin_theme")) + DefaultPluginTheme.initDefaultPluginTheme(classLoader) + } - factory.componentNames("miui.systemui.controlcenter.MiuiControlCenter") -> { - val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader - logD(TAG, lpparam.packageName, "Plugin for sysui control center loaded.") + factory.componentNames("miui.systemui.quicksettings.LocalMiuiQSTilePlugin"), + factory.componentNames("miui.systemui.controlcenter.MiuiControlCenter") -> { + val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader + logD(TAG, lpparam.packageName, "Plugin for sysui qs tiles && control center loaded.") - if (mPrefsMap.getBoolean("system_ui_control_center_hide_edit_botton")) - HideEditButton.initHideEditButton(classLoader) + if (mPrefsMap.getBoolean("systemui_plugin_card_tiles_enabled") && + mPrefsMap.getString("systemui_plugin_card_tiles", "").isNotEmpty() + ) { + CustomCardTiles.initCustomCardTiles(classLoader, mCardStyleTiles) } - - factory.componentNames("miui.systemui.notification.NotificationStatPluginImpl") -> { - val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader - logD(TAG, lpparam.packageName, "Plugin for sysui NotificationStatPluginImpl loaded.") - - if (mPrefsMap.getBoolean("system_ui_statusbar_music_switch")) - FocusNotifLyric.initLoader(classLoader); + if (mPrefsMap.getBoolean("system_ui_control_center_hide_edit_botton")) + HideEditButton.initHideEditButton(classLoader) + if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect")) + CCGridForHyperOS.initCCGridForHyperOS(classLoader) // 控制中心磁贴圆角 + if (mPrefsMap.getBoolean("system_ui_control_center_qs_open_color") || + mPrefsMap.getBoolean("system_ui_control_center_qs_big_open_color") + ) { + QSColor.pluginHook(classLoader) } + if (mPrefsMap.getBoolean("system_showpct_title")) + NewBrightnessPct.initLoaderHook(classLoader) // 亮度百分比 - else -> { - val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader - - if (mPrefsMap.getStringAsInt("system_ui_control_center_mi_smart_hub_entry", 0) != 0) - HideMiSmartHubEntry.initHideMiSmartHubEntry(classLoader) - if (mPrefsMap.getStringAsInt("system_ui_control_center_device_ctrl_entry", 0) != 0) - HideDeviceControlEntry.initHideDeviceControlEntry(classLoader) - if (mPrefsMap.getStringAsInt("system_ui_control_center_cc_bluetooth_tile_style", 1) > 1) - BluetoothTileStyle.initHideDeviceControlEntry(classLoader) - if (mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 3) - ShowDeviceName.initShowDeviceName(classLoader) - if (mPrefsMap.getBoolean("system_ui_control_center_disable_device_managed")) - DisableDeviceManaged.initDisableDeviceManaged(classLoader) - // logD(TAG, lpparam.packageName, "Plugin is ${factory.mComponentName}") - // 仅备份当前可用注入 ClassLoader - // miui.systemui.volume.VolumeDialogPlugin - // miui.systemui.miplay.MiPlayPluginImpl - // miui.systemui.quicksettings.LocalMiuiQSTilePlugin - // miui.systemui.controlcenter.MiuiControlCenter - // ↓ - // miui.systemui.notification.NotificationStatPluginImpl - // miui.systemui.globalactions.GlobalActionsPlugin - // miui.systemui.notification.FocusNotificationPluginImpl - // miui.systemui.notification.unimportant.UnimportantSdkPluginImpl - } + if (mPrefsMap.getBoolean("system_ui_other_default_plugin_theme")) + DefaultPluginTheme.initDefaultPluginTheme(classLoader) } - } catch (_: Exception) {} - } - private fun onPluginLoadedAll(factory: PluginFactory) { - // 本列表将一次性加载所有插件,适用于需要载入多个 factory.mComponentName 的情况 - val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader - val mCardStyleTiles = getTileList() + factory.componentNames("miui.systemui.notification.NotificationStatPluginImpl") -> { + val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader + logD(TAG, lpparam.packageName, "Plugin for sysui NotificationStatPluginImpl loaded.") - if (mPrefsMap.getBoolean("systemui_plugin_card_tiles_enabled") && - mPrefsMap.getString("systemui_plugin_card_tiles", "").isNotEmpty()) { - CustomCardTiles.initCustomCardTiles(classLoader, mCardStyleTiles) //A - } - if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect")) - CCGridForHyperOS.initCCGridForHyperOS(classLoader) // 控制中心磁贴圆角 - if (mPrefsMap.getBoolean("system_ui_control_center_qs_open_color") || - mPrefsMap.getBoolean("system_ui_control_center_qs_big_open_color") - ) { - QSColor.pluginHook(classLoader) - } + if (mPrefsMap.getBoolean("system_ui_statusbar_music_switch")) + FocusNotifLyric.initLoader(classLoader); + if (mPrefsMap.getBoolean("system_ui_other_default_plugin_theme")) + DefaultPluginTheme.initDefaultPluginTheme(classLoader) + } - if (mPrefsMap.getBoolean("system_ui_other_default_plugin_theme")) - DefaultPluginTheme.initDefaultPluginTheme(classLoader) + else -> { + val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader + if (mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 3) + ShowDeviceName.initShowDeviceName(classLoader) + if (mPrefsMap.getBoolean("system_ui_control_center_disable_device_managed")) + DisableDeviceManaged.initDisableDeviceManaged(classLoader) + + // logD(TAG, lpparam.packageName, "Plugin is ${factory.mComponentName}") + // 仅备份当前可用注入 ClassLoader + // miui.systemui.volume.VolumeDialogPlugin + // miui.systemui.miplay.MiPlayPluginImpl + // miui.systemui.quicksettings.LocalMiuiQSTilePlugin + // miui.systemui.controlcenter.MiuiControlCenter + // ↓ + // miui.systemui.notification.NotificationStatPluginImpl + // miui.systemui.globalactions.GlobalActionsPlugin + // miui.systemui.notification.FocusNotificationPluginImpl + // miui.systemui.notification.unimportant.UnimportantSdkPluginImpl + } + } } private fun getTileList(): List { diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewShowVolumePct.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewShowVolumePct.kt index b9e05929f..04c4e5cb7 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewShowVolumePct.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewShowVolumePct.kt @@ -29,7 +29,6 @@ import com.sevtinge.hyperceiler.module.base.tool.* import com.sevtinge.hyperceiler.module.base.tool.OtherTool.* import com.sevtinge.hyperceiler.utils.* import com.sevtinge.hyperceiler.utils.devicesdk.* -import de.robv.android.xposed.* object NewShowVolumePct { @JvmStatic @@ -45,9 +44,9 @@ object NewShowVolumePct { volumePanelViewControllerClazz.methodFinder().filterByName("showVolumePanelH") .first().createAfterHook { val mVolumeView = - XposedHelpers.getObjectField(it.thisObject, "mVolumeView") as View + it.thisObject.getObjectField("mVolumeView") as View val windowView = mVolumeView.parent as FrameLayout - initPct(windowView, 3, windowView.context) + initPct(windowView, 3) } mVolumeDisable(volumePanelViewControllerClazz) @@ -63,9 +62,9 @@ object NewShowVolumePct { miuiVolumeDialogImplClazz.methodFinder().filterByName("showVolumeDialogH") .first().createAfterHook { val mVolumeView = - XposedHelpers.getObjectField(it.thisObject, "mDialogView") as View + it.thisObject.getObjectField("mDialogView") as View val windowView = mVolumeView.parent as FrameLayout - initPct(windowView, 3, windowView.context) + initPct(windowView, 3) } mVolumeDisable(miuiVolumeDialogImplClazz) @@ -76,7 +75,7 @@ object NewShowVolumePct { private fun mVolumeDisable(clazz: Class<*>) { clazz.methodFinder().filterByName("dismissH") .first().createAfterHook { - removePct(getTextView()) + removePct(mPct) } } @@ -105,10 +104,10 @@ object NewShowVolumePct { if (nowLevel == arg1) return@createAfterHook var pctTag = 0 - if (getTextView() != null && getTextView().tag != null) { - pctTag = getTextView().tag as Int + if (mPct != null && mPct.tag != null) { + pctTag = mPct.tag as Int } - if (pctTag != 3 || getTextView() == null) return@createAfterHook + if (pctTag != 3 || mPct == null) return@createAfterHook val mColumn = it.thisObject.getObjectFieldOrNull("mColumn") if (mColumn == null) return@createAfterHook val ss = mColumn.getObjectFieldOrNull( "ss") @@ -123,7 +122,7 @@ object NewShowVolumePct { currentLevel = mColumn.getIntField("animTargetProgress") } nowLevel = currentLevel - getTextView().visibility = View.VISIBLE + mPct.visibility = View.VISIBLE val levelMin = ss.getIntField("levelMin") if (levelMin > 0 && currentLevel < levelMin * 1000) { currentLevel = levelMin * 1000 @@ -136,8 +135,8 @@ object NewShowVolumePct { if (currentLevel == max) maxLevel else (currentLevel * i3 / max) + 1 } if (((currentLevel * 100) / maxLevel) == 100 && (HookTool.mPrefsMap.getBoolean("system_ui_unlock_super_volume") || mSupportSV)) - getTextView().text = "200%" - else getTextView().text = ((currentLevel * 100) / maxLevel).toString() + "%" + mPct.text = "200%" + else mPct.text = ((currentLevel * 100) / maxLevel).toString() + "%" } } } \ No newline at end of file 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 a1487cdbc..9dac2ed32 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 @@ -18,7 +18,6 @@ */ package com.sevtinge.hyperceiler.module.hook.systemui.plugin; -import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isAndroidVersion; import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion; import android.content.pm.ApplicationInfo; @@ -44,9 +43,7 @@ public class PluginHelper extends BaseHook { @Override public void init() { - String pluginLoaderClass = isAndroidVersion(33) - ? "com.android.systemui.shared.plugins.PluginInstance$Factory" - : "com.android.systemui.shared.plugins.PluginManagerImpl"; + String pluginLoaderClass = "com.android.systemui.shared.plugins.PluginInstance$Factory"; hookAllMethods(pluginLoaderClass, "getClassLoader", new MethodHook() { private boolean isHooked = false; diff --git a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/SystemUIOtherSettings.java b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/SystemUIOtherSettings.java index 4896e3f52..6d4216b41 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/SystemUIOtherSettings.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/SystemUIOtherSettings.java @@ -48,7 +48,6 @@ public class SystemUIOtherSettings extends DashboardFragment { SwitchPreference mPower; SwitchPreference mDisableBluetoothRestrict; // 禁用蓝牙临时关闭 SwitchPreference mPctUseBlur; - SwitchPreference mShowPct; SwitchPreference mFuckSG; SwitchPreference mTimer; SwitchPreference mPluginThemeBlur; @@ -70,7 +69,6 @@ public void initPrefs() { mVolume = findPreference("prefs_key_system_ui_disable_volume"); mPower = findPreference("prefs_key_system_ui_disable_power"); mPctUseBlur = findPreference("prefs_key_system_showpct_use_blur"); - mShowPct = findPreference("prefs_key_system_showpct_title"); mFuckSG = findPreference("prefs_key_system_ui_move_log_to_miui"); mTimer = findPreference("prefs_key_system_ui_volume_timer"); mPluginThemeBlur = findPreference("prefs_key_system_ui_other_default_plugin_theme"); @@ -82,7 +80,6 @@ public void initPrefs() { mDisableInfinitymodeGesture.setVisible(isMoreHyperOSVersion(1f) && isMoreAndroidVersion(34) && isPad()); mBottomBar.setVisible(isMoreHyperOSVersion(1f) && isMoreAndroidVersion(34)); mPctUseBlur.setVisible(isMoreHyperOSVersion(1f)); - mShowPct.setVisible(!isMoreHyperOSVersion(1f)); mFuckSG.setVisible(isMoreHyperOSVersion(2f)); mTimer.setVisible(!isMoreAndroidVersion(35)); mPluginThemeBlur.setVisible(isMoreHyperOSVersion(1f)); diff --git a/app/src/main/res/xml/guard_provider.xml b/app/src/main/res/xml/guard_provider.xml index 8e6d8f043..ec6843d79 100644 --- a/app/src/main/res/xml/guard_provider.xml +++ b/app/src/main/res/xml/guard_provider.xml @@ -21,13 +21,15 @@ app:myLocation="@string/guard_provider" app:myLocationHyper="@string/guard_provider_hyperos" app:quick_restart="com.miui.guardprovider"> - - + + + + \ No newline at end of file