mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 11:21:18 +08:00
更新AndoridHooker
This commit is contained in:
@@ -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.all.MenuPage
|
||||||
import com.lt2333.simplicitytools.activity.pages.s.*
|
import com.lt2333.simplicitytools.activity.pages.s.*
|
||||||
import com.lt2333.simplicitytools.activity.pages.t.*
|
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 java.util.*
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
@@ -19,6 +22,14 @@ class MainActivity : MIUIActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
if (!checkLSPosed()) isLoad = false
|
if (!checkLSPosed()) isLoad = false
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
if (isLoad && !BuildConfig.DEBUG) {
|
||||||
|
AppCenter.start(
|
||||||
|
application,
|
||||||
|
"ae2037d3-9914-4e0c-b02b-f9b2bb2574e5",
|
||||||
|
Analytics::class.java,
|
||||||
|
Crashes::class.java
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测LSPosed是否激活
|
//检测LSPosed是否激活
|
||||||
|
|||||||
@@ -2,18 +2,23 @@ package com.lt2333.simplicitytools.hooks.apps
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
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.android.DisableFlagSecureForAll
|
||||||
import com.lt2333.simplicitytools.hooks.rules.all.corepatch.CorePatchMainHook
|
|
||||||
|
|
||||||
object AndroidHooker: YukiBaseHooker() {
|
object AndroidHooker: YukiBaseHooker() {
|
||||||
override fun onHook() {
|
override fun onHook() {
|
||||||
when (Build.VERSION.SDK_INT) {
|
when (Build.VERSION.SDK_INT) {
|
||||||
Build.VERSION_CODES.TIRAMISU -> {
|
Build.VERSION_CODES.TIRAMISU -> {
|
||||||
loadHooker(DisableFlagSecureForAll) //允许截图
|
loadHooker(DisableFlagSecureForAll) //允许截图
|
||||||
|
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
|
||||||
|
loadHooker(DeleteOnPostNotificationForAll) //上层显示
|
||||||
}
|
}
|
||||||
|
|
||||||
Build.VERSION_CODES.S -> {
|
Build.VERSION_CODES.S -> {
|
||||||
loadHooker(DisableFlagSecureForAll) //允许截图
|
loadHooker(DisableFlagSecureForAll) //允许截图
|
||||||
|
loadHooker(AllowUntrustedTouchesForAll) //允许不受信任触摸
|
||||||
|
loadHooker(DeleteOnPostNotificationForAll) //上层显示
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,17 @@ package com.lt2333.simplicitytools.hooks.apps
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
|
||||||
|
import com.lt2333.simplicitytools.hooks.rules.all.miuihome.ShortcutAddSmallWindowForAll
|
||||||
|
|
||||||
object MiuiHomeHooker: YukiBaseHooker() {
|
object MiuiHomeHooker: YukiBaseHooker() {
|
||||||
override fun onHook() {
|
override fun onHook() {
|
||||||
when (Build.VERSION.SDK_INT) {
|
when (Build.VERSION.SDK_INT) {
|
||||||
Build.VERSION_CODES.TIRAMISU -> {
|
Build.VERSION_CODES.TIRAMISU -> {
|
||||||
|
loadHooker(ShortcutAddSmallWindowForAll) //快捷方式添加小窗
|
||||||
}
|
}
|
||||||
|
|
||||||
Build.VERSION_CODES.S -> {
|
Build.VERSION_CODES.S -> {
|
||||||
|
loadHooker(ShortcutAddSmallWindowForAll) //快捷方式添加小窗
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user