Skip to content

Commit

Permalink
一些log优化
Browse files Browse the repository at this point in the history
  • Loading branch information
hosizoraru committed May 18, 2023
1 parent 84ed571 commit 9922ee9
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ class AppManagerPage : BasePage() {
TextSummaryV(textId = R.string.Disable_Safe_Model_Tip),
SwitchV("Disable_Safe_Model_Tip")
)
// TextSummaryWithSwitch(
// TextSummaryV(textId = R.string.package_installer_allow_update_system_app),
// SwitchV("package_installer_allow_update_system_app")
// )
TextSummaryWithSwitch(
TextSummaryV(
textId = R.string.package_installer_allow_update_system_app,
tipsId = R.string.already_can_not_use
),
SwitchV("package_installer_allow_update_system_app")
)
TextSummaryWithSwitch(
TextSummaryV(textId = R.string.package_installer_show_more_apk_info),
SwitchV("package_installer_show_more_apk_info")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package star.sky.voyager.hook.apps

import de.robv.android.xposed.callbacks.XC_LoadPackage
import star.sky.voyager.hook.hooks.packageinstaller.AllowUpdateSystemApp
import star.sky.voyager.hook.hooks.packageinstaller.DisableCountCheck
import star.sky.voyager.hook.hooks.packageinstaller.DisableSafeModelTip
import star.sky.voyager.hook.hooks.packageinstaller.RemovePackageInstallerAds
Expand All @@ -16,7 +17,7 @@ object PackageInstaller : AppRegister() {
DisableCountCheck, // 禁用频繁安装应用检查
RemovePackageInstallerAds, // 去广告
DisableSafeModelTip, // // 禁用安全守护提示
// AllowUpdateSystemApp, // 允许更新系统应用
AllowUpdateSystemApp, // 允许更新系统应用
ShowMoreApkInfo, // 显示更多应用信息
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.github.kyuubiran.ezxhelper.ClassUtils.loadClassOrNull
import com.github.kyuubiran.ezxhelper.EzXHelper
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.Log
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import star.sky.voyager.utils.api.hookBeforeMethod
import star.sky.voyager.utils.init.HookRegister
import star.sky.voyager.utils.key.hasEnable
Expand All @@ -25,20 +24,28 @@ object AllowUpdateSystemApp : HookRegister() {
}

var letter = 'a'
var foundMethod = false // 标志变量
for (i in 0..25) {
val classIfExists = loadClassOrNull("j2.${letter}")
classIfExists?.let {
if (it.declaredMethods.size in 15..25) {
it.methodFinder().first {
parameterTypes[0] == ApplicationInfo::class.java
}.createHook {
before { hookParam ->
hookParam.result = false
val qwq = classIfExists.declaredMethods.toList()
for (qaq in qwq) {
if (qaq.parameterTypes[0] == ApplicationInfo::class.java) {
qaq.createHook {
before { param ->
param.result = false
}
}
foundMethod = true // 找到匹配的方法并创建了钩子
break
}
}
}
}
Log.i(letter.toString() + classIfExists.toString())
if (foundMethod) {
break // 跳出外部循环
}
letter++
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package star.sky.voyager.hook.hooks.packageinstaller

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.FieldFinder.`-Static`.fieldFinder
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
Expand All @@ -9,31 +9,38 @@ import star.sky.voyager.utils.key.hasEnable

object DisableSafeModelTip : HookRegister() {
override fun init() = hasEnable("Disable_Safe_Model_Tip") {
loadClass("com.miui.packageInstaller.model.ApkInfo").methodFinder().first {
name == "getSystemApp"
}.createHook {
returnConstant(true)
}
loadClass("com.miui.packageInstaller.InstallProgressActivity").methodFinder().first {
name == "g0"
}.createHook {
returnConstant(false)
}
loadClass("com.miui.packageInstaller.InstallProgressActivity").methodFinder().first {
name == "Q1"
}.createHook {
before {
it.result = null
}
}
loadClass("com.miui.packageInstaller.InstallProgressActivity").methodFinder().first {
true
}.createHook {
after { param ->
param.thisObject.javaClass.fieldFinder().first {
type == Boolean::class.java
}.setBoolean(param.thisObject, false)
try {
loadClassOrNull("com.miui.packageInstaller.model.ApkInfo")?.methodFinder()?.first {
name == "getSystemApp"
}?.createHook {
returnConstant(true)
}
loadClassOrNull("com.miui.packageInstaller.InstallProgressActivity")?.methodFinder()
?.first {
name == "g0"
}?.createHook {
returnConstant(false)
}
loadClassOrNull("com.miui.packageInstaller.InstallProgressActivity")?.methodFinder()
?.first {
name == "Q1"
}?.createHook {
before {
it.result = null
}
}
loadClassOrNull("com.miui.packageInstaller.InstallProgressActivity")?.methodFinder()
?.first {
true
}?.createHook {
after { param ->
param.thisObject.javaClass.fieldFinder().first {
type == Boolean::class.java
}.setBoolean(param.thisObject, false)
}
}
} catch (_: Throwable) {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package star.sky.voyager.hook.hooks.packageinstaller

import android.content.Context
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClassOrNull
import com.github.kyuubiran.ezxhelper.EzXHelper
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.MemberExtensions.paramCount
Expand Down Expand Up @@ -30,11 +31,11 @@ object RemovePackageInstallerAds : HookRegister() {
}
}
val qaq = listOf("s", "q", "f", "t", "r")
loadClass("m2.b").methodFinder().apply {
loadClassOrNull("m2.b")?.methodFinder().apply {
qaq.forEach { qaq ->
first {
this?.first {
name == qaq
}.createHook {
}?.createHook {
returnConstant(false)
}
}
Expand Down

0 comments on commit 9922ee9

Please sign in to comment.