Skip to content

Commit

Permalink
HomeHandle: Fix crash if blurCompat Class not found
Browse files Browse the repository at this point in the history
Fixed Crash on Android U without HyperOS

Signed-off-by: Art_Chen <[email protected]>
  • Loading branch information
Art-Chen committed Nov 5, 2023
1 parent 1dab18e commit c847a3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "moe.chenxy.miuiextra"
minSdk 31
targetSdk 34
versionCode 14
versionName "2.6.9-U-Pre_Hyper"
versionCode 16
versionName "2.6.9.2-U-Pre_Hyper"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package moe.chenxy.miuiextra.hooker.entity.systemui

import android.view.View
import com.highcapable.yukihookapi.hook.factory.toClassOrNull
import de.robv.android.xposed.XposedHelpers
import moe.chenxy.miuiextra.hooker.entity.systemui.MiBlurCompatUtils.isSupportMiBlur
import moe.chenxy.miuiextra.hooker.entity.systemui.StatusBarBlurUtilsHooker.toClass
import moe.chenxy.miuiextra.utils.ChenUtils

object MiBlurCompatUtils {
private const val blurCompatCls = "com.miui.systemui.util.MiBlurCompat"
private val blurCompatCls = "com.miui.systemui.util.MiBlurCompat".toClassOrNull()

@JvmStatic
fun View.setPassWindowBlurEnabledCompat(enable: Boolean) =
if (ChenUtils.isAboveAndroidVersion(ChenUtils.Companion.AndroidVersion.U)) {
blurCompatCls?.let {
XposedHelpers.callStaticMethod(
blurCompatCls.toClass(), "setPassWindowBlurEnabledCompat", this, enable
it, "setPassWindowBlurEnabledCompat", this, enable
)
} else {

}


@JvmStatic
fun View.setMiBackgroundBlurModeCompat(mode: Int) = XposedHelpers.callMethod(
this, "setMiBackgroundBlurMode", mode)
Expand All @@ -32,13 +33,11 @@ object MiBlurCompatUtils {

@JvmStatic
fun View.isSupportMiBlur() =
if (ChenUtils.isAboveAndroidVersion(ChenUtils.Companion.AndroidVersion.U)) {
blurCompatCls?.let {
XposedHelpers.callStaticMethod(
blurCompatCls.toClass(),
it,
"getBackgroundBlurOpened",
this.context
) as Boolean
} else {
false
}
} ?: false
}

0 comments on commit c847a3a

Please sign in to comment.