-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Open
Description
Issue Description:
1. Problem Statement
I am developing a pure C++ tool using the NDK Camera2 API (NdkCameraManager, NdkCameraDevice, AImageReader) without any Java or JNI glue code. The goal is to capture frames and save them to the local filesystem from the shell.
The binary initializes successfully, and ACameraManager_openCamera returns ACAMERA_OK. However, none of the callbacks are being triggered:
ACameraDevice_StateCallbacks(e.g.,onOpened) are not called.ACameraCaptureSession_stateCallbacks(e.g.,onReady) are not called.AImageReader_ImageCallback(onImageAvailable) is never triggered.
The program enters a loop but stays idle until the timeout, with no error messages in logcat related to camera service denials.
2. Minimal Code Snippet
I am using ALooper to handle asynchronous callbacks as follows:
// In main thread
ALooper* looper = ALooper_prepare(0);
camera.startCapture(1920, 1080, 10);
int64_t start_time = time(nullptr);
while (time(nullptr) - start_time < 10) {
int ident = ALooper_pollAll(1000, nullptr, nullptr, nullptr);
if (ident == ALOOPER_POLL_TIMEOUT) {
}
}
3. What I Have Tried
- Root Access: Ran the binary as root.
- SELinux: Set
setenforce 0to rule out SELinux policy issues. - Looper: Added
ALooper_prepareandALooper_pollAllin the main thread to ensure the event loop is running. - Verification: Verified that
cmd camera list-camerasshows the cameras are available.
4. Questions
- Is it possible to use NDK Camera2 API in a standalone binary without a
VieworSurfaceTexturefrom the Java side? - Does the
shellUID (2000) orrootUID (0) have inherent restrictions for accessingCameraServicevia NDK even if SELinux is disabled? - Am I missing any specific initialization required for the
ALooperto correctly routeCameraServicecallbacks to a native process?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels