protection interfaces
This commit is contained in:
parent
325311e865
commit
9f5af9b80c
|
@ -37,11 +37,11 @@ import info.nightscout.androidaps.activities.SingleFragmentActivity
|
||||||
import info.nightscout.androidaps.databinding.ActivityMainBinding
|
import info.nightscout.androidaps.databinding.ActivityMainBinding
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
||||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.configuration.setupwizard.SetupWizardActivity
|
import info.nightscout.configuration.setupwizard.SetupWizardActivity
|
||||||
import info.nightscout.core.ui.UIRunnable
|
import info.nightscout.core.ui.UIRunnable
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
|
import info.nightscout.core.utils.CryptoUtil
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.core.utils.isRunningRealPumpTest
|
import info.nightscout.core.utils.isRunningRealPumpTest
|
||||||
import info.nightscout.database.entities.UserEntry.Action
|
import info.nightscout.database.entities.UserEntry.Action
|
||||||
|
@ -51,9 +51,11 @@ import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.aps.Loop
|
import info.nightscout.interfaces.aps.Loop
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.locale.LocaleHelper
|
import info.nightscout.interfaces.locale.LocaleHelper
|
||||||
|
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
|
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
|
||||||
import info.nightscout.interfaces.ui.IconsProvider
|
import info.nightscout.interfaces.ui.IconsProvider
|
||||||
import info.nightscout.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
import info.nightscout.plugins.constraints.signatureVerifier.SignatureVerifierPlugin
|
||||||
|
@ -71,6 +73,7 @@ import info.nightscout.ui.activities.TreatmentsActivity
|
||||||
import info.nightscout.ui.tabs.TabPageAdapter
|
import info.nightscout.ui.tabs.TabPageAdapter
|
||||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
|
import java.io.File
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
@ -95,7 +98,8 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
|
@Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var passwordCheck: PasswordCheck
|
@Inject lateinit var fileListProvider: PrefFileListProvider
|
||||||
|
@Inject lateinit var cryptoUtil: CryptoUtil
|
||||||
|
|
||||||
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
|
private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle
|
||||||
private var pluginPreferencesMenuItem: MenuItem? = null
|
private var pluginPreferencesMenuItem: MenuItem? = null
|
||||||
|
@ -150,9 +154,7 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventInitializationChanged::class.java)
|
.toObservable(EventInitializationChanged::class.java)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe({
|
.subscribe({ passwordResetCheck(this) }, fabricPrivacy::logException)
|
||||||
passwordCheck.passwordResetCheck(this)
|
|
||||||
}, fabricPrivacy::logException)
|
|
||||||
if (startWizard() && !isRunningRealPumpTest()) {
|
if (startWizard() && !isRunningRealPumpTest()) {
|
||||||
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
protectionCheck.queryProtection(this, ProtectionCheck.Protection.PREFERENCES, {
|
||||||
startActivity(Intent(this, SetupWizardActivity::class.java))
|
startActivity(Intent(this, SetupWizardActivity::class.java))
|
||||||
|
@ -467,4 +469,17 @@ class MainActivity : NoSplashAppCompatActivity() {
|
||||||
FirebaseCrashlytics.getInstance().setCustomKey("Email", sp.getString(R.string.key_email_for_crash_report, ""))
|
FirebaseCrashlytics.getInstance().setCustomKey("Email", sp.getString(R.string.key_email_for_crash_report, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for existing PasswordReset file and
|
||||||
|
* reset password to SN of active pump if file exists
|
||||||
|
*/
|
||||||
|
fun passwordResetCheck(context: Context) {
|
||||||
|
val passwordReset = File(fileListProvider.ensureExtraDirExists(), "PasswordReset")
|
||||||
|
if (passwordReset.exists()) {
|
||||||
|
val sn = activePlugin.activePump.serialNumber()
|
||||||
|
sp.putString(info.nightscout.core.main.R.string.key_master_password, cryptoUtil.hashPassword(sn))
|
||||||
|
passwordReset.delete()
|
||||||
|
ToastUtils.okToast(context, context.getString(info.nightscout.core.main.R.string.password_set))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import info.nightscout.androidaps.danar.DanaRPlugin
|
||||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||||
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
|
||||||
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
|
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
|
||||||
import info.nightscout.plugins.aps.loop.LoopPlugin
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||||
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
|
import info.nightscout.androidaps.plugins.general.wear.WearPlugin
|
||||||
|
@ -31,14 +30,6 @@ import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.eopatch.EopatchPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
|
||||||
import info.nightscout.sensitivity.SensitivityAAPSPlugin
|
|
||||||
import info.nightscout.sensitivity.SensitivityOref1Plugin
|
|
||||||
import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin
|
|
||||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionType.BIOMETRIC
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionType.CUSTOM_PASSWORD
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionType.CUSTOM_PIN
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.ProtectionType.NONE
|
|
||||||
import info.nightscout.automation.AutomationPlugin
|
import info.nightscout.automation.AutomationPlugin
|
||||||
import info.nightscout.core.profile.toCurrentUnits
|
import info.nightscout.core.profile.toCurrentUnits
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
|
@ -46,6 +37,12 @@ import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck.ProtectionType.BIOMETRIC
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck.ProtectionType.CUSTOM_PASSWORD
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck.ProtectionType.CUSTOM_PIN
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck.ProtectionType.NONE
|
||||||
|
import info.nightscout.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.plugins.constraints.safety.SafetyPlugin
|
import info.nightscout.plugins.constraints.safety.SafetyPlugin
|
||||||
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
import info.nightscout.plugins.general.smsCommunicator.SmsCommunicatorPlugin
|
||||||
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
|
import info.nightscout.plugins.general.xdripStatusline.StatusLinePlugin
|
||||||
|
@ -66,6 +63,9 @@ import info.nightscout.plugins.sync.tidepool.TidepoolPlugin
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventPreferenceChange
|
import info.nightscout.rx.events.EventPreferenceChange
|
||||||
import info.nightscout.rx.events.EventRebuildTabs
|
import info.nightscout.rx.events.EventRebuildTabs
|
||||||
|
import info.nightscout.sensitivity.SensitivityAAPSPlugin
|
||||||
|
import info.nightscout.sensitivity.SensitivityOref1Plugin
|
||||||
|
import info.nightscout.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
import info.nightscout.shared.SafeParse
|
import info.nightscout.shared.SafeParse
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
|
|
@ -7,9 +7,9 @@ import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.interfaces.locale.LocaleHelper
|
import info.nightscout.interfaces.locale.LocaleHelper
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
|
class SingleFragmentActivity : DaggerAppCompatActivityWithResult() {
|
||||||
|
|
|
@ -3,18 +3,11 @@ package info.nightscout.androidaps.di
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.androidaps.activities.MyPreferenceFragment
|
import info.nightscout.androidaps.activities.MyPreferenceFragment
|
||||||
import info.nightscout.plugins.aps.loop.LoopFragment
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
|
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
|
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
||||||
import info.nightscout.androidaps.plugins.general.wear.WearFragment
|
import info.nightscout.androidaps.plugins.general.wear.WearFragment
|
||||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
|
||||||
import info.nightscout.plugins.constraints.objectives.ObjectivesFragment
|
|
||||||
import info.nightscout.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
|
||||||
import info.nightscout.plugins.constraints.objectives.dialogs.NtpProgressDialog
|
|
||||||
import info.nightscout.plugins.general.actions.ActionsFragment
|
|
||||||
import info.nightscout.ui.dialogs.WizardDialog
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
@ -22,19 +15,10 @@ abstract class FragmentsModule {
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesPreferencesFragment(): MyPreferenceFragment
|
@ContributesAndroidInjector abstract fun contributesPreferencesFragment(): MyPreferenceFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesActionsFragment(): ActionsFragment
|
|
||||||
@ContributesAndroidInjector abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
|
@ContributesAndroidInjector abstract fun contributesConfigBuilderFragment(): ConfigBuilderFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesObjectivesFragment(): ObjectivesFragment
|
|
||||||
@ContributesAndroidInjector abstract fun contributesOpenAPSFragment(): info.nightscout.plugins.aps.OpenAPSFragment
|
|
||||||
@ContributesAndroidInjector abstract fun contributesOverviewFragment(): OverviewFragment
|
@ContributesAndroidInjector abstract fun contributesOverviewFragment(): OverviewFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
|
|
||||||
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
|
@ContributesAndroidInjector abstract fun contributesMaintenanceFragment(): MaintenanceFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment
|
@ContributesAndroidInjector abstract fun contributesWearFragment(): WearFragment
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
@ContributesAndroidInjector abstract fun contributesEditQuickWizardDialog(): EditQuickWizardDialog
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesWizardDialog(): WizardDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog
|
|
||||||
@ContributesAndroidInjector abstract fun contributesPasswordCheck(): PasswordCheck
|
|
||||||
}
|
}
|
|
@ -20,13 +20,13 @@ import info.nightscout.androidaps.activities.PreferencesActivity
|
||||||
import info.nightscout.androidaps.activities.SingleFragmentActivity
|
import info.nightscout.androidaps.activities.SingleFragmentActivity
|
||||||
import info.nightscout.androidaps.databinding.ConfigbuilderFragmentBinding
|
import info.nightscout.androidaps.databinding.ConfigbuilderFragmentBinding
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
|
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.PREFERENCES
|
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventRebuildTabs
|
import info.nightscout.rx.events.EventRebuildTabs
|
||||||
|
|
|
@ -27,7 +27,6 @@ import info.nightscout.androidaps.activities.PreferencesActivity
|
||||||
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8PumpLogReset
|
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8PumpLogReset
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
||||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
|
||||||
import info.nightscout.androidaps.utils.userEntry.UserEntryPresentationHelper
|
import info.nightscout.androidaps.utils.userEntry.UserEntryPresentationHelper
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.dialogs.TwoMessagesAlertDialog
|
import info.nightscout.core.ui.dialogs.TwoMessagesAlertDialog
|
||||||
|
@ -48,6 +47,7 @@ import info.nightscout.interfaces.maintenance.PrefsFile
|
||||||
import info.nightscout.interfaces.maintenance.PrefsFormat
|
import info.nightscout.interfaces.maintenance.PrefsFormat
|
||||||
import info.nightscout.interfaces.maintenance.PrefsMetadataKey
|
import info.nightscout.interfaces.maintenance.PrefsMetadataKey
|
||||||
import info.nightscout.interfaces.maintenance.PrefsStatus
|
import info.nightscout.interfaces.maintenance.PrefsStatus
|
||||||
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
import info.nightscout.interfaces.storage.Storage
|
import info.nightscout.interfaces.storage.Storage
|
||||||
import info.nightscout.interfaces.utils.MidnightTime
|
import info.nightscout.interfaces.utils.MidnightTime
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
|
|
@ -18,8 +18,6 @@ import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSett
|
||||||
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
import info.nightscout.androidaps.plugins.general.overview.OverviewData
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.PREFERENCES
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.database.entities.UserEntry.Action
|
import info.nightscout.database.entities.UserEntry.Action
|
||||||
|
@ -27,6 +25,8 @@ import info.nightscout.database.entities.UserEntry.Sources
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
import info.nightscout.interfaces.maintenance.ImportExportPrefs
|
import info.nightscout.interfaces.maintenance.ImportExportPrefs
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.utils.HtmlHelper
|
import info.nightscout.interfaces.utils.HtmlHelper
|
||||||
|
|
|
@ -43,7 +43,6 @@ import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.automation.AutomationPlugin
|
import info.nightscout.automation.AutomationPlugin
|
||||||
import info.nightscout.core.iob.displayText
|
import info.nightscout.core.iob.displayText
|
||||||
import info.nightscout.core.profile.toSignedUnitsString
|
import info.nightscout.core.profile.toSignedUnitsString
|
||||||
|
@ -70,6 +69,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.defs.PumpType
|
import info.nightscout.interfaces.pump.defs.PumpType
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
import info.nightscout.interfaces.utils.JsonHelper
|
import info.nightscout.interfaces.utils.JsonHelper
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
import androidx.lifecycle.DefaultLifecycleObserver
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ProcessLifecycleListener @Inject constructor(private val protectionCheck: ProtectionCheck) : DefaultLifecycleObserver {
|
class ProcessLifecycleListener @Inject constructor(private val protectionCheck: ProtectionCheck) : DefaultLifecycleObserver {
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
package info.nightscout.androidaps.utils.protection
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import info.nightscout.core.main.R
|
|
||||||
import info.nightscout.shared.utils.DateUtil
|
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import javax.inject.Inject
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
class ProtectionCheck @Inject constructor(
|
|
||||||
val sp: SP,
|
|
||||||
val passwordCheck: PasswordCheck,
|
|
||||||
val dateUtil: DateUtil
|
|
||||||
) {
|
|
||||||
|
|
||||||
private var lastAuthorization = mutableListOf(0L, 0L, 0L)
|
|
||||||
|
|
||||||
enum class Protection {
|
|
||||||
PREFERENCES,
|
|
||||||
APPLICATION,
|
|
||||||
BOLUS
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class ProtectionType {
|
|
||||||
NONE,
|
|
||||||
BIOMETRIC,
|
|
||||||
MASTER_PASSWORD,
|
|
||||||
CUSTOM_PASSWORD,
|
|
||||||
CUSTOM_PIN
|
|
||||||
}
|
|
||||||
|
|
||||||
private val passwordsResourceIDs = listOf(
|
|
||||||
R.string.key_settings_password,
|
|
||||||
R.string.key_application_password,
|
|
||||||
R.string.key_bolus_password)
|
|
||||||
|
|
||||||
private val pinsResourceIDs = listOf(
|
|
||||||
R.string.key_settings_pin,
|
|
||||||
R.string.key_application_pin,
|
|
||||||
R.string.key_bolus_pin)
|
|
||||||
|
|
||||||
private val protectionTypeResourceIDs = listOf(
|
|
||||||
R.string.key_settings_protection,
|
|
||||||
R.string.key_application_protection,
|
|
||||||
R.string.key_bolus_protection)
|
|
||||||
|
|
||||||
private val titlePassResourceIDs = listOf(
|
|
||||||
R.string.settings_password,
|
|
||||||
R.string.application_password,
|
|
||||||
R.string.bolus_password)
|
|
||||||
|
|
||||||
private val titlePinResourceIDs = listOf(
|
|
||||||
R.string.settings_pin,
|
|
||||||
R.string.application_pin,
|
|
||||||
R.string.bolus_pin)
|
|
||||||
|
|
||||||
fun isLocked(protection: Protection): Boolean {
|
|
||||||
if (activeSession(protection)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return when (ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionType.NONE.ordinal)]) {
|
|
||||||
ProtectionType.NONE -> false
|
|
||||||
ProtectionType.BIOMETRIC -> true
|
|
||||||
ProtectionType.MASTER_PASSWORD -> sp.getString(R.string.key_master_password, "") != ""
|
|
||||||
ProtectionType.CUSTOM_PASSWORD -> sp.getString(passwordsResourceIDs[protection.ordinal], "") != ""
|
|
||||||
ProtectionType.CUSTOM_PIN -> sp.getString(pinsResourceIDs[protection.ordinal], "") != ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resetAuthorization() {
|
|
||||||
lastAuthorization = mutableListOf(0L, 0L, 0L)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun activeSession(protection: Protection): Boolean {
|
|
||||||
var timeout = TimeUnit.SECONDS.toMillis(sp.getInt(R.string.key_protection_timeout, 0).toLong())
|
|
||||||
// Default timeout to pass the resume check at start of an activity
|
|
||||||
timeout = if (timeout < 1000) 1000 else timeout
|
|
||||||
val last = lastAuthorization[protection.ordinal]
|
|
||||||
val diff = dateUtil.now() - last
|
|
||||||
return diff < timeout
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onOk(protection: Protection) {
|
|
||||||
lastAuthorization[protection.ordinal] = dateUtil.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun queryProtection(activity: FragmentActivity, protection: Protection, ok: Runnable?, cancel: Runnable? = null, fail: Runnable? = null) {
|
|
||||||
if (activeSession(protection)) {
|
|
||||||
onOk(protection)
|
|
||||||
ok?.run()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
when (ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionType.NONE.ordinal)]) {
|
|
||||||
ProtectionType.NONE ->
|
|
||||||
ok?.run()
|
|
||||||
ProtectionType.BIOMETRIC ->
|
|
||||||
BiometricCheck.biometricPrompt(activity, titlePassResourceIDs[protection.ordinal], { onOk(protection); ok?.run() }, cancel, fail, passwordCheck)
|
|
||||||
ProtectionType.MASTER_PASSWORD ->
|
|
||||||
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { onOk(protection); ok?.run() }, { cancel?.run() }, { fail?.run() })
|
|
||||||
ProtectionType.CUSTOM_PASSWORD ->
|
|
||||||
passwordCheck.queryPassword(activity, titlePassResourceIDs[protection.ordinal], passwordsResourceIDs[protection.ordinal], { onOk(protection); ok?.run() }, { cancel?.run() }, { fail?.run() })
|
|
||||||
ProtectionType.CUSTOM_PIN ->
|
|
||||||
passwordCheck.queryPassword(activity, titlePinResourceIDs[protection.ordinal], pinsResourceIDs[protection.ordinal], { onOk(protection); ok?.run() }, { cancel?.run() }, { fail?.run() }, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,18 +6,23 @@ import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.EncryptedPrefsFormat
|
||||||
|
import info.nightscout.core.utils.CryptoUtil
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.implementation.HardLimitsImpl
|
import info.nightscout.implementation.HardLimitsImpl
|
||||||
import info.nightscout.implementation.logging.LoggerUtilsImpl
|
import info.nightscout.implementation.logging.LoggerUtilsImpl
|
||||||
import info.nightscout.implementation.maintenance.PrefFileListProviderImpl
|
import info.nightscout.implementation.maintenance.PrefFileListProviderImpl
|
||||||
import info.nightscout.implementation.profiling.ProfilerImpl
|
import info.nightscout.implementation.profiling.ProfilerImpl
|
||||||
|
import info.nightscout.implementation.protection.PasswordCheckImpl
|
||||||
|
import info.nightscout.implementation.protection.ProtectionCheckImpl
|
||||||
import info.nightscout.implementation.pump.WarnColorsImpl
|
import info.nightscout.implementation.pump.WarnColorsImpl
|
||||||
import info.nightscout.implementation.resources.ResourceHelperImpl
|
import info.nightscout.implementation.resources.ResourceHelperImpl
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.logging.LoggerUtils
|
import info.nightscout.interfaces.logging.LoggerUtils
|
||||||
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
||||||
import info.nightscout.interfaces.profiling.Profiler
|
import info.nightscout.interfaces.profiling.Profiler
|
||||||
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.WarnColors
|
import info.nightscout.interfaces.pump.WarnColors
|
||||||
import info.nightscout.interfaces.storage.Storage
|
import info.nightscout.interfaces.storage.Storage
|
||||||
import info.nightscout.interfaces.utils.HardLimits
|
import info.nightscout.interfaces.utils.HardLimits
|
||||||
|
@ -25,6 +30,7 @@ import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.logging.AAPSLogger
|
import info.nightscout.rx.logging.AAPSLogger
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module(
|
@Module(
|
||||||
|
@ -58,6 +64,14 @@ open class ImplementationModule {
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideLoggerUtils(prefFileListProvider: PrefFileListProvider): LoggerUtils = LoggerUtilsImpl(prefFileListProvider)
|
fun provideLoggerUtils(prefFileListProvider: PrefFileListProvider): LoggerUtils = LoggerUtilsImpl(prefFileListProvider)
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun providePasswordCheck(sp: SP, cryptoUtil: CryptoUtil): PasswordCheck = PasswordCheckImpl(sp, cryptoUtil)
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideProtectionCheck(sp: SP, passwordCheck: PasswordCheck, dateUtil: DateUtil): ProtectionCheck = ProtectionCheckImpl(sp, passwordCheck, dateUtil)
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun providePrefFileListProvider(
|
fun providePrefFileListProvider(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.utils.protection
|
package info.nightscout.implementation.protection
|
||||||
|
|
||||||
import androidx.biometric.BiometricPrompt
|
import androidx.biometric.BiometricPrompt
|
||||||
import androidx.biometric.BiometricPrompt.AuthenticationResult
|
import androidx.biometric.BiometricPrompt.AuthenticationResult
|
||||||
|
@ -19,6 +19,7 @@ import androidx.biometric.BiometricPrompt.PromptInfo
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import info.nightscout.core.main.R
|
import info.nightscout.core.main.R
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
import info.nightscout.shared.extensions.runOnUiThread
|
import info.nightscout.shared.extensions.runOnUiThread
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.utils.protection
|
package info.nightscout.implementation.protection
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -15,29 +15,26 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import info.nightscout.core.main.R
|
import info.nightscout.core.main.R
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.CryptoUtil
|
import info.nightscout.core.utils.CryptoUtil
|
||||||
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import java.io.File
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
// since androidx.autofill.HintConstants are not available
|
|
||||||
const val AUTOFILL_HINT_NEW_PASSWORD = "newPassword"
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class PasswordCheck @Inject constructor(
|
class PasswordCheckImpl @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val cryptoUtil: CryptoUtil,
|
private val cryptoUtil: CryptoUtil
|
||||||
private val fileListProvider: PrefFileListProvider,
|
) : PasswordCheck {
|
||||||
private val activePlugin: ActivePlugin
|
|
||||||
) {
|
// since androidx.autofill.HintConstants are not available
|
||||||
|
@Suppress("PrivatePropertyName")
|
||||||
|
private val AUTOFILL_HINT_NEW_PASSWORD = "newPassword"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Asks for "managed" kind of password, checking if it is valid.
|
Asks for "managed" kind of password, checking if it is valid.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
fun queryPassword(context: Context, @StringRes labelId: Int, @StringRes preference: Int, ok: ((String) -> Unit)?, cancel: (() -> Unit)? = null, fail: (() -> Unit)? = null, pinInput: Boolean = false) {
|
override fun queryPassword(context: Context, @StringRes labelId: Int, @StringRes preference: Int, ok: ((String) -> Unit)?, cancel: (() -> Unit)?, fail: (() -> Unit)?, pinInput: Boolean) {
|
||||||
val password = sp.getString(preference, "")
|
val password = sp.getString(preference, "")
|
||||||
if (password == "") {
|
if (password == "") {
|
||||||
ok?.invoke("")
|
ok?.invoke("")
|
||||||
|
@ -99,7 +96,7 @@ class PasswordCheck @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
fun setPassword(context: Context, @StringRes labelId: Int, @StringRes preference: Int, ok: ((String) -> Unit)? = null, cancel: (() -> Unit)? = null, clear: (() -> Unit)? = null, pinInput: Boolean = false) {
|
override fun setPassword(context: Context, @StringRes labelId: Int, @StringRes preference: Int, ok: ((String) -> Unit)?, cancel: (() -> Unit)?, clear: (() -> Unit)?, pinInput: Boolean) {
|
||||||
val promptsView = LayoutInflater.from(context).inflate(R.layout.passwordprompt, null)
|
val promptsView = LayoutInflater.from(context).inflate(R.layout.passwordprompt, null)
|
||||||
val alertDialogBuilder = MaterialAlertDialogBuilder(context, R.style.DialogTheme)
|
val alertDialogBuilder = MaterialAlertDialogBuilder(context, R.style.DialogTheme)
|
||||||
alertDialogBuilder.setView(promptsView)
|
alertDialogBuilder.setView(promptsView)
|
||||||
|
@ -161,8 +158,10 @@ class PasswordCheck @Inject constructor(
|
||||||
since this query does NOT check validity of password.
|
since this query does NOT check validity of password.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("InflateParams")
|
@SuppressLint("InflateParams")
|
||||||
fun queryAnyPassword(context: Context, @StringRes labelId: Int, @StringRes preference: Int, @StringRes passwordExplanation: Int?,
|
override fun queryAnyPassword(
|
||||||
@StringRes passwordWarning: Int?, ok: ((String) -> Unit)?, cancel: (() -> Unit)? = null) {
|
context: Context, @StringRes labelId: Int, @StringRes preference: Int, @StringRes passwordExplanation: Int?,
|
||||||
|
@StringRes passwordWarning: Int?, ok: ((String) -> Unit)?, cancel: (() -> Unit)?
|
||||||
|
) {
|
||||||
|
|
||||||
val promptsView = LayoutInflater.from(context).inflate(R.layout.passwordprompt, null)
|
val promptsView = LayoutInflater.from(context).inflate(R.layout.passwordprompt, null)
|
||||||
val alertDialogBuilder = MaterialAlertDialogBuilder(context, R.style.DialogTheme)
|
val alertDialogBuilder = MaterialAlertDialogBuilder(context, R.style.DialogTheme)
|
||||||
|
@ -214,18 +213,4 @@ class PasswordCheck @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check for existing PasswordReset file and
|
|
||||||
* reset password to SN of active pump if file exists
|
|
||||||
*/
|
|
||||||
fun passwordResetCheck(context: Context) {
|
|
||||||
val passwordReset = File(fileListProvider.ensureExtraDirExists(), "PasswordReset")
|
|
||||||
if (passwordReset.exists()) {
|
|
||||||
val sn = activePlugin.activePump.serialNumber()
|
|
||||||
sp.putString(R.string.key_master_password, cryptoUtil.hashPassword(sn))
|
|
||||||
passwordReset.delete()
|
|
||||||
ToastUtils.okToast(context, context.getString(R.string.password_set))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
package info.nightscout.implementation.protection
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import info.nightscout.core.main.R
|
||||||
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
|
import info.nightscout.shared.utils.DateUtil
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class ProtectionCheckImpl @Inject constructor(
|
||||||
|
private val sp: SP,
|
||||||
|
private val passwordCheck: PasswordCheck,
|
||||||
|
private val dateUtil: DateUtil
|
||||||
|
) : ProtectionCheck {
|
||||||
|
|
||||||
|
private var lastAuthorization = mutableListOf(0L, 0L, 0L)
|
||||||
|
|
||||||
|
private val passwordsResourceIDs = listOf(
|
||||||
|
R.string.key_settings_password,
|
||||||
|
R.string.key_application_password,
|
||||||
|
R.string.key_bolus_password
|
||||||
|
)
|
||||||
|
|
||||||
|
private val pinsResourceIDs = listOf(
|
||||||
|
R.string.key_settings_pin,
|
||||||
|
R.string.key_application_pin,
|
||||||
|
R.string.key_bolus_pin)
|
||||||
|
|
||||||
|
private val protectionTypeResourceIDs = listOf(
|
||||||
|
R.string.key_settings_protection,
|
||||||
|
R.string.key_application_protection,
|
||||||
|
R.string.key_bolus_protection)
|
||||||
|
|
||||||
|
private val titlePassResourceIDs = listOf(
|
||||||
|
R.string.settings_password,
|
||||||
|
R.string.application_password,
|
||||||
|
R.string.bolus_password)
|
||||||
|
|
||||||
|
private val titlePinResourceIDs = listOf(
|
||||||
|
R.string.settings_pin,
|
||||||
|
R.string.application_pin,
|
||||||
|
R.string.bolus_pin)
|
||||||
|
|
||||||
|
override fun isLocked(protection: ProtectionCheck.Protection): Boolean {
|
||||||
|
if (activeSession(protection)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return when (ProtectionCheck.ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionCheck.ProtectionType.NONE.ordinal)]) {
|
||||||
|
ProtectionCheck.ProtectionType.NONE -> false
|
||||||
|
ProtectionCheck.ProtectionType.BIOMETRIC -> true
|
||||||
|
ProtectionCheck.ProtectionType.MASTER_PASSWORD -> sp.getString(R.string.key_master_password, "") != ""
|
||||||
|
ProtectionCheck.ProtectionType.CUSTOM_PASSWORD -> sp.getString(passwordsResourceIDs[protection.ordinal], "") != ""
|
||||||
|
ProtectionCheck.ProtectionType.CUSTOM_PIN -> sp.getString(pinsResourceIDs[protection.ordinal], "") != ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resetAuthorization() {
|
||||||
|
lastAuthorization = mutableListOf(0L, 0L, 0L)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun activeSession(protection: ProtectionCheck.Protection): Boolean {
|
||||||
|
var timeout = TimeUnit.SECONDS.toMillis(sp.getInt(R.string.key_protection_timeout, 0).toLong())
|
||||||
|
// Default timeout to pass the resume check at start of an activity
|
||||||
|
timeout = if (timeout < 1000) 1000 else timeout
|
||||||
|
val last = lastAuthorization[protection.ordinal]
|
||||||
|
val diff = dateUtil.now() - last
|
||||||
|
return diff < timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onOk(protection: ProtectionCheck.Protection) {
|
||||||
|
lastAuthorization[protection.ordinal] = dateUtil.now()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun queryProtection(activity: FragmentActivity, protection: ProtectionCheck.Protection, ok: Runnable?, cancel: Runnable?, fail: Runnable?) {
|
||||||
|
if (activeSession(protection)) {
|
||||||
|
onOk(protection)
|
||||||
|
ok?.run()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
when (ProtectionCheck.ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionCheck.ProtectionType.NONE.ordinal)]) {
|
||||||
|
ProtectionCheck.ProtectionType.NONE ->
|
||||||
|
ok?.run()
|
||||||
|
|
||||||
|
ProtectionCheck.ProtectionType.BIOMETRIC ->
|
||||||
|
BiometricCheck.biometricPrompt(activity, titlePassResourceIDs[protection.ordinal], { onOk(protection); ok?.run() }, cancel, fail, passwordCheck)
|
||||||
|
|
||||||
|
ProtectionCheck.ProtectionType.MASTER_PASSWORD ->
|
||||||
|
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { onOk(protection); ok?.run() }, { cancel?.run() }, { fail?.run() })
|
||||||
|
|
||||||
|
ProtectionCheck.ProtectionType.CUSTOM_PASSWORD ->
|
||||||
|
passwordCheck.queryPassword(
|
||||||
|
activity,
|
||||||
|
titlePassResourceIDs[protection.ordinal],
|
||||||
|
passwordsResourceIDs[protection.ordinal],
|
||||||
|
{ onOk(protection); ok?.run() },
|
||||||
|
{ cancel?.run() },
|
||||||
|
{ fail?.run() })
|
||||||
|
|
||||||
|
ProtectionCheck.ProtectionType.CUSTOM_PIN ->
|
||||||
|
passwordCheck.queryPassword(
|
||||||
|
activity,
|
||||||
|
titlePinResourceIDs[protection.ordinal],
|
||||||
|
pinsResourceIDs[protection.ordinal],
|
||||||
|
{ onOk(protection); ok?.run() },
|
||||||
|
{ cancel?.run() },
|
||||||
|
{ fail?.run() },
|
||||||
|
true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package info.nightscout.interfaces.protection
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
|
||||||
|
interface PasswordCheck {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks for "managed" kind of password, checking if it is valid.
|
||||||
|
*/
|
||||||
|
fun queryPassword(
|
||||||
|
context: Context,
|
||||||
|
@StringRes labelId: Int,
|
||||||
|
@StringRes preference: Int,
|
||||||
|
ok: ((String) -> Unit)?,
|
||||||
|
cancel: (() -> Unit)? = null,
|
||||||
|
fail: (() -> Unit)? = null,
|
||||||
|
pinInput: Boolean = false
|
||||||
|
)
|
||||||
|
|
||||||
|
fun setPassword(
|
||||||
|
context: Context,
|
||||||
|
@StringRes labelId: Int,
|
||||||
|
@StringRes preference: Int,
|
||||||
|
ok: ((String) -> Unit)? = null,
|
||||||
|
cancel: (() -> Unit)? = null,
|
||||||
|
clear: (() -> Unit)? = null,
|
||||||
|
pinInput: Boolean = false
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt free-form password, with additional help and warning messages.
|
||||||
|
* Preference ID (preference) is used only to generate ID for password managers,
|
||||||
|
* since this query does NOT check validity of password.
|
||||||
|
*/
|
||||||
|
fun queryAnyPassword(
|
||||||
|
context: Context, @StringRes labelId: Int, @StringRes preference: Int, @StringRes passwordExplanation: Int?,
|
||||||
|
@StringRes passwordWarning: Int?, ok: ((String) -> Unit)?, cancel: (() -> Unit)? = null
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package info.nightscout.interfaces.protection
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
|
||||||
|
interface ProtectionCheck {
|
||||||
|
enum class Protection {
|
||||||
|
PREFERENCES,
|
||||||
|
APPLICATION,
|
||||||
|
BOLUS
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class ProtectionType {
|
||||||
|
NONE,
|
||||||
|
BIOMETRIC,
|
||||||
|
MASTER_PASSWORD,
|
||||||
|
CUSTOM_PASSWORD,
|
||||||
|
CUSTOM_PIN
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isLocked(protection: Protection): Boolean
|
||||||
|
fun resetAuthorization()
|
||||||
|
fun queryProtection(activity: FragmentActivity, protection: Protection, ok: Runnable?, cancel: Runnable? = null, fail: Runnable? = null)
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.plugins.aps.di
|
package info.nightscout.plugins.aps.di
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.plugins.aps.OpenAPSFragment
|
||||||
import info.nightscout.plugins.di.AutotuneModule
|
import info.nightscout.plugins.di.AutotuneModule
|
||||||
|
|
||||||
@Module(
|
@Module(
|
||||||
|
@ -11,4 +13,6 @@ import info.nightscout.plugins.di.AutotuneModule
|
||||||
)
|
)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class ApsModule
|
abstract class ApsModule {
|
||||||
|
@ContributesAndroidInjector abstract fun contributesOpenAPSFragment(): OpenAPSFragment
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import android.widget.LinearLayout
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.utils.protection.PasswordCheck
|
import info.nightscout.interfaces.protection.PasswordCheck
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
import info.nightscout.rx.events.EventPreferenceChange
|
import info.nightscout.rx.events.EventPreferenceChange
|
||||||
import info.nightscout.rx.events.EventSWUpdate
|
import info.nightscout.rx.events.EventSWUpdate
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package info.nightscout.plugins.di
|
||||||
|
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.plugins.general.actions.ActionsFragment
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@Suppress("unused")
|
||||||
|
abstract class ActionsModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun contributesActionsFragment(): ActionsFragment
|
||||||
|
}
|
|
@ -3,10 +3,11 @@ package info.nightscout.plugins.di
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
import info.nightscout.plugins.aps.loop.CarbSuggestionReceiver
|
import info.nightscout.plugins.aps.loop.CarbSuggestionReceiver
|
||||||
|
import info.nightscout.plugins.aps.loop.LoopFragment
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class LoopModule {
|
abstract class LoopModule {
|
||||||
|
@ContributesAndroidInjector abstract fun contributesLoopFragment(): LoopFragment
|
||||||
@ContributesAndroidInjector abstract fun contributesCarbSuggestionReceiver(): CarbSuggestionReceiver
|
@ContributesAndroidInjector abstract fun contributesCarbSuggestionReceiver(): CarbSuggestionReceiver
|
||||||
}
|
}
|
|
@ -2,6 +2,9 @@ package info.nightscout.plugins.di
|
||||||
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
import dagger.android.ContributesAndroidInjector
|
||||||
|
import info.nightscout.plugins.constraints.objectives.ObjectivesFragment
|
||||||
|
import info.nightscout.plugins.constraints.objectives.activities.ObjectivesExamDialog
|
||||||
|
import info.nightscout.plugins.constraints.objectives.dialogs.NtpProgressDialog
|
||||||
import info.nightscout.plugins.constraints.objectives.objectives.Objective
|
import info.nightscout.plugins.constraints.objectives.objectives.Objective
|
||||||
import info.nightscout.plugins.constraints.objectives.objectives.Objective0
|
import info.nightscout.plugins.constraints.objectives.objectives.Objective0
|
||||||
import info.nightscout.plugins.constraints.objectives.objectives.Objective1
|
import info.nightscout.plugins.constraints.objectives.objectives.Objective1
|
||||||
|
@ -18,6 +21,10 @@ import info.nightscout.plugins.constraints.objectives.objectives.Objective9
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class ObjectivesModule {
|
abstract class ObjectivesModule {
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun contributesObjectivesFragment(): ObjectivesFragment
|
||||||
|
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
||||||
|
@ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog
|
||||||
|
|
||||||
@ContributesAndroidInjector abstract fun objectiveInjector(): Objective
|
@ContributesAndroidInjector abstract fun objectiveInjector(): Objective
|
||||||
@ContributesAndroidInjector abstract fun objective0Injector(): Objective0
|
@ContributesAndroidInjector abstract fun objective0Injector(): Objective0
|
||||||
@ContributesAndroidInjector abstract fun objective1Injector(): Objective1
|
@ContributesAndroidInjector abstract fun objective1Injector(): Objective1
|
||||||
|
@ -29,5 +36,4 @@ abstract class ObjectivesModule {
|
||||||
@ContributesAndroidInjector abstract fun objective7Injector(): Objective7
|
@ContributesAndroidInjector abstract fun objective7Injector(): Objective7
|
||||||
@ContributesAndroidInjector abstract fun objective9Injector(): Objective9
|
@ContributesAndroidInjector abstract fun objective9Injector(): Objective9
|
||||||
@ContributesAndroidInjector abstract fun objective10Injector(): Objective10
|
@ContributesAndroidInjector abstract fun objective10Injector(): Objective10
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,8 @@ import dagger.Module
|
||||||
ObjectivesModule::class,
|
ObjectivesModule::class,
|
||||||
SkinsModule::class,
|
SkinsModule::class,
|
||||||
SkinsUiModule::class,
|
SkinsUiModule::class,
|
||||||
LoopModule::class
|
LoopModule::class,
|
||||||
|
ActionsModule::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.extensions.toStringMedium
|
import info.nightscout.androidaps.extensions.toStringMedium
|
||||||
import info.nightscout.androidaps.extensions.toStringShort
|
import info.nightscout.androidaps.extensions.toStringShort
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.UIRunnable
|
import info.nightscout.core.ui.UIRunnable
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.elements.SingleClickButton
|
import info.nightscout.core.ui.elements.SingleClickButton
|
||||||
|
@ -27,6 +26,7 @@ import info.nightscout.interfaces.aps.Loop
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.actions.CustomAction
|
import info.nightscout.interfaces.pump.actions.CustomAction
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
|
|
@ -13,7 +13,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.UIRunnable
|
import info.nightscout.core.ui.UIRunnable
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
@ -22,6 +21,7 @@ import info.nightscout.database.entities.UserEntry.Action
|
||||||
import info.nightscout.database.entities.UserEntry.Sources
|
import info.nightscout.database.entities.UserEntry.Sources
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
import info.nightscout.database.impl.transactions.InvalidateFoodTransaction
|
import info.nightscout.database.impl.transactions.InvalidateFoodTransaction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
import info.nightscout.plugins.R
|
import info.nightscout.plugins.R
|
||||||
import info.nightscout.plugins.databinding.FoodFragmentBinding
|
import info.nightscout.plugins.databinding.FoodFragmentBinding
|
||||||
|
|
|
@ -13,7 +13,6 @@ import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.data.ProfileSealed
|
import info.nightscout.androidaps.data.ProfileSealed
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.profile.fromMgdlToUnits
|
import info.nightscout.core.profile.fromMgdlToUnits
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
@ -24,6 +23,7 @@ import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
import info.nightscout.interfaces.utils.HardLimits
|
import info.nightscout.interfaces.utils.HardLimits
|
||||||
import info.nightscout.plugins.R
|
import info.nightscout.plugins.R
|
||||||
|
|
|
@ -25,13 +25,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertType
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.UIRunnable
|
import info.nightscout.core.ui.UIRunnable
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.notifications.Notification
|
import info.nightscout.interfaces.notifications.Notification
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
|
|
|
@ -34,12 +34,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodE
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.queue.command.CommandGetPodStatus
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.queue.command.CommandGetPodStatus
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.OmnipodAlertUtil
|
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.OmnipodAlertUtil
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.Constants
|
import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.notifications.Notification
|
import info.nightscout.interfaces.notifications.Notification
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.ui.dialogs.ProfileViewerDialog
|
||||||
import info.nightscout.ui.dialogs.TempBasalDialog
|
import info.nightscout.ui.dialogs.TempBasalDialog
|
||||||
import info.nightscout.ui.dialogs.TempTargetDialog
|
import info.nightscout.ui.dialogs.TempTargetDialog
|
||||||
import info.nightscout.ui.dialogs.TreatmentDialog
|
import info.nightscout.ui.dialogs.TreatmentDialog
|
||||||
|
import info.nightscout.ui.dialogs.WizardDialog
|
||||||
import info.nightscout.ui.dialogs.WizardInfoDialog
|
import info.nightscout.ui.dialogs.WizardInfoDialog
|
||||||
import info.nightscout.ui.widget.Widget
|
import info.nightscout.ui.widget.Widget
|
||||||
import info.nightscout.ui.widget.WidgetConfigureActivity
|
import info.nightscout.ui.widget.WidgetConfigureActivity
|
||||||
|
@ -39,6 +40,7 @@ abstract class UiModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesWidget(): Widget
|
@ContributesAndroidInjector abstract fun contributesWidget(): Widget
|
||||||
@ContributesAndroidInjector abstract fun contributesWidgetConfigureActivity(): WidgetConfigureActivity
|
@ContributesAndroidInjector abstract fun contributesWidgetConfigureActivity(): WidgetConfigureActivity
|
||||||
|
|
||||||
|
@ContributesAndroidInjector abstract fun contributesWizardDialog(): WizardDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
|
@ContributesAndroidInjector abstract fun contributesCalibrationDialog(): CalibrationDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
|
@ContributesAndroidInjector abstract fun contributesCarbsDialog(): CarbsDialog
|
||||||
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
|
@ContributesAndroidInjector abstract fun contributesCareDialog(): CareDialog
|
||||||
|
|
|
@ -13,8 +13,6 @@ import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
|
||||||
import info.nightscout.core.profile.toMgdl
|
import info.nightscout.core.profile.toMgdl
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
|
@ -33,6 +31,8 @@ import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck.Protection.BOLUS
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.extensions.formatColor
|
import info.nightscout.core.utils.extensions.formatColor
|
||||||
|
@ -17,6 +16,7 @@ import info.nightscout.database.entities.ValueWithUnit
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
import info.nightscout.interfaces.ui.ActivityNames
|
import info.nightscout.interfaces.ui.ActivityNames
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.extensions.formatColor
|
import info.nightscout.core.utils.extensions.formatColor
|
||||||
|
@ -21,6 +20,7 @@ import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyE
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
|
|
@ -12,7 +12,6 @@ import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.profile.toMgdl
|
import info.nightscout.core.profile.toMgdl
|
||||||
import info.nightscout.core.pump.insertBolusTransaction
|
import info.nightscout.core.pump.insertBolusTransaction
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
|
@ -31,6 +30,7 @@ import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.view.WindowManager
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import dagger.android.support.DaggerDialogFragment
|
import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
@ -31,6 +30,7 @@ import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.plugin.PluginBase
|
import info.nightscout.interfaces.plugin.PluginBase
|
||||||
import info.nightscout.interfaces.plugin.PluginType
|
import info.nightscout.interfaces.plugin.PluginType
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.defs.PumpDescription
|
import info.nightscout.interfaces.pump.defs.PumpDescription
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
|
|
@ -13,7 +13,6 @@ import info.nightscout.androidaps.data.ProfileSealed
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.profile.toMgdl
|
import info.nightscout.core.profile.toMgdl
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
|
@ -27,6 +26,7 @@ import info.nightscout.interfaces.Constants
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.utils.HardLimits
|
import info.nightscout.interfaces.utils.HardLimits
|
||||||
import info.nightscout.interfaces.utils.HtmlHelper
|
import info.nightscout.interfaces.utils.HtmlHelper
|
||||||
import info.nightscout.rx.bus.RxBus
|
import info.nightscout.rx.bus.RxBus
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
import info.nightscout.core.ui.toast.ToastUtils
|
import info.nightscout.core.ui.toast.ToastUtils
|
||||||
import info.nightscout.core.utils.extensions.formatColor
|
import info.nightscout.core.utils.extensions.formatColor
|
||||||
|
@ -18,6 +17,7 @@ import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.PumpSync
|
import info.nightscout.interfaces.pump.PumpSync
|
||||||
import info.nightscout.interfaces.pump.defs.PumpDescription
|
import info.nightscout.interfaces.pump.defs.PumpDescription
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.google.common.collect.Lists
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.profile.toCurrentUnitsString
|
import info.nightscout.core.profile.toCurrentUnitsString
|
||||||
import info.nightscout.core.profile.toMgdl
|
import info.nightscout.core.profile.toMgdl
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
|
@ -28,6 +27,7 @@ import info.nightscout.interfaces.GlucoseUnit
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.utils.HtmlHelper
|
import info.nightscout.interfaces.utils.HtmlHelper
|
||||||
import info.nightscout.rx.logging.LTag
|
import info.nightscout.rx.logging.LTag
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.pump.insertBolusTransaction
|
import info.nightscout.core.pump.insertBolusTransaction
|
||||||
import info.nightscout.core.pump.insertCarbsTransaction
|
import info.nightscout.core.pump.insertCarbsTransaction
|
||||||
import info.nightscout.core.ui.dialogs.OKDialog
|
import info.nightscout.core.ui.dialogs.OKDialog
|
||||||
|
@ -24,6 +23,7 @@ import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.constraints.Constraint
|
import info.nightscout.interfaces.constraints.Constraint
|
||||||
import info.nightscout.interfaces.constraints.Constraints
|
import info.nightscout.interfaces.constraints.Constraints
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
import info.nightscout.interfaces.queue.Callback
|
import info.nightscout.interfaces.queue.Callback
|
||||||
import info.nightscout.interfaces.queue.CommandQueue
|
import info.nightscout.interfaces.queue.CommandQueue
|
||||||
|
|
|
@ -21,7 +21,6 @@ import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.data.ProfileSealed
|
import info.nightscout.androidaps.data.ProfileSealed
|
||||||
import info.nightscout.androidaps.extensions.valueToUnits
|
import info.nightscout.androidaps.extensions.valueToUnits
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
|
||||||
import info.nightscout.core.iob.round
|
import info.nightscout.core.iob.round
|
||||||
import info.nightscout.core.profile.toMgdl
|
import info.nightscout.core.profile.toMgdl
|
||||||
import info.nightscout.core.profile.toUnitsString
|
import info.nightscout.core.profile.toUnitsString
|
||||||
|
@ -39,6 +38,7 @@ import info.nightscout.interfaces.iob.IobCobCalculator
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.profile.Profile
|
import info.nightscout.interfaces.profile.Profile
|
||||||
import info.nightscout.interfaces.profile.ProfileFunction
|
import info.nightscout.interfaces.profile.ProfileFunction
|
||||||
|
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||||
import info.nightscout.interfaces.utils.HtmlHelper
|
import info.nightscout.interfaces.utils.HtmlHelper
|
||||||
import info.nightscout.interfaces.utils.Round
|
import info.nightscout.interfaces.utils.Round
|
||||||
import info.nightscout.rx.AapsSchedulers
|
import info.nightscout.rx.AapsSchedulers
|
||||||
|
|
Loading…
Reference in a new issue