From 5f4043ccc2d842efa56113679e078318bb4b5740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=83=E6=9F=92=E6=9F=92?= Date: Wed, 11 Dec 2024 01:48:33 +0800 Subject: [PATCH] opt: SystemUI Plugin loaded --- .../module/base/dexkit/DexKit.java | 14 ++-- .../hook/systemui/plugin/NewPluginHelperKt.kt | 66 +++++++------------ .../app/systemui/ControlCenterSettings.java | 3 - app/src/main/res/values-zh-rCN/strings.xml | 6 -- app/src/main/res/values/arrays.xml | 12 ---- app/src/main/res/values/strings.xml | 5 -- .../main/res/xml/system_ui_control_center.xml | 13 ---- gradle/libs.versions.toml | 2 +- 8 files changed, 31 insertions(+), 90 deletions(-) diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java b/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java index cec899c2b..cac445257 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/base/dexkit/DexKit.java @@ -119,13 +119,13 @@ public static T findMember(@NonNull String key, ClassLoader classLoader, IDe try { BaseData baseData = iDexKit.dexkit(dexKitBridge); if (baseData instanceof FieldData fieldData) { - mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_FIELD, fieldData.toDexField().serialize()))); + mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_FIELD, fieldData.toDexField().serialize())) + "\n\n"); return (T) fieldData.getFieldInstance(classLoader); } else if (baseData instanceof MethodData methodData) { - mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_METHOD, methodData.toDexMethod().serialize()))); + mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_METHOD, methodData.toDexMethod().serialize())) + "\n\n"); return (T) methodData.getMethodInstance(classLoader); } else if (baseData instanceof ClassData classData) { - mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_CLASS, classData.toDexType().serialize()))); + mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_CLASS, classData.toDexType().serialize())) + "\n\n"); return (T) classData.getInstance(classLoader); } } catch (ReflectiveOperationException e) { @@ -170,21 +170,21 @@ public static List findMemberList(@NonNull String key, ClassLoader classL serializeList.add(f.toDexField().serialize()); instanceList.add((T) f.getFieldInstance(classLoader)); } - mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_FIELD, serializeList))); + mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_FIELD, serializeList)) + "\n\n"); return instanceList; } else if (baseDataList instanceof MethodDataList methodDataList) { for (MethodData m : methodDataList) { serializeList.add(m.toDexMethod().serialize()); instanceList.add((T) m.getMethodInstance(classLoader)); } - mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_METHOD, serializeList))); + mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_METHOD, serializeList)) + "\n\n"); return instanceList; } else if (baseDataList instanceof ClassDataList classDataList) { for (ClassData c : classDataList) { serializeList.add(c.toDexType().serialize()); instanceList.add((T) c.getInstance(classLoader)); } - mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_CLASS, serializeList))); + mMMKV.putString(key, mGson.toJson(new MemberData(TYPE_CLASS, serializeList)) + "\n\n"); return instanceList; } } catch (ReflectiveOperationException e) { @@ -253,7 +253,7 @@ public static void close() { } private static final class MemberData { - public String type = ""; + public String type; public String serialize = ""; public ArrayList serializeList = new ArrayList<>(); 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 62b17ac55..26ed30bd8 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 @@ -48,10 +48,9 @@ object NewPluginHelperKt : BaseHook() { } private fun onPluginLoaded(factory: PluginFactory) { - val mCardStyleTiles = getTileList() - val mIsDefaultMode = mPrefsMap.getStringAsInt("system_ui_plugin_tiles_load_way", 0) == 0 || mPrefsMap.getStringAsInt("system_ui_plugin_tiles_load_way", 0) == 1 - val mIsCompatibilityMode = mPrefsMap.getStringAsInt("system_ui_plugin_tiles_load_way", 0) == 0 || mPrefsMap.getStringAsInt("system_ui_plugin_tiles_load_way", 0) == 2 try { + onPluginLoadedAll(factory) + when (factory.mComponentName) { factory.componentNames("miui.systemui.volume.VolumeDialogPlugin") -> { val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader @@ -66,8 +65,6 @@ object NewPluginHelperKt : BaseHook() { 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.miplay.MiPlayPluginImpl") -> { @@ -78,48 +75,12 @@ object NewPluginHelperKt : BaseHook() { HideMiPlayEntry.initHideMiPlayEntry(classLoader) } - factory.componentNames("miui.systemui.quicksettings.LocalMiuiQSTilePlugin") -> { - val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader - logD(TAG, lpparam.packageName, "Plugin for sysui qs tiles loaded.") - - if (mPrefsMap.getBoolean("systemui_plugin_card_tiles_enabled") && - mPrefsMap.getString("systemui_plugin_card_tiles", "").isNotEmpty() && - mIsCompatibilityMode - ) { - CustomCardTiles.initCustomCardTiles(classLoader, mCardStyleTiles) - } - if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect") && mIsDefaultMode) - CCGridForHyperOS.initCCGridForHyperOS(classLoader) // 控制中心磁贴圆角 //A - 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_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.") - if (mPrefsMap.getBoolean("systemui_plugin_card_tiles_enabled") && - mPrefsMap.getString("systemui_plugin_card_tiles", "").isNotEmpty() && - mIsDefaultMode - ) { - CustomCardTiles.initCustomCardTiles(classLoader, mCardStyleTiles) //A - } if (mPrefsMap.getBoolean("system_ui_control_center_hide_edit_botton")) HideEditButton.initHideEditButton(classLoader) - if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect") && mIsCompatibilityMode) - 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_other_default_plugin_theme")) - DefaultPluginTheme.initDefaultPluginTheme(classLoader) } factory.componentNames("miui.systemui.notification.NotificationStatPluginImpl") -> { @@ -128,8 +89,6 @@ object NewPluginHelperKt : BaseHook() { if (mPrefsMap.getBoolean("system_ui_statusbar_music_switch")) FocusNotifLyric.initLoader(classLoader); - if (mPrefsMap.getBoolean("system_ui_other_default_plugin_theme")) - DefaultPluginTheme.initDefaultPluginTheme(classLoader) } else -> { @@ -161,6 +120,27 @@ object NewPluginHelperKt : BaseHook() { } catch (_: Exception) {} } + private fun onPluginLoadedAll(factory: PluginFactory) { + // 本列表将一次性加载所有插件,适用于需要载入多个 factory.mComponentName 的情况 + val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader + val mCardStyleTiles = getTileList() + + 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_other_default_plugin_theme")) + DefaultPluginTheme.initDefaultPluginTheme(classLoader) + } + private fun getTileList(): List { val cardTiles = mPrefsMap.getString("systemui_plugin_card_tiles", "").replace("List_", "") diff --git a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java index 25b822604..3cc073cb1 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/ControlCenterSettings.java @@ -73,7 +73,6 @@ public class ControlCenterSettings extends DashboardFragment implements Preferen ColorPickerPreference mProgressBarColor; SwitchPreference mRedirectNotice; SwitchPreference mShadeHeaderBlur; - DropDownPreference mPluginLoadMode; DropDownPreference mSunshineMode; DropDownPreference mSunshineModeHigh; SeekBarPreferenceCompat mSunshineModeHighBrightness; @@ -122,7 +121,6 @@ public void initPrefs() { mProgressBarColor = findPreference("prefs_key_system_ui_control_center_media_control_seekbar_color"); mRedirectNotice = findPreference("prefs_key_system_ui_control_center_redirect_notice"); mShadeHeaderBlur = findPreference("prefs_key_system_ui_shade_header_gradient_blur"); - mPluginLoadMode = findPreference("prefs_key_system_ui_plugin_tiles_load_way"); mSunshineMode = findPreference("prefs_key_system_control_center_sunshine_new_mode"); mSunshineModeHigh = findPreference("prefs_key_system_control_center_sunshine_new_mode_high"); mSunshineModeHighBrightness = findPreference("prefs_key_system_control_center_sunshine_mode_brightness"); @@ -160,7 +158,6 @@ public void initPrefs() { mSunshineModeHighBrightness.setVisible(false); } - mPluginLoadMode.setVisible(isMoreHyperOSVersion(2f)); if (isMoreHyperOSVersion(1f)) { mNewCCGrid.setVisible(false); mCard.setVisible(false); diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 3397478da..ee399605b 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -1078,12 +1078,6 @@ 解除系统界面组件对第三方主题默认禁用的高级材质模糊 音量条模糊 仅供 Android 12 及以上的 MTK 机型使用,可能存在 GPU 负载较高的情况 - - 磁贴 hook 加载方式 - 全局加载可能会导致不必要的卡顿;请根据实际可用性选择加载方式 - 全局 - 默认 - 兼容 设置 国际版本设置页面 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index d6f6aeda1..5336f8430 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1127,18 +1127,6 @@ @color/update_text_border1 - - @string/system_ui_plugin_tiles_load_way_global - @string/system_ui_plugin_tiles_load_way_default - @string/system_ui_plugin_tiles_load_way_compatibility - - - - 0 - 1 - 2 - - @string/array_global_actions_none @string/array_global_actions_lock diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2e3cb3271..39cb6cb02 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1016,11 +1016,6 @@ There is no restriction on background blur for Advanced textures, only for third-party theme removal. Remove notification count limit Allow display 10, 17 or more notifications. - Tiles hook loading mode - Global mode may cause unnecessary lag. Please choose the loading mode based on actual availability. - Global - Default - Compatibility Others Native volume bar diff --git a/app/src/main/res/xml/system_ui_control_center.xml b/app/src/main/res/xml/system_ui_control_center.xml index e87f11da3..c1177a36e 100644 --- a/app/src/main/res/xml/system_ui_control_center.xml +++ b/app/src/main/res/xml/system_ui_control_center.xml @@ -20,20 +20,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" app:myLocation="@string/system_ui_controlcenter_title" app:quick_restart="com.android.systemui"> - - - - - - -