Skip to content
Snippets Groups Projects
Commit 6ae8a7bb authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

Automatically delete the auto update APK file on startup

parent 97e5fbad
No related branches found
No related tags found
1 merge request!1942Automatically delete the auto update APK file on startup
Pipeline #490168 passed with stage
in 4 minutes and 12 seconds
......@@ -80,6 +80,7 @@ class MainTvActivity : BaseTvActivity(), StoragePermissionsDelegate.CustomAction
browseFragment = fragmentManager.findFragmentById(R.id.browse_fragment) as MainTvFragment
progressBar = findViewById(R.id.tv_main_progress)
lifecycleScope.launch {
AutoUpdate.clean(this@MainTvActivity.application)
if (!Settings.getInstance(this@MainTvActivity).getBoolean(KEY_SHOW_UPDATE, true)) return@launch
AutoUpdate.checkUpdate(this@MainTvActivity.application) {url, date ->
val updateDialog = UpdateDialog().apply {
......
......@@ -123,6 +123,7 @@ class MainActivity : ContentActivity(),
}
lifecycleScope.launch {
AutoUpdate.clean(this@MainActivity.application)
if (!settings.getBoolean(KEY_SHOW_UPDATE, true)) return@launch
AutoUpdate.checkUpdate(this@MainActivity.application) {url, date ->
val updateDialog = UpdateDialog().apply {
......
......@@ -178,5 +178,14 @@ object AutoUpdate {
}
}
suspend fun clean(context: Application) = withContext(Dispatchers.IO) {
try {
val downloadedFile = File(context.getCacheDir(), "update.apk")
if (downloadedFile.exists()) downloadedFile.delete() else { }
} catch (e: Exception) {
Log.e(TAG, e.message, e)
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment