mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Fixed extension job queueing library to run ext updates when not needed
Best way i can phrase it, but theres a chance the previous logic would run the extension job at weird times
This commit is contained in:
parent
6990bcaa26
commit
2c7e9ef7f3
1 changed files with 21 additions and 22 deletions
|
@ -56,10 +56,14 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
|||
val extensions = extensionsList.toMutableList()
|
||||
val preferences: PreferencesHelper by injectLazy()
|
||||
preferences.extensionUpdatesCount().set(extensions.size)
|
||||
val extensionsInstalledByApp by lazy {
|
||||
extensions.filter { Injekt.get<ExtensionManager>().isInstalledByApp(it) }
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||
inputData.getBoolean(RUN_AUTO, true) &&
|
||||
preferences.autoUpdateExtensions() != AutoUpdaterJob.NEVER &&
|
||||
!ExtensionInstallService.isRunning()
|
||||
!ExtensionInstallService.isRunning() &&
|
||||
extensionsInstalledByApp.isNotEmpty()
|
||||
) {
|
||||
val cm = context.connectivityManager
|
||||
val libraryServiceRunning = LibraryUpdateService.isRunning()
|
||||
|
@ -69,27 +73,22 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
|||
!cm.isActiveNetworkMetered
|
||||
) && !libraryServiceRunning
|
||||
) {
|
||||
val extensionManager = Injekt.get<ExtensionManager>()
|
||||
val extensionsInstalledByApp =
|
||||
extensions.filter { extensionManager.isInstalledByApp(it) }
|
||||
if (extensionsInstalledByApp.isNotEmpty()) {
|
||||
val intent =
|
||||
ExtensionInstallService.jobIntent(
|
||||
context,
|
||||
extensionsInstalledByApp,
|
||||
// Re run this job if not all the extensions can be auto updated
|
||||
if (extensionsInstalledByApp.size == extensions.size) {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
}
|
||||
)
|
||||
context.startForegroundService(intent)
|
||||
if (extensionsInstalledByApp.size == extensions.size) {
|
||||
return
|
||||
} else {
|
||||
extensions.removeAll(extensionsInstalledByApp)
|
||||
}
|
||||
val intent =
|
||||
ExtensionInstallService.jobIntent(
|
||||
context,
|
||||
extensionsInstalledByApp,
|
||||
// Re run this job if not all the extensions can be auto updated
|
||||
if (extensionsInstalledByApp.size == extensions.size) {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
}
|
||||
)
|
||||
context.startForegroundService(intent)
|
||||
if (extensionsInstalledByApp.size == extensions.size) {
|
||||
return
|
||||
} else {
|
||||
extensions.removeAll(extensionsInstalledByApp)
|
||||
}
|
||||
} else if (!libraryServiceRunning) {
|
||||
runJobAgain(context, NetworkType.UNMETERED)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue