Skip to content

Commit b652d97

Browse files
authored
Fix lock bypass through floating window, multi window
1 parent 039c5fc commit b652d97

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

app/src/main/java/dev/pranav/applock/features/lockscreen/ui/PasswordOverlayScreen.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,28 @@ class PasswordOverlayActivity : FragmentActivity() {
136136
}
137137
}
138138

139+
139140
private fun setupWindow() {
140141
window.addFlags(
141142
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or
142-
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
143-
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
143+
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
144+
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON or
145+
WindowManager.LayoutParams.FLAG_SECURE
144146
)
147+
145148
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
146149
setShowWhenLocked(true)
147150
setTurnScreenOn(true)
148151
}
152+
153+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
154+
window.setHideOverlayWindows(true)
155+
}
156+
149157

150158
val layoutParams = window.attributes
151-
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
159+
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
160+
152161
if (appLockRepository.shouldUseMaxBrightness()) {
153162
layoutParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL
154163
}

0 commit comments

Comments
 (0)