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 extensions = extensionsList.toMutableList()
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
preferences.extensionUpdatesCount().set(extensions.size)
|
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 &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
|
||||||
inputData.getBoolean(RUN_AUTO, true) &&
|
inputData.getBoolean(RUN_AUTO, true) &&
|
||||||
preferences.autoUpdateExtensions() != AutoUpdaterJob.NEVER &&
|
preferences.autoUpdateExtensions() != AutoUpdaterJob.NEVER &&
|
||||||
!ExtensionInstallService.isRunning()
|
!ExtensionInstallService.isRunning() &&
|
||||||
|
extensionsInstalledByApp.isNotEmpty()
|
||||||
) {
|
) {
|
||||||
val cm = context.connectivityManager
|
val cm = context.connectivityManager
|
||||||
val libraryServiceRunning = LibraryUpdateService.isRunning()
|
val libraryServiceRunning = LibraryUpdateService.isRunning()
|
||||||
|
@ -69,10 +73,6 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
||||||
!cm.isActiveNetworkMetered
|
!cm.isActiveNetworkMetered
|
||||||
) && !libraryServiceRunning
|
) && !libraryServiceRunning
|
||||||
) {
|
) {
|
||||||
val extensionManager = Injekt.get<ExtensionManager>()
|
|
||||||
val extensionsInstalledByApp =
|
|
||||||
extensions.filter { extensionManager.isInstalledByApp(it) }
|
|
||||||
if (extensionsInstalledByApp.isNotEmpty()) {
|
|
||||||
val intent =
|
val intent =
|
||||||
ExtensionInstallService.jobIntent(
|
ExtensionInstallService.jobIntent(
|
||||||
context,
|
context,
|
||||||
|
@ -90,7 +90,6 @@ class ExtensionUpdateJob(private val context: Context, workerParams: WorkerParam
|
||||||
} else {
|
} else {
|
||||||
extensions.removeAll(extensionsInstalledByApp)
|
extensions.removeAll(extensionsInstalledByApp)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (!libraryServiceRunning) {
|
} else if (!libraryServiceRunning) {
|
||||||
runJobAgain(context, NetworkType.UNMETERED)
|
runJobAgain(context, NetworkType.UNMETERED)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue