Merge pull request #7526 from thunderbird/fix-android-alarm-manager-api-34
Fix AndroidAlarmManager
This commit is contained in:
commit
42fd52d311
5 changed files with 14 additions and 33 deletions
|
@ -19,6 +19,12 @@ dependencies {
|
|||
debugImplementation(projects.backend.demo)
|
||||
|
||||
implementation(libs.androidx.work.runtime)
|
||||
|
||||
testImplementation(libs.robolectric)
|
||||
|
||||
// Required for DependencyInjectionTest to be able to resolve OpenPgpApiManager
|
||||
testImplementation(projects.plugins.openpgpApiLib.openpgpApi)
|
||||
testImplementation(projects.feature.account.setup)
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.fsck.k9
|
||||
package app.k9mail
|
||||
|
||||
import android.view.ContextThemeWrapper
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
|
@ -29,10 +29,8 @@ import org.mockito.kotlin.mock
|
|||
import org.openintents.openpgp.OpenPgpApiManager
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(application = TestApp::class)
|
||||
class DependencyInjectionTest : AutoCloseKoinTest() {
|
||||
private val lifecycleOwner = mock<LifecycleOwner> {
|
||||
on { lifecycle } doReturn mock()
|
|
@ -1,4 +1,4 @@
|
|||
package com.fsck.k9.widget.unread
|
||||
package app.k9mail.unread
|
||||
|
||||
import android.content.Context
|
||||
import assertk.assertThat
|
||||
|
@ -6,7 +6,6 @@ import assertk.assertions.isEqualTo
|
|||
import assertk.assertions.isNull
|
||||
import com.fsck.k9.Account
|
||||
import com.fsck.k9.Preferences
|
||||
import com.fsck.k9.TestApp
|
||||
import com.fsck.k9.controller.MessageCounts
|
||||
import com.fsck.k9.controller.MessageCountsProvider
|
||||
import com.fsck.k9.mailstore.Folder
|
||||
|
@ -15,6 +14,8 @@ import com.fsck.k9.mailstore.FolderType
|
|||
import com.fsck.k9.search.SearchAccount
|
||||
import com.fsck.k9.ui.folders.FolderNameFormatter
|
||||
import com.fsck.k9.ui.messagelist.DefaultFolderProvider
|
||||
import com.fsck.k9.widget.unread.UnreadWidgetConfiguration
|
||||
import com.fsck.k9.widget.unread.UnreadWidgetDataProvider
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.koin.test.AutoCloseKoinTest
|
||||
|
@ -22,10 +23,8 @@ import org.mockito.kotlin.doReturn
|
|||
import org.mockito.kotlin.mock
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(application = TestApp::class)
|
||||
class UnreadWidgetDataProviderTest : AutoCloseKoinTest() {
|
||||
private val context: Context = RuntimeEnvironment.getApplication()
|
||||
private val account = createAccount()
|
|
@ -6,6 +6,7 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.SystemClock
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.fsck.k9.backend.imap.SystemAlarmManager
|
||||
import com.fsck.k9.helper.AlarmManagerCompat
|
||||
import com.fsck.k9.helper.PendingIntentCompat.FLAG_IMMUTABLE
|
||||
|
@ -40,7 +41,8 @@ class AndroidAlarmManager(
|
|||
|
||||
init {
|
||||
val intentFilter = IntentFilter(ALARM_ACTION)
|
||||
context.registerReceiver(
|
||||
ContextCompat.registerReceiver(
|
||||
context,
|
||||
object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
val callback = callback.getAndSet(null)
|
||||
|
@ -54,6 +56,7 @@ class AndroidAlarmManager(
|
|||
}
|
||||
},
|
||||
intentFilter,
|
||||
ContextCompat.RECEIVER_NOT_EXPORTED,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package com.fsck.k9
|
||||
|
||||
import app.k9mail.core.common.oauth.OAuthConfigurationFactory
|
||||
import com.fsck.k9.backend.BackendFactory
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
class TestApp : CommonApp() {
|
||||
override fun provideAppModule(): Module = module {
|
||||
single(named("ClientIdAppName")) { "ClientIdAppName" }
|
||||
single(named("ClientIdAppVersion")) { "ClientIdAppVersion" }
|
||||
single {
|
||||
AppConfig(
|
||||
componentsToDisable = emptyList(),
|
||||
)
|
||||
}
|
||||
single<Map<String, BackendFactory>>(named("developmentBackends")) {
|
||||
emptyMap()
|
||||
}
|
||||
single<OAuthConfigurationFactory> {
|
||||
OAuthConfigurationFactory { emptyMap() }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue