Compare commits

2 Commits

Author SHA1 Message Date
LittleTurtle2333
23832a4e0d 更新10个系统界面Hooker 2023-02-24 05:12:45 +08:00
LittleTurtle2333
582af167ed 更新AndoridHooker 2023-02-24 01:32:59 +08:00
16 changed files with 648 additions and 1 deletions

View File

@@ -11,6 +11,9 @@ import com.lt2333.simplicitytools.activity.pages.all.AboutPage
import com.lt2333.simplicitytools.activity.pages.all.MenuPage
import com.lt2333.simplicitytools.activity.pages.s.*
import com.lt2333.simplicitytools.activity.pages.t.*
import com.microsoft.appcenter.AppCenter
import com.microsoft.appcenter.analytics.Analytics
import com.microsoft.appcenter.crashes.Crashes
import java.util.*
import kotlin.system.exitProcess
@@ -19,6 +22,14 @@ class MainActivity : MIUIActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
if (!checkLSPosed()) isLoad = false
super.onCreate(savedInstanceState)
if (isLoad && !BuildConfig.DEBUG) {
AppCenter.start(
application,
"ae2037d3-9914-4e0c-b02b-f9b2bb2574e5",
Analytics::class.java,
Crashes::class.java
)
}
}
//检测LSPosed是否激活

View File

