mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Add cellular backup toggle for message backup.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.jobmanager.impl
|
||||
|
||||
import android.app.Application
|
||||
import android.app.job.JobInfo
|
||||
import org.thoughtcrime.securesms.jobmanager.Constraint
|
||||
import org.thoughtcrime.securesms.util.NetworkUtil
|
||||
|
||||
/**
|
||||
* Constraint that, when added, means that a job cannot be performed unless the user has Wifi
|
||||
*/
|
||||
class WifiConstraint(private val application: Application) : Constraint {
|
||||
|
||||
companion object {
|
||||
const val KEY = "WifiConstraint"
|
||||
}
|
||||
|
||||
override fun isMet(): Boolean {
|
||||
return NetworkUtil.isConnectedWifi(application)
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun applyToJobInfo(jobInfoBuilder: JobInfo.Builder) = Unit
|
||||
|
||||
class Factory(val application: Application) : Constraint.Factory<WifiConstraint> {
|
||||
override fun create(): WifiConstraint {
|
||||
return WifiConstraint(application)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user