Skip to content

Commit

Permalink
Handle some missing methods and fields
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 242a82d commit 5036b43
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,17 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
}
})

try {
val hasSwitchAllContentToParent = qsPanelClass.declaredMethods.any {
it.name == "switchAllContentToParent"
}
val hasSwitchToParentMethod = qsPanelClass.declaredMethods.any { method ->
method.name == "switchToParent" &&
method.parameterTypes.contentEquals(
arrayOf(View::class.java, ViewGroup::class.java, Int::class.java)
)
}

if (hasSwitchAllContentToParent && hasSwitchToParentMethod) {
hookAllMethods(qsPanelClass, "switchAllContentToParent", object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
if (!showHeaderClock) return
Expand Down Expand Up @@ -403,7 +413,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
}
)
}
} catch (ignored: Throwable) { // Some ROMs don't have this method switchAllContentToParent()
} else { // Some ROMs don't have this method switchAllContentToParent()
hookAllMethods(
qsPanelControllerBase,
"onInit",
Expand Down Expand Up @@ -439,7 +449,7 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) {
val targetParentId = mContext.resources.getIdentifier(
"quick_settings_panel",
"id",
mContext.packageName
SYSTEMUI_PACKAGE
)

if (parent.id == targetParentId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,18 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
override fun afterHookedMethod(param: MethodHookParam) {
if (!showOpQsHeaderView) return

val mQsPanel = getObjectField(param.thisObject, "mQSPanel") as LinearLayout
val mQsPanel = try {
getObjectField(param.thisObject, "mQSPanel")
} catch (ignored: Throwable) {
(param.thisObject as FrameLayout).findViewById(
mContext.resources.getIdentifier(
"quick_settings_panel",
"id",
SYSTEMUI_PACKAGE
)
)
} as LinearLayout

val isLandscape =
mContext.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE

Expand All @@ -499,7 +510,17 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
}
})

try {
val hasSwitchAllContentToParent = qsPanelClass.declaredMethods.any {
it.name == "switchAllContentToParent"
}
val hasSwitchToParentMethod = qsPanelClass.declaredMethods.any { method ->
method.name == "switchToParent" &&
method.parameterTypes.contentEquals(
arrayOf(View::class.java, ViewGroup::class.java, Int::class.java)
)
}

if (hasSwitchAllContentToParent && hasSwitchToParentMethod) {
hookAllMethods(qsPanelClass, "switchAllContentToParent", object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
if (!showOpQsHeaderView) return
Expand All @@ -512,7 +533,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
val targetParentId = mContext.resources.getIdentifier(
"quick_settings_panel",
"id",
mContext.packageName
SYSTEMUI_PACKAGE
)

if (parent.id == targetParentId) {
Expand Down Expand Up @@ -569,7 +590,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
}
)
}
} catch (ignored: Throwable) { // Some ROMs don't have this method switchAllContentToParent()
} else { // Some ROMs don't have this method switchAllContentToParent()
hookAllMethods(
qsPanelControllerBase,
"onInit",
Expand Down Expand Up @@ -605,7 +626,7 @@ class OpQsHeader(context: Context?) : ModPack(context!!) {
val targetParentId = mContext.resources.getIdentifier(
"quick_settings_panel",
"id",
mContext.packageName
SYSTEMUI_PACKAGE
)

if (parent.id == targetParentId) {
Expand Down

0 comments on commit 5036b43

Please sign in to comment.