Skip to content

Commit 308fe39

Browse files
authored
Merge pull request #4108 from kiwix/Fixes#4106
Fixed: Download notification was disappearing when the application is in background.
2 parents fff3c3e + 05891eb commit 308fe39

File tree

13 files changed

+742
-616
lines changed

13 files changed

+742
-616
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
tools:ignore="CoarseFineLocation" />
99
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
1010
<uses-permission android:name="${permission}" />
11-
<!-- Device with versions >= Pie need this permission -->
12-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
13-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
1411
<uses-permission
1512
android:name="android.permission.NEARBY_WIFI_DEVICES"
1613
android:usesPermissionFlags="neverForLocation"

app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import android.content.Context
2424
import dagger.Module
2525
import dagger.Provides
2626
import org.kiwix.kiwixmobile.core.qr.GenerateQR
27-
import org.kiwix.kiwixmobile.core.read_aloud.ReadAloudNotificationManger
2827
import org.kiwix.kiwixmobile.di.ServiceScope
2928
import org.kiwix.kiwixmobile.webserver.KiwixServer
3029
import org.kiwix.kiwixmobile.webserver.WebServerHelper
@@ -34,12 +33,6 @@ import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks
3433

3534
@Module
3635
class ServiceModule {
37-
@Provides
38-
@ServiceScope
39-
fun providesReadAloudNotificationManager(
40-
notificationManager: NotificationManager,
41-
context: Context
42-
): ReadAloudNotificationManger = ReadAloudNotificationManger(notificationManager, context)
4336

4437
@Provides
4538
@ServiceScope

core/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<uses-permission
1717
android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
1818
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
19+
<!-- Device with versions >= Pie need this permission -->
20+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
21+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
1922
<queries>
2023
<intent>
2124
<action android:name="android.intent.action.TTS_SERVICE" />
@@ -90,5 +93,8 @@
9093
android:name=".error.DiagnosticReportActivity"
9194
android:exported="false" />
9295
<service android:name=".read_aloud.ReadAloudService" />
96+
<service
97+
android:name=".downloader.downloadManager.DownloadMonitorService"
98+
android:foregroundServiceType="dataSync" />
9399
</application>
94100
</manifest>

core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreComponent.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import org.kiwix.kiwixmobile.core.di.modules.NetworkModule
5252
import org.kiwix.kiwixmobile.core.di.modules.SearchModule
5353
import org.kiwix.kiwixmobile.core.downloader.Downloader
5454
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadManagerBroadcastReceiver
55-
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadNotificationActionsBroadcastReceiver
5655
import org.kiwix.kiwixmobile.core.error.ErrorActivity
5756
import org.kiwix.kiwixmobile.core.main.KiwixWebView
5857
import org.kiwix.kiwixmobile.core.reader.ZimFileReader
@@ -117,8 +116,6 @@ interface CoreComponent {
117116
fun mutex(): Mutex
118117

119118
fun downloadManagerBroadCastReceiver(): DownloadManagerBroadcastReceiver
120-
fun downloadNotificationActionBroadCastReceiver(): DownloadNotificationActionsBroadcastReceiver
121-
122119
fun inject(application: CoreApp)
123120
fun inject(kiwixWebView: KiwixWebView)
124121
fun inject(storageSelectDialog: StorageSelectDialog)

core/src/main/java/org/kiwix/kiwixmobile/core/di/components/CoreServiceComponent.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import dagger.BindsInstance
2323
import dagger.Subcomponent
2424
import org.kiwix.kiwixmobile.core.di.CoreServiceScope
2525
import org.kiwix.kiwixmobile.core.di.modules.CoreServiceModule
26+
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadMonitorService
2627
import org.kiwix.kiwixmobile.core.read_aloud.ReadAloudService
2728

2829
@Subcomponent(modules = [CoreServiceModule::class])
2930
@CoreServiceScope
3031
interface CoreServiceComponent {
3132
fun inject(readAloudService: ReadAloudService)
33+
fun inject(downloadMonitorService: DownloadMonitorService)
3234

3335
@Subcomponent.Builder
3436
interface Builder {

core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/DownloaderModule.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import org.kiwix.kiwixmobile.core.downloader.DownloaderImpl
3030
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadManagerBroadcastReceiver
3131
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadManagerMonitor
3232
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadManagerRequester
33-
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadNotificationActionsBroadcastReceiver
3433
import org.kiwix.kiwixmobile.core.downloader.downloadManager.DownloadNotificationManager
3534
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
3635
import javax.inject.Singleton
@@ -71,13 +70,6 @@ object DownloaderModule {
7170
callback: DownloadManagerBroadcastReceiver.Callback
7271
): DownloadManagerBroadcastReceiver = DownloadManagerBroadcastReceiver(callback)
7372

74-
@Provides
75-
@Singleton
76-
fun providesDownloadNotificationActionsBroadcastReceiver(
77-
downloadManagerMonitor: DownloadManagerMonitor
78-
): DownloadNotificationActionsBroadcastReceiver =
79-
DownloadNotificationActionsBroadcastReceiver(downloadManagerMonitor)
80-
8173
@Provides
8274
@Singleton
8375
fun providesDownloadNotificationManager(

core/src/main/java/org/kiwix/kiwixmobile/core/di/modules/NetworkModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const val CONNECTION_TIMEOUT = 10L
3535
// increase the read and call timeout since the content is 19MB large so it takes
3636
// more time to read on slow internet connection, and due to less read timeout
3737
// the request is canceled.
38-
const val READ_TIMEOUT = 180L
39-
const val CALL_TIMEOUT = 180L
38+
const val READ_TIMEOUT = 300L
39+
const val CALL_TIMEOUT = 300L
4040
const val USER_AGENT = "kiwix-android-version:${BuildConfig.VERSION_CODE}"
4141
const val KIWIX_DOWNLOAD_URL = "https://mirror.download.kiwix.org/"
4242

0 commit comments

Comments
 (0)