@@ -2,18 +2,23 @@ package com.lt2333.simplicitytools.hooks.apps
import android.os.Build
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.hooks.rules.all.android.AllowUntrustedTouchesForAll
import com.lt2333.simplicitytools.hooks.rules.all.android.DeleteOnPostNotificationForAll
import com.lt2333.simplicitytools.hooks.rules.all.android.DisableFlagSecureForAll
import com.lt2333.simplicitytools.hooks.rules.all.corepatch.CorePatchMainHook
object AndroidHooker: YukiBaseHooker() {
override fun onHook() {
when (Build.VERSION.SDK_INT) {
Build.VERSION_CODES.TIRAMISU -> {
loadHooker(DisableFlagSecureForAll) //允许截图
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
loadHooker(DeleteOnPostNotificationForAll) //上层显示
}
Build.VERSION_CODES.S -> {
loadHooker(DisableFlagSecureForAll) //允许截图
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
loadHooker(DeleteOnPostNotificationForAll) //上层显示
}
}
}

View File

@@ -2,14 +2,17 @@ package com.lt2333.simplicitytools.hooks.apps
import android.os.Build
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.hooks.rules.all.miuihome.ShortcutAddSmallWindowForAll
object MiuiHomeHooker: YukiBaseHooker() {
override fun onHook() {
when (Build.VERSION.SDK_INT) {
Build.VERSION_CODES.TIRAMISU -> {
loadHooker(ShortcutAddSmallWindowForAll) //快捷方式添加小窗
}
Build.VERSION_CODES.S -> {
loadHooker(ShortcutAddSmallWindowForAll) //快捷方式添加小窗
}
}
}

View File

@@ -0,0 +1,19 @@
package com.lt2333.simplicitytools.hooks.rules.all.android
import android.content.Context
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.utils.hasEnable
object AllowUntrustedTouchesForAll : YukiBaseHooker() {
override fun onHook() = hasEnable("allow_untrusted_touches") {
"android.hardware.input.InputManager".hook {
injectMember {
method {
name = "getBlockUntrustedTouchesMode"
param(Context::class.java)
}
replaceTo(0)
}
}
}
}

View File

@@ -0,0 +1,19 @@
package com.lt2333.simplicitytools.hooks.rules.all.android
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.utils.hasEnable
object DeleteOnPostNotificationForAll: YukiBaseHooker() {
override fun onHook() {
"com.android.server.wm.AlertWindowNotification".hook {
injectMember {
method { name = "onPostNotification" }
beforeHook {
hasEnable("delete_on_post_notification") {
this.result = null
}
}
}
}
}
}

View File

@@ -0,0 +1,137 @@
package com.lt2333.simplicitytools.hooks.rules.all.miuihome
import android.app.AndroidAppHelper
import android.content.ComponentName
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.view.View
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.factory.field
import com.highcapable.yukihookapi.hook.factory.toClass
import com.lt2333.simplicitytools.R
import com.lt2333.simplicitytools.utils.hasEnable
import de.robv.android.xposed.XposedHelpers
object ShortcutAddSmallWindowForAll : YukiBaseHooker() {
override fun onHook() = hasEnable("miuihome_shortcut_add_small_window") {
val mViewDarkModeHelper = "com.miui.home.launcher.util.ViewDarkModeHelper".toClass()
val mSystemShortcutMenu = "com.miui.home.launcher.shortcuts.SystemShortcutMenu".toClass()
val mSystemShortcutMenuItem = "com.miui.home.launcher.shortcuts.SystemShortcutMenuItem".toClass()
val mAppShortcutMenu = "com.miui.home.launcher.shortcuts.AppShortcutMenu".toClass()
val mShortcutMenuItem = "com.miui.home.launcher.shortcuts.ShortcutMenuItem".toClass()
val mAppDetailsShortcutMenuItem = "com.miui.home.launcher.shortcuts.SystemShortcutMenuItem\$AppDetailsShortcutMenuItem".toClass()
val mActivityUtilsCompat = "com.miui.launcher.utils.ActivityUtilsCompat".toClass()
mViewDarkModeHelper.hook {
injectMember {
method { name = "onConfigurationChanged" }.all()
afterHook {
mSystemShortcutMenuItem.current {
method { name = "createAllSystemShortcutMenuItems" }.call()
}
}
}
}
mShortcutMenuItem.hook {
injectMember {
method { name = "getShortTitle" }
afterHook {
if (this.result == "应用信息") {
this.result = "信息"
}
}
}
}
mAppDetailsShortcutMenuItem.hook {
injectMember {
method {
name = "lambda\$getOnClickListener$0"
paramCount = 2
}
beforeHook {
val obj = this.args[0]
val view: View = this.args[1] as View
val mShortTitle = obj?.current {
method { name = "getShortTitle" }.invoke<CharSequence>()
}
if (mShortTitle == moduleAppResources.getString(R.string.miuihome_shortcut_add_small_window_title)) {
this.result = null
val intent = Intent()
val mComponentName = obj.current {
method { name = "getComponentName" }.call()
} as ComponentName
intent.action = "android.intent.action.MAIN"
intent.addCategory("android.intent.category.LAUNCHER")
intent.component = mComponentName
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val callStaticMethod = mActivityUtilsCompat.current {
method {
name = "makeFreeformActivityOptions"
paramCount = 2
}.call(
view.context, mComponentName.packageName
)
}
if (callStaticMethod != null) {
view.context.startActivity(intent, callStaticMethod.current {
method { name = "toBundle" }.call()
} as Bundle)
}
}
}
}
}
mSystemShortcutMenu.hook {
injectMember {
method {
name = "getMaxShortcutItemCount"
}.all()
afterHook {
this.result = 5
}
}
}
mAppShortcutMenu.hook {
injectMember {
method {
name = "getMaxShortcutItemCount"
}.all()
afterHook {
this.result = 5
}
}
}
mSystemShortcutMenuItem.hook {
injectMember {
method { name = "createAllSystemShortcutMenuItems" }.all()
afterHook {
val isDarkMode =
AndroidAppHelper.currentApplication().applicationContext.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
val mAllSystemShortcutMenuItems = mSystemShortcutMenuItem.field {
name = "sAllSystemShortcutMenuItems"
}.get().cast<Collection<Any>>()
val mSmallWindowInstance = mAppDetailsShortcutMenuItem.newInstance()
mSmallWindowInstance.current {
method {
name = "setShortTitle"
}.call(moduleAppResources.getString(R.string.miuihome_shortcut_add_small_window_title))
}
mSmallWindowInstance.current {
method {
name = "setIconDrawable"
}.call(if (isDarkMode) moduleAppResources.getDrawable(R.drawable.ic_small_window_dark) else moduleAppResources.getDrawable(R.drawable.ic_small_window_light))
}
val sAllSystemShortcutMenuItems = ArrayList<Any>()
sAllSystemShortcutMenuItems.add(mSmallWindowInstance)
mAllSystemShortcutMenuItems?.let { sAllSystemShortcutMenuItems.addAll(it) }
mSystemShortcutMenuItem.field { name = "sAllSystemShortcutMenuItems" }.get().set(sAllSystemShortcutMenuItems)
}
}
}
}
}

View File

@@ -0,0 +1,50 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.hasEnable
object HideBatteryIconForT : YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.views.MiuiBatteryMeterView".hook {
injectMember {
method { name = "updateResources" }
afterHook {
//隐藏电池图标
hasEnable("hide_battery_icon") {
instance.current().field { name = "mBatteryStyle" }.cast<ImageView>()?.visibility = View.GONE
if (instance.current().field { name = "mBatteryStyle" }.int() == 1) {
instance.current().field { name = "mBatteryDigitalView" }.cast<FrameLayout>()?.visibility = View.GONE
}
}
//隐藏电池内的百分比
hasEnable("hide_battery_percentage_icon") {
instance.current().field { name = "mBatteryPercentMarkView" }.cast<TextView>()?.textSize=0F
}
"com.android.systemui.statusbar.views.MiuiBatteryMeterView".hook {
injectMember {
method {
name = "updateChargeAndText"
}
afterHook {
//隐藏电池充电图标
hasEnable("hide_battery_charging_icon") {
instance.current().field { name = "mBatteryChargingInView" }.cast<ImageView>()?.visibility = View.GONE
instance.current().field { name = "mBatteryChargingView" }.cast<ImageView>()?.visibility = View.GONE
}
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,54 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.view.View
import android.widget.ImageView
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.param.HookParam
import com.lt2333.simplicitytools.utils.hasEnable
object HideHDIconForT : YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.StatusBarMobileView".hook {
injectMember {
method {
name = "initViewState"
paramCount = 1
}
afterHook {
hide(this)
}
}
injectMember {
method {
name = "updateState"
paramCount = 1
}
afterHook {
hide(this)
}
}
}
hasEnable("hide_new_hd_icon") {
"com.android.systemui.statusbar.policy.HDController".hook {
injectMember {
method { name = "update" }
beforeHook {
this.result = null
}
}
}
}
}
private fun hide(it: HookParam) {
hasEnable("hide_big_hd_icon") {
it.instance.current().field {name = "mVolte" }.cast<ImageView>()?.visibility = View.GONE
}
hasEnable("hide_small_hd_icon") {
it.instance.current().field {name = "mSmallHd" }.cast<ImageView>()?.visibility = View.GONE
}
hasEnable("hide_hd_no_service_icon") {
it.instance.current().field {name = "mVolteNoService" }.cast<ImageView>()?.visibility = View.GONE
}
}
}

View File

@@ -0,0 +1,43 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.view.View
import android.widget.ImageView
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.param.HookParam
import com.lt2333.simplicitytools.utils.hasEnable
object HideMobileActivityIconForT : YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.StatusBarMobileView".hook {
injectMember {
method {
name = "initViewState"
paramCount = 1
}
afterHook {
hide(this)
}
}
}
"com.android.systemui.statusbar.StatusBarMobileView".hook {
injectMember {
method {
name = "updateState"
paramCount = 1
}
afterHook {
hide(this)
}
}
}
}
private fun hide(it: HookParam) {
hasEnable("hide_mobile_activity_icon") {
it.instance.current().field { name = "mLeftInOut" }.cast<ImageView>()?.visibility = View.GONE
it.instance.current().field { name = "mRightInOut" }.cast<ImageView>()?.visibility = View.GONE
}
}
}

View File

@@ -0,0 +1,54 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.view.View
import android.widget.ImageView
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.param.HookParam
import com.lt2333.simplicitytools.utils.XSPUtils
import com.lt2333.simplicitytools.utils.hasEnable
object HideMobileTypeIconForT : YukiBaseHooker() {
private val isBigType = XSPUtils.getBoolean("big_mobile_type_icon", false)
override fun onHook() {
"com.android.systemui.statusbar.StatusBarMobileView".hook {
injectMember {
method {
name = "initViewState"
paramCount = 1
}
afterHook {
hideMobileTypeIcon(this)
}
}
}
"com.android.systemui.statusbar.StatusBarMobileView".hook {
injectMember {
method {
name = "updateState"
paramCount = 1
}
afterHook {
hideMobileTypeIcon(this)
}
}
}
}
private fun hideMobileTypeIcon(it: HookParam) {
hasEnable("hide_mobile_type_icon") {
if (isBigType) {
it.instance.current().field { name = "mMobileType" }.cast<ImageView>()?.visibility = View.GONE
it.instance.current().field { name = "mMobileTypeImage" }.cast<ImageView>()?.visibility = View.GONE
it.instance.current().field { name = "mMobileTypeSingle" }.cast<ImageView>()?.visibility = View.GONE
} else {
it.instance.current().field { name = "mMobileType" }.cast<ImageView>()?.visibility = View.INVISIBLE
it.instance.current().field { name = "mMobileTypeImage" }.cast<ImageView>()?.visibility = View.INVISIBLE
it.instance.current().field { name = "mMobileTypeSingle" }.cast<ImageView>()?.visibility = View.INVISIBLE
}
}
}
}

View File

@@ -0,0 +1,28 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.utils.hasEnable
object HideSimIconForT:YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy".hook {
injectMember {
method {
name = "hasCorrectSubs"
param(MutableList::class.java)
}
beforeHook {
val list = this.args[0] as MutableList<*>
val size = list.size
hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) {
list.removeAt(1)
}
hasEnable("hide_sim_one_icon", extraCondition = { size >= 1 }) {
list.removeAt(0)
}
}
}
}
}
}

