From 255bed276022b777d205905836acb60a644a9f30 Mon Sep 17 00:00:00 2001 From: lucky <> Date: Wed, 12 Jan 2022 10:12:30 +0300 Subject: [PATCH] ref --- app/src/main/java/me/lucky/wasted/AppNotificationManager.kt | 4 ++-- app/src/main/java/me/lucky/wasted/DeviceAdminManager.kt | 2 +- app/src/main/java/me/lucky/wasted/UnlockService.kt | 4 +--- app/src/main/java/me/lucky/wasted/WipeJobManager.kt | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/me/lucky/wasted/AppNotificationManager.kt b/app/src/main/java/me/lucky/wasted/AppNotificationManager.kt index f3330af..006c14b 100644 --- a/app/src/main/java/me/lucky/wasted/AppNotificationManager.kt +++ b/app/src/main/java/me/lucky/wasted/AppNotificationManager.kt @@ -13,7 +13,7 @@ class AppNotificationManager(private val ctx: Context) { private var manager: NotificationManager? = null init { - manager = ctx.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager? + manager = ctx.getSystemService(NotificationManager::class.java) } fun createNotificationChannels() { @@ -26,4 +26,4 @@ class AppNotificationManager(private val ctx: Context) { ) ) } -} \ No newline at end of file +} diff --git a/app/src/main/java/me/lucky/wasted/DeviceAdminManager.kt b/app/src/main/java/me/lucky/wasted/DeviceAdminManager.kt index 4ab6f7f..8d8910f 100644 --- a/app/src/main/java/me/lucky/wasted/DeviceAdminManager.kt +++ b/app/src/main/java/me/lucky/wasted/DeviceAdminManager.kt @@ -12,7 +12,7 @@ class DeviceAdminManager(private val ctx: Context) { private val prefs by lazy { Preferences(ctx) } init { - dpm = ctx.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager? + dpm = ctx.getSystemService(DevicePolicyManager::class.java) } fun remove() = dpm?.removeActiveAdmin(deviceAdmin) diff --git a/app/src/main/java/me/lucky/wasted/UnlockService.kt b/app/src/main/java/me/lucky/wasted/UnlockService.kt index 91673b1..3e8f3ba 100644 --- a/app/src/main/java/me/lucky/wasted/UnlockService.kt +++ b/app/src/main/java/me/lucky/wasted/UnlockService.kt @@ -21,9 +21,7 @@ class UnlockService : Service() { private class UnlockReceiver : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { if (context == null) return - val keyguardManager = context - .getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager? - if (keyguardManager?.isDeviceSecure != true) return + if (context.getSystemService(KeyguardManager::class.java)?.isDeviceSecure != true) return val manager = WipeJobManager(context) var delay = 1000L while (manager.schedule() != JobScheduler.RESULT_SUCCESS) { diff --git a/app/src/main/java/me/lucky/wasted/WipeJobManager.kt b/app/src/main/java/me/lucky/wasted/WipeJobManager.kt index 1f7732c..0067246 100644 --- a/app/src/main/java/me/lucky/wasted/WipeJobManager.kt +++ b/app/src/main/java/me/lucky/wasted/WipeJobManager.kt @@ -14,7 +14,7 @@ class WipeJobManager(private val ctx: Context) { private var scheduler: JobScheduler? = null init { - scheduler = ctx.getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler? + scheduler = ctx.getSystemService(JobScheduler::class.java) } fun schedule(): Int {