From b28e5fded71cbd399ef9800ea9186c88b9b8d19f Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Tue, 16 May 2023 14:35:19 +0100 Subject: [PATCH 1/2] fix: Improve Magisk detection as /sbin may not exist anymore --- app/src/main/java/me/phh/treble/app/UpdaterActivity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt b/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt index 12f3834e1b67..94ce28ed7c20 100644 --- a/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt +++ b/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt @@ -222,8 +222,8 @@ class UpdaterActivity : PreferenceActivity() { } private fun isMagiskInstalled() { - val magiskDir = File("/sbin/.magisk") - if (magiskDir.exists()) { + val magiskBin = File("/system/bin/magisk") + if (magiskBin.exists()) { Log.e("PHH", "Magisk is installed") val builder = AlertDialog.Builder(this) builder.setTitle(getString(R.string.warning_dialog_title)) From 241c616946e43cb1ef7560fee730c603a45b94eb Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Tue, 16 May 2023 14:36:21 +0100 Subject: [PATCH 2/2] fix: Improve HTTP response handling --- .../java/me/phh/treble/app/UpdaterActivity.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt b/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt index 94ce28ed7c20..3a58035970dc 100644 --- a/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt +++ b/app/src/main/java/me/phh/treble/app/UpdaterActivity.kt @@ -125,11 +125,20 @@ class UpdaterActivity : PreferenceActivity() { } override fun onResponse(call: Call, response: Response) { Log.e("PHH", "Got response") - otaJson = JSONTokener(response.body?.string()).nextValue() as JSONObject - runOnUiThread(Runnable { - hasUpdate = existsUpdate() - updateUiElements(false) - }) + if ((response.code == 200 || response.code == 304) && response.body != null) { + Log.e("PHH", "Response body: " + response.body.string()) + otaJson = JSONTokener(response.body?.string()).nextValue() as JSONObject + runOnUiThread(Runnable { + hasUpdate = existsUpdate() + updateUiElements(false) + }) + } else { + Log.e("PHH", "Invalid HTTP response or body. Code: " + response.code) + runOnUiThread(Runnable { + hasUpdate = false + updateUiElements(false) + }) + } } }) } else {