View File

@@ -0,0 +1,94 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.param.HookParam
import com.lt2333.simplicitytools.utils.hasEnable
object HideStatusBarIconForT : YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.phone.StatusBarIconControllerImpl".hook {
injectMember {
method {
name = "setIconVisibility"
paramCount = 2
}
beforeHook {
hideIcon(this)
}
}
}
"com.android.systemui.statusbar.phone.MiuiDripLeftStatusBarIconControllerImpl".hook {
injectMember {
method {
name = "setIconVisibility"
paramCount = 2
}
beforeHook {
hideIcon(this)
}
}
}
}
private fun hideIcon(it: HookParam) {
//Log.d("图标名字", "handleLoadPackage: " + it.args[0])
when (it.args[0] as String) {
//隐藏蓝牙
"bluetooth" -> hasEnable("hide_bluetooth_icon") {
it.args[1] = false
}
//隐藏蓝牙电量
"bluetooth_handsfree_battery" -> hasEnable("hide_bluetooth_battery_icon") {
it.args[1] = false
}
//隐藏勿扰
"zen" -> hasEnable("hide_zen_icon") {
it.args[1] = false
}
//隐藏声音
"volume" -> hasEnable("hide_volume_icon") {
it.args[1] = false
}
//隐藏WIFI
"wifi" -> hasEnable("hide_wifi_icon") {
it.args[1] = false
}
//隐藏WIFI辅助
"slave_wifi" -> hasEnable("hide_slave_wifi_icon") {
it.args[1] = false
}
//隐藏飞行模式
"airplane" -> hasEnable("hide_airplane_icon") {
it.args[1] = false
}
//隐藏闹钟
"alarm_clock" -> hasEnable("hide_alarm_icon") {
it.args[1] = false
}
//隐藏定位
"location" -> hasEnable("hide_gps_icon") {
it.args[1] = false
}
//隐藏热点
"hotspot" -> hasEnable("hide_hotspot_icon") {
it.args[1] = false
}
//隐藏耳机
"headset" -> hasEnable("hide_headset_icon") {
it.args[1] = false
}
//隐藏VPN
"vpn" -> hasEnable("hide_vpn_icon") {
it.args[1] = false
}
//隐藏无SIM卡
"no_sim" -> hasEnable("hide_no_sim_icon") {
it.args[1] = false
}
//隐藏NFC图标
"nfc" -> hasEnable("hide_nfc_icon") {
it.args[1] = false
}
}
}
}

View File

@@ -0,0 +1,29 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.utils.hasEnable
object HideStatusBarNetworkSpeedSecondForT : YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.views.NetworkSpeedView".hook {
injectMember {
method {
name = "setNetworkSpeed"
paramCount = 1
}
beforeHook {
hasEnable("hide_status_bar_network_speed_second") {
if (this.args[0] != null) {
val mText = (this.args[0] as String)
.replace("/", "")
.replace("s", "")
.replace("\'", "")
.replace("วิ", "")
this.args[0] = mText
}
}
}
}
}
}
}

View File

@@ -0,0 +1,46 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.highcapable.yukihookapi.hook.param.HookParam
import com.lt2333.simplicitytools.utils.hasEnable
object HideWifiActivityIconForT: YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.StatusBarWifiView".hook {
injectMember {
method {
name = "initViewState"
paramCount = 1
}
afterHook {
hide(this)
}
}
}
"com.android.systemui.statusbar.StatusBarWifiView".hook {
injectMember {
method {
name = "updateState"
paramCount = 1
}
afterHook {
hide(this)
}
}
}
}
private fun hide(it: HookParam) {
//隐藏WIFI箭头
hasEnable("hide_wifi_activity_icon") {
it.instance.current().field { name = "mWifiActivityView" }.cast<ImageView>()?.visibility = View.INVISIBLE
}
//隐藏WIFI标准图标
hasEnable("hide_wifi_standard_icon") {
it.instance.current().field { name = "mWifiStandardView" }.cast<TextView>()?.visibility = View.INVISIBLE
}
}
}

View File

@@ -0,0 +1,33 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.factory.current
import com.lt2333.simplicitytools.utils.XSPUtils
import java.lang.reflect.Method
object MaximumNumberOfNotificationIconsForT: YukiBaseHooker() {
override fun onHook() {
val icons = XSPUtils.getInt("maximum_number_of_notification_icons", 3)
val dots = XSPUtils.getInt("maximum_number_of_notification_dots", 3)
"com.android.systemui.statusbar.phone.NotificationIconContainer".hook {
injectMember {
method {
name = "miuiShowNotificationIcons"
paramCount = 1
}
replaceUnit {
if (this.args[0] as Boolean) {
instance.current().field { name = "MAX_DOTS" }.set(dots)
instance.current().field { name = "MAX_STATIC_ICONS" }.set(icons)
instance.current().field { name = "MAX_VISIBLE_ICONS_ON_LOCK" }.set(icons)
} else {
instance.current().field { name = "MAX_DOTS" }.set(0)
instance.current().field { name = "MAX_STATIC_ICONS" }.set(0)
instance.current().field { name = "MAX_VISIBLE_ICONS_ON_LOCK" }.set(0)
}
instance.current().method { name = "updateState" }.call()
}
}
}
}
}

View File

@@ -0,0 +1,22 @@
package com.lt2333.simplicitytools.hooks.rules.t.systemui
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.lt2333.simplicitytools.utils.hasEnable
object StatusBarNetworkSpeedRefreshSpeedForT : YukiBaseHooker() {
override fun onHook() {
"com.android.systemui.statusbar.policy.NetworkSpeedController".hook {
injectMember {
method {
name = "postUpdateNetworkSpeedDelay"
param { it[0] == Long::class.java }
}
beforeHook {
hasEnable("status_bar_network_speed_refresh_speed") {
this.args[0] = 1000L
}
}
}
}
}
}