From 432ec13c05a0abae0093c2cc373719e6a21d4333 Mon Sep 17 00:00:00 2001 From: LittleTurtle2333 Date: Wed, 13 Apr 2022 23:24:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=81=E8=AE=B8=E4=B8=8D?= =?UTF-8?q?=E5=8F=97=E4=BF=A1=E4=BB=BB=E7=9A=84=E8=A7=A6=E6=91=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/SettingsActivity.kt | 47 +++++++++++-------- .../simplicitytools/hook/app/Android.kt | 1 + .../hook/app/android/AllowUntrustedTouches.kt | 21 +++++++++ app/src/main/res/values/strings.xml | 5 +- 4 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 app/src/main/java/com/lt2333/simplicitytools/hook/app/android/AllowUntrustedTouches.kt diff --git a/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt b/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt index 80a95b2e..4d5fd76a 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/activity/SettingsActivity.kt @@ -390,11 +390,11 @@ class SettingsActivity : MIUIActivity() { return getSP().getBoolean("big_mobile_type_icon", false) } }) { view, flags, data -> - when (flags) { - 1 -> (view as Switch).isEnabled = data as Boolean - 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + when (flags) { + 1 -> (view as Switch).isEnabled = data as Boolean + 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + } } - } TextSummaryWithSwitch( TextSummaryV( textId = R.string.big_mobile_type_icon @@ -620,11 +620,11 @@ class SettingsActivity : MIUIActivity() { return getSP().getBoolean("status_bar_dual_row_network_speed", false) } }) { view, flags, data -> - when (flags) { - 1 -> (view as Switch).isEnabled = data as Boolean - 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + when (flags) { + 1 -> (view as Switch).isEnabled = data as Boolean + 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + } } - } TextSummaryWithSwitch( TextSummaryV( textId = R.string.status_bar_dual_row_network_speed, @@ -724,11 +724,11 @@ class SettingsActivity : MIUIActivity() { return getSP().getBoolean("notification_weather", false) } }) { view, flags, data -> - when (flags) { - 1 -> (view as Switch).isEnabled = data as Boolean - 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + when (flags) { + 1 -> (view as Switch).isEnabled = data as Boolean + 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + } } - } TextSummaryWithSwitch( TextSummaryV( textId = R.string.show_weather_main_switch, colorId = R.color.purple_700 @@ -752,11 +752,11 @@ class SettingsActivity : MIUIActivity() { return getSP().getBoolean("control_center_weather", false) } }) { view, flags, data -> - when (flags) { - 1 -> (view as Switch).isEnabled = data as Boolean - 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + when (flags) { + 1 -> (view as Switch).isEnabled = data as Boolean + 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + } } - } TextSummaryWithSwitch( TextSummaryV( textId = R.string.show_weather_main_switch, @@ -824,11 +824,11 @@ class SettingsActivity : MIUIActivity() { return getSP().getBoolean("old_qs_custom_switch", false) } }) { view, flags, data -> - when (flags) { - 1 -> (view as Switch).isEnabled = data as Boolean - 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + when (flags) { + 1 -> (view as Switch).isEnabled = data as Boolean + 2 -> view.visibility = if (data as Boolean) View.VISIBLE else View.GONE + } } - } TextSummaryWithSwitch( TextSummaryV( textId = R.string.old_qs_custom_switch, @@ -974,6 +974,13 @@ class SettingsActivity : MIUIActivity() { }.show() }) ) + TextSummaryWithSwitch( + TextSummaryV( + textId = R.string.allow_untrusted_touches, + tipsId = R.string.take_effect_after_reboot + ), + SwitchV("allow_untrusted_touches") + ) Line() TitleText(resId = R.string.sound) val mediaVolumeStepsSwitchBinding = GetDataBinding( diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/Android.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/Android.kt index eb00aac9..42bf770d 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/Android.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/Android.kt @@ -23,6 +23,7 @@ object Android : AppRegister() { RemoveSmallWindowRestrictions, //解除小窗限制 MaxWallpaperScale, //壁纸缩放比例 SystemPropertiesHook, //SystemPropertiesHook + AllowUntrustedTouches, //允许不受信任的触摸 ) } diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/AllowUntrustedTouches.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/AllowUntrustedTouches.kt new file mode 100644 index 00000000..adf4be81 --- /dev/null +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/android/AllowUntrustedTouches.kt @@ -0,0 +1,21 @@ +package com.lt2333.simplicitytools.hook.app.android + +import android.content.Context +import com.lt2333.simplicitytools.util.hasEnable +import com.lt2333.simplicitytools.util.hookBeforeMethod +import com.lt2333.simplicitytools.util.xposed.base.HookRegister + +object AllowUntrustedTouches : HookRegister() { + + override fun init() { + hasEnable("allow_untrusted_touches") { + "android.hardware.input.InputManager".hookBeforeMethod( + getDefaultClassLoader(), + "getBlockUntrustedTouchesMode", + Context::class.java + ) { + it.result = 0 + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 811580a8..89111aca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -215,5 +215,8 @@ Rear Display (11Ultra) Clock display seconds Sound - Media volume steps (Take effect after reboot) + Media volume steps + Allow untrusted touches + Take effect after reboot + Turning on may cause the scrolling of the volume bar to freeze or the Bluetooth volume to be abnormal