Skip to content

Commit

Permalink
OP QS Header: Fix missing BluetoothController class
Browse files Browse the repository at this point in the history
Signed-off-by: DrDisagree <[email protected]>
  • Loading branch information
Mahmud0808 committed Sep 4, 2024
1 parent 9192482 commit 7906c22
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
private lateinit var opMediaPlayIconDrawable: Drawable
private lateinit var opMediaPauseIconDrawable: Drawable
private lateinit var mediaSessionLegacyHelperClass: Class<*>
private lateinit var bluetoothControllerClass: Class<*>

private var deferredInternetActiveColorAction: (() -> Unit)? = null
private var deferredInternetInactiveColorAction: (() -> Unit)? = null
Expand All @@ -195,6 +194,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
private var deferredMediaPlayerInactiveColorAction: (() -> Unit)? = null

private var lastUpdateTime = 0L
private var opQsLayoutCreated = false

override fun updatePrefs(vararg key: String) {
if (!XprefsIsInitialized) return
Expand Down Expand Up @@ -255,8 +255,8 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
"$SYSTEMUI_PACKAGE.plugins.ActivityStarter",
loadPackageParam.classLoader
)
bluetoothControllerClass = findClass(
"$SYSTEMUI_PACKAGE.statusbar.policy.BluetoothController",
val bluetoothControllerImplClass = findClass(
"$SYSTEMUI_PACKAGE.statusbar.policy.BluetoothControllerImpl",
loadPackageParam.classLoader
)
val notificationMediaManagerClass = findClass(
Expand Down Expand Up @@ -298,11 +298,6 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
"get",
activityStarterClass
)
mBluetoothController = callStaticMethod(
dependencyClass,
"get",
bluetoothControllerClass
)
}
})
} else {
Expand All @@ -312,15 +307,16 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
param.thisObject,
"mActivityStarter"
)
mBluetoothController = callStaticMethod(
dependencyClass,
"get",
bluetoothControllerClass
)
}
})
}

hookAllConstructors(bluetoothControllerImplClass, object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
mBluetoothController = param.thisObject
}
})

hookAllConstructors(notificationMediaManagerClass, object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
mNotificationMediaManager = param.thisObject
Expand Down Expand Up @@ -371,7 +367,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {

initResources(mContext)

onColorsInitialized()
updateOpHeaderView()
}
}

Expand Down Expand Up @@ -476,6 +472,8 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
}
mQsHeaderContainerShade.visibility = View.GONE
}

updateOpHeaderView()
}
})

Expand Down Expand Up @@ -721,6 +719,9 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
}

private fun updateOpHeaderView() {
if (!opQsLayoutCreated) return

onColorsInitialized()
updateMediaController()
setClickListeners()
startMediaUpdater()
Expand Down Expand Up @@ -1368,7 +1369,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
setImageDrawable(artworkDrawable)
scaleType = ImageView.ScaleType.CENTER_CROP
clipToOutline = true
applyBlur(mediaBlurLevel)
applyBlur(if (processedArtwork != null) mediaBlurLevel else 0f)
}

mPreviousMediaArtwork = mMediaArtwork
Expand Down Expand Up @@ -1417,7 +1418,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
}
}

fun onColorsInitialized() {
private fun onColorsInitialized() {
initResources(mContext)

deferredInternetActiveColorAction?.invoke()
Expand Down Expand Up @@ -1935,6 +1936,8 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
}
)
}

opQsLayoutCreated = true
}

private fun createTiles() {
Expand Down

0 comments on commit 7906c22

Please sign in to comment.