Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Issue #11732: Refactor Frequency into support-base component
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielluong authored and mergify[bot] committed Feb 22, 2022
1 parent eb2057a commit e9b721d
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import kotlinx.coroutines.withContext
import mozilla.components.concept.engine.webextension.EnableSource
import mozilla.components.feature.addons.Addon
import mozilla.components.feature.addons.R
import mozilla.components.feature.addons.migration.SupportedAddonsChecker.Frequency
import mozilla.components.feature.addons.ui.translateName
import mozilla.components.feature.addons.update.GlobalAddonDependencyProvider
import mozilla.components.feature.addons.worker.shouldReport
import mozilla.components.support.base.ids.SharedIdsHelper
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.base.worker.Frequency
import mozilla.components.support.ktx.android.content.appName
import mozilla.components.support.ktx.android.notification.ChannelData
import mozilla.components.support.ktx.android.notification.ensureNotificationChannelExists
Expand All @@ -50,13 +50,6 @@ interface SupportedAddonsChecker {
* Unregisters for periodic checks for new available add-ons.
*/
fun unregisterForChecks()

/**
* Indicates how often checks for newly supported add-ons should happen.
* @property repeatInterval Integer indicating how often the update should happen.
* @property repeatIntervalTimeUnit The time unit of the [repeatInterval].
*/
data class Frequency(val repeatInterval: Long, val repeatIntervalTimeUnit: TimeUnit)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ import mozilla.components.concept.engine.webextension.WebExtensionException
import mozilla.components.concept.engine.webextension.isUnsupported
import mozilla.components.feature.addons.Addon
import mozilla.components.feature.addons.R
import mozilla.components.feature.addons.update.AddonUpdater.Frequency
import mozilla.components.feature.addons.update.db.UpdateAttemptsDatabase
import mozilla.components.feature.addons.update.db.toEntity
import mozilla.components.feature.addons.worker.shouldReport
import mozilla.components.support.base.ids.SharedIdsHelper
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.base.worker.Frequency
import mozilla.components.support.ktx.android.notification.ChannelData
import mozilla.components.support.ktx.android.notification.ensureNotificationChannelExists
import mozilla.components.support.utils.PendingIntentUtils
Expand Down Expand Up @@ -134,13 +134,6 @@ interface AddonUpdater {
data class Error(val message: String, val exception: Throwable) : Status()
}

/**
* Indicates how often an extension should be updated.
* @property repeatInterval Integer indicating how often the update should happen.
* @property repeatIntervalTimeUnit The time unit of the [repeatInterval].
*/
class Frequency(val repeatInterval: Long, val repeatIntervalTimeUnit: TimeUnit)

/**
* Represents an attempt to update an add-on.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import mozilla.components.feature.addons.migration.DefaultSupportedAddonsChecker.Companion.CHECKER_UNIQUE_PERIODIC_WORK_NAME
import mozilla.components.feature.addons.migration.DefaultSupportedAddonsChecker.Companion.WORK_TAG_PERIODIC
import mozilla.components.feature.addons.migration.SupportedAddonsChecker.Frequency
import mozilla.components.support.base.worker.Frequency
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import kotlinx.coroutines.runBlocking
import mozilla.components.concept.engine.webextension.DisabledFlags
import mozilla.components.concept.engine.webextension.Metadata
import mozilla.components.concept.engine.webextension.WebExtension
import mozilla.components.feature.addons.update.AddonUpdater.Frequency
import mozilla.components.feature.addons.update.AddonUpdaterWorker.Companion.KEY_DATA_EXTENSIONS_ID
import mozilla.components.feature.addons.update.DefaultAddonUpdater.Companion.WORK_TAG_IMMEDIATE
import mozilla.components.feature.addons.update.DefaultAddonUpdater.Companion.WORK_TAG_PERIODIC
import mozilla.components.feature.addons.update.DefaultAddonUpdater.NotificationHandlerService
import mozilla.components.support.base.worker.Frequency
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.base.worker.Frequency
import java.util.concurrent.TimeUnit

/**
Expand Down Expand Up @@ -78,14 +79,3 @@ class ContileTopSitesUpdater(
internal const val PERIODIC_WORK_TAG = "mozilla.components.service.contile.periodicWork"
}
}

/**
* Indicates how often Contile top sites should be updated.
*
* @property repeatInterval Long indicating how often the update should happen.
* @property repeatIntervalTimeUnit The time unit of the [repeatInterval].
*/
data class Frequency(
val repeatInterval: Long,
val repeatIntervalTimeUnit: TimeUnit
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package mozilla.components.service.pocket

import mozilla.components.concept.fetch.Client
import mozilla.components.support.base.worker.Frequency
import java.util.concurrent.TimeUnit

internal const val DEFAULT_REFRESH_INTERVAL = 4L
Expand All @@ -24,11 +25,3 @@ class PocketStoriesConfig(
DEFAULT_REFRESH_TIMEUNIT
)
)

/**
* Indicates how often the pocket stories should be refreshed.
*
* @param repeatInterval Integer indicating how often the update should happen.
* @param repeatIntervalTimeUnit The time unit of the [repeatInterval].
*/
class Frequency(val repeatInterval: Long, val repeatIntervalTimeUnit: TimeUnit)
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequest
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import mozilla.components.service.pocket.Frequency
import mozilla.components.service.pocket.PocketStoriesConfig
import mozilla.components.service.pocket.logger
import mozilla.components.service.pocket.stories.update.RefreshPocketWorker.Companion.REFRESH_WORK_TAG
import mozilla.components.support.base.worker.Frequency

/**
* Class used to schedule Pocket recommended stories refresh.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package mozilla.components.service.pocket

import androidx.test.ext.junit.runners.AndroidJUnit4
import mozilla.components.service.pocket.helpers.assertClassVisibility
import mozilla.components.support.base.worker.Frequency
import mozilla.components.support.test.mock
import org.junit.Assert.assertEquals
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequest
import androidx.work.WorkManager
import mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
import mozilla.components.service.pocket.Frequency
import mozilla.components.service.pocket.PocketStoriesConfig
import mozilla.components.service.pocket.helpers.assertClassVisibility
import mozilla.components.service.pocket.stories.update.RefreshPocketWorker.Companion.REFRESH_WORK_TAG
import mozilla.components.support.base.worker.Frequency
import mozilla.components.support.test.any
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package mozilla.components.support.base.worker

import java.util.concurrent.TimeUnit

/**
* Indicates how often the work request should be run.
*
* @property repeatInterval Long indicating how often the update should happen.
* @property repeatIntervalTimeUnit The time unit of [repeatInterval].
*/
data class Frequency(
val repeatInterval: Long,
val repeatIntervalTimeUnit: TimeUnit
)
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ permalink: /changelog/

* **feature-top-sites**
* ⚠️ **This is a breaking change**: This changes `fetchProvidedTopSites` in `TopSitesConfig` into a data class `TopSitesProviderConfig` that specifies whether or not to display the top sites from the provider. [#11654](https://github.com/mozilla-mobile/android-components/issues/11654)

* **support-base**
* ⚠️ **This is a breaking change**: Refactor `Frequency` out of **feature-addons** and **service-pocket** [#11732](https://github.com/mozilla-mobile/android-components/pull/11732).

* **support-utils**
* 🌟️️ **Added new Browsers constant for Fennec `Browsers.FIREFOX_FENNEC_NIGHTLY`.
* ⚠️ **This is a breaking change**: `Browsers.FIREFOX_NIGHTLY` now points to `org.mozilla.fenix`, for fennec nightly use `Browsers.FIREFOX_FENNEC_NIGHTLY` [#11682](https://github.com/mozilla-mobile/android-components/pull/11682).
Expand Down
1 change: 1 addition & 0 deletions samples/browser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ dependencies {
implementation project(':service-digitalassetlinks')
implementation project(':service-sync-logins')

implementation project(':support-base')
implementation project(':support-utils')
implementation project(':support-ktx')
implementation project(':support-webextensions')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import mozilla.components.concept.fetch.Client
import mozilla.components.feature.addons.AddonManager
import mozilla.components.feature.addons.amo.AddonCollectionProvider
import mozilla.components.feature.addons.migration.DefaultSupportedAddonsChecker
import mozilla.components.feature.addons.migration.SupportedAddonsChecker
import mozilla.components.feature.addons.update.AddonUpdater
import mozilla.components.feature.addons.update.DefaultAddonUpdater
import mozilla.components.feature.app.links.AppLinksInterceptor
import mozilla.components.feature.app.links.AppLinksUseCases
Expand Down Expand Up @@ -78,6 +76,7 @@ import mozilla.components.service.digitalassetlinks.local.StatementApi
import mozilla.components.service.digitalassetlinks.local.StatementRelationChecker
import mozilla.components.service.location.LocationService
import mozilla.components.service.sync.logins.SyncableLoginsStorage
import mozilla.components.support.base.worker.Frequency
import org.mozilla.samples.browser.addons.AddonsActivity
import org.mozilla.samples.browser.autofill.AutofillConfirmActivity
import org.mozilla.samples.browser.autofill.AutofillSearchActivity
Expand Down Expand Up @@ -129,7 +128,7 @@ open class DefaultComponents(private val applicationContext: Context) {
}

val addonUpdater =
DefaultAddonUpdater(applicationContext, AddonUpdater.Frequency(1, TimeUnit.DAYS))
DefaultAddonUpdater(applicationContext, Frequency(1, TimeUnit.DAYS))

// Engine
open val engine: Engine by lazy {
Expand Down Expand Up @@ -190,7 +189,7 @@ open class DefaultComponents(private val applicationContext: Context) {
}

val supportedAddonsChecker by lazy {
DefaultSupportedAddonsChecker(applicationContext, SupportedAddonsChecker.Frequency(1, TimeUnit.DAYS))
DefaultSupportedAddonsChecker(applicationContext, Frequency(1, TimeUnit.DAYS))
}

val searchUseCases by lazy {
Expand Down

1 comment on commit e9b721d

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

Failed to fetch task artifact public/github/customCheckRunText.md for GitHub integration.
Make sure the artifact exists on the worker or other location.

Please sign in to comment.