From 40c24cbb4080e517e97b965c68e65b160de3577d Mon Sep 17 00:00:00 2001
From: QQ little ice <60041789+qqlittleice233@users.noreply.github.com>
Date: Sun, 12 Feb 2023 20:34:38 +0800
Subject: [PATCH] Disable installation's count checking (#216)
Disable installation's count checking
---
.../activity/pages/all/MenuPage.kt | 1 +
.../activity/pages/s/OtherPageForS.kt | 6 +++++
.../activity/pages/t/OtherPageForT.kt | 6 +++++
.../lt2333/simplicitytools/hooks/MainHook.kt | 1 +
.../hooks/apps/PackageInstaller.kt | 24 +++++++++++++++++++
app/src/main/res/values-zh-rCN/strings.xml | 2 ++
app/src/main/res/values-zh-rHK/strings.xml | 2 ++
app/src/main/res/values-zh-rTW/strings.xml | 2 ++
app/src/main/res/values/arrays.xml | 1 +
app/src/main/res/values/strings.xml | 2 ++
10 files changed, 47 insertions(+)
create mode 100644 app/src/main/java/com/lt2333/simplicitytools/hooks/apps/PackageInstaller.kt
diff --git a/app/src/main/java/com/lt2333/simplicitytools/activity/pages/all/MenuPage.kt b/app/src/main/java/com/lt2333/simplicitytools/activity/pages/all/MenuPage.kt
index 305c2d1f..764ffadc 100644
--- a/app/src/main/java/com/lt2333/simplicitytools/activity/pages/all/MenuPage.kt
+++ b/app/src/main/java/com/lt2333/simplicitytools/activity/pages/all/MenuPage.kt
@@ -47,6 +47,7 @@ class MenuPage : BasePage() {
"killall com.miui.screenshot",
"killall com.milink.service",
"killall com.xiaomi.misubscreenui",
+ "killall com.miui.packageinstaller"
)
ShellUtils.execCommand(command, true)
dismiss()
diff --git a/app/src/main/java/com/lt2333/simplicitytools/activity/pages/s/OtherPageForS.kt b/app/src/main/java/com/lt2333/simplicitytools/activity/pages/s/OtherPageForS.kt
index 359dbb36..1a6eb9ac 100644
--- a/app/src/main/java/com/lt2333/simplicitytools/activity/pages/s/OtherPageForS.kt
+++ b/app/src/main/java/com/lt2333/simplicitytools/activity/pages/s/OtherPageForS.kt
@@ -172,6 +172,12 @@ class OtherPageForS : BasePage() {
TextSummaryV(textId = R.string.remove_thememanager_ads),
SwitchV("remove_thememanager_ads")
)
+ Line()
+ TitleText(textId = R.string.pkg_installer)
+ TextSummaryWithSwitch(
+ TextSummaryV(textId = R.string.pkg_installer_summary),
+ SwitchV("pkg_installer_count_checking")
+ )
}
}
diff --git a/app/src/main/java/com/lt2333/simplicitytools/activity/pages/t/OtherPageForT.kt b/app/src/main/java/com/lt2333/simplicitytools/activity/pages/t/OtherPageForT.kt
index 55c349b2..5634a5de 100644
--- a/app/src/main/java/com/lt2333/simplicitytools/activity/pages/t/OtherPageForT.kt
+++ b/app/src/main/java/com/lt2333/simplicitytools/activity/pages/t/OtherPageForT.kt
@@ -172,6 +172,12 @@ class OtherPageForT : BasePage() {
TextSummaryV(textId = R.string.remove_thememanager_ads),
SwitchV("remove_thememanager_ads")
)
+ Line()
+ TitleText(textId = R.string.pkg_installer)
+ TextSummaryWithSwitch(
+ TextSummaryV(textId = R.string.pkg_installer_summary),
+ SwitchV("pkg_installer_count_checking")
+ )
}
}
diff --git a/app/src/main/java/com/lt2333/simplicitytools/hooks/MainHook.kt b/app/src/main/java/com/lt2333/simplicitytools/hooks/MainHook.kt
index 137acb76..39e5e932 100644
--- a/app/src/main/java/com/lt2333/simplicitytools/hooks/MainHook.kt
+++ b/app/src/main/java/com/lt2333/simplicitytools/hooks/MainHook.kt
@@ -25,6 +25,7 @@ class MainHook : EasyXposedInit() {
ScreenShot, // 截屏
Cast, //投屏
RearDisplay, //背屏
+ PackageInstaller, // 应用包管理组件
)
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
diff --git a/app/src/main/java/com/lt2333/simplicitytools/hooks/apps/PackageInstaller.kt b/app/src/main/java/com/lt2333/simplicitytools/hooks/apps/PackageInstaller.kt
new file mode 100644
index 00000000..64e45cc6
--- /dev/null
+++ b/app/src/main/java/com/lt2333/simplicitytools/hooks/apps/PackageInstaller.kt
@@ -0,0 +1,24 @@
+package com.lt2333.simplicitytools.hooks.apps
+
+import com.github.kyuubiran.ezxhelper.utils.findMethod
+import com.github.kyuubiran.ezxhelper.utils.hookBefore
+import com.lt2333.simplicitytools.utils.hasEnable
+import com.lt2333.simplicitytools.utils.xposed.base.AppRegister
+import de.robv.android.xposed.XposedBridge
+import de.robv.android.xposed.callbacks.XC_LoadPackage
+
+object PackageInstaller: AppRegister() {
+
+ override val packageName: String = "com.miui.packageinstaller"
+
+ override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
+ hasEnable("pkg_installer_count_checking") {
+ findMethod("com.miui.packageInstaller.model.RiskControlRules") {
+ name == "getCurrentLevel"
+ }.hookBefore { param ->
+ XposedBridge.log("Hooked getCurrentLevel, param result = ${param.result}")
+ param.result = 0
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 98045a61..b27c0b36 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -233,4 +233,6 @@
允许 Millet 在后台应用有通知、有服务运行、有进程运行的情况下冻结应用。\n不希望被冻结的应用可将省电策略设置为无限制\n启用前请先卸载墓碑和 NoANR 相关模块。
允许 Millet 冻结活跃的应用
非常激进,可能会影响应用运行
+ 应用包管理组件
+ 禁用频繁安装应用检查
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index f6440a9e..b9e184b8 100644
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -156,4 +156,6 @@
隱藏 勿擾 圖標
隱藏圖標
雙擊鎖定螢幕
+ 應用包管理組件
+ 禁用頻繁安裝應用檢查
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 747d39aa..2cbeb4fb 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -224,4 +224,6 @@
關閉
置中
左右
+ 應用包管理組件
+ 禁用頻繁安裝應用檢查
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 71af9095..385dfa2e 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -13,5 +13,6 @@
- com.miui.screenshot
- com.milink.service
- com.xiaomi.misubscreenui
+ - com.miui.packageinstaller
\ 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 c0d13b9c..43c1fc21 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -237,4 +237,6 @@
Allows Millet to freeze apps while background apps have notifications, services running, and processes running.\nApps that don\'t want to be frozen can set Battery saver to No restriction\nPlease uninstall tombstone and NoANR related modules before enabling.
Allow Millet to freeze active apps
Very aggressive and may affect application running
+ Package Installer
+ Disable the app installation\'s count checking