Skip to content

Commit

Permalink
Merge pull request phhusson#5 from ponces/improve-updater
Browse files Browse the repository at this point in the history
Improve OTA Updater activity
  • Loading branch information
phhusson authored May 17, 2023
2 parents f7743b9 + 241c616 commit 1fec05c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions app/src/main/java/me/phh/treble/app/UpdaterActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 1fec05c

Please sign in to comment.