Commit 6d1bfc1b authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Don't allow user to cancel while app is installing

parent 487b77f9
......@@ -39,6 +39,7 @@ class Application(val packageName: String, private val applicationManager: Appli
get() = stateManager.state
var downloader: Downloader? = null
private val blocker = Object()
var isInstalling = false
fun incrementUses() {
uses.incrementAndGet()
......@@ -69,10 +70,12 @@ class Application(val packageName: String, private val applicationManager: Appli
}
}
INSTALLING -> {
if (downloader != null) {
downloader?.cancelDownload()
} else {
onDownloadComplete(context, DownloadManager.STATUS_FAILED)
if (!isInstalling) {
if (downloader != null) {
downloader?.cancelDownload()
} else {
onDownloadComplete(context, DownloadManager.STATUS_FAILED)
}
}
return
}
......@@ -124,6 +127,7 @@ class Application(val packageName: String, private val applicationManager: Appli
}
private fun install(context: Context) {
isInstalling = true
info.install(context, basicData!!, this)
}
......@@ -132,6 +136,7 @@ class Application(val packageName: String, private val applicationManager: Appli
blocker.notify()
}
info.getApkFile(context, basicData!!).delete()
isInstalling = false
}
fun isUsed(): Boolean {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment