mirror of
https://github.com/LittleTurtle2333/SimplicityTools.git
synced 2026-07-12 11:21:18 +08:00
@@ -57,12 +57,15 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
|
||||
// implementation("androidx.constraintlayout:constraintlayout:2.1.3")
|
||||
//API
|
||||
compileOnly("de.robv.android.xposed:api:82")
|
||||
//UI
|
||||
implementation(project(":blockmiui"))
|
||||
|
||||
val appCenterSdkVersion = "4.3.1"
|
||||
implementation("com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}")
|
||||
implementation("com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}")
|
||||
|
||||
implementation("com.github.kyuubiran:EzXHelper:0.7.4")
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.lt2333.simplicitytools.hook
|
||||
|
||||
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
|
||||
import com.lt2333.simplicitytools.BuildConfig
|
||||
import com.lt2333.simplicitytools.hook.app.*
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
@@ -10,6 +11,8 @@ class MainHook : IXposedHookLoadPackage {
|
||||
var prefs = XSharedPreferences(BuildConfig.APPLICATION_ID, "config")
|
||||
override fun handleLoadPackage(lpparam: LoadPackageParam) {
|
||||
if (prefs.getBoolean("main_switch", true)) {
|
||||
EzXHelperInit.initHandleLoadPackage(lpparam)
|
||||
EzXHelperInit.setEzClassLoader(lpparam.classLoader)
|
||||
when (lpparam.packageName) {
|
||||
//Android
|
||||
"android" -> {
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class DeleteOnPostNotification : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.server.wm.AlertWindowNotification",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(classIfExists,
|
||||
"onPostNotification",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("delete_on_post_notification", false)) {
|
||||
param.result = null
|
||||
"com.android.server.wm.AlertWindowNotification".hookBeforeMethod(lpparam.classLoader, "onPostNotification") {
|
||||
hasEnable("delete_on_post_notification") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,15 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class DisableFlagSecure :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.server.wm.WindowState",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(classIfExists,
|
||||
"isSecureLocked",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("disable_flag_secure",false)) {
|
||||
param.result = false
|
||||
"com.android.server.wm.WindowState".hookBeforeMethod(lpparam.classLoader, "isSecureLocked") {
|
||||
hasEnable("disable_flag_secure") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,76 +1,38 @@
|
||||
package com.lt2333.simplicitytools.hook.app.android
|
||||
|
||||
import android.content.Context
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class RemoveSmallWindowRestrictions : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
|
||||
// 强制所有活动设为可以调整大小
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.server.wm.Task",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"isResizeable",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
|
||||
param.result = true
|
||||
"com.android.server.wm.Task".hookBeforeMethod(lpparam.classLoader, "isResizeable") {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
"android.util.MiuiMultiWindowAdapter".hookAfterMethod(lpparam.classLoader, "getFreeformBlackList") {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = (it.result as MutableList<*>).apply { clear() }
|
||||
}
|
||||
}
|
||||
|
||||
"android.util.MiuiMultiWindowAdapter".hookAfterMethod(lpparam.classLoader, "getFreeformBlackListFromCloud") {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = (it.result as MutableList<*>).apply { clear() }
|
||||
}
|
||||
}
|
||||
|
||||
val classIfExists2 = XposedHelpers.findClassIfExists(
|
||||
"android.util.MiuiMultiWindowAdapter",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists2,
|
||||
"getFreeformBlackList",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
|
||||
val blackList = param.result as MutableList<String>
|
||||
blackList.clear()
|
||||
param.result = blackList
|
||||
"android.util.MiuiMultiWindowUtils".hookAfterMethod(lpparam.classLoader, "supportFreeform") {
|
||||
hasEnable("remove_small_window_restrictions") {
|
||||
it.result = true
|
||||
}
|
||||
}
|
||||
})
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists2,
|
||||
"getFreeformBlackListFromCloud",
|
||||
Context::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
|
||||
val blackList = param.result as MutableList<String>
|
||||
blackList.clear()
|
||||
param.result = blackList
|
||||
}
|
||||
}
|
||||
})
|
||||
val classIfExists3 = XposedHelpers.findClassIfExists(
|
||||
"android.util.MiuiMultiWindowUtils",
|
||||
lpparam.classLoader
|
||||
)
|
||||
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists3,
|
||||
"supportFreeform",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_small_window_restrictions", false)) {
|
||||
param.result = true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,17 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideAirplaneIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"setIsAirplaneMode",
|
||||
XposedHelpers.findClass(
|
||||
"com.android.systemui.statusbar.policy.NetworkController\$IconState",
|
||||
lpparam.classLoader
|
||||
),
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_airplane_icon", false)) {
|
||||
param.result = null
|
||||
val iconState = "com.android.systemui.statusbar.policy.NetworkController\$IconState"
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "setIsAirplaneMode", iconState) {
|
||||
hasEnable("hide_airplane_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideAlarmIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"onMiuiAlarmChanged",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_alarm_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "onMiuiAlarmChanged") {
|
||||
hasEnable("hide_alarm_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,82 +4,41 @@ import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideBatteryIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.views.MiuiBatteryMeterView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateResources",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
"com.android.systemui.statusbar.views.MiuiBatteryMeterView".hookAfterMethod(lpparam.classLoader, "updateResources") {
|
||||
|
||||
//隐藏电池图标
|
||||
if (XSPUtils.getBoolean("hide_battery_icon", false)) {
|
||||
val mBatteryIconView = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mBatteryIconView"
|
||||
) as ImageView
|
||||
mBatteryIconView.visibility = View.GONE
|
||||
|
||||
if (XposedHelpers.getObjectField(param.thisObject, "mBatteryStyle") == 1) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mBatteryDigitalView"
|
||||
) as FrameLayout).visibility = View.GONE
|
||||
hasEnable("hide_battery_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryIconView") as ImageView).visibility = View.GONE
|
||||
if (it.thisObject.getObjectField("mBatteryStyle") == 1) {
|
||||
(it.thisObject.getObjectField("mBatteryDigitalView") as FrameLayout).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//隐藏电池内的百分比
|
||||
if (XSPUtils.getBoolean("hide_battery_percentage_icon", false)) {
|
||||
val mBatteryPercentMarkView = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mBatteryPercentMarkView"
|
||||
) as TextView
|
||||
mBatteryPercentMarkView.textSize = 0F
|
||||
hasEnable("hide_battery_percentage_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryPercentMarkView") as TextView).textSize = 0F
|
||||
}
|
||||
|
||||
//隐藏电池百分号
|
||||
if (XSPUtils.getBoolean("hide_battery_percentage_icon", false)) {
|
||||
val mBatteryPercentMarkView = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mBatteryPercentMarkView"
|
||||
) as TextView
|
||||
mBatteryPercentMarkView.textSize = 0F
|
||||
hasEnable("hide_battery_percentage_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryPercentMarkView") as TextView).textSize = 0F
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
XposedHelpers.findAndHookMethod(classIfExists,"updateChargeAndText",object :XC_MethodHook(){
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
"com.android.systemui.statusbar.views.MiuiBatteryMeterView".hookAfterMethod(lpparam.classLoader, "updateChargeAndText") {
|
||||
//隐藏电池充电图标
|
||||
if (XSPUtils.getBoolean("hide_battery_charging_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mBatteryChargingInView"
|
||||
) as ImageView).visibility = View.GONE
|
||||
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mBatteryChargingView"
|
||||
) as ImageView).visibility = View.GONE
|
||||
|
||||
hasEnable("hide_battery_charging_icon") {
|
||||
(it.thisObject.getObjectField("mBatteryChargingInView") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectField("mBatteryChargingView") as ImageView).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,17 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Intent
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideBluetoothHandsfreeBatteryIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateBluetoothHandsfreeBattery",
|
||||
Intent::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_bluetooth_battery_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateBluetoothHandsfreeBattery", Intent::class.java) {
|
||||
hasEnable("hide_bluetooth_battery_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideBluetoothIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateBluetooth",
|
||||
String::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_bluetooth_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateBluetooth", String::class.java) {
|
||||
hasEnable("hide_bluetooth_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideGPSIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateLocationFromController",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_gps_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateLocationFromController") {
|
||||
hasEnable("hide_gps_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2,76 +2,37 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideHDIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.StatusBarMobileView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"initViewState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_big_hd_icon", false)) {
|
||||
val bigHd = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mVolte"
|
||||
) as ImageView
|
||||
bigHd.visibility = View.GONE
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
hasEnable("hide_big_hd_icon") {
|
||||
(it.thisObject.getObjectField("mVolte") as ImageView).visibility = View.GONE
|
||||
}
|
||||
if (XSPUtils.getBoolean("hide_small_hd_icon", false)) {
|
||||
val smallHd = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mSmallHd"
|
||||
) as ImageView
|
||||
smallHd.visibility = View.GONE
|
||||
hasEnable("hide_small_hd_icon") {
|
||||
(it.thisObject.getObjectField("mSmallHd") as ImageView).visibility = View.GONE
|
||||
}
|
||||
if (XSPUtils.getBoolean("hide_hd_no_service_icon", false)) {
|
||||
val volteNoService = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mVolteNoService"
|
||||
) as ImageView
|
||||
volteNoService.visibility = View.GONE
|
||||
hasEnable("hide_hd_no_service_icon") {
|
||||
(it.thisObject.getObjectField("mVolteNoService") as ImageView).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_big_hd_icon", false)) {
|
||||
val bigHd = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mVolte"
|
||||
) as ImageView
|
||||
bigHd.visibility = View.GONE
|
||||
}
|
||||
if (XSPUtils.getBoolean("hide_small_hd_icon", false)) {
|
||||
val smallHd = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mSmallHd"
|
||||
) as ImageView
|
||||
|
||||
smallHd.visibility = View.GONE
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
hasEnable("hide_big_hd_icon") {
|
||||
(it.thisObject.getObjectField("mVolte") as ImageView).visibility = View.GONE
|
||||
}
|
||||
if (XSPUtils.getBoolean("hide_hd_no_service_icon", false)) {
|
||||
val volteNoService = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mVolteNoService"
|
||||
) as ImageView
|
||||
volteNoService.visibility = View.GONE
|
||||
hasEnable("hide_small_hd_icon") {
|
||||
(it.thisObject.getObjectField("mSmallHd") as ImageView).visibility = View.GONE
|
||||
}
|
||||
hasEnable("hide_hd_no_service_icon") {
|
||||
(it.thisObject.getObjectField("mVolteNoService") as ImageView).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,17 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.content.Intent
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideHeadsetIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateHeadsetPlug",
|
||||
Intent::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_headset_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateHeadsetPlug", Intent::class.java) {
|
||||
hasEnable("hide_headset_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideHotspotIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarPolicy\$2",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"onHotspotChanged",
|
||||
Boolean::class.java, Int::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_hotspot_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.PhoneStatusBarPolicy\$2".hookBeforeMethod(lpparam.classLoader, "onHotspotChanged", Boolean::class.java, Int::class.java) {
|
||||
hasEnable("hide_hotspot_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2,58 +2,27 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideMobileActivityIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.StatusBarMobileView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"initViewState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_mobile_activity_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mLeftInOut"
|
||||
) as ImageView).visibility = View.GONE
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
hasEnable("hide_mobile_activity_icon") {
|
||||
(it.thisObject.getObjectField("mLeftInOut") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectField("mRightInOut") as ImageView).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mRightInOut"
|
||||
) as ImageView).visibility = View.GONE
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
hasEnable("hide_mobile_activity_icon") {
|
||||
(it.thisObject.getObjectField("mLeftInOut") as ImageView).visibility = View.GONE
|
||||
(it.thisObject.getObjectField("mRightInOut") as ImageView).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_mobile_activity_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mLeftInOut"
|
||||
) as ImageView).visibility = View.GONE
|
||||
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mRightInOut"
|
||||
) as ImageView).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,68 +3,29 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideMobileTypeIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.StatusBarMobileView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"initViewState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_mobile_type_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mMobileType"
|
||||
) as TextView).visibility = View.INVISIBLE
|
||||
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mMobileTypeImage"
|
||||
) as ImageView).visibility = View.INVISIBLE
|
||||
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mMobileTypeSingle"
|
||||
) as TextView).visibility = View.INVISIBLE
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState"
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$MobileIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_mobile_type_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mMobileType"
|
||||
) as TextView).visibility = View.INVISIBLE
|
||||
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mMobileTypeImage"
|
||||
) as ImageView).visibility = View.INVISIBLE
|
||||
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mMobileTypeSingle"
|
||||
) as TextView).visibility = View.INVISIBLE
|
||||
"com.android.systemui.statusbar.StatusBarMobileView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
hasEnable("hide_mobile_type_icon") {
|
||||
(it.thisObject.getObjectField("mMobileType") as TextView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeImage") as ImageView).visibility = View.INVISIBLE
|
||||
(it.thisObject.getObjectField("mMobileTypeSingle") as TextView).visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideNoSimIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.MiuiStatusBarSignalPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"setNoSims",
|
||||
Boolean::class.javaPrimitiveType,
|
||||
Boolean::class.javaPrimitiveType,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_no_sim_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.MiuiStatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "setNoSims", Boolean::class.javaPrimitiveType, Boolean::class.javaPrimitiveType) {
|
||||
hasEnable("hide_no_sim_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,21 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideSimIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"hasCorrectSubs", MutableList::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
val list = param.args[0] as MutableList<*>
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "hasCorrectSubs", MutableList::class.java) {
|
||||
val list = it.args[0] as MutableList<*>
|
||||
val size = list.size
|
||||
|
||||
if (size == 2 && XSPUtils.getBoolean("hide_sim_two_icon", false)) {
|
||||
hasEnable("hide_sim_two_icon", extraCondition = { size == 2 }) {
|
||||
list.removeAt(1)
|
||||
}
|
||||
if (size >= 1 && XSPUtils.getBoolean("hide_sim_one_icon", false)) {
|
||||
hasEnable("hide_sim_one_icon", extraCondition = { size >= 1 }) {
|
||||
list.removeAt(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideSlaveWifiIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.policy.SlaveWifiSignalController",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_slave_wifi_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.policy.SlaveWifiSignalController".hookBeforeMethod(lpparam.classLoader, "updateIconState") {
|
||||
hasEnable("hide_slave_wifi_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,22 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import com.lt2333.simplicitytools.util.isNonNull
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideStatusBarNetworkSpeedSecond :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.views.NetworkSpeedView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"setNetworkSpeed",
|
||||
String::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_status_bar_network_speed_second", false)) {
|
||||
if (param.args[0] != null) {
|
||||
param.args[0] = (param.args[0] as String)
|
||||
"com.android.systemui.statusbar.views.NetworkSpeedView".hookBeforeMethod(lpparam.classLoader, "setNetworkSpeed", String::class.java) {
|
||||
hasEnable("hide_status_bar_network_speed_second") {
|
||||
it.args[0].isNonNull { s ->
|
||||
it.args[0] = (s as String)
|
||||
.replace("/", "")
|
||||
.replace("s", "")
|
||||
.replace("'", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideVolumeZenIcon :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateVolumeZen",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_volume_zen_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.MiuiPhoneStatusBarPolicy".hookBeforeMethod(lpparam.classLoader, "updateVolumeZen") {
|
||||
hasEnable("hide_volume_zen_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideVpnIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateVpn",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_vpn_icon", false)) {
|
||||
param.result = null
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "updateVpn") {
|
||||
hasEnable("hide_vpn_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -3,68 +3,35 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideWifiActivityIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.StatusBarWifiView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"initViewState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState"
|
||||
"com.android.systemui.statusbar.StatusBarWifiView".hookAfterMethod(lpparam.classLoader, "initViewState", iconState) {
|
||||
//隐藏WIFI箭头
|
||||
if (XSPUtils.getBoolean("hide_wifi_activity_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mWifiActivityView"
|
||||
) as ImageView).visibility = View.INVISIBLE
|
||||
hasEnable("hide_wifi_activity_icon") {
|
||||
(it.thisObject.getObjectField("mWifiActivityView") as ImageView).visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
//隐藏WIFI标准图标
|
||||
if (XSPUtils.getBoolean("hide_wifi_standard_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mWifiStandardView"
|
||||
) as TextView).visibility = View.INVISIBLE
|
||||
hasEnable("hide_wifi_standard_icon") {
|
||||
(it.thisObject.getObjectField("mWifiStandardView") as TextView).visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateState",
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
"com.android.systemui.statusbar.StatusBarWifiView".hookAfterMethod(lpparam.classLoader, "updateState", iconState) {
|
||||
//隐藏WIFI箭头
|
||||
if (XSPUtils.getBoolean("hide_wifi_activity_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mWifiActivityView"
|
||||
) as ImageView).visibility = View.INVISIBLE
|
||||
hasEnable("hide_wifi_activity_icon") {
|
||||
(it.thisObject.getObjectField("mWifiActivityView") as ImageView).visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
//隐藏WIFI标准图标
|
||||
if (XSPUtils.getBoolean("hide_wifi_standard_icon", false)) {
|
||||
(XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mWifiStandardView"
|
||||
) as TextView).visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
hasEnable("hide_wifi_standard_icon") {
|
||||
(it.thisObject.getObjectField("mWifiStandardView") as TextView).visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,17 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class HideWifiIcon : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.MiuiStatusBarSignalPolicy",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"updateWifiIconWithState",
|
||||
XposedHelpers.findClass(
|
||||
"com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState",
|
||||
lpparam.classLoader
|
||||
),
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("hide_wifi_icon", false)) {
|
||||
param.result = null
|
||||
val iconState = "com.android.systemui.statusbar.phone.StatusBarSignalPolicy\$WifiIconState"
|
||||
"com.android.systemui.statusbar.phone.MiuiStatusBarSignalPolicy".hookBeforeMethod(lpparam.classLoader, "updateWifiIconWithState", iconState) {
|
||||
hasEnable("hide_wifi_icon") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -6,110 +6,59 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.github.kyuubiran.ezxhelper.utils.loadClass
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import com.lt2333.simplicitytools.view.WeatherView
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class NotificationWeather : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
|
||||
hasEnable("notification_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
|
||||
if (!XSPUtils.getBoolean("notification_weather", false)) return
|
||||
|
||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.qs.MiuiNotificationHeaderView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
|
||||
XposedHelpers.findAndHookMethod(classIfExists, "onFinishInflate", object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
|
||||
val layout = XposedHelpers.findClass(
|
||||
"androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams",
|
||||
lpparam.classLoader
|
||||
).getConstructor(Int::class.java, Int::class.java).newInstance(
|
||||
"com.android.systemui.qs.MiuiNotificationHeaderView".hookAfterMethod(lpparam.classLoader, "onFinishInflate") {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val layoutParam = loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||
.getConstructor(Int::class.java, Int::class.java).newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
layoutParam.setObjectField("bottomToTop", context.resources.getIdentifier("date_time", "id", context.packageName))
|
||||
layoutParam.setObjectField("startToEnd", context.resources.getIdentifier("big_time", "id", context.packageName))
|
||||
|
||||
XposedHelpers.setObjectField(
|
||||
layout,
|
||||
"bottomToTop",
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"date_time",
|
||||
"id",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
layoutParam.marginStart = context.resources.getDimensionPixelSize(
|
||||
context.resources.getIdentifier("notification_panel_time_date_space", "dimen", context.packageName)
|
||||
)
|
||||
|
||||
XposedHelpers.setObjectField(
|
||||
layout,
|
||||
"startToEnd",
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"big_time",
|
||||
"id",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
layout.marginStart = viewGroup.context.resources.getDimensionPixelSize(
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"notification_panel_time_date_space",
|
||||
"dimen",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
mWeatherView = WeatherView(viewGroup.context, isDisplayCity).also {
|
||||
it.setTextAppearance(
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"TextAppearance.QSControl.Date",
|
||||
"style",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
)
|
||||
it.layoutParams = layout
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(context.resources.getIdentifier("TextAppearance.QSControl.Date", "style", context.packageName))
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
val intent = Intent()
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
intent.component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
viewGroup.context.startActivity(intent)
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName("com.miui.weather2", "com.miui.weather2.ActivityWeatherMain")
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(viewGroup.context, "启动失败", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(context, "启动失败", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
//解决横屏重叠
|
||||
XposedHelpers.findAndHookMethod(classIfExists, "updateLayout", object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
super.afterHookedMethod(param)
|
||||
val mOrientation =
|
||||
XposedHelpers.getObjectField(param.thisObject, "mOrientation") as Int
|
||||
"com.android.systemui.qs.MiuiNotificationHeaderView".hookAfterMethod(lpparam.classLoader, "updateLayout") {
|
||||
val mOrientation = it.thisObject.getObjectField("mOrientation") as Int
|
||||
if (mOrientation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mWeatherView!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,108 +6,55 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.github.kyuubiran.ezxhelper.utils.loadClass
|
||||
import com.lt2333.simplicitytools.util.*
|
||||
import com.lt2333.simplicitytools.view.WeatherView
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class OldNotificationWeather : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
|
||||
hasEnable("notification_weather") {
|
||||
var mWeatherView: TextView? = null
|
||||
|
||||
if (!XSPUtils.getBoolean("notification_weather", false)) return
|
||||
|
||||
val isDisplayCity = XSPUtils.getBoolean("notification_weather_city", false)
|
||||
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(lpparam.classLoader, "onFinishInflate") {
|
||||
val viewGroup = it.thisObject as ViewGroup
|
||||
val context = viewGroup.context
|
||||
val layoutParam = loadClass("androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams")
|
||||
.getConstructor(Int::class.java, Int::class.java)
|
||||
.newInstance(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) as ViewGroup.MarginLayoutParams
|
||||
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.qs.MiuiQSHeaderView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
layoutParam.setObjectField("engToStart", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
||||
layoutParam.setObjectField("topToTop", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
||||
layoutParam.setObjectField("bottomToBottom", context.resources.getIdentifier("notification_shade_shortcut", "id", context.packageName))
|
||||
|
||||
XposedHelpers.findAndHookMethod(classIfExists, "onFinishInflate", object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
val viewGroup = param.thisObject as ViewGroup
|
||||
|
||||
val layout = XposedHelpers.findClass(
|
||||
"androidx.constraintlayout.widget.ConstraintLayout\$LayoutParams",
|
||||
lpparam.classLoader
|
||||
).getConstructor(Int::class.java, Int::class.java).newInstance(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
) as ViewGroup.MarginLayoutParams
|
||||
|
||||
XposedHelpers.setObjectField(
|
||||
layout,
|
||||
"endToStart",
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
XposedHelpers.setObjectField(
|
||||
layout,
|
||||
"topToTop",
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
)
|
||||
XposedHelpers.setObjectField(
|
||||
layout,
|
||||
"bottomToBottom",
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"notification_shade_shortcut",
|
||||
"id",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
mWeatherView = WeatherView(viewGroup.context,isDisplayCity).also {
|
||||
it.setTextAppearance(
|
||||
viewGroup.context.resources.getIdentifier(
|
||||
"TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate",
|
||||
"style",
|
||||
viewGroup.context.packageName
|
||||
)
|
||||
)
|
||||
it.layoutParams = layout
|
||||
mWeatherView = WeatherView(context, isDisplayCity).apply {
|
||||
setTextAppearance(context.resources.getIdentifier("TextAppearance.StatusBar.Expanded.Clock.QuickSettingDate", "style", context.packageName))
|
||||
layoutParams = layoutParam
|
||||
}
|
||||
viewGroup.addView(mWeatherView)
|
||||
(mWeatherView as WeatherView).setOnClickListener {
|
||||
try {
|
||||
val intent = Intent()
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
intent.component = ComponentName(
|
||||
"com.miui.weather2",
|
||||
"com.miui.weather2.ActivityWeatherMain"
|
||||
)
|
||||
viewGroup.context.startActivity(intent)
|
||||
val intent = Intent().apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
component = ComponentName("com.miui.weather2", "com.miui.weather2.ActivityWeatherMain")
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(viewGroup.context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(context, "启动失败,可能是不支持", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
//解决横屏重叠
|
||||
XposedHelpers.findAndHookMethod(classIfExists, "updateLayout", object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
super.afterHookedMethod(param)
|
||||
val mOrientation =
|
||||
XposedHelpers.getObjectField(param.thisObject, "mOrientation") as Int
|
||||
if (mOrientation == 1) {
|
||||
"com.android.systemui.qs.MiuiQSHeaderView".hookAfterMethod(lpparam.classLoader, "updateLayout") {
|
||||
val mOritation = it.thisObject.getObjectField("mOrientation") as Int
|
||||
if (mOritation == 1) {
|
||||
mWeatherView!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
mWeatherView!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,64 +2,34 @@ package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.getObjectField
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookAfterMethod
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class RemoveLockScreenCamera : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
|
||||
//屏蔽右下角组件显示
|
||||
val classIfExists1 = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.KeyguardBottomAreaView",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists1,
|
||||
"onFinishInflate",
|
||||
object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_lock_screen_camera", false)) {
|
||||
val view = XposedHelpers.getObjectField(
|
||||
param.thisObject,
|
||||
"mRightAffordanceViewLayout"
|
||||
) as LinearLayout
|
||||
view.visibility = View.GONE
|
||||
"com.android.systemui.statusbar.phone.KeyguardBottomAreaView".hookAfterMethod(lpparam.classLoader, "onFinishInflate") {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
(it.thisObject.getObjectField("mRightAffordanceViewLayout") as LinearLayout).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
//屏蔽滑动撞墙动画
|
||||
val classIfExists2 = XposedHelpers.findClassIfExists(
|
||||
"com.android.keyguard.KeyguardMoveRightController",
|
||||
lpparam.classLoader
|
||||
)
|
||||
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists2,
|
||||
"onTouchMove",
|
||||
Float::class.java,
|
||||
Float::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_lock_screen_camera", false)) {
|
||||
param.result = false
|
||||
"com.android.keyguard.KeyguardMoveRightController".hookBeforeMethod(lpparam.classLoader, "onTouchMove", Float::class.java, Float::class.java) {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
it.result = false
|
||||
}
|
||||
}
|
||||
})
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists2,
|
||||
"reset",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_lock_screen_camera", false)) {
|
||||
param.result = null
|
||||
"com.android.keyguard.KeyguardMoveRightController".hookBeforeMethod(lpparam.classLoader, "reset") {
|
||||
hasEnable("remove_lock_screen_camera") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class RemoveTheLeftSideOfTheLockScreen : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.keyguard.negative.MiuiKeyguardMoveLeftViewContainer",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"inflateLeftView",
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("remove_the_left_side_of_the_lock_screen", false)) {
|
||||
param.result = null
|
||||
"com.android.keyguard.negative.MiuiKeyguardMoveLeftViewContainer".hookBeforeMethod(lpparam.classLoader, "inflateLeftView") {
|
||||
hasEnable("remove_the_left_side_of_the_lock_screen") {
|
||||
it.result = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,27 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.callMethod
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.replaceMethod
|
||||
import com.lt2333.simplicitytools.util.setIntField
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodReplacement
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class RemoveTheMaximumNumberOfNotificationIcons : IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
if (XSPUtils.getBoolean("remove_the_maximum_number_of_notification_icons", false)) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.phone.NotificationIconContainer",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"miuiShowNotificationIcons",
|
||||
Boolean::class.java,
|
||||
object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) {
|
||||
|
||||
if (param.args[0] as Boolean) {
|
||||
XposedHelpers.setIntField(param.thisObject, "MAX_DOTS", 30)
|
||||
XposedHelpers.setIntField(param.thisObject, "MAX_STATIC_ICONS", 30)
|
||||
XposedHelpers.setIntField(
|
||||
param.thisObject,
|
||||
"MAX_VISIBLE_ICONS_ON_LOCK",
|
||||
30
|
||||
)
|
||||
hasEnable("remove_the_maximum_number_of_notification_icons") {
|
||||
"com.android.systemui.statusbar.phone.NotificationIconContainer".replaceMethod(lpparam.classLoader, "miuiShowNotificationIcons", Boolean::class.java) {
|
||||
if (it.args[0] as Boolean) {
|
||||
it.thisObject.setIntField("MAX_DOTS", 30)
|
||||
it.thisObject.setIntField("MAX_STATIC_ICONS", 30)
|
||||
it.thisObject.setIntField("MAX_VISIBLE_ICONS_ON_LOCK", 30)
|
||||
} else {
|
||||
XposedHelpers.setIntField(param.thisObject, "MAX_DOTS", 0)
|
||||
XposedHelpers.setIntField(param.thisObject, "MAX_STATIC_ICONS", 0)
|
||||
XposedHelpers.setIntField(
|
||||
param.thisObject,
|
||||
"MAX_VISIBLE_ICONS_ON_LOCK",
|
||||
0
|
||||
)
|
||||
it.thisObject.setIntField("MAX_DOTS", 0)
|
||||
it.thisObject.setIntField("MAX_STATIC_ICONS", 0)
|
||||
it.thisObject.setIntField("MAX_VISIBLE_ICONS_ON_LOCK", 0)
|
||||
}
|
||||
it.thisObject.callMethod("updateState")
|
||||
}
|
||||
|
||||
XposedHelpers.callMethod(param.thisObject, "updateState")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,16 @@
|
||||
package com.lt2333.simplicitytools.hook.app.systemui
|
||||
|
||||
import com.lt2333.simplicitytools.util.XSPUtils
|
||||
import com.lt2333.simplicitytools.util.hasEnable
|
||||
import com.lt2333.simplicitytools.util.hookBeforeMethod
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class StatusBarNetworkSpeedRefreshSpeed :IXposedHookLoadPackage {
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
val classIfExists = XposedHelpers.findClassIfExists(
|
||||
"com.android.systemui.statusbar.policy.NetworkSpeedController",
|
||||
lpparam.classLoader
|
||||
)
|
||||
XposedHelpers.findAndHookMethod(
|
||||
classIfExists,
|
||||
"postUpdateNetworkSpeedDelay",
|
||||
Long::class.java,
|
||||
object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) {
|
||||
if (XSPUtils.getBoolean("status_bar_network_speed_refresh_speed", false)) {
|
||||
param.args[0] = 1000L
|
||||
"com.android.systemui.statusbar.policy.NetworkSpeedController".hookBeforeMethod(lpparam.classLoader, "postUpdateNetworkSpeedDelay", Long::class.java) {
|
||||
hasEnable("status_bar_network_speed_refresh_speed") {
|
||||
it.args[0] = 1000L
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,500 @@
|
||||
package com.lt2333.simplicitytools.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.XResources
|
||||
import android.util.Log
|
||||
import dalvik.system.BaseDexClassLoader
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XC_MethodReplacement
|
||||
import de.robv.android.xposed.XposedBridge
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LayoutInflated
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Member
|
||||
import java.util.*
|
||||
|
||||
const val TAG = "SimplicityTools"
|
||||
|
||||
fun log(any: Any?, online: Boolean = false) {
|
||||
val msg: String = if (any is Throwable) Log.getStackTraceString(any) else any.toString()
|
||||
// Log.d(TAG, msg)
|
||||
XposedBridge.log("$TAG: $msg")
|
||||
}
|
||||
|
||||
typealias MethodHookParam = XC_MethodHook.MethodHookParam
|
||||
typealias Replacer = (XC_MethodHook.MethodHookParam) -> Any?
|
||||
typealias Hooker = (XC_MethodHook.MethodHookParam) -> Unit
|
||||
|
||||
fun Class<*>.hookMethod(method: String?, vararg args: Any?) = try {
|
||||
XposedHelpers.findAndHookMethod(this, method, *args)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
fun Member.hookMethod(callback: XC_MethodHook) = try {
|
||||
XposedBridge.hookMethod(this, callback)
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun XC_MethodHook.MethodHookParam.callHooker(crossinline hooker: Hooker) = try {
|
||||
hooker(this)
|
||||
} catch (e: Throwable) {
|
||||
log("Error occurred calling hooker on ${this.method}")
|
||||
log(e)
|
||||
}
|
||||
|
||||
inline fun XC_MethodHook.MethodHookParam.callReplacer(crossinline replacer: Replacer) = try {
|
||||
replacer(this)
|
||||
} catch (e: Throwable) {
|
||||
log("Error occurred calling replacer on ${this.method}")
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun Member.replaceMethod(crossinline replacer: Replacer) =
|
||||
hookMethod(object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callReplacer(replacer)
|
||||
})
|
||||
|
||||
inline fun Member.hookAfterMethod(crossinline hooker: Hooker) =
|
||||
hookMethod(object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Member.hookBeforeMethod(crossinline hooker: (XC_MethodHook.MethodHookParam) -> Unit) =
|
||||
hookMethod(object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookBeforeMethod(
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = hookMethod(method, *args, object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookAfterMethod(
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = hookMethod(method, *args, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceMethod(
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline replacer: Replacer
|
||||
) = hookMethod(method, *args, object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callReplacer(replacer)
|
||||
})
|
||||
|
||||
fun Class<*>.hookAllMethods(methodName: String?, hooker: XC_MethodHook): Set<XC_MethodHook.Unhook> =
|
||||
try {
|
||||
XposedBridge.hookAllMethods(this, methodName, hooker)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
emptySet()
|
||||
}
|
||||
|
||||
inline fun Class<*>.hookBeforeAllMethods(methodName: String?, crossinline hooker: Hooker) =
|
||||
hookAllMethods(methodName, object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookAfterAllMethods(methodName: String?, crossinline hooker: Hooker) =
|
||||
hookAllMethods(methodName, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceAfterAllMethods(methodName: String?, crossinline replacer: Replacer) =
|
||||
hookAllMethods(methodName, object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callReplacer(replacer)
|
||||
})
|
||||
|
||||
fun Class<*>.hookConstructor(vararg args: Any?) = try {
|
||||
XposedHelpers.findAndHookConstructor(this, *args)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun Class<*>.hookBeforeConstructor(vararg args: Any?, crossinline hooker: Hooker) =
|
||||
hookConstructor(*args, object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookAfterConstructor(vararg args: Any?, crossinline hooker: Hooker) =
|
||||
hookConstructor(*args, object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceConstructor(vararg args: Any?, crossinline hooker: Hooker) =
|
||||
hookConstructor(*args, object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
fun Class<*>.hookAllConstructors(hooker: XC_MethodHook): Set<XC_MethodHook.Unhook> = try {
|
||||
XposedBridge.hookAllConstructors(this, hooker)
|
||||
} catch (e: NoSuchMethodError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
emptySet()
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
emptySet()
|
||||
}
|
||||
|
||||
inline fun Class<*>.hookAfterAllConstructors(crossinline hooker: Hooker) =
|
||||
hookAllConstructors(object : XC_MethodHook() {
|
||||
override fun afterHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.hookBeforeAllConstructors(crossinline hooker: Hooker) =
|
||||
hookAllConstructors(object : XC_MethodHook() {
|
||||
override fun beforeHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
inline fun Class<*>.replaceAfterAllConstructors(crossinline hooker: Hooker) =
|
||||
hookAllConstructors(object : XC_MethodReplacement() {
|
||||
override fun replaceHookedMethod(param: MethodHookParam) = param.callHooker(hooker)
|
||||
})
|
||||
|
||||
fun String.hookMethod(classLoader: ClassLoader, method: String?, vararg args: Any?) = try {
|
||||
findClass(classLoader).hookMethod(method, *args)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun String.hookBeforeMethod(
|
||||
classLoader: ClassLoader,
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = try {
|
||||
findClass(classLoader).hookBeforeMethod(method, *args, hooker = hooker)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun String.hookAfterMethod(
|
||||
classLoader: ClassLoader,
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline hooker: Hooker
|
||||
) = try {
|
||||
findClass(classLoader).hookAfterMethod(method, *args, hooker = hooker)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
inline fun String.replaceMethod(
|
||||
classLoader: ClassLoader,
|
||||
method: String?,
|
||||
vararg args: Any?,
|
||||
crossinline replacer: Replacer
|
||||
) = try {
|
||||
findClass(classLoader).replaceMethod(method, *args, replacer = replacer)
|
||||
} catch (e: XposedHelpers.ClassNotFoundError) {
|
||||
log(e)
|
||||
null
|
||||
} catch (e: ClassNotFoundException) {
|
||||
log(e)
|
||||
null
|
||||
}
|
||||
|
||||
fun XC_MethodHook.MethodHookParam.invokeOriginalMethod(): Any? =
|
||||
XposedBridge.invokeOriginalMethod(method, thisObject, args)
|
||||
|
||||
inline fun <T, R> T.runCatchingOrNull(func: T.() -> R?) = try {
|
||||
func()
|
||||
} catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
|
||||
fun Any.getObjectField(field: String?): Any? = XposedHelpers.getObjectField(this, field)
|
||||
|
||||
fun Any.getObjectFieldOrNull(field: String?): Any? = runCatchingOrNull {
|
||||
XposedHelpers.getObjectField(this, field)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getObjectFieldAs(field: String?) = XposedHelpers.getObjectField(this, field) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getObjectFieldOrNullAs(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getObjectField(this, field) as T
|
||||
}
|
||||
|
||||
fun Any.getIntField(field: String?) = XposedHelpers.getIntField(this, field)
|
||||
|
||||
fun Any.getIntFieldOrNull(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getIntField(this, field)
|
||||
}
|
||||
|
||||
fun Any.getLongField(field: String?) = XposedHelpers.getLongField(this, field)
|
||||
|
||||
fun Any.getLongFieldOrNull(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getLongField(this, field)
|
||||
}
|
||||
|
||||
fun Any.getBooleanFieldOrNull(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getBooleanField(this, field)
|
||||
}
|
||||
|
||||
fun Any.callMethod(methodName: String?, vararg args: Any?): Any? =
|
||||
XposedHelpers.callMethod(this, methodName, *args)
|
||||
|
||||
fun Any.callMethodOrNull(methodName: String?, vararg args: Any?): Any? = runCatchingOrNull {
|
||||
XposedHelpers.callMethod(this, methodName, *args)
|
||||
}
|
||||
|
||||
fun Class<*>.callStaticMethod(methodName: String?, vararg args: Any?): Any? =
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args)
|
||||
|
||||
fun Class<*>.callStaticMethodOrNull(methodName: String?, vararg args: Any?): Any? =
|
||||
runCatchingOrNull {
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.callStaticMethodAs(methodName: String?, vararg args: Any?) =
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.callStaticMethodOrNullAs(methodName: String?, vararg args: Any?) =
|
||||
runCatchingOrNull {
|
||||
XposedHelpers.callStaticMethod(this, methodName, *args) as T
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.getStaticObjectFieldAs(field: String?) = XposedHelpers.getStaticObjectField(
|
||||
this,
|
||||
field
|
||||
) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Class<*>.getStaticObjectFieldOrNullAs(field: String?) = runCatchingOrNull {
|
||||
XposedHelpers.getStaticObjectField(this, field) as T
|
||||
}
|
||||
|
||||
fun Class<*>.getStaticObjectField(field: String?): Any? =
|
||||
XposedHelpers.getStaticObjectField(this, field)
|
||||
|
||||
fun Class<*>.getStaticObjectFieldOrNull(field: String?): Any? = runCatchingOrNull {
|
||||
XposedHelpers.getStaticObjectField(this, field)
|
||||
}
|
||||
|
||||
fun Class<*>.setStaticObjectField(field: String?, obj: Any?) = apply {
|
||||
XposedHelpers.setStaticObjectField(this, field, obj)
|
||||
}
|
||||
|
||||
fun Class<*>.setStaticObjectFieldIfExist(field: String?, obj: Any?) = apply {
|
||||
try {
|
||||
XposedHelpers.setStaticObjectField(this, field, obj)
|
||||
} catch (ignored: Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <reified T> Class<*>.findFieldByExactType(): Field? =
|
||||
XposedHelpers.findFirstFieldByExactType(this, T::class.java)
|
||||
|
||||
fun Class<*>.findFieldByExactType(type: Class<*>): Field? =
|
||||
XposedHelpers.findFirstFieldByExactType(this, type)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.callMethodAs(methodName: String?, vararg args: Any?) =
|
||||
XposedHelpers.callMethod(this, methodName, *args) as T
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.callMethodOrNullAs(methodName: String?, vararg args: Any?) = runCatchingOrNull {
|
||||
XposedHelpers.callMethod(this, methodName, *args) as T
|
||||
}
|
||||
|
||||
fun Any.callMethod(methodName: String?, parameterTypes: Array<Class<*>>, vararg args: Any?): Any? =
|
||||
XposedHelpers.callMethod(this, methodName, parameterTypes, *args)
|
||||
|
||||
fun Any.callMethodOrNull(
|
||||
methodName: String?,
|
||||
parameterTypes: Array<Class<*>>,
|
||||
vararg args: Any?
|
||||
): Any? = runCatchingOrNull {
|
||||
XposedHelpers.callMethod(this, methodName, parameterTypes, *args)
|
||||
}
|
||||
|
||||
fun Class<*>.callStaticMethod(
|
||||
methodName: String?,
|
||||
parameterTypes: Array<Class<*>>,
|
||||
vararg args: Any?
|
||||
): Any? = XposedHelpers.callStaticMethod(this, methodName, parameterTypes, *args)
|
||||
|
||||
fun Class<*>.callStaticMethodOrNull(
|
||||
methodName: String?,
|
||||
parameterTypes: Array<Class<*>>,
|
||||
vararg args: Any?
|
||||
): Any? = runCatchingOrNull {
|
||||
XposedHelpers.callStaticMethod(this, methodName, parameterTypes, *args)
|
||||
}
|
||||
|
||||
fun String.findClass(classLoader: ClassLoader?): Class<*> =
|
||||
XposedHelpers.findClass(this, classLoader)
|
||||
|
||||
fun String.findClassOrNull(classLoader: ClassLoader?): Class<*>? =
|
||||
XposedHelpers.findClassIfExists(this, classLoader)
|
||||
|
||||
fun Class<*>.new(vararg args: Any?): Any = XposedHelpers.newInstance(this, *args)
|
||||
|
||||
fun Class<*>.new(parameterTypes: Array<Class<*>>, vararg args: Any?): Any =
|
||||
XposedHelpers.newInstance(this, parameterTypes, *args)
|
||||
|
||||
fun Class<*>.findField(field: String?): Field = XposedHelpers.findField(this, field)
|
||||
|
||||
fun Class<*>.findFieldOrNull(field: String?): Field? = XposedHelpers.findFieldIfExists(this, field)
|
||||
|
||||
fun <T> T.setIntField(field: String?, value: Int) = apply {
|
||||
XposedHelpers.setIntField(this, field, value)
|
||||
}
|
||||
|
||||
fun <T> T.setLongField(field: String?, value: Long) = apply {
|
||||
XposedHelpers.setLongField(this, field, value)
|
||||
}
|
||||
|
||||
fun <T> T.setObjectField(field: String?, value: Any?) = apply {
|
||||
XposedHelpers.setObjectField(this, field, value)
|
||||
}
|
||||
|
||||
fun <T> T.setBooleanField(field: String?, value: Boolean) = apply {
|
||||
XposedHelpers.setBooleanField(this, field, value)
|
||||
}
|
||||
|
||||
inline fun XResources.hookLayout(
|
||||
id: Int,
|
||||
crossinline hooker: (XC_LayoutInflated.LayoutInflatedParam) -> Unit
|
||||
) {
|
||||
try {
|
||||
hookLayout(id, object : XC_LayoutInflated() {
|
||||
override fun handleLayoutInflated(liparam: LayoutInflatedParam) {
|
||||
try {
|
||||
hooker(liparam)
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun XResources.hookLayout(
|
||||
pkg: String,
|
||||
type: String,
|
||||
name: String,
|
||||
crossinline hooker: (XC_LayoutInflated.LayoutInflatedParam) -> Unit
|
||||
) {
|
||||
try {
|
||||
val id = getIdentifier(name, type, pkg)
|
||||
hookLayout(id, hooker)
|
||||
} catch (e: Throwable) {
|
||||
log(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun Class<*>.findFirstFieldByExactType(type: Class<*>): Field =
|
||||
XposedHelpers.findFirstFieldByExactType(this, type)
|
||||
|
||||
fun Class<*>.findFirstFieldByExactTypeOrNull(type: Class<*>?): Field? = runCatchingOrNull {
|
||||
XposedHelpers.findFirstFieldByExactType(this, type)
|
||||
}
|
||||
|
||||
fun Any.getFirstFieldByExactType(type: Class<*>): Any? =
|
||||
javaClass.findFirstFieldByExactType(type).get(this)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getFirstFieldByExactTypeAs(type: Class<*>) =
|
||||
javaClass.findFirstFieldByExactType(type).get(this) as? T
|
||||
|
||||
inline fun <reified T : Any> Any.getFirstFieldByExactType() =
|
||||
javaClass.findFirstFieldByExactType(T::class.java).get(this) as? T
|
||||
|
||||
fun Any.getFirstFieldByExactTypeOrNull(type: Class<*>?): Any? = runCatchingOrNull {
|
||||
javaClass.findFirstFieldByExactTypeOrNull(type)?.get(this)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> Any.getFirstFieldByExactTypeOrNullAs(type: Class<*>?) =
|
||||
getFirstFieldByExactTypeOrNull(type) as? T
|
||||
|
||||
inline fun <reified T> Any.getFirstFieldByExactTypeOrNull() =
|
||||
getFirstFieldByExactTypeOrNull(T::class.java) as? T
|
||||
|
||||
fun ClassLoader.allClassesList(): List<String> {
|
||||
var classLoader = this
|
||||
while (classLoader !is BaseDexClassLoader) {
|
||||
if (classLoader.parent != null) classLoader = classLoader.parent
|
||||
else return emptyList()
|
||||
}
|
||||
return classLoader.getObjectField("pathList")
|
||||
?.getObjectFieldAs<Array<Any>>("dexElements")
|
||||
?.flatMap {
|
||||
it.getObjectField("dexFile")?.callMethodAs<Enumeration<String>>("entries")?.toList()
|
||||
.orEmpty()
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
inline fun ClassLoader.findDexClassLoader(): BaseDexClassLoader? {
|
||||
var classLoader = this
|
||||
while (classLoader !is BaseDexClassLoader) {
|
||||
if (classLoader.parent != null) classLoader = classLoader.parent
|
||||
else return null
|
||||
}
|
||||
return classLoader
|
||||
}
|
||||
|
||||
inline fun <T> T?.isNull(crossinline isNull: () -> Unit):T? {
|
||||
if (this == null) isNull()
|
||||
return this
|
||||
}
|
||||
|
||||
inline fun <T> T?.isNonNull(crossinline nonNull: (T) -> Unit): T? {
|
||||
if (this != null) nonNull(this)
|
||||
return this
|
||||
}
|
||||
@@ -19,3 +19,10 @@ object XSPUtils {
|
||||
return prefs.getInt(key, defValue)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun hasEnable(key: String, default: Boolean = false, noinline extraCondition: (() -> Boolean)? = null, crossinline block: () -> Unit) {
|
||||
val conditionResult = if (extraCondition != null) extraCondition() else true
|
||||
if (XSPUtils.getBoolean(key, default) && conditionResult) {
|
||||
block()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user