Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Had issue on Samsung s5 mini with custom Android 9.0 firmware (Lineage OS based). Legacy camera.
termux-camera-photo command resulted in an empty file (see the logcat error below).
Looks like this fix should (at least partially) cover some of these issues:
#124
#435
UPD: also noticed that not all the resources were cleaned up after the shot is taken, looks like that is why
pkill com.termux.apiworked as a workaround in some cases in those issues. Added a second commit to fix this.Error looked like this:
android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): submitRequestList - configured surface is abandoned.
at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:731)
at android.hardware.camera2.impl.ICameraDeviceUserWrapper.submitRequestList(ICameraDeviceUserWrapper.java:86)
at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest(CameraDeviceImpl.java:1047)
at android.hardware.camera2.impl.CameraDeviceImpl.capture(CameraDeviceImpl.java:914)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture(CameraCaptureSessionImpl.java:173)
at com.termux.api.PhotoAPI.saveImage(PhotoAPI.java:186)
at com.termux.api.PhotoAPI$3.onConfigured(PhotoAPI.java:170)
at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigured$0(CallbackProxies.java:53)
at android.hardware.camera2.impl.-$$Lambda$CallbackProxies$SessionStateCallbackProxy$soW0qC12Osypoky6AfL3P2-TeDw.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at com.termux.api.PhotoAPI.takePicture(PhotoAPI.java:85)
at com.termux.api.PhotoAPI.lambda$onReceive$0(PhotoAPI.java:49)
at com.termux.api.-$$Lambda$PhotoAPI$TVeyrywhoGcxn5rY6HAcKkOPTo0.writeResult(Unknown Source:8)
at com.termux.api.util.ResultReturner.lambda$returnData$0(ResultReturner.java:133)
at com.termux.api.util.-$$Lambda$ResultReturner$oCU8JqHW5HLMrNZa40ThjAWcwzo.run(Unknown Source:8)
at java.lang.Thread.run(Thread.java:764)
Caused by: android.os.ServiceSpecificException: submitRequestList - configured surface is abandoned. (code -22)
at android.hardware.camera2.legacy.LegacyCameraDevice.submitRequestList(LegacyCameraDevice.java:446)
at android.hardware.camera2.legacy.CameraDeviceUserShim.submitRequestList(CameraDeviceUserShim.java:458)
at android.hardware.camera2.impl.ICameraDeviceUserWrapper.submitRequestList(ICameraDeviceUserWrapper.java:84)
... 16 more