This commit is contained in:
lucky 2022-01-12 14:27:15 +03:00
parent 255bed2760
commit 74533a60c3
3 changed files with 3 additions and 15 deletions

View File

@ -10,11 +10,7 @@ class AppNotificationManager(private val ctx: Context) {
const val CHANNEL_DEFAULT_ID = "default" const val CHANNEL_DEFAULT_ID = "default"
} }
private var manager: NotificationManager? = null private val manager = ctx.getSystemService(NotificationManager::class.java)
init {
manager = ctx.getSystemService(NotificationManager::class.java)
}
fun createNotificationChannels() { fun createNotificationChannels() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return

View File

@ -7,14 +7,10 @@ import android.content.Intent
import android.os.Build import android.os.Build
class DeviceAdminManager(private val ctx: Context) { class DeviceAdminManager(private val ctx: Context) {
private var dpm: DevicePolicyManager? = null private val dpm = ctx.getSystemService(DevicePolicyManager::class.java)
private val deviceAdmin by lazy { ComponentName(ctx, DeviceAdminReceiver::class.java) } private val deviceAdmin by lazy { ComponentName(ctx, DeviceAdminReceiver::class.java) }
private val prefs by lazy { Preferences(ctx) } private val prefs by lazy { Preferences(ctx) }
init {
dpm = ctx.getSystemService(DevicePolicyManager::class.java)
}
fun remove() = dpm?.removeActiveAdmin(deviceAdmin) fun remove() = dpm?.removeActiveAdmin(deviceAdmin)
fun isActive(): Boolean = dpm?.isAdminActive(deviceAdmin) ?: false fun isActive(): Boolean = dpm?.isAdminActive(deviceAdmin) ?: false
fun getCurrentFailedPasswordAttempts(): Int = dpm?.currentFailedPasswordAttempts ?: 0 fun getCurrentFailedPasswordAttempts(): Int = dpm?.currentFailedPasswordAttempts ?: 0

View File

@ -11,11 +11,7 @@ class WipeJobManager(private val ctx: Context) {
private const val JOB_ID = 1000 private const val JOB_ID = 1000
} }
private val prefs by lazy { Preferences(ctx) } private val prefs by lazy { Preferences(ctx) }
private var scheduler: JobScheduler? = null private val scheduler = ctx.getSystemService(JobScheduler::class.java)
init {
scheduler = ctx.getSystemService(JobScheduler::class.java)
}
fun schedule(): Int { fun schedule(): Int {
return scheduler?.schedule( return scheduler?.schedule(