-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8b9253
commit 2f1c2f7
Showing
7 changed files
with
157 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 16 additions & 20 deletions
36
...src/main/kotlin/star/sky/voyager/hook/hooks/packageinstaller/RemovePackageInstallerAds.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
package star.sky.voyager.hook.hooks.packageinstaller | ||
|
||
import android.view.View | ||
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClassOrNull | ||
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook | ||
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks | ||
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder | ||
import star.sky.voyager.utils.api.setBooleanField | ||
import star.sky.voyager.utils.api.callMethodOrNullAs | ||
import star.sky.voyager.utils.init.HookRegister | ||
import star.sky.voyager.utils.key.hasEnable | ||
|
||
object RemovePackageInstallerAds : HookRegister() { | ||
override fun init() = hasEnable("package_installer_remove_ads") { | ||
val miuiSettingsCompatClass = | ||
loadClassOrNull("com.android.packageinstaller.compat.MiuiSettingsCompat")!! | ||
loadClassOrNull("com.android.packageinstaller.compat.MiuiSettingsCompat") | ||
val mSafeModeTipViewObjectCls = | ||
loadClassOrNull("com.miui.packageInstaller.ui.listcomponets.SafeModeTipViewObject") | ||
val mSafeModeTipViewObjectViewHolderCls = | ||
loadClassOrNull("com.miui.packageInstaller.ui.listcomponets.SafeModeTipViewObject\$ViewHolder") | ||
|
||
runCatching { | ||
miuiSettingsCompatClass.methodFinder() | ||
miuiSettingsCompatClass!!.methodFinder() | ||
.filterByName("isPersonalizedAdEnabled") | ||
.filterByReturnType(Boolean::class.java) | ||
.toList().createHooks { | ||
before { | ||
it.result = false | ||
} | ||
returnConstant(false) | ||
} | ||
} | ||
|
||
var letter = 'a' | ||
for (i in 0..25) { | ||
try { | ||
val classIfExists = | ||
loadClassOrNull("com.miui.packageInstaller.ui.listcomponets.${letter}0") | ||
classIfExists?.let { | ||
it.methodFinder().filterByName("a").first().createHook { | ||
after { hookParam -> | ||
hookParam.thisObject.setBooleanField("l", false) | ||
} | ||
runCatching { | ||
mSafeModeTipViewObjectCls!!.methodFinder() | ||
.filterByParamTypes(mSafeModeTipViewObjectViewHolderCls) | ||
.toList().createHooks { | ||
after { | ||
it.args[0].callMethodOrNullAs<View>("getClContentView")?.visibility = | ||
View.GONE | ||
} | ||
} | ||
} catch (t: Throwable) { | ||
letter++ | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.