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..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 { @@ -222,8 +231,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))