File tree Expand file tree Collapse file tree
app/src/main/java/com/enaboapps/switchify/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,7 +145,9 @@ class MainMenuStructure(
145145 action = { MenuManager .getInstance().openMediaControlMenu() }
146146 )
147147 },
148- if (deviceLockObserver.isUserUnlocked() == true ) {
148+ if (deviceLockObserver.isUserUnlocked() == true &&
149+ ! DeviceLockObserver .isKeyguardLocked(accessibilityService)
150+ ) {
149151 MenuItemRegistry .getMainMenuDefinition(" control_pc" )?.let { def ->
150152 MenuItem (
151153 definition = def,
Original file line number Diff line number Diff line change 11package com.enaboapps.switchify.service.utils
22
3+ import android.app.KeyguardManager
34import android.content.BroadcastReceiver
45import android.content.Context
56import android.content.Intent
@@ -20,6 +21,13 @@ class DeviceLockObserver(context: Context) {
2021 context.applicationContext.getSystemService(Context .USER_SERVICE ) as UserManager
2122 return um.isUserUnlocked
2223 }
24+
25+ @JvmStatic
26+ fun isKeyguardLocked (context : Context ): Boolean {
27+ val km =
28+ context.applicationContext.getSystemService(Context .KEYGUARD_SERVICE ) as KeyguardManager
29+ return km.isKeyguardLocked
30+ }
2331 }
2432
2533 private val appContext = context.applicationContext
You can’t perform that action at this time.
0 commit comments