Skip to content

Commit 4736264

Browse files
committed
#1627 fix: open camera app action does not work when device is locked
1 parent 5a9b8a2 commit 4736264

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [3.0 Beta 5](https://github.com/sds100/KeyMapper/releases/tag/v3.0.0-beta.5)
2+
3+
#### TO BE RELEASED
4+
5+
## Bug fixes
6+
7+
- #1627 open camera app action does not work when device is locked
8+
19
## [3.0 Beta 4](https://github.com/sds100/KeyMapper/releases/tag/v3.0.0-beta.4)
210

311
#### 2 April 2025

app/src/main/java/io/github/sds100/keymapper/system/apps/AndroidPackageManagerAdapter.kt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,31 @@ class AndroidPackageManagerAdapter(
281281

282282
override fun launchCameraApp(): Result<*> {
283283
try {
284-
Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA).apply {
284+
/**
285+
* See this guide on how the camera is launched with double press power button in
286+
* SystemUI. https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/docs/camera.md
287+
*
288+
* First launch the SECURE camera intent so the camera opens when the device
289+
* is locked.
290+
*/
291+
Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE).apply {
285292
flags = Intent.FLAG_ACTIVITY_NEW_TASK
286293
ctx.startActivity(this)
287294
}
288295

289296
return Success(Unit)
290297
} catch (e: ActivityNotFoundException) {
291-
return Error.NoCameraApp
298+
// Just in case the camera app didn't implement the secure intent, try the normal one.
299+
try {
300+
Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA).apply {
301+
flags = Intent.FLAG_ACTIVITY_NEW_TASK
302+
ctx.startActivity(this)
303+
}
304+
305+
return Success(Unit)
306+
} catch (e: ActivityNotFoundException) {
307+
return Error.NoCameraApp
308+
}
292309
}
293310
}
294311

0 commit comments

Comments
 (0)