mirror of https://github.com/x13a/Wasted.git
ref
This commit is contained in:
parent
255bed2760
commit
74533a60c3
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue