Skip to content

Commit

Permalink
fix: revert toasts change to fix unloading issue
Browse files Browse the repository at this point in the history
  • Loading branch information
PalmDevs authored Oct 4, 2024
1 parent de0a2ac commit 72af6df
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions app/src/main/kotlin/io/github/pyoncord/xposed/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,23 @@ class Main : IXposedHookLoadPackage {
return Json.encodeToString(obj)
}

override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
val reactActivity = runCatching {
lpparam.classLoader.loadClass("com.discord.react_activities.ReactActivity")
}.getOrElse { return } // Package is not our the target app, return

XposedBridge.hookMethod(reactActivity.getDeclaredMethod("onCreate", Bundle::class.java), object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
init(lpparam, param.thisObject as Activity)
}
})
}

fun init(param: XC_LoadPackage.LoadPackageParam, activity: Activity) = with (param) {
val catalystInstanceImpl = classLoader.loadClass("com.facebook.react.bridge.CatalystInstanceImpl")
override fun handleLoadPackage(param: XC_LoadPackage.LoadPackageParam) = with (param) {
// val reactActivity = runCatching {
// lpparam.classLoader.loadClass("com.discord.react_activities.ReactActivity")
// }.getOrElse { return } // Package is not our the target app, return

// XposedBridge.hookMethod(reactActivity.getDeclaredMethod("onCreate", Bundle::class.java), object : XC_MethodHook() {
// override fun beforeHookedMethod(param: MethodHookParam) {
// init(lpparam, param.thisObject as Activity)
// }
// })
// }

// fun init(param: XC_LoadPackage.LoadPackageParam, activity: Activity) = with (param) {
// val catalystInstanceImpl = classLoader.loadClass("com.facebook.react.bridge.CatalystInstanceImpl")
val catalystInstanceImpl = runCatching {
classLoader.loadClass("com.facebook.react.bridge.CatalystInstanceImpl")
}.getOrElse { return@with }

for (module in pyonModules) module.onInit(param)

Expand Down Expand Up @@ -152,9 +155,9 @@ class Main : IXposedHookLoadPackage {
if (e.response.status != HttpStatusCode.NotModified) throw e;
Log.e("Bunny", "Server reponded with status code 304 - no changes to file")
} catch (e: Throwable) {
activity.runOnUiThread {
Toast.makeText(activity.applicationContext, "Failed to fetch JS bundle, Bunny may not load!", Toast.LENGTH_SHORT).show()
}
// activity.runOnUiThread {
// Toast.makeText(activity.applicationContext, "Failed to fetch JS bundle, Bunny may not load!", Toast.LENGTH_SHORT).show()
// }

Log.e("Bunny", "Failed to download bundle", e)
}
Expand Down Expand Up @@ -208,4 +211,4 @@ class Main : IXposedHookLoadPackage {
})
}
}
}
}

0 comments on commit 72af6df

Please sign in to comment.