mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-11 17:26:53 -04:00
Add marker files to indicate download progress
1bfc8a14 adds the ability to download APKs via an intent, but since
intents are asynchronous, and the incomplete APK appears in its final
destination ~immediately while it downloads, the caller lacks a way to
identify that download has completed.
This commit adds two marker files in the form:
sdcard/Aurora/Store/Downloads/com.pkg/.1234.download-in-progress
sdcard/Aurora/Store/Downloads/com.pkg/.1234.download-complete
(where `com.pkg` and `1234` are package names and version codes
respectively)
in order that the caller can see:
1. the version that is being downloaded;
2. when the download has finished.
This commit is contained in:
committed by
Rahul Kumar Patel
parent
1bfc8a14fb
commit
86c08e9eab
@@ -76,6 +76,8 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
private lateinit var downloadManager: DownloadManager
|
||||
private lateinit var fetch: Fetch
|
||||
private lateinit var fetchGroupListener: FetchGroupListener
|
||||
private lateinit var completionMarker: java.io.File
|
||||
private lateinit var inProgressMarker: java.io.File
|
||||
|
||||
private var isExternal = false
|
||||
private var isNone = false
|
||||
@@ -186,8 +188,10 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
fetchCompleteApp()
|
||||
}
|
||||
|
||||
autoDownload = intent.data!!.getBooleanQueryParameter("download", false)
|
||||
downloadOnly = !intent.data!!.getBooleanQueryParameter("install", false)
|
||||
intent.data?.let {
|
||||
autoDownload = it.getBooleanQueryParameter("download", false)
|
||||
downloadOnly = it.getBooleanQueryParameter("install", false)
|
||||
}
|
||||
} else {
|
||||
val rawApp: String? = intent.getStringExtra(Constants.STRING_EXTRA)
|
||||
if (rawApp != null) {
|
||||
@@ -661,6 +665,17 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
if (groupId == app.id) {
|
||||
status = download.status
|
||||
flip(1)
|
||||
|
||||
val pkgDir = PathUtil.getPackageDirectory(applicationContext, app.packageName)
|
||||
completionMarker =
|
||||
java.io.File("$pkgDir/.${app.versionCode}.download-complete")
|
||||
inProgressMarker =
|
||||
java.io.File("$pkgDir/.${app.versionCode}.download-in-progress")
|
||||
|
||||
if (completionMarker.exists())
|
||||
completionMarker.delete()
|
||||
|
||||
inProgressMarker.createNewFile()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,6 +683,7 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
if (groupId == app.id) {
|
||||
status = download.status
|
||||
flip(1)
|
||||
FileUtils.touch(inProgressMarker)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,6 +715,8 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
status = download.status
|
||||
flip(0)
|
||||
updateProgress(fetchGroup, -1, -1)
|
||||
inProgressMarker.delete()
|
||||
completionMarker.createNewFile()
|
||||
try {
|
||||
verifyAndInstall(fetchGroup.downloads)
|
||||
} catch (e: Exception) {
|
||||
@@ -711,6 +729,7 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
if (groupId == app.id) {
|
||||
status = download.status
|
||||
flip(0)
|
||||
inProgressMarker.delete()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,6 +743,7 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
||||
if (groupId == app.id) {
|
||||
status = download.status
|
||||
flip(0)
|
||||
inProgressMarker.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user