mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Rationalize download failure
This commit is contained in:
parent
a230d63cf9
commit
93edf72993
@ -42,11 +42,7 @@ abstract class RemoteFileService : NotificationService() {
|
|||||||
.doOnSubscribe { update(subject.hashCode()) { it.setContentTitle(subject.title) } }
|
.doOnSubscribe { update(subject.hashCode()) { it.setContentTitle(subject.title) } }
|
||||||
.subscribeK(onError = {
|
.subscribeK(onError = {
|
||||||
Timber.e(it)
|
Timber.e(it)
|
||||||
finishNotify(subject.hashCode()) { notification ->
|
failNotify(subject)
|
||||||
notification.setContentText(getString(R.string.download_file_error))
|
|
||||||
.setSmallIcon(android.R.drawable.stat_notify_error)
|
|
||||||
.setOngoing(false)
|
|
||||||
}
|
|
||||||
}) {
|
}) {
|
||||||
val newId = finishNotify(subject)
|
val newId = finishNotify(subject)
|
||||||
if (get<Activity>() !is NullActivity) {
|
if (get<Activity>() !is NullActivity) {
|
||||||
@ -76,7 +72,7 @@ abstract class RemoteFileService : NotificationService() {
|
|||||||
}.doOnComplete {
|
}.doOnComplete {
|
||||||
if (subject is Manager)
|
if (subject is Manager)
|
||||||
handleAPK(subject)
|
handleAPK(subject)
|
||||||
}.doOnError { send(0f, subject) }
|
}
|
||||||
|
|
||||||
private fun ResponseBody.toStream(id: Int, subject: DownloadSubject): InputStream {
|
private fun ResponseBody.toStream(id: Int, subject: DownloadSubject): InputStream {
|
||||||
val maxRaw = contentLength()
|
val maxRaw = contentLength()
|
||||||
@ -97,6 +93,13 @@ abstract class RemoteFileService : NotificationService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun failNotify(subject: DownloadSubject) = finishNotify(subject.hashCode()) {
|
||||||
|
send(0f, subject)
|
||||||
|
it.setContentText(getString(R.string.download_file_error))
|
||||||
|
.setSmallIcon(android.R.drawable.stat_notify_error)
|
||||||
|
.setOngoing(false)
|
||||||
|
}
|
||||||
|
|
||||||
private fun finishNotify(subject: DownloadSubject) = finishNotify(subject.hashCode()) {
|
private fun finishNotify(subject: DownloadSubject) = finishNotify(subject.hashCode()) {
|
||||||
send(1f, subject)
|
send(1f, subject)
|
||||||
it.addActions(subject)
|
it.addActions(subject)
|
||||||
|
Loading…
Reference in New Issue
Block a user