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 0 to rule out SELinux policy issues.
- Looper: Added
ALooper_prepare and ALooper_pollAll in the main thread to ensure the event loop is running.
- Verification: Verified that
cmd camera list-cameras shows the cameras are available.
4. Questions
- Is it possible to use NDK Camera2 API in a standalone binary without a
View or SurfaceTexture from the Java side?
- Does the
shell UID (2000) or root UID (0) have inherent restrictions for accessing CameraService via NDK even if SELinux is disabled?
- Am I missing any specific initialization required for the
ALooper to correctly route CameraService callbacks to a native process?
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_openCamerareturnsACAMERA_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
ALooperto handle asynchronous callbacks as follows:3. What I Have Tried
setenforce 0to rule out SELinux policy issues.ALooper_prepareandALooper_pollAllin the main thread to ensure the event loop is running.cmd camera list-camerasshows the cameras are available.4. Questions
VieworSurfaceTexturefrom the Java side?shellUID (2000) orrootUID (0) have inherent restrictions for accessingCameraServicevia NDK even if SELinux is disabled?ALooperto correctly routeCameraServicecallbacks to a native process?