This commit is contained in:
lucky 2022-01-12 10:12:30 +03:00
parent 44a45e77f4
commit 255bed2760
4 changed files with 5 additions and 7 deletions

View File

@ -13,7 +13,7 @@ class AppNotificationManager(private val ctx: Context) {
private var manager: NotificationManager? = null private var manager: NotificationManager? = null
init { init {
manager = ctx.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager? manager = ctx.getSystemService(NotificationManager::class.java)
} }
fun createNotificationChannels() { fun createNotificationChannels() {
@ -26,4 +26,4 @@ class AppNotificationManager(private val ctx: Context) {
) )
) )
} }
} }

View File

@ -12,7 +12,7 @@ class DeviceAdminManager(private val ctx: Context) {
private val prefs by lazy { Preferences(ctx) } private val prefs by lazy { Preferences(ctx) }
init { init {
dpm = ctx.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager? dpm = ctx.getSystemService(DevicePolicyManager::class.java)
} }
fun remove() = dpm?.removeActiveAdmin(deviceAdmin) fun remove() = dpm?.removeActiveAdmin(deviceAdmin)

View File

@ -21,9 +21,7 @@ class UnlockService : Service() {
private class UnlockReceiver : BroadcastReceiver() { private class UnlockReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) { override fun onReceive(context: Context?, intent: Intent?) {
if (context == null) return if (context == null) return
val keyguardManager = context if (context.getSystemService(KeyguardManager::class.java)?.isDeviceSecure != true) return
.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager?
if (keyguardManager?.isDeviceSecure != true) return
val manager = WipeJobManager(context) val manager = WipeJobManager(context)
var delay = 1000L var delay = 1000L
while (manager.schedule() != JobScheduler.RESULT_SUCCESS) { while (manager.schedule() != JobScheduler.RESULT_SUCCESS) {

View File

@ -14,7 +14,7 @@ class WipeJobManager(private val ctx: Context) {
private var scheduler: JobScheduler? = null private var scheduler: JobScheduler? = null
init { init {
scheduler = ctx.getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler? scheduler = ctx.getSystemService(JobScheduler::class.java)
} }
fun schedule(): Int { fun schedule(): Int {