Fix the downloader

With all databases enabled the ThreadPool queue is exceed (25>16).
This normally isn't an issue for other users of the pool as it will get pushed onto the main thread.
But Android prohibits network activity on the main thread, which the downloader runs from.

Increase it 32 which should be suitable for now.
Maybe consider adding a separate pool in future.

Fixes https://github.com/Divested-Mobile/Hypatia/issues/34
Fixes https://gitlab.com/divested-mobile/hypatia/-/issues/31

Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
Tad 2023-05-15 23:52:14 -04:00
parent e018000c46
commit 22cc72ab87
No known key found for this signature in database
GPG key ID: B286E9F57A07424B
3 changed files with 3 additions and 2 deletions

View file

@ -6,7 +6,7 @@ android {
applicationId "us.spotco.malwarescanner"
minSdkVersion 16
targetSdkVersion 32
versionCode 101
versionCode 102
versionName "2.32"
resConfigs 'en', 'af', 'de', 'es', 'fi', 'fr', 'it', 'pl', 'pt', 'ru', 'tr', 'zh-rCN'
}

View file

@ -53,7 +53,7 @@ class Utils {
}
public static ThreadPoolExecutor getNewThreadPoolExecutor(int threads) {
return new ThreadPoolExecutor(threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(16), new ThreadPoolExecutor.CallerRunsPolicy());
return new ThreadPoolExecutor(threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(32), new ThreadPoolExecutor.CallerRunsPolicy());
}
public static int getMaxThreads() {

View file

@ -0,0 +1 @@
* Fix the downloader when many databases are enabled