TakePhotoTool
Captures a still JPEG headlessly (no on-screen preview) via Camera2, preferring the back-facing camera at its maximum JPEG resolution, then saves it to MediaStore under Pictures/droid-mcp.
Before the still capture a repeating preview request (into a small off-screen YUV reader) runs so auto-exposure / auto-focus / auto-white-balance can converge — it waits until CONTROL_AE_STATE reports converged / flash-required / locked (and AWB, when reported, has converged), or ~1.5 seconds elapse — avoiding the dark, unfocused first frame a cold capture produces. JPEG_ORIENTATION is set from the sensor orientation (assuming the device is held in its natural orientation). The whole capture is bounded by a 10-second timeout.
The MediaStore row is inserted with IS_PENDING on API 29+ and deleted if writing fails, so no empty gallery entries are left behind.
With return_data = true the photo is also returned base64-encoded — downscaled so its longest side is at most max_dimension (default 1280), EXIF rotation applied, re-encoded as format (jpeg default, or png) at quality (JPEG only, default 85). The saved gallery file is always the full-resolution JPEG.
Requires android.Manifest.permission.CAMERA and camera hardware; uses android.hardware.camera2.params.SessionConfiguration (API 28+, met by the SDK's min API).
Result keys: file_path (MediaStore content URI), width, height (full-resolution capture), and with return_data: image_data (base64), data_format, data_width, data_height.