From 7b017e4328a00f0b7c0061581207ae7e1ba98ec5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 11 Aug 2020 12:42:32 +0200 Subject: [PATCH] Ensure we will always use `Context#getSystemService` extension function provided by `core-ktx` --- tools/check/forbidden_strings_in_code.txt | 3 +++ .../src/main/java/im/vector/app/core/services/CallService.kt | 2 +- .../app/features/notifications/NotificationDrawerManager.kt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/check/forbidden_strings_in_code.txt b/tools/check/forbidden_strings_in_code.txt index 8d181f1da4..ed9809100c 100644 --- a/tools/check/forbidden_strings_in_code.txt +++ b/tools/check/forbidden_strings_in_code.txt @@ -169,3 +169,6 @@ enum class===76 ### Do not import temporary legacy classes import im.vector.matrix.android.internal.legacy.riot===3 import org.matrix.androidsdk.crypto.data===2 + +### Use `Context#getSystemService` extension function provided by `core-ktx` +getSystemService\(Context diff --git a/vector/src/main/java/im/vector/app/core/services/CallService.kt b/vector/src/main/java/im/vector/app/core/services/CallService.kt index bb7dccb91e..1362c20be1 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallService.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallService.kt @@ -172,7 +172,7 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe // turn the screen on for 3 seconds // if (Matrix.getInstance(VectorApp.getInstance())!!.pushManager.isScreenTurnedOn) { // try { -// val pm = getSystemService(Context.POWER_SERVICE) as PowerManager +// val pm = getSystemService()!! // val wl = pm.newWakeLock( // WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or PowerManager.ACQUIRE_CAUSES_WAKEUP, // CallService::class.java.simpleName) diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt index a485ba7bea..2ff7a9c40e 100644 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationDrawerManager.kt @@ -442,7 +442,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context /* TODO if (Matrix.getInstance(VectorApp.getInstance())!!.pushManager.isScreenTurnedOn) { - val pm = VectorApp.getInstance().getSystemService(Context.POWER_SERVICE) as PowerManager + val pm = VectorApp.getInstance().getSystemService()!! val wl = pm.newWakeLock(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or PowerManager.ACQUIRE_CAUSES_WAKEUP, NotificationDrawerManager::class.java.name) wl.acquire(3000)