Skip to content

App constantly trying to connect to camera service on device with no camera #2142

@backcountrymountains

Description

@backcountrymountains

Have you checked if an issue already exists for this bug?

  • Nobody else has reported this bug before

Have you tried restarting your device?

  • I have tried restarting my device and that did not help

What happened that you did not expect?

I have a Nook eReader and I use KeyMapper to change what the physical buttons do. For that, it works very well so thank you.
However, I have an issue that KeyMapper is constantly trying to open a camera when there is no camera on the device. I don't know how big of a deal this is, but I would prefer it if KeyMapper didn't do this.

logcat:

05-19 12:55:48.831  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:49.833  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:50.834  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:51.836  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:52.837  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:53.838  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:54.839  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:55.841  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:56.842  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:57.843  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:58.845  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:55:59.846  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:00.847  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:01.849  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:02.850  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:03.852  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:04.853  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:05.855  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:06.856  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:07.858  2311  2311 I CameraManagerGlobal: Connecting to camera service
05-19 12:56:08.859  2311  2311 I CameraManagerGlobal: Connecting to camera service

ps:

ps -p 2311 -o NAME
NAME
io.github.sds100.keymapper

I'm not a developer at all but google ai said that maybe there could be some kind of check before trying to connect to the camera service:

1. Modify the AndroidManifest.xmlTell the Android system that your app does not strictly require a camera to function. This prevents Google Play from filtering your app for cameraless devices and signals intent to the OS.xml<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
Use code with caution.2. Wrap Camera Initialization in a Hardware CheckThe CameraManagerGlobal error triggers because your code (or a third-party SDK) is actively calling CameraManager.openCamera() or getCameraIdList(). You must wrap all camera-related code inside a conditional check.Kotlin Example:kotlinval hasCamera = packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)

if (hasCamera) {
    // Only initialize or connect to the camera service here
    initializeCamera()
} else {
    // Safely skip camera setup, hide camera UI elements, or show an error
    disableCameraFeatures()
}

Anyway, thanks for this, it is super helpful for me on my weird device.

What did you expect to happen?

KeyMapper wouldn't try to connect to nonexistent camera.

Thanks!

What would the developer need to do to reproduce the bug?

No response

App version

3.2.1-foss132

Android version

8.1.0 if you can believe it

Device model and manufacturer

BN Nook Glowlight 4 plus

Extra info

  • My device is rooted

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions