From 96c263de8932dc33e288a50ecd01b769f8a6004e Mon Sep 17 00:00:00 2001 From: xzakota <51871051+xzakota@users.noreply.github.com> Date: Tue, 3 Dec 2024 00:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A7=BB=E5=8A=A8=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E7=B1=BB=E5=9E=8B=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= =?UTF-8?q?=20&&=20=E4=BC=98=E5=8C=96=E9=80=9A=E7=9F=A5=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E5=A4=A9=E6=B0=94=E7=82=B9=E5=87=BB=E9=80=BB=E8=BE=91=20=20(#1?= =?UTF-8?q?014)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 暂时移除对于 OS1 安装新版桌面的解锁布局 HOOK - 优化跳转天气应用后自动关闭通知中心 - 优化大 5G 反色逻辑 - 修复移动网络活动指示器在部分情况显示多余 padding 的问题 Co-authored-by: 铃柒柒 --- .../module/app/Home/Phone/HomeU.java | 5 - .../module/app/Home/Phone/HomeV.java | 1 - .../module/app/SystemUI/Phone/SystemUiV.java | 14 +- .../module/hook/home/layout/LayoutRules.kt | 34 +-- .../module/hook/systemui/Dependency.kt | 32 ++- .../hook/systemui/InterfacesImplManager.kt | 29 +++ .../controlcenter/NotificationWeather.kt | 238 ++++++------------ .../controlcenter/NotificationWeatherNew.kt | 3 +- .../statusbar/model/DualRowSignalHookV.kt | 3 +- .../statusbar/model/MobilePublicHookV.kt | 3 - .../statusbar/model/MobileTypeSingle2Hook.kt | 227 ++++++++++++----- .../statusbar/model/public/MobileClass.kt | 7 +- 12 files changed, 324 insertions(+), 272 deletions(-) create mode 100644 app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/InterfacesImplManager.kt diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeU.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeU.java index ad660e098d..bd8a44f7f5 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeU.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeU.java @@ -165,11 +165,6 @@ public void handleLoadPackage() { initHook(new BackGestureAreaWidth(), mPrefsMap.getInt("home_navigation_back_area_width", 100) != 100); // 布局 - initHook(LayoutRules.INSTANCE, mPrefsMap.getBoolean("home_layout_unlock_grids_new") || - mPrefsMap.getBoolean("home_layout_unlock_grids") || - mPrefsMap.getBoolean("home_layout_workspace_padding_bottom_enable") || - mPrefsMap.getBoolean("home_layout_workspace_padding_top_enable") || - mPrefsMap.getBoolean("home_layout_workspace_padding_horizontal_enable")); initHook(new UnlockGrids(), mPrefsMap.getBoolean("home_layout_unlock_grids")); // initHook(new UnlockGridsNoWord(), mPrefsMap.getBoolean("home_layout_unlock_grids_no_word")); initHook(new WorkspacePadding(), diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeV.java b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeV.java index 356302cb8d..c40a2d804b 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeV.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/app/Home/Phone/HomeV.java @@ -162,7 +162,6 @@ public void handleLoadPackage() { // 布局 initHook(LayoutRules.INSTANCE, mPrefsMap.getBoolean("home_layout_unlock_grids_new") || - mPrefsMap.getBoolean("home_layout_unlock_grids") || mPrefsMap.getBoolean("home_layout_workspace_padding_bottom_enable") || mPrefsMap.getBoolean("home_layout_workspace_padding_top_enable") || mPrefsMap.getBoolean("home_layout_workspace_padding_horizontal_enable")); 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 56cf43801a..7820142e2e 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 @@ -161,17 +161,17 @@ public void handleLoadPackage() { initHook(new StatusBarIconPositionAdjust(), mPrefsMap.getBoolean("system_ui_status_bar_swap_wifi_and_mobile_network")); // 移动网络图标 - boolean isEnableMobilePublic = mPrefsMap.getBoolean("system_ui_status_bar_icon_mobile_network_hide_card_1") || + boolean isEnabledDualRowSignal = mPrefsMap.getBoolean("system_ui_statusbar_network_icon_enable"); + initHook(new DualRowSignalHookV(), isEnabledDualRowSignal); + initHook(new MobilePublicHookV(), isEnabledDualRowSignal || + mPrefsMap.getBoolean("system_ui_status_bar_icon_mobile_network_hide_card_1") || mPrefsMap.getBoolean("system_ui_status_bar_icon_mobile_network_hide_card_2") || - mPrefsMap.getStringAsInt("system_ui_status_bar_icon_show_mobile_network_type", 0) != 0 || mPrefsMap.getBoolean("system_ui_status_bar_mobile_hide_roaming_icon") || - mPrefsMap.getBoolean("system_ui_statusbar_mobile_type_enable") || mPrefsMap.getBoolean("system_ui_status_bar_mobile_indicator") || mPrefsMap.getStringAsInt("system_ui_status_bar_icon_small_hd", 0) != 0 || - mPrefsMap.getStringAsInt("system_ui_status_bar_icon_big_hd", 0) != 0; - initHook(new DualRowSignalHookV(), mPrefsMap.getBoolean("system_ui_statusbar_network_icon_enable")); - initHook(new MobilePublicHookV(), true); - initHook(MobileTypeSingle2Hook.INSTANCE, isEnableMobilePublic); + mPrefsMap.getStringAsInt("system_ui_status_bar_icon_big_hd", 0) != 0); + initHook(MobileTypeSingle2Hook.INSTANCE, mPrefsMap.getStringAsInt("system_ui_status_bar_icon_show_mobile_network_type", 0) != 0 || + mPrefsMap.getBoolean("system_ui_statusbar_mobile_type_enable")); initHook(MobileTypeTextCustom.INSTANCE, !Objects.equals(mPrefsMap.getString("system_ui_status_bar_mobile_type_custom", ""), "")); // 电池相关 diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/layout/LayoutRules.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/layout/LayoutRules.kt index dc92f3ed24..ad80f9fb0a 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/layout/LayoutRules.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/home/layout/LayoutRules.kt @@ -28,10 +28,18 @@ object LayoutRules : HomeBaseHook() { private const val PHONE_RULES = "com.miui.home.launcher.compat.PhoneDeviceRules" private const val HOME_SETTINGS = "com.miui.home.settings.MiuiHomeSettings" - private var isUnlockGridsHook = false - private var isSetWSPaddingTopHook = false - private var isSetWSPaddingBottomHook = false - private var isSetWSPaddingSideHook = false + private val isUnlockGridsHook by lazy { + mPrefsMap.getBoolean("home_layout_unlock_grids_new") + } + private val isSetWSPaddingTopHook by lazy { + mPrefsMap.getBoolean("home_layout_workspace_padding_top_enable") + } + private val isSetWSPaddingBottomHook by lazy { + mPrefsMap.getBoolean("home_layout_workspace_padding_bottom_enable") + } + private val isSetWSPaddingSideHook by lazy { + mPrefsMap.getBoolean("home_layout_workspace_padding_horizontal_enable") + } private var sCellCountX = 0 private var sCellCountY = 0 @@ -42,14 +50,6 @@ object LayoutRules : HomeBaseHook() { private var currentCellHeight = 0 override fun initForNewHome() { - isUnlockGridsHook = mPrefsMap.getBoolean("home_layout_unlock_grids_new") || - mPrefsMap.getBoolean("home_layout_unlock_grids") - isSetWSPaddingTopHook = mPrefsMap.getBoolean("home_layout_workspace_padding_top_enable") - isSetWSPaddingBottomHook = - mPrefsMap.getBoolean("home_layout_workspace_padding_bottom_enable") - isSetWSPaddingSideHook = - mPrefsMap.getBoolean("home_layout_workspace_padding_horizontal_enable") - if (isUnlockGridsHook) { sCellCountX = mPrefsMap.getInt("home_layout_unlock_grids_cell_x", 0) sCellCountY = mPrefsMap.getInt("home_layout_unlock_grids_cell_y", 0) @@ -67,8 +67,7 @@ object LayoutRules : HomeBaseHook() { mMiuiHomeConfig?.callMethod("removePreference", mScreenCellsConfig) logI( - TAG, - lpparam.packageName, + TAG, lpparam.packageName, "Remove preference($mScreenCellsConfig) form MIUIHomeSettings" ) param.result = null @@ -125,8 +124,9 @@ object LayoutRules : HomeBaseHook() { val mCellSize = rules.getIntField("mCellSize") val mCellCountY = rules.getIntField("mCellCountY") val mWorkspaceTopPadding = rules.callMethodAs("getWorkspacePaddingTop") - val mWorkspaceCellPaddingBottom = rules.getObjectFieldAs("mWorkspaceCellPaddingBottom") - .callMethodAs("getValue") + val mWorkspaceCellPaddingBottom = + rules.getObjectFieldAs("mWorkspaceCellPaddingBottom") + .callMethodAs("getValue") val sWorkspacePaddingTop = if (isSetWSPaddingTopHook) { DisplayUtils.dp2px( @@ -232,4 +232,4 @@ object LayoutRules : HomeBaseHook() { ) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/Dependency.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/Dependency.kt index a28b7fbea4..c705fc4987 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/Dependency.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/Dependency.kt @@ -1,25 +1,47 @@ package com.sevtinge.hyperceiler.module.hook.systemui import com.github.kyuubiran.ezxhelper.* -import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.MobileTypeSingle2Hook.findClass import com.sevtinge.hyperceiler.utils.* +import de.robv.android.xposed.XposedHelpers.* + @Suppress("MemberVisibilityCanBePrivate") object Dependency { private const val DEPENDENCY = "com.android.systemui.Dependency" - val sDependency by lazy { - findClass(DEPENDENCY, EzXHelper.classLoader).getStaticObjectField("sDependency") + + private val dependencyClz by lazy { + findClass(DEPENDENCY, EzXHelper.classLoader) } - val mMiuiLegacyDependency : Any? + + /* ========================== only for HyperOS2 ========================== */ + @JvmStatic + @get:JvmName(name = "getDependency") + val sDependency: Any? + get() = dependencyClz.getStaticObjectField("sDependency") + + @JvmStatic + @get:JvmName(name = "getMiuiLegacyDependency") + val mMiuiLegacyDependency: Any? get() = sDependency?.getObjectField("mMiuiLegacyDependency") - val mDependencies : Map<*, *>? + + @JvmStatic + @get:JvmName(name = "getDependencies") + val mDependencies: Map<*, *>? get() = sDependency?.getObjectField("mDependencies") as Map<*, *>? + @JvmStatic fun getDependencyInner(depClz: Class<*>): Any? { return sDependency?.callMethod("getDependencyInner", depClz) } + @JvmStatic fun getDependencyInner(depClzName: String): Any? { return getDependencyInner(findClass(depClzName, EzXHelper.classLoader)) } + + /* ========================== only for HyperOS1 ========================== */ + @JvmStatic + fun get(depClz: Class<*>): Any? { + return dependencyClz.callStaticMethod("get", depClz) + } } \ No newline at end of file diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/InterfacesImplManager.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/InterfacesImplManager.kt new file mode 100644 index 0000000000..f219daead3 --- /dev/null +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/InterfacesImplManager.kt @@ -0,0 +1,29 @@ +package com.sevtinge.hyperceiler.module.hook.systemui + +import com.github.kyuubiran.ezxhelper.* +import com.sevtinge.hyperceiler.utils.* +import de.robv.android.xposed.XposedHelpers.* + +/** + * only for HyperOS2 + */ +object InterfacesImplManager { + private const val IMPL_MANAGER = "com.miui.systemui.interfacesmanager.InterfacesImplManager" + + const val I_ACTIVITY_STARTER = "com.android.systemui.plugins.ActivityStarter" + + @JvmStatic + @get:JvmName(name = "getClassContainer") + val sClassContainer by lazy { + managerClz.getStaticObjectFieldAs, Any>>("sClassContainer") + } + + private val managerClz by lazy { + findClass(IMPL_MANAGER, EzXHelper.classLoader) + } + + @JvmStatic + fun registerImpl(clz: Class<*>, obj: Any) { + managerClz.callStaticMethod("registerImpl", clz, obj) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeather.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeather.kt index 4340870d01..2e804da30e 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeather.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeather.kt @@ -22,23 +22,20 @@ import android.annotation.* import android.content.* import android.view.* import android.widget.* -import androidx.constraintlayout.widget.* import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass -import com.github.kyuubiran.ezxhelper.ClassUtils.loadClassOrNull import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder import com.sevtinge.hyperceiler.module.base.* +import com.sevtinge.hyperceiler.module.hook.systemui.* import com.sevtinge.hyperceiler.utils.* -import com.sevtinge.hyperceiler.utils.api.* import com.sevtinge.hyperceiler.utils.devicesdk.* import com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.* import com.sevtinge.hyperceiler.view.* @SuppressLint("DiscouragedApi", "ServiceCast", "StaticFieldLeak") object NotificationWeather : BaseHook() { - private var mWeatherView: TextView? = null - private var mWeatherViewFolme: Any? = null - private var mConstraintLayout: ConstraintLayout? = null + private var mWeatherView : TextView? = null + private var mWeatherViewFolme : Any? = null private val isDisplayCity by lazy { mPrefsMap.getBoolean("system_ui_control_center_show_weather_city") } @@ -49,7 +46,6 @@ object NotificationWeather : BaseHook() { } else { oldNotificationWeather() } - } private fun newNotificationWeather() { @@ -57,54 +53,13 @@ object NotificationWeather : BaseHook() { .single().createHook { after { param -> val headerController = param.thisObject - val notificationDateTime = - headerController.getObjectFieldAs("notificationDateTime") + val notificationDateTime = headerController.getObjectFieldAs("notificationDateTime") val context = notificationDateTime.context - val layoutParam = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ) - - layoutParam.gravity = Gravity.BOTTOM - layoutParam.marginStart = context.resources.getDimensionPixelSize( - context.resources.getIdentifier( - "notification_panel_time_date_space", - "dimen", - context.packageName - ) - ) + dp2px(5f) - - mWeatherView = WeatherView(context, isDisplayCity).apply { - setTextAppearance( - context.resources.getIdentifier( - "TextAppearance.QSControl.Date", - "style", - context.packageName - ) - ) - layoutParams = layoutParam - } - - val dateTimeParent = notificationDateTime.parent as ViewGroup - dateTimeParent.addView(mWeatherView) + addWeatherViewAfterOf(notificationDateTime) + setWeatherViewOnClinkListener(context) mWeatherView?.let { - it.setOnClickListener { - try { - val intent = Intent().apply { - flags = Intent.FLAG_ACTIVITY_NEW_TASK - component = ComponentName( - "com.miui.weather2", - "com.miui.weather2.ActivityWeatherMain" - ) - } - context.startActivity(intent) - } catch (e: Exception) { - Toast.makeText(context, "启动失败", Toast.LENGTH_LONG).show() - } - } - mWeatherViewFolme = loadClass("miuix.animation.Folme") .callStaticMethod("useAt", arrayOf(it)) } @@ -120,7 +75,6 @@ object NotificationWeather : BaseHook() { val dateTime = headerController.getObjectFieldAs("notificationDateTime") mWeatherView?.translationX = dateTime.translationX mWeatherView?.translationY = dateTime.translationY - mWeatherView?.visibility = dateTime.visibility } } @@ -137,10 +91,9 @@ object NotificationWeather : BaseHook() { .first() .createHook { after { - val dateTime = - expandController.getObjectFieldAs("headerController") - .callMethodAs("get") - .getObjectFieldAs("notificationDateTime") + val dateTime = expandController.getObjectFieldAs("headerController") + .callMethodAs("get") + .getObjectFieldAs("notificationDateTime") mWeatherView?.translationX = dateTime.translationX mWeatherView?.translationY = dateTime.translationY @@ -155,8 +108,8 @@ object NotificationWeather : BaseHook() { before { param -> val view = param.args[1] as View val context = view.context - val id = context.resources.getIdentifier("date_time", "id", context.packageName) - if (view.id == id) { + val dateTimeId = context.resources.getIdentifier("date_time", "id", context.packageName) + if (view.id == dateTimeId) { expandControllerClz.callStaticMethod( "access\$startFolmeAnimationAlpha", param.args[0], @@ -175,8 +128,8 @@ object NotificationWeather : BaseHook() { before { param -> val view = param.args[1] as View val context = view.context - val id = context.resources.getIdentifier("date_time", "id", context.packageName) - if (view.id == id) { + val dateTimeId = context.resources.getIdentifier("date_time", "id", context.packageName) + if (view.id == dateTimeId) { expandControllerClz.callStaticMethod( "access\$startFolmeAnimationTranslationX", param.args[0], @@ -198,106 +151,16 @@ object NotificationWeather : BaseHook() { val viewGroup = param.thisObject as ViewGroup val context = viewGroup.context - // MIUI编译时间大于 2022-03-12 00:00:00 且为内测版 - if (!isMoreHyperOSVersion(1f)) { - // 获取原组件 - val bigTimeId = - context.resources.getIdentifier( - "big_time", - "id", - context.packageName - ) - val bigTime: TextView = viewGroup.findViewById(bigTimeId) - - val dateTimeId = - context.resources.getIdentifier( - "date_time", - "id", - context.packageName - ) - val dateTime: TextView = viewGroup.findViewById(dateTimeId) - - // 创建新布局 - val mConstraintLayoutLp = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.WRAP_CONTENT - ).also { - it.topMargin = context.resources.getDimensionPixelSize( - context.resources.getIdentifier( - "qs_control_header_tiles_margin_top", - "dimen", - context.packageName - ) - ) - } - - mConstraintLayout = - ConstraintLayout(context).also { - it.layoutParams = mConstraintLayoutLp - } - - (bigTime.parent as ViewGroup).addView(mConstraintLayout, 0) - - - // 从原布局中删除组件 - (bigTime.parent as ViewGroup).removeView(bigTime) - (dateTime.parent as ViewGroup).removeView(dateTime) - - - // 添加组件至新布局 - mConstraintLayout!!.addView(bigTime) - mConstraintLayout!!.addView(dateTime) - - // 组件属性 - val dateTimeLp = ConstraintLayout.LayoutParams( - ConstraintLayout.LayoutParams.WRAP_CONTENT, - ConstraintLayout.LayoutParams.WRAP_CONTENT - ).also { - it.startToEnd = bigTimeId - it.bottomToBottom = 0 - it.marginStart = context.resources.getDimensionPixelSize( - context.resources.getIdentifier( - "notification_panel_time_date_space", - "dimen", - context.packageName - ) - ) - it.bottomMargin = dp2px(5f) - } - dateTime.layoutParams = dateTimeLp - - - // 创建天气组件 - mWeatherView = WeatherView(context, isDisplayCity).apply { - setTextAppearance( - context.resources.getIdentifier( - "TextAppearance.QSControl.Date", - "style", - context.packageName - ) - ) - - } - mConstraintLayout!!.addView(mWeatherView) - - val mweatherviewLp = ConstraintLayout.LayoutParams( - ConstraintLayout.LayoutParams.WRAP_CONTENT, - ConstraintLayout.LayoutParams.WRAP_CONTENT - ).also { - it.startToEnd = bigTimeId - it.bottomToTop = dateTimeId - it.marginStart = context.resources.getDimensionPixelSize( - context.resources.getIdentifier( - "notification_panel_time_date_space", - "dimen", - context.packageName - ) - ) - } - - (mWeatherView as WeatherView).layoutParams = mweatherviewLp + val dateTime = viewGroup.findViewById( + context.resources.getIdentifier( + "date_time", + "id", + context.packageName + ) + ) - } + addWeatherViewAfterOf(dateTime) + setWeatherViewOnClinkListener(context) } } @@ -308,12 +171,63 @@ object NotificationWeather : BaseHook() { val viewGroup = it.thisObject as ViewGroup val mOrientation = viewGroup.getObjectField("mOrientation") as Int - if (mOrientation == 1) { - mWeatherView!!.visibility = View.VISIBLE + mWeatherView?.visibility = if (mOrientation == 1) { + View.VISIBLE } else { - mWeatherView!!.visibility = View.GONE + View.GONE } } } } + + private fun addWeatherViewAfterOf(dateTimeView : View) { + mWeatherView = WeatherView(dateTimeView.context, isDisplayCity).apply { + setTextAppearance( + context.resources.getIdentifier( + "TextAppearance.QSControl.Date", + "style", + context.packageName + ) + ) + layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.WRAP_CONTENT + ).apply { + gravity = Gravity.BOTTOM + marginStart = context.resources.getDimensionPixelSize( + context.resources.getIdentifier( + "notification_panel_time_date_space", + "dimen", + context.packageName + ) + ) + dp2px(5f) + } + } + + val dateTimeParent = dateTimeView.parent as ViewGroup + dateTimeParent.addView(mWeatherView) + } + + private fun setWeatherViewOnClinkListener(context : Context) { + mWeatherView?.setOnClickListener { + try { + val intent = Intent().apply { + flags = Intent.FLAG_ACTIVITY_NEW_TASK + component = ComponentName( + "com.miui.weather2", + "com.miui.weather2.ActivityWeatherMain" + ) + } + + val clz = findClass(InterfacesImplManager.I_ACTIVITY_STARTER) + if (isMoreHyperOSVersion(2f)) { + InterfacesImplManager.sClassContainer[clz] + } else { + Dependency.get(clz) + }?.callMethod("startActivity", intent, true) + } catch (e : Exception) { + Toast.makeText(context, e.message, Toast.LENGTH_LONG).show() + } + } + } } diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt index 45fcbded6c..33bca672bf 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/NotificationWeatherNew.kt @@ -68,8 +68,7 @@ object NotificationWeatherNew : BaseHook() { val pluginLoaderClass = if (isAndroidVersion(34)) "com.android.systemui.shared.plugins.PluginInstance\$Factory\$\$ExternalSyntheticLambda0" - else if (isAndroidVersion(33)) "com.android.systemui.shared.plugins.PluginInstance\$Factory" - else "com.android.systemui.shared.plugins.PluginManagerImpl" + else "com.android.systemui.shared.plugins.PluginInstance\$Factory" var appInfo: ApplicationInfo? diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt index 5e11a2aa14..0a568196ca 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/DualRowSignalHookV.kt @@ -196,8 +196,7 @@ class DualRowSignalHookV : BaseHook() { if (dataSim) { val subscriptionInfo = signalController.getObjectFieldAs("mSubscriptionInfo") - val subscriptionId = - subscriptionInfo.callMethodAs("getSubscriptionId") + val subscriptionId = subscriptionInfo.callMethodAs("getSubscriptionId") val isSubIdChanged = subscriptionId != mobileInfo.subId diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobilePublicHookV.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobilePublicHookV.kt index 3b1c1ba0df..cc50e98d65 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobilePublicHookV.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobilePublicHookV.kt @@ -1,7 +1,6 @@ package com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model import android.telephony.* -import android.view.* import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.hook.systemui.* import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobileClass.miuiCellularIconVM @@ -10,8 +9,6 @@ import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.Mobi import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.hideIndicator import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.hideRoaming import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.isEnableDouble -import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.mobileNetworkType -import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.showMobileType import com.sevtinge.hyperceiler.utils.* import com.sevtinge.hyperceiler.utils.StateFlowHelper.newReadonlyStateFlow import com.sevtinge.hyperceiler.utils.StateFlowHelper.setStateFlowValue diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt index 494024b328..41076c9f6a 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/MobileTypeSingle2Hook.kt @@ -19,11 +19,11 @@ package com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model -import android.annotation.* import android.graphics.* import android.telephony.* import android.view.* import android.widget.* +import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder import com.github.kyuubiran.ezxhelper.misc.ViewUtils.findViewByIdName @@ -31,13 +31,13 @@ import com.sevtinge.hyperceiler.module.base.* import com.sevtinge.hyperceiler.module.hook.systemui.* import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobileClass.hdController import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobileClass.mOperatorConfig -import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobileClass.miuiCellularIconVM import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobileClass.modernStatusBarMobileView -import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobileClass.shadeCarrierGroupController +import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobileClass.shadeHeaderController import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.bold import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.fontSize import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.getLocation import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.hideIndicator +import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.isEnableDouble import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.leftMargin import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.mobileNetworkType import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.MobilePrefs.rightMargin @@ -46,35 +46,117 @@ import com.sevtinge.hyperceiler.module.hook.systemui.statusbar.model.public.Mobi import com.sevtinge.hyperceiler.utils.* import com.sevtinge.hyperceiler.utils.StateFlowHelper.newReadonlyStateFlow import com.sevtinge.hyperceiler.utils.devicesdk.DisplayUtils.* +import java.lang.reflect.* import java.util.function.* object MobileTypeSingle2Hook : BaseHook() { + private val DarkIconDispatcherClass by lazy { + loadClass("com.android.systemui.plugins.DarkIconDispatcher", lpparam.classLoader) + } + var method: Method? = null + var method2: Method? = null + private var get0: Float = 0.0f + private var get1: Int = 0 + private var get2: Int = 0 + private val simDataConnected = booleanArrayOf(false, false) private val mobileSignalViewMap = HashMap>() override fun init() { - // by customiuizer - hookAllConstructors(miuiCellularIconVM, object : MethodHook() { - override fun after(param: MethodHookParam) { - // 显示逻辑 - hookMobileView(param.thisObject) - } - }) + if (mobileNetworkType != 0) { + hookMobileView() + } - if (showMobileType && mobileNetworkType == 4) { - showMobileTypeSingle() + if (!showMobileType) { + return + } + + try { + method = DarkIconDispatcherClass.getMethod( + "isInAreas", + MutableCollection::class.java, + View::class.java + ) + try { + method2 = DarkIconDispatcherClass.getMethod( + "getTint", + MutableCollection::class.java, + View::class.java, + Integer.TYPE + ) + } catch (unused: Throwable) { + logE(TAG, lpparam.packageName, "DarkIconDispatcher.isInArea not found") + if (method != null) { + return + } + return + } + } catch (unused2: Throwable) { + method = null } + if (method == null || method2 == null) { + return + } + + findAndHookMethod( + "com.android.systemui.statusbar.pipeline.shared.ui.view.ModernStatusBarView", + "onDarkChanged", + ArrayList::class.java, + Float::class.java, + Integer.TYPE, + Integer.TYPE, + Integer.TYPE, + Boolean::class.java, + object : MethodHook() { + override fun after(it: MethodHookParam) { + if ("mobile" == it.thisObject.getObjectFieldAs("slot")) { + get0 = it.args[1] as Float + get1 = it.args[3] as Int + get2 = it.args[4] as Int + val num = it.args[2] as Int + val getBoolean = it.args[5] as Boolean + val getView = it.thisObject as ViewGroup + val textView: TextView = + getView.findViewByIdName("mobile_type_single") as TextView + + // 切换深色模式时请调用此逻辑,否则无法即时更新 + if ((!hideIndicator && (showMobileType || mobileNetworkType == 3)) || mobileNetworkType == 4) { + setOnDataChangedListener() + } + + if (getBoolean) { + method2?.invoke(null, it.args[0], textView, num)?.let { it1 -> + textView.setTextColor(it1.hashCode()) + } + return + } + val getBoolean2 = method?.invoke(null, it.args[0], textView)?.let { it1 -> + textView.setTextColor(num) + } as Boolean + if (getBoolean2) { + get0 = 0.0f + } + if (get0 > 0.0f) { + get1 = get2 + } + textView.setTextColor(get1) + return + } + } + }) } - private fun hookMobileView(cellularIcon: Any) { + private fun hookMobileView() { modernStatusBarMobileView.methodFinder() .filterByName("constructAndBind") + .filterByParamCount(5) .single().createHook { after { param -> + // logI(TAG, lpparam.packageName, "${param.args.contentToString()}") + val viewModel = param.args[4] val rootView = param.result as ViewGroup val subId = rootView.getIntField("subId") - val mobileGroup = - rootView.findViewByIdName("mobile_group") as LinearLayout + val mobileGroup = rootView.findViewByIdName("mobile_group") as LinearLayout val mobileGroupParent = mobileGroup.parent as ViewGroup val containerLeft = mobileGroup.findViewByIdName("mobile_container_left") as ViewGroup @@ -115,51 +197,58 @@ object MobileTypeSingle2Hook : BaseHook() { } // 调整初始样式 + val dataConnected = simDataConnected[SubscriptionManager.getSlotIndex(subId)] if (mobileNetworkType == 3 || mobileNetworkType == 4 || showMobileType) { - containerLeft.setPadding(20, 0, 0, 0) - containerRight.setPadding(20, 0, 0, 0) - } - } - } - - shadeCarrierGroupController.methodFinder() - .filterByName("updateModernMobileIcons") - .single().createHook { - after { param -> - val subList = param.args[0] as List<*> - if (subList.isEmpty()) { - return@after - } + val paddingLeft = if (dataConnected && !(showMobileType || hideIndicator)) { + 0 + } else { + 20 + } - if ((!hideIndicator && (showMobileType || mobileNetworkType == 3)) || mobileNetworkType == 4) { - dataChangedMobileType() + containerLeft.setPadding(paddingLeft, 0, 0, 0) + containerRight.setPadding(paddingLeft, 0, 0, 0) } if (showMobileType && mobileNetworkType != 4) { // 大 5G 显示逻辑 - cellularIcon.setObjectField( + viewModel.setObjectField( "mobileTypeSingleVisible", newReadonlyStateFlow(true) ) - if (mobileNetworkType == 0 || mobileNetworkType == 2) { - showWifi() - } } else if (!showMobileType) { // 小 5G 显示逻辑 - if (mobileNetworkType == 1) { - cellularIcon.setObjectField( - "mobileTypeVisible", - newReadonlyStateFlow(true) + viewModel.setObjectField( + "mobileTypeVisible", + newReadonlyStateFlow( + when (mobileNetworkType) { + 1, 2 -> true + 3 -> false + else -> dataConnected + } ) - } else if (mobileNetworkType == 3 || mobileNetworkType == 4) { - cellularIcon.setObjectField( - "mobileTypeVisible", - newReadonlyStateFlow(false) - ) - } + ) } } } + + shadeHeaderController.methodFinder() + .filterByName("onViewAttached") + .single() + .createHook { + after { + if ((!hideIndicator && (showMobileType || mobileNetworkType == 3)) || mobileNetworkType == 4) { + setOnDataChangedListener() + } + } + } + + if (showMobileType && mobileNetworkType == 4) { + showMobileTypeSingle() + } + + if (showMobileType && (mobileNetworkType == 0 || mobileNetworkType == 2)) { + setOnWiFiChangedListener() + } } private fun showMobileTypeSingle() { @@ -172,8 +261,7 @@ object MobileTypeSingle2Hook : BaseHook() { } } - @SuppressLint("NewApi") - private fun dataChangedMobileType() { + private fun setOnDataChangedListener() { val javaAdapter = Dependency.mMiuiLegacyDependency ?.getObjectField("mCentralSurfaces") ?.callMethod("get") @@ -193,18 +281,31 @@ object MobileTypeSingle2Hook : BaseHook() { dataConnected, Consumer { val simCount = it.size + logI(TAG, lpparam.packageName, "${it.contentToString()}") + val isNoDataConnected = when (simCount) { + 1 -> { + simDataConnected[0] = it[0] + !it[0] + } + + 2 -> { + simDataConnected[0] = it[0] + simDataConnected[1] = it[1] + !it[0] && !it[1] + } + else -> { + simDataConnected[0] = false + simDataConnected[1] = false + false + } + } val subId = SubscriptionManager.getDefaultDataSubscriptionId() mobileSignalViewMap[subId]?.forEach { view -> val containerLeft = view.findViewByIdName("mobile_container_left") as ViewGroup val containerRight = view.findViewByIdName("mobile_container_right") as ViewGroup - val isNoDataConnected = when (simCount) { - 1 -> !it[0] - 2 -> !it[0] && !it[1] - else -> false - } if (!showMobileType && mobileNetworkType == 4) { val mobileType = view.findViewByIdName("mobile_type") as ImageView mobileType.visibility = if (isNoDataConnected || showMobileType) { @@ -221,7 +322,7 @@ object MobileTypeSingle2Hook : BaseHook() { containerLeft.setPadding(paddingLeft, 0, 0, 0) containerRight.setPadding(paddingLeft, 0, 0, 0) } - if (mobileSignalViewMap.size == simCount) { + if (mobileSignalViewMap.size == simCount && !isEnableDouble) { mobileSignalViewMap[(mobileSignalViewMap.keys - subId).single()]?.forEach { view -> val containerLeft = view.findViewByIdName("mobile_container_left") as ViewGroup @@ -239,16 +340,7 @@ object MobileTypeSingle2Hook : BaseHook() { ) } - private fun setViewVisibility(getId: String, visibility: Int) { - mobileSignalViewMap.forEach { (_, v) -> - v.forEach { - val mMobileType = it.findViewByIdName(getId) as View - mMobileType.visibility = visibility - } - } - } - - private fun showWifi() { + private fun setOnWiFiChangedListener() { hdController.methodFinder().filterByName("update") .single().createHook { after { @@ -262,4 +354,13 @@ object MobileTypeSingle2Hook : BaseHook() { } } } + + private fun setViewVisibility(getId: String, visibility: Int) { + mobileSignalViewMap.forEach { (_, v) -> + v.forEach { + val mMobileType = it.findViewByIdName(getId) as View + mMobileType.visibility = visibility + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/public/MobileClass.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/public/MobileClass.kt index 94427216d9..c01e106023 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/public/MobileClass.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/statusbar/model/public/MobileClass.kt @@ -15,9 +15,6 @@ object MobileClass { val miuiCellularIconVM by lazy { loadClass("com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.MiuiCellularIconVM") } - val miuiCarrier by lazy { - loadClass("com.android.systemui.statusbar.policy.MiuiCarrierTextControllerImpl") - } val hdController by lazy { loadClass("com.android.systemui.statusbar.policy.HDController") } @@ -27,8 +24,8 @@ object MobileClass { val mobileSignalController by lazy { loadClass("com.android.systemui.statusbar.connectivity.MobileSignalController") } - val shadeCarrierGroupController by lazy { - loadClass("com.android.systemui.shade.carrier.ShadeCarrierGroupController") + val shadeHeaderController by lazy { + loadClass("com.android.systemui.shade.ShadeHeaderController") } val modernStatusBarMobileView by lazy { loadClass("com.android.systemui.statusbar.pipeline.mobile.ui.view.ModernStatusBarMobileView")