Connectivity & Media

Camera End-to-End

A dedicated walk of one preview frame and one still capture through CameraX/Camera2, cameraserver, AIDL Camera HAL3, the sensor and ISP, and the three output Surfaces. This expands the map on Trace a Path Through the Android Stack. Codecs and muxers live on Multimedia End-to-End — here video only hands a Surface to MediaCodec.

~80 min read 0 interview questions
In 30 seconds
  • Control plane opens the device, configures streams, programs 3A and holds a session. Frame plane is every HAL3 request/result plus the buffers that ride with it. Mixing "takePicture" with "trace this frame" is the usual fail.
  • CameraX is Jetpack on Camera2. Both Binder to CameraService in cameraserver. The vendor process implements ICameraProvider and ICameraDevice (AIDL on Android 13–15; HIDL 3.x on older images).
  • The ISP is the producer. Preview goes to a Surface → BLAST/BufferQueue → SurfaceFlinger. A still goes to an ImageReader (JPEG or YUV). Video goes to a Surface that MediaCodec owns.
  • HAL1 (startPreview / takePicture) is deprecated. HAL3 is one request with settings and stream targets, one result with metadata and filled buffers, every frame.
  • Reconfigure is expensive: new sensor mode, ISP graph, Gralloc/DMA-BUF set, and 3A restart. A still tap should be a second request on a live session, not a new session.
  • ZSL reuses a recent full-res frame from a ring; non-ZSL waits for a new exposure. Upload after save is the data call or Wi-Fi path, not more camera HAL.
  • Bisect "black preview" vs "no JPEG" vs "green frames" with dumpsys media.camera, dumpsys media.camera.provider, Perfetto camera, and Camera2 logcat. Permission and SELinux sit above the ISP.

Two planes: control vs frame

Camera is two conversations that share a sensor and a buffer pool but almost no logic. Interviewers use this split as a filter. If you start "trace a preview frame" with openCamera and never name a request, or you start a "how does the app start the camera" answer with CSI and DMA, you have mixed the planes. The map on data-flow already draws the destinations; this page is the walk.

Control plane (lease the lab)

  • Enumerate IDs, characteristics, concurrent combinations.
  • Runtime CAMERA permission, AppOps, privacy indicator.
  • openCamera → CameraDevice; HAL ICameraDevice.open → session.
  • Stream config: which Surfaces, sizes, formats, use cases.
  • 3A and scene settings that apply until the next request overrides them.
  • Session close, eviction, torch, foldable device-state notify.

Frame plane (every request)

  • One HAL3 request: metadata (exposure, AF trigger, crop, JPEG quality) plus a list of output streams.
  • Sensor exposure + readout, CSI, ISP (and optional NPU extras).
  • Filled buffers with acquire/release fences.
  • One or more results: partial then final metadata, plus buffer status.
  • Consumers: SurfaceFlinger (preview), ImageReader (still), MediaCodec (video), analysis ImageReader.
Analogy

Leasing a photo lab versus running one order through it. The lease (control) is paperwork: which rooms are open (streams), who is allowed in (permission), and standing instructions for the technicians (3A). Each order form (a capture request) comes back as a finished packet (a result plus prints). You do not drive the shutter timing yourself on preview; you keep a repeating order on the preview stream and submit a still order when the user taps. That is the same lab metaphor as the map.

CONTROL (once per session)                      FRAME (every request)
App CameraX / Camera2                           Repeating or single CaptureRequest
        |                                               |
CameraManager.open / createCaptureSession       CameraCaptureSession.capture / setRepeating
        |                                               |
CameraService (cameraserver)                    ICameraDeviceSession.processCaptureRequest
        |                                               |
ICameraProvider + ICameraDevice.open            sensor + CSI + ISP (+ NPU extras)
        |                                               |
configureStreams (sizes, formats, Surfaces)     result metadata + fences + DMA-BUF
        v                                               v
   "session is usable"                          buffers at preview / still / video

HAL1 deprecated versus HAL3 request/result

HAL1 (deprecated)HAL3 (required story)
API shapestartPreview, takePicture, a few callbacksPer-frame request with settings and stream targets; per-frame result with metadata and buffers
Who times the shutterThe HAL hides a "take picture" sequenceThe framework submits requests; the HAL pipelines several in flight
Preview + still togetherAwkward; often stop preview to snapOne session, several streams, a still request while preview repeats
Where you still hear itLegacy android.hardware.Camera (the "Camera1" SDK)Camera2, CameraX, ICameraDevice AIDL/HIDL 3.x

Say in interviews: "HAL1 is a camcorder remote. HAL3 is a photo lab that takes an order form every frame." Do not implement new features on HAL1. AOSP 13–15 Camera HAL is AIDL android.hardware.camera.provider.ICameraProvider and android.hardware.camera.device.ICameraDevice; HIDL @3.x remains on vendor images that have not migrated. Confirm the VINTF manifest on the build.

Common pitfall Answering "trace taking a photo" with only takePicture, or answering "how does preview start?" with CSI lane counts and never naming a repeating request. Name both planes, then stay on the one the question asked.
Interview angle Open with one sentence per plane, then ask which they want. Framework services: Android frameworks. Binder hops: Binder & AIDL. Sensor/CSI/DMA: Linux Kernel & BSP.

Layer cake: app to sensor

The producer is the ISP, not the app. The app owns Surfaces and requests. Everything between is policy, IPC and a vendor pipeline you describe at the public HAL boundary — not as a proprietary graph.

App process
  CameraX use cases  or  Camera2 CameraManager / CameraDevice / Session
           |  Binder (ICameraService)
cameraserver
  CameraService  →  Camera3Device  →  CameraProviderManager
           |  Binder (AIDL ICameraProvider / ICameraDevice / ICameraDeviceSession)
Vendor camera provider process
  ICameraProvider  →  ICameraDevice  →  ICameraDeviceSession
           |  ioctl / DMA-BUF / vendor IPC
Kernel + silicon
  sensor I2C/SPI  →  MIPI CSI-2  →  CSI RX + DMA (+ IOMMU)
  → ISP  →  optional NPU extras  →  output buffers (Gralloc / DMA-BUF)
           |
Destinations (consumers of those buffers)
  preview Surface  →  BLAST / BufferQueue  →  SurfaceFlinger  →  display
  still ImageReader  →  JPEG / YUV  →  app save or upload
  video Surface  →  MediaCodec   (muxer / file = multimedia.html)
Analogy

A restaurant brigade. The diner (app) orders from a menu (Camera2/CameraX). The head waiter (CameraService) checks the reservation (permission) and walks the ticket to the kitchen pass (HAL). The kitchen (sensor, CSI, ISP) plates the food onto dishes the diner already set on the table (Surfaces / ImageReader). The window display is SurfaceFlinger; the take-away box is the still buffer; the packing belt is MediaCodec. You do not invent a secret sauce recipe for a particular kitchen — you name the pass and the plates.

CameraX

Jetpack. Use cases: Preview, ImageCapture, ImageAnalysis, VideoCapture. Lifecycle-aware. Still Camera2 underneath; CameraService and the HAL do not change.

Camera2

Public framework API: CameraManager, CameraDevice, CameraCaptureSession, CaptureRequest, CaptureResult, CameraCharacteristics.

CameraService

Native service in cameraserver. Client eviction, permission/AppOps, privacy indicators, HAL open, stream config, request fan-in. Apps never talk to the provider process directly.

Provider + device HAL

AIDL ICameraProvider lists IDs and concurrent sets; ICameraDevice.open returns ICameraDeviceSession. HIDL 3.x is the older equivalent.

Who talks to whom

HopInterfaceProcess
App → frameworkSDK Camera2 / CameraX (in-process) then Binder ICameraServiceApp → cameraserver
Framework → vendorAIDL ICameraProvider, ICameraDevice, ICameraDeviceSession, ICameraDeviceCallbackcameraserver → provider HAL
Vendor → kernelSensor I2C, CSI, V4L2 or vendor ioctl, DMA-BUF / dma-heap / ION remnantsHAL process → kernel
Buffers → consumersGraphicBuffer handles, fences, BufferQueue or BLASTHAL producer; SF / ImageReader / MediaCodec consumer

Binder identity and AIDL versioning: Binder & AIDL. cameraserver is a native daemon started by init; if it dies, camera clients fail and init restarts it (often beside other media daemons on a Zygote onrestart line). Framework overview: Android frameworks.

Tip In Android 13–15 interviews, say "AIDL Camera HAL" and name ICameraProvider / ICameraDevice / ICameraDeviceSession. Then: "I would confirm HIDL versus AIDL on that device with the VINTF manifest and dumpsys media.camera.provider." Do not recite a frozen HIDL minor as if it were universal.
Interview angle Walk the cake top-down in one breath, then offer to go deep on the hop they care about: session config, one preview buffer, one JPEG, or the MediaCodec handoff. Do not open muxers or codec profiles here — that is multimedia.

Open and configure: from enumerate to session

Nothing on the frame plane exists until a session is up. This is the control-plane bring-up that juniors skip when they jump to "and then the ISP writes JPEG."

  1. Enumerate CameraManager.getCameraIdList() (and getConcurrentCameraIds() if you need two at once). Characteristics tell facing, capabilities, StreamConfigurationMap, logical/physical IDs.
  2. Permission Dangerous runtime CAMERA. AppOps must be allowed. Background camera is restricted. The privacy indicator turns on when a client is active, not when the HAL process merely exists. Video-with-mic also needs RECORD_AUDIO — that is a recorder/media permission, not a second camera HAL.
  3. Open openCamera(id, executor, stateCallback). CameraService checks eviction (another app may be using the device), then ICameraDevice.open. You get a CameraDevice whose onOpened is the green light to configure, not to assume frames are flowing.
  4. Build outputs Surfaces: a preview Surface from a SurfaceView / TextureView / CameraX PreviewView; a still ImageReader Surface; optional analysis ImageReader; optional video Surface from MediaCodec. Sizes and formats must appear together in the advertised stream combinations.
  5. Create session SessionConfiguration + OutputConfiguration (Android 10+ path) or the older createCaptureSession(surfaces). HAL configureStreams / configureStreamsV2 programs the sensor mode and ISP outputs. onConfigured means you may submit requests.
  6. First repeating request Preview (and usually analysis) start only when you setRepeatingRequest. An open device with no repeating request is a black preview.
Analogy

Booking a studio and dressing the set. Enumeration is the directory of rooms. Permission is the keycard. Open is unlocking the door. Stream config is hanging the backdrops and plugging the lights (preview monitor, still archive, video packer). Reconfigure is tearing the set down and building another — you lose time, heat, and the first good take. A still click should be "one more order on the same set," not a new booking.

Stream kinds you actually configure

StreamTypical SurfaceFormat / size notes
PreviewDisplay Surface (View / Texture / PreviewView)Often PRIVATE or YUV, viewfinder size, 30 fps class
StillImageReaderJPEG or YUV_420_888 at a still size; max JPEG is not always a valid combo with 4K video
VideoMediaCodec input SurfaceSize/fps the encoder and the stream map both allow
AnalysisImageReader (YUV)Smaller, for ML / QR; CameraX ImageAnalysis

Android 11+ OutputConfiguration.setStreamUseCase (PREVIEW, STILL_CAPTURE, VIDEO_RECORD, PREVIEW_VIDEO_STILL, VIDEO_CALL) tells the HAL how you intend to use the stream so it can pick an ISP path. Wrong use case is a quality or fps bug, not a crash. Always check StreamConfigurationMap and, on 13+, isSessionConfigurationSupported.

Why reconfigure is expensive

  • Sensor mode change (crop, binning, fps) — milliseconds to tens of milliseconds, plus a dropped frame streak.
  • ISP graph rebuild and 3A restart (AE/AF hunt again).
  • Gralloc / DMA-BUF reallocation; old buffers must drain; IOMMU maps churn. CMA pressure if the device still needs large contiguous chunks — see Linux Kernel & BSP.
  • Consumers must reconnect Surfaces. A preview Surface that is recreated late looks like a black viewfinder.

App pattern: configure preview + still (+ analysis) once. Add a video Surface when recording starts only if you must; prefer a session that already included the record size, or accept a visible glitch. CameraX hides some of this; the HAL still pays.

Common pitfall Creating a new session on every shutter tap "to add a JPEG stream." That is a control-plane restart in the middle of a frame-plane question. Configure JPEG (or YUV still) up front.
Interview angle List enumerate → permission → open → Surfaces → session → repeating request. Then say why a still is a request, not a reconfigure. If they ask "CameraX versus Camera2," CameraX is the use-case wrapper; the hops below it stay the same.

Request, result, fences and buffers

HAL3's unit of work is one request. The session is a pipeline: several requests can be in flight (sensor exposing N, ISP working N−1, JPEG of N−2). That pipeline depth is why shutter lag and preview latency are not "one function call."

Repeating preview request

setRepeatingRequest with TEMPLATE_PREVIEW (and the preview / analysis Surfaces). Replaced as a whole when you set a new repeating request. This is the idle heartbeat of a live viewfinder.

Still capture request

capture or captureBurst with TEMPLATE_STILL_CAPTURE or TEMPLATE_ZERO_SHUTTER_LAG, targeting the still Surface and usually still the preview Surface so the viewfinder does not freeze.

Result metadata

CaptureResult / TotalCaptureResult: timestamps, exposure, sensitivity, AF/AE/AWB state, faces, crop, color spaces, JPEG size. Partial results may arrive before the final one.

Templates

TEMPLATE_PREVIEW, STILL_CAPTURE, RECORD, VIDEO_SNAPSHOT, ZERO_SHUTTER_LAG, MANUAL. They are starting metadata, not different HALs.

Analogy

A sushi-bar ticket rail. Each ticket (request) lists the plate type (which streams) and the seasoning (3A, crop, JPEG quality). Several tickets are in progress at once. The plate comes back with a receipt (result metadata) clipped to it. The plate itself is a shared dish (DMA-BUF) that the window (SurfaceFlinger) or the box (ImageReader) already owns — nobody photocopies the fish.

App:  setRepeatingRequest(preview)     ... later capture(still+preview)
                |                              |
CameraService assigns frame numbers            |
                v                              v
HAL session:  processCaptureRequest     processCaptureRequest
                |                              |
         [ pipeline: expose → readout → ISP → optional JPEG ]
                |                              |
callback: processCaptureResult + notify(shutter)
                |
         buffers queued to each target Surface
                |
         consumers wait on release fence, then use pixels

Fences, BufferQueue, GraphicBuffer, DMA-BUF

The HAL is the producer. It dequeues a free GraphicBuffer, waits on the acquire fence (previous consumer finished), writes pixels (ISP / DMA), and queues the buffer with a release fence that signals when the write is done. The consumer (SurfaceFlinger, ImageReader, MediaCodec) waits on that fence, reads or encodes, then releases the buffer so it can return. There is no memcpy of a 12 MP frame into the app heap on the happy path.

  • GraphicBuffer — Android's gralloc-allocated image buffer (handle + width/height/stride/format).
  • DMA-BUF — the kernel object behind modern handles: a file descriptor you can pass over Binder. Zero-copy among ISP, GPU, display, encoder. Details: Linux Kernel & BSP.
  • BufferQueue / BLAST — the queue abstraction. Android 10+ preview Surfaces are usually BLASTBufferQueue: same producer-consumer idea, cheaper SurfaceFlinger transaction. The map already says "BufferQueue / BLAST" — keep both names.
  • Frame number — HAL and Camera2 correlate request, shutter notify, result and buffers. Debug with that number, not wall-clock guesses.

Errors you must name

ErrorMeaning
ERROR_REQUESTThis request failed; pipeline may continue.
ERROR_RESULTMetadata broken; buffers may still be usable.
ERROR_BUFFEROne output buffer failed (still JPEG failed, preview OK — a classic split).
ERROR_DEVICEDevice is toast; session is dead; reopen.
Tip If the app never acquireLatestImage() / acquireNextImage() on an ImageReader, the queue fills, the HAL cannot dequeue still buffers, and you get stalls or ERROR_BUFFER on the still stream while preview keeps going. Consume or drop.
Interview angle Draw request → in-flight pipeline → result + fence + buffer. Say "shared GraphicBuffer / DMA-BUF, not a copy." If they ask HIDL versus AIDL, the ideas (configureStreams, processCaptureRequest, processCaptureResult, notify) are the same; the IPC language changed.

Preview path: one viewfinder frame

This is the hop-by-hop the map summarised as "preview Surface → BufferQueue / BLAST → SurfaceFlinger → display." Stay on one frame.

  1. Request The repeating preview request names the preview stream (and maybe analysis). CameraService forwards processCaptureRequest.
  2. Expose and read out Sensor integrates for SENSOR_EXPOSURE_TIME, then reads rows over MIPI CSI-2 into the CSI receiver. DMA writes raw or ISP-inbound lines; the IOMMU translates device addresses. Large contiguous needs may still hit CMA. Kernel concepts: CSI, DMA, IOMMU, CMA.
  3. ISP Demosaic, denoise, sharpen, color, tone, scale to the preview size. Optional vendor extras (face crop hints, preview EIS). You describe this as "ISP produces the preview buffer," not a secret node graph.
  4. Queue to the preview Surface HAL signals the release fence. BLAST/BufferQueue now holds a ready GraphicBuffer.
  5. SurfaceFlinger Latches the buffer on vsync, Hardware Composer chooses overlay vs GPU client composition, the panel scans out.
  6. App UI For TextureView / PreviewView there may be an extra GPU blit into the app's layer. SurfaceView / ASurfaceTransaction paths can be overlay-friendly and cheaper.
Analogy

A shop window. The workshop (ISP) finishes a print, hangs it on the shared clip (buffer + fence), and the window dresser (SurfaceFlinger) swaps it on the next drum beat (vsync). If three prints are already hanging on the rail (queue depth), the newest one waits — that is extra frame latency, not extra exposure.

repeating request (preview Surface)
        |
   sensor expose  -- CSI -->  ISP scale/color
        |
   GraphicBuffer + release fence
        |
   BLAST / BufferQueue          <-- extra queued frames = latency
        |
   SurfaceFlinger  -- vsync -->  HWC / GPU  -->  display
        |
   user sees viewfinder

Latency sources (add, do not pick one)

SourceBallpark thinking
Exposure + readoutA 30 fps rolling shutter is already ~33 ms of light plus readout; long night exposures dwarf everything else.
ISP + extrasPer-frame processing; heavier at night or with preview stabilization.
BufferQueue depthEach extra queued preview buffer is one more frame of glass-to-glass delay.
SurfaceFlinger + HWCUp to one vsync (8.3–16.6 ms at 120–60 Hz) plus composition if not overlay.
3A huntDoes not add a fixed offset every frame, but AF/AE search makes the useful image late after a scene change.

Glass-to-glass preview latency is typically a few frames. Do not quote a single OEM number. Say "exposure + pipeline + queue + vsync" and offer to measure with Perfetto camera/display tracks and a LED-vs-display test.

tpreview ≈ texpose + treadout + tISP + Nq·Tframe + tSF+display where Nq is extra queued preview buffers and Tframe is the sensor frame period. Night: texpose dominates. Janky UI: tSF+display and GPU blits dominate.
Common pitfall "Preview is slow, so the JPEG encoder is slow." Preview never visits the JPEG block. Bisect: if the ImageReader still is fast and the viewfinder is late, you are on this path (queue, SF, extra GPU), not the still path.
Interview angle Walk one frame with named hops and fences. Mention BLAST by name (Android 10+). Power: a repeating request holds sensor + ISP rails — close the session when the app is not visible. See Power and thermal.

Still path: shutter to JPEG (or YUV)

The map's still line is "ImageReader → JPEG / YUV → app saves or uploads." Here is the walk, including ZSL versus a fresh exposure.

ZSL (zero shutter lag)

  • HAL (and/or framework) keeps a ring of recent full-res frames while preview repeats.
  • A TEMPLATE_ZERO_SHUTTER_LAG or equivalent still request can reprocess an already-captured frame (crop, NR, JPEG) instead of waiting for a new exposure.
  • Needs enough buffer count and a stream combination that allows the ring (often a PRIVATE or YUV full-res stream the app never sees).
  • Best when 3A was already converged. A flash or AE precapture usually abandons pure ZSL and takes a new shot.

Non-ZSL

  • AF trigger and/or AE precapture, then a new exposure after the tap.
  • Honest for flash, long exposure, and "I need this moment after lock."
  • Shutter lag ≈ lock time + expose + readout + ISP + JPEG.
  • Preview can keep repeating if the still request also targets the preview Surface.
Analogy

A Polaroid pile versus asking the subject to hold still for a new plate. ZSL grabs a recent Polaroid off the pile and runs it through the finishing machine (reprocess / JPEG). Non-ZSL turns the lights up, focuses, and exposes again. Flash is almost always the second story: you cannot reuse a dark Polaroid and pretend the flash fired.

  1. User tap App builds a still request (CameraX ImageCapture or Camera2 capture) targeting the still Surface, usually plus preview.
  2. Optional lock CONTROL_AF_TRIGGER_START, CONTROL_AE_PRECAPTURE_TRIGGER_START. Wait for AF/AE state in results. Skip or shorten if ZSL and already converged.
  3. Capture or reprocess New sensor frame, or pick from the ZSL ring. ISP produces a full-res YUV (and/or HAL JPEG).
  4. Still buffer JPEG bytes or YUV planes land in the ImageReader GraphicBuffer. Thumbnail: JPEG_THUMBNAIL_SIZE / quality in the request; the HAL embeds a thumbnail in the JPEG (EXIF) so galleries have a small image without decoding 12 MP.
  5. App consume Image.acquire*, write to MediaStore / file, or keep YUV for the app's own encode. Close the Image or the queue wedges.
  6. Save or upload Save is storage. Upload is no longer camera: socket on the default Network, then Android Data Call and/or Wi-Fi. Compose with data-flow.
ZSL (happy, converged 3A)
 preview repeating  -- keeps full-res ring -->
 tap: still request (ZSL) -- reprocess ring frame --> JPEG/YUV ImageReader --> app

Non-ZSL / flash / long exposure
 tap: AF/AE trigger -- wait results -- new expose -- ISP -- JPEG/YUV -- ImageReader --> app

After the bytes exist
  app file / MediaStore
  app HTTP/QUIC upload  -->  android-data-call.html / Wi-Fi   (not more HAL3)

JPEG ImageReader versus YUV ImageReader

JPEG ImageReaderYUV ImageReader
Who encodesHAL / ISP JPEG blockApp or a later MediaCodec (still: you are leaving camera)
CPU / copyApp sees a compressed blobApp can process pixels; watch stride and Image.getPlanes()
Failure lookNo JPEG / truncated JPEG / ERROR_BUFFER on that streamGreen or striped frames if format/stride is wrong
ThumbnailUsually inside the JPEGYou make your own downsample
Tip CameraX ImageCapture "JPEG" versus "YUV" is this choice. A vendor JPEG path can fail while YUV preview is fine — that is ERROR_BUFFER on the still stream, not a dead sensor.
Interview angle "Trace taking a photo" = CameraX/Camera2 → CameraService → HAL3 still request → ZSL or new expose → ISP → ImageReader → app. Then one sentence on upload using the data path. Do not start at CSI unless they asked for silicon.

Video path: Surface to MediaCodec

Video is a third consumer of the same HAL3 pipeline, not a second camera stack. This page stops at the encoder sink. Profiles, muxers, MediaMuxer, AAC, MP4 and DRM are Multimedia End-to-End.

  1. Record Surface MediaCodec.createInputSurface() (or a persistent input Surface) is added as a camera output. CameraX VideoCapture does this for you.
  2. Session Preview + video (and maybe video snapshot) must be a supported combination. Adding the Surface late is a reconfigure — expect a glitch.
  3. Repeating record request TEMPLATE_RECORD targets preview + video Surfaces. The HAL produces frames the encoder can import (often PRIVATE / implementation-defined).
  4. Handoff Same GraphicBuffer / DMA-BUF + fences. MediaCodec is the consumer. After that, encoded access units go to a muxer — another page.
Analogy

A packing belt at the end of the kitchen. The cooks (ISP) still plate every ticket. The belt (video Surface) carries plates into a sealing machine (MediaCodec). How the machine compresses, and how boxes are taped into a crate (muxer / file), is the factory next door — multimedia. Do not give a codec lecture on a camera interview unless they walk you through the door.

TEMPLATE_RECORD repeating
   preview Surface ──▶ BLAST ──▶ SurfaceFlinger
   video Surface   ──▶ MediaCodec (encoder HAL) ──▶  [muxer / file = multimedia.html]
   optional snapshot ImageReader on VIDEO_SNAPSHOT

Stabilization, 4K/60, thermal

TopicPublic-API facts
OISLENS_OPTICAL_STABILIZATION_MODE — lens/module hardware. Works on still and video if the unit has it.
EIS / video stabCONTROL_VIDEO_STABILIZATION_MODE — digital; crops and warps. Preview stab on recent APIs is a separate control. Costs FOV and ISP/GPU load.
4K / 60Must be in the stream map together with the preview size you want. CSI lane rate, ISP clock, DRAM bandwidth and the encoder cap all have to hold. If any hop cannot, the combination is missing or fps collapses.
ThermalSensor + ISP + encoder + DRAM are a heat engine. Thermal HAL / framework can drop fps, shrink size, disable EIS, or kill the session. Apps should listen to thermal status and back off. See Power and thermal.
Common pitfall Describing video as "the camera writes an MP4." The camera writes buffers into a Surface. MediaCodec encodes. A muxer wraps the file. Three owners, three dumps.
Interview angle Name the video Surface as a HAL3 output and MediaCodec as the sink. Then stop. Follow-ups: why 4K60 is a combination problem, and why a long 4K recording throttles (thermal/power), not "the JPEG block."

3A, faces, scenes and public extensions

3A is control metadata on requests and state in results. It is not a vendor night-mode flowchart. Stay at the public Camera2 / CameraX / Extensions API.

AF

CONTROL_AF_MODE (AUTO, CONTINUOUS_PICTURE, CONTINUOUS_VIDEO, OFF / MANUAL). Trigger with CONTROL_AF_TRIGGER. Results: CONTROL_AF_STATE (INACTIVE, SCAN, FOCUSED_LOCKED, …) and lens focus distance.

AE

CONTROL_AE_MODE (ON, ON_AUTO_FLASH, …). Precapture trigger for flash/torch sequences. Results: CONTROL_AE_STATE, exposure time, sensitivity, frame duration. Regions: CONTROL_AE_REGIONS.

AWB

CONTROL_AWB_MODE (AUTO, INCANDESCENT, …). Results: CONTROL_AWB_STATE and color correction gains/transform when available.

Manual override

TEMPLATE_MANUAL plus CONTROL_MODE_OFF and explicit exposure/sensitivity/focus. Used by "pro" apps. The HAL still runs the sensor; you just own the numbers.

Analogy

Three technicians behind the pass: focus puller (AF), iris/lights (AE), gel filters (AWB). The ticket can say "you pick" or "lock these numbers." A receptionist (face/scene stats) points at where the customer is standing so the technicians meter off a face instead of the window. Night or bokeh "specials" are menu items (Extensions). You do not walk into the kitchen to redraw the plumbing.

Faces, scenes, extensions

  • Face STATISTICS_FACE_DETECT_MODE (OFF / SIMPLE / FULL). Results carry face rectangles and optional landmarks/IDs. Used to bias 3A regions. There is no public API for a vendor face-beauty graph — if the product does it, it is a vendor extension or an app-side filter.
  • Scenes CONTROL_SCENE_MODE (ACTION, NIGHT, PORTRAIT, …) when CONTROL_MODE is USE_SCENE_MODE. Many modern HALs ignore these in favor of their own scene detector behind AUTO. Say that out loud.
  • Camera Extensions (Android 12+ public API): CameraExtensionCharacteristics / CameraX Extensions — BOKEH, HDR, NIGHT, FACE_RETOUCH, AUTOMATIC. The app opens an extension session. Internals may use burst + NPU + fusion. You name the session type and the user-visible mode, not a proprietary multi-frame recipe.
  • Vendor tags exist on characteristics/requests/results. In interviews, say "vendor tag section in metadata; I would read the published SDK or characteristics dump," and refuse to invent tag names.
CaptureRequest metadata
  CONTROL_AF_MODE / AF_TRIGGER / AF_REGIONS
  CONTROL_AE_MODE / AE_PRECAPTURE_TRIGGER / AE_EXPOSURE_COMPENSATION
  CONTROL_AWB_MODE
  STATISTICS_FACE_DETECT_MODE
  optional: extension session instead of a plain session
        |
HAL 3A (+ optional NPU extras) runs across the request pipeline
        |
CaptureResult metadata
  AF/AE/AWB_STATE, faces[], exposure, sensitivity, color, timestamp
Common pitfall Drawing a secret multi-frame night pipeline in a public interview. The strong answer is: "Extensions or a burst of requests plus app/HAL fusion; I will stay on request/result and the public mode name."
Interview angle Define 3A as request keys + result states. Walk a tap-to-focus: set region, AF trigger, wait FOCUSED_LOCKED, then still capture. Mention precapture for flash. Point NPU extras at Extensions, not at a chipset brand cookbook.

Multi-camera, zoom and privacy

Phones expose more sensors than camera IDs. The public model is logical versus physical IDs, plus an optional concurrent set. Privacy indicators are a CameraService/AppOps story, not an ISP story.

IdeaWhat the app sees
Logical cameraOne ID in getCameraIdList() that may wrap several physical sensors (UW / wide / tele). Characteristics include getPhysicalCameraIds().
Physical streamsAn OutputConfiguration can be bound to a physical ID so you receive that sensor's frames while the logical device stays open.
Zoom switchingOften SCALER_CROP_REGION / zoom ratio on the logical camera. The HAL may switch physical sensors internally. That can look like a one-frame hitch if they reconfigure the sensor mode underneath you.
Concurrent camerasPackageManager.FEATURE_CAMERA_CONCURRENT and getConcurrentCameraIds(). Typical: front + back at reduced size. Not "open every ID at 4K."
Privacy indicatorAndroid 12+ status-bar camera chip while an app (or the HAL on its behalf) is using a camera. Driven by CameraService / AppOps, not by whether pixels reached SurfaceFlinger.
Analogy

One storefront (logical ID) with several photographers in the back (physical sensors). Zoom is the manager handing the job to the tele photographer without changing the shop sign. Concurrent cameras are two storefronts open at once — the city only permits certain pairs, and each works smaller rooms. The green light over the door (privacy indicator) means someone is in the shop, even if the window display is still black.

CameraManager.getCameraIdList()
   0  logical (physical: 2 UW, 3 wide, 4 tele)
   1  logical front
getConcurrentCameraIds()  e.g. {0, 1} at limited sizes

App opens 0, sets zoom ratio
   HAL may remap 2 ↔ 3 ↔ 4   (possible silent sensor switch)

Privacy: CameraService notes active client
   → AppOps / permission controller → status bar indicator
  • Foldables: ICameraProvider.notifyDeviceStateChange (and framework device-state) so the provider can enable/disable cameras as hinges move. Characteristics can change; apps should listen for availability callbacks.
  • Eviction: a higher-priority client (another app, or a system voice/video use) can steal the device. onDisconnected is not "the ISP crashed."
  • Do not claim a specific OEM's UW/wide/tele switch hysteresis. Say "logical zoom; HAL may switch physical IDs; I would confirm with dumpsys media.camera and physical result metadata."
Interview angle Define logical vs physical in one sentence, then concurrent vs "two logical streams on one device." End with privacy indicators so they know you remember the user-visible control plane. Framework permission model: Android frameworks.

Debug: dumps, traces and a three-way bisect

Name the flow, reproduce, tap each layer, then bisect. The three user-visible failures that interviewers love are black preview, no JPEG and green frames. They are not the same hop.

adb shell dumpsys media.camera
adb shell dumpsys media.camera.provider
# Optional file dump when the live dump is huge:
adb shell dumpsys media.camera -f /data/local/tmp/camera.txt

adb logcat -b all -s Camera2:V CameraService:V CameraProvider:V cameraserver:V
# Also watch the app tag and ActivityTaskManager for permission denials.

# Perfetto: enable camera + display/SurfaceFlinger + binder tracks on the build's
# camera data source (name has moved; pick it in the Perfetto UI / config).
# Confirm a request frame number lines up with a displayed layer latch.

adb shell ps -A | grep -E 'camera|provider'
adb shell dmesg | grep -i -E 'csi|cam|smmu|iommu|dma-buf|dma_heap'
adb shell logcat -b events | grep -i camera
Analogy

Finding a leak in a long pipe: open valves and see which side still has water. The valves are dumpsys (who has a session), logcat Camera2 (were requests submitted), Perfetto (did a buffer latch at SF), HAL/provider logs (did the ISP finish), and kernel CSI/IOMMU (did silicon transfer). The last valve with water is the owning team.

Black preview vs no JPEG vs green frames

SymptomLikely hopWhat you check
Black previewControl or preview consumerPermission/AppOps; session onConfigured; repeating request actually set; preview Surface valid (View size > 0); SF latching; not a still-only bug
Preview OK, no JPEGStill stream / JPEG block / ImageReaderStill Surface in the session; still request targets it; ImageReader consumed; ERROR_BUFFER vs HAL JPEG fail; ZSL ring empty after mode change
Green / pink / striped framesFormat, stride, or unfilled bufferHAL wrote the wrong color space or stride; consumer interpreted NV12 as YV12; buffer queued without a real fill (fence signaled on zeroed memory); analysis ImageReader plane alignment
Green indicator, no framesPolicy vs pipelineClient is open (indicator is honest) but repeating request missing, or buffers dying before SF
Open failsPermission, eviction, SELinux, HAL crashAppOps, other client in dumpsys media.camera, avc: denied, provider process missing

Permission and SELinux

  • App missing CAMERA or denied AppOps: open fails in the framework. No HAL traffic. Teach the app / permission UX.
  • Privacy indicator on with a black view: the control plane succeeded; the frame plane did not. Do not "fix SELinux" first.
  • SELinux avc: denied on dma-heap, /dev/video*, vendor camera device nodes, or Binder to the provider: HAL or cameraserver never maps buffers. This is a policy bug on a new bring-up, not an AE bug. Kernel access model: Linux Kernel & BSP.
  • Neverallow violations fail the sepolicy build; runtime denials are the ones you grep in logcat audit.
Tip Read dumpsys media.camera for camera IDs, who holds the device, session streams, and HAL version (AIDL vs HIDL). Read dumpsys media.camera.provider for the provider process, ID list and concurrent sets. If the provider dump is empty, the HAL process is dead or not registered in VINTF.
Interview angle Always bisect the three symptoms before touching 3A. Offer one tool per layer: app log → dumpsys media.camera → provider dump → Perfetto → CSI/IOMMU dmesg. Same triage habit as data-flow debug taps.

Quick revision

  • Control plane: enumerate, permission, open, configure streams, 3A defaults, session. Frame plane: every HAL3 request/result plus buffers.
  • HAL1 (startPreview / takePicture) is deprecated. HAL3 is request/result per frame.
  • CameraX is Jetpack on Camera2. CameraService and the HAL stay the same.
  • App → Binder ICameraService → cameraserver → AIDL ICameraProvider / ICameraDevice / session → sensor + CSI + ISP → buffers.
  • Android 13–15 Camera HAL is AIDL; HIDL 3.x remains on some vendor images. Confirm VINTF.
  • A session is usable only after configure. Frames start only after a repeating request.
  • Streams: preview, still, video, analysis. Combinations must be in StreamConfigurationMap.
  • Reconfigure is expensive: sensor mode, ISP graph, DMA-BUF set, 3A restart, preview glitch.
  • Still tap = extra request on a live session, not a new session.
  • Fences + GraphicBuffer / DMA-BUF = zero-copy. HAL produces; SF / ImageReader / MediaCodec consume.
  • BLASTBufferQueue is the usual Android 10+ preview path into SurfaceFlinger.
  • Preview latency = expose + readout + ISP + queue depth + SF/vsync. JPEG is not on this path.
  • ZSL reuses a recent full-res frame; non-ZSL takes a new exposure. Flash usually forces non-ZSL.
  • Still destinations: JPEG ImageReader (HAL encodes) or YUV ImageReader (app sees pixels). Thumbnail lives in the JPEG.
  • After save, upload is the data-call / Wi-Fi path, not more camera HAL.
  • Video: camera output Surface into MediaCodec. Muxers and codec profiles are the multimedia page.
  • OIS is lens hardware; EIS is digital crop/warp. 4K60 is a stream-combo + bandwidth + encoder + thermal problem.
  • 3A is request keys and result states (AF/AE/AWB). Faces and scene modes are public metadata. Bokeh/night: Extensions API, not a secret graph.
  • Logical camera IDs wrap physical sensors. Zoom may switch physicals. Concurrent cameras are an advertised set at limited size.
  • Privacy indicators mean a client is active (CameraService/AppOps), not that pixels reached the display.
  • Close the session when not visible. Sensor + ISP + AF are large rails (power).
  • CSI + DMA + IOMMU (and CMA if needed) move raw frames into the ISP. See kernel/BSP.
  • dumpsys media.camera and dumpsys media.camera.provider are the first two taps. Perfetto camera + SF tracks the frame plane.
  • Black preview ≠ no JPEG ≠ green frames. Bisect permission/session/repeating request vs still stream vs format/stride.
  • SELinux avc on dma-heap or camera nodes is bring-up, not 3A.
  • ERROR_DEVICE kills the session; ERROR_BUFFER can be still-only.
  • Foldables notify device state so the provider can add/remove cameras.
  • Compose "photo then upload" as this page plus Android Data Call, using the map on data-flow.

Glossary

3A
Auto-focus, auto-exposure, auto-white-balance. Programmed on requests; state returns on results.
AIDL Camera HAL
Android 13–15 vendor interface: ICameraProvider, ICameraDevice, ICameraDeviceSession, callbacks. Replaces HIDL camera 3.x on migrated devices.
BLASTBufferQueue
Android 10+ buffer path for most Surfaces: producer-consumer buffers with a cheaper SurfaceFlinger transaction than classic BufferQueue setup alone.
BufferQueue
Shared pool of GraphicBuffers between a producer (ISP/HAL) and a consumer (SurfaceFlinger, ImageReader, MediaCodec).
Camera2
Public Android framework API for HAL3 cameras: manager, device, session, request, result, characteristics.
CameraX
Jetpack library that wraps Camera2 in lifecycle-aware use cases (Preview, ImageCapture, ImageAnalysis, VideoCapture).
CameraService
The framework camera broker in the cameraserver process. Apps Binder to it; it talks to the provider HAL.
CSI
MIPI Camera Serial Interface (usually CSI-2): the wire from the sensor to the SoC receiver.
CMA
Contiguous Memory Allocator; used when a device needs large physically contiguous DMA buffers. Prefer IOMMU scatter-gather when the SMMU can do it.
Capture request
One HAL3 order: metadata settings plus which output streams to fill for that frame.
Capture result
Metadata (and buffer status) returned for a request. May arrive as partial results then a total result.
Concurrent cameras
Advertised set of camera IDs that may be open at once, usually at reduced resolution.
configureStreams
HAL session call that programs outputs (size, format, usage). The expensive control-plane step behind createCaptureSession.
DMA-BUF
Kernel buffer object passed as an fd; zero-copy sharing among camera, GPU, display and codec.
Extension session
Public Camera Extensions path (bokeh, night, HDR, face retouch, automatic) that wraps a special session rather than a normal one.
Fence
Sync object: acquire means "safe to write/read"; release means "producer finished this buffer."
GraphicBuffer
Gralloc-allocated image buffer (dimensions, stride, format, native handle).
HAL1
Deprecated camera HAL shaped as start-preview / take-picture. Do not design new work on it.
HAL3
Request/result camera HAL: each frame is a request with streams and settings, plus a result with metadata and buffers.
HIDL camera 3.x
Older Treble camera HAL language. Same request/result ideas; still present if the vendor image did not move to AIDL.
ICameraDevice
HAL interface for one camera node: characteristics, open, session.
ICameraProvider
HAL interface that lists cameras, concurrent combinations, and device-state changes (foldables).
ImageReader
App-side consumer that gives Java/NDK Image objects (JPEG blobs or YUV planes) from a Surface.
IOMMU / SMMU
Hardware that maps device DMA addresses so the ISP/CSI can use non-contiguous pages safely.
ISP
Image Signal Processor: silicon (and firmware) that turns sensor raw into YUV/RGB/JPEG-ready frames.
Logical camera
One camera ID that may represent several physical sensors; the HAL can switch or fuse them.
MediaCodec (camera role)
The encoder that consumes a camera video Surface. Not covered here beyond that handoff.
OutputConfiguration
Framework object describing one session output: Surface, rotation, physical ID, stream use case.
Physical camera ID
An actual module under a logical camera. Can be targeted as a physical stream.
Privacy indicator
System UI chip showing that an app is using the camera (or microphone). Tied to an active client, not to displayed pixels.
processCaptureRequest
HAL session method that submits one (or a burst of) HAL3 requests.
Repeating request
A request the session keeps submitting for preview/record until replaced or stopped.
Session
Configured HAL pipeline bound to a set of streams. Created after open; destroyed on close or ERROR_DEVICE.
Stream
One configured output (or input, for reprocess): size, format, usage, destination Surface.
Stream use case
Hint (preview, still, video, video-call, …) so the HAL can pick an ISP path without guessing from size alone.
SurfaceFlinger
System compositor. Preview consumer: latches camera buffers and shows them on the display.
Vendor tags
OEM-defined metadata keys beyond the AOSP section. Read them from characteristics; do not invent names.
ZSL
Zero shutter lag: still capture that reprocesses a recent full-resolution frame from a ring instead of waiting for a new exposure.

Interview questions

Fundamentals

What are the two planes of the Android camera stack?

The control plane leases the pipeline: enumerate, permission, open, configure streams, standing 3A, session lifecycle. The frame plane is every HAL3 request and result plus the buffers and fences for that frame. Opening a device is not a preview frame. CSI traffic is not how you start the camera.

HAL1 versus HAL3 — what changed?

HAL1 is startPreview / takePicture with a few callbacks. HAL3 is a per-frame request (settings + stream targets) and a result (metadata + filled buffers). HAL1 is deprecated. Camera2 and CameraX are HAL3 clients. Say "photo-lab order form," not "camcorder remote."

What is CameraX, and how does it relate to Camera2?

CameraX is a Jetpack library: Preview, ImageCapture, ImageAnalysis, VideoCapture, lifecycle binding. It talks Camera2. CameraService, the HAL and the ISP do not change. If CameraX preview is black, you still dump media.camera the same way.

What process hosts CameraService, and who implements the HAL?

cameraserver hosts CameraService. The vendor camera provider process implements AIDL ICameraProvider / ICameraDevice (or HIDL 3.x). Apps Binder to CameraService only. Binder mechanics: Binder & AIDL.

Name the AOSP 13–15 Camera HAL AIDL interfaces.

android.hardware.camera.provider.ICameraProvider, android.hardware.camera.device.ICameraDevice, ICameraDeviceSession, and ICameraDeviceCallback. Session methods to name: configureStreams / configureStreamsV2, processCaptureRequest, flush, close. Confirm the exact AIDL version on the device.

What is a stream in HAL3?

One configured input or output: size, format, usage, and a destination (a Surface). Preview, still, video and analysis are streams in one session if the combination is advertised. The ISP may fill several streams from one exposure.

What is a capture request?

One order for one pipeline tick: metadata (3A, crop, JPEG quality, AF trigger, …) plus which streams to write. Repeating requests keep preview/record alive. A still is usually a one-shot capture on top of that.

What is a capture result?

The metadata that comes back for a request — timestamps, exposure, AF/AE/AWB state, faces, crop — plus which buffers succeeded. Partial results can arrive before TotalCaptureResult. Correlate by frame number.

What is a CaptureSession?

The configured HAL pipeline bound to a set of Surfaces. Created after CameraDevice opens; you submit requests only after onConfigured. Close it when the UI is gone so the sensor/ISP rails drop. See power.

Which permission does camera need, and when does the privacy indicator turn on?

Dangerous runtime CAMERA (plus RECORD_AUDIO if you record sound). AppOps must allow it. The Android 12+ privacy chip turns on when CameraService has an active client — not when the first pixel hits the panel. An indicator with a black view means control succeeded and the frame plane failed.

Where do preview, still and video buffers go?

Preview Surface → BLAST/BufferQueue → SurfaceFlinger → display. Still → ImageReader as JPEG or YUV. Video Surface → MediaCodec. That is the same split as data-flow camera-path.

What is an ISP?

The Image Signal Processor: hardware/firmware that converts sensor raw into viewable or encodable frames (demosaic, denoise, color, scale, sometimes JPEG). It is the producer in the camera BufferQueue. You do not need a vendor node graph to say that.

What is CSI in the camera path?

MIPI CSI-2 (usually) from the sensor module to the SoC CSI receiver. After that, DMA (through an IOMMU) feeds the ISP. Kernel/BSP depth: Linux Kernel & BSP.

What is ZSL?

Zero shutter lag: the HAL keeps a ring of recent full-res frames while preview runs, and a still request can reprocess one instead of waiting for a new exposure. Flash, long exposure and unconverged 3A usually take a new shot instead.

What does 3A mean?

Auto-focus, auto-exposure, auto-white-balance. The app sets modes/triggers/regions on the request; the HAL returns states and the numbers it used on the result. Manual apps turn CONTROL_MODE off and supply the numbers.

What is MediaCodec's role on this page?

The video sink. Camera produces frames into a Surface that MediaCodec owns. How the encoder compresses and how a muxer writes a file is multimedia. Do not say "the camera writes MP4."

What dumpsys commands do you run first?

adb shell dumpsys media.camera for clients, sessions, HAL version and IDs. adb shell dumpsys media.camera.provider for the provider process and concurrent sets. Then Camera2 logcat and a Perfetto camera+display trace.

Why close the camera when the app is not visible?

A repeating request keeps the sensor, CSI, ISP and often AF/OIS powered. That is a large rail and a thermal load. Lifecycle: close the session in the matching pause/stop. CameraX does this if you bind to the lifecycle correctly. Power and thermal.

What is a logical camera?

One camera ID that may wrap several physical sensors (ultra-wide, wide, tele). The app opens one ID; zoom or the HAL may switch physicals. getPhysicalCameraIds() lists them. Concurrent cameras are a different feature: two IDs open at once from an advertised set.

What is a GraphicBuffer, and why is it not a Java byte[]?

A gralloc-allocated image (width, height, stride, format, native handle). The ISP, GPU, display and encoder share it as DMA-BUF. Copying 12 MP into a byte[] every preview frame would destroy latency and power. ImageReader JPEG is a compressed blob; YUV Image planes still alias the same memory.

Going deeper

Walk open to the first preview frame.

Enumerate IDs and characteristics. Check CAMERA / AppOps. openCamera → CameraService eviction check → ICameraDevice.open. Build preview (and still/analysis) Surfaces. SessionConfiguration → HAL configureStreams → onConfigured. setRepeatingRequest(TEMPLATE_PREVIEW) → processCaptureRequest → expose, CSI, ISP → buffer + release fence → BLAST → SurfaceFlinger vsync. Until the repeating request, the viewfinder stays black.

Why is session reconfigure expensive?

Sensor mode (binning, crop, fps) changes. The ISP graph is rebuilt and 3A restarts. Gralloc/DMA-BUF sets are freed and allocated; IOMMU maps churn; CMA can stall if the device still needs huge contiguous chunks. Consumers must reconnect Surfaces. You pay a black flash. Add the JPEG stream up front instead of reconfiguring on shutter.

How does a still request coexist with a repeating preview request?

The repeating request keeps preview (and analysis) flowing. capture() submits one extra request that targets the still Surface and usually the preview Surface so the viewfinder does not freeze. The HAL pipelines them: several requests in flight. It is not HAL1 takePicture that stops preview.

Explain acquire and release fences on a camera buffer.

The HAL is the producer. It dequeues a GraphicBuffer, waits on the acquire fence (last consumer finished), writes via ISP/DMA, and queues with a release fence that signals write-complete. SurfaceFlinger, ImageReader or MediaCodec waits on release, uses the pixels, then releases so the buffer returns. No memcpy of the frame on the happy path.

BufferQueue versus BLAST — what do you say in 2024–2026 interviews?

The idea is still producer-consumer GraphicBuffers. Android 10+ preview Surfaces usually use BLASTBufferQueue: same buffers, cheaper SurfaceFlinger transactions. Say both names, matching data-flow. Do not claim classic BufferQueue-only setup is what every viewfinder uses.

What is StreamConfigurationMap, and what happens if you ignore it?

It is the advertised legal sizes, formats and (with later APIs) session combinations. An illegal combo fails configure or runs at a surprise fps. 4K video plus max JPEG plus a large preview is the classic illegal set. On 13+ also call isSessionConfigurationSupported.

Name the Camera2 templates and what each is for.

TEMPLATE_PREVIEW viewfinder, STILL_CAPTURE high-quality still, RECORD video, VIDEO_SNAPSHOT still while recording, ZERO_SHUTTER_LAG ZSL still, MANUAL app-owned exposure/focus. They are starting metadata, not different HALs.

What is a partial result?

The HAL may deliver metadata in pieces via processCaptureResult before the final TotalCaptureResult. Shutter notify can arrive before pixels. Apps that need AF state can act on a partial; apps that need the JPEG must wait for the still buffer, not the first callback.

JPEG ImageReader versus YUV ImageReader — when do you pick each?

JPEG: HAL encodes; app writes a file or uploads bytes; thumbnail is usually inside the JPEG. YUV: app wants pixels (its own encode, ML, edit). YUV failures look like green/stride bugs; JPEG failures look like no file or ERROR_BUFFER on that stream while preview lives.

Walk CameraX use cases down to HAL streams.

Preview → display Surface. ImageCapture → still ImageReader (JPEG or YUV). ImageAnalysis → small YUV ImageReader. VideoCapture → MediaCodec input Surface. CameraX picks sizes and binds lifecycle; Camera2 still opens one device and one session with those Surfaces. The HAL sees streams, not "use cases," unless you set stream use-case hints.

Logical versus physical camera IDs — how does zoom switching work at the public API?

The app opens the logical ID and sets zoom ratio / SCALER_CROP_REGION. The HAL may remap UW/wide/tele underneath. The app can also attach an OutputConfiguration to a physical ID to get that sensor's frames. A hitch at a zoom step is often a silent sensor-mode change, not an app bug. Do not invent OEM hysteresis numbers.

What are concurrent cameras?

FEATURE_CAMERA_CONCURRENT plus getConcurrentCameraIds(). Typical: front + back at reduced resolution. Opening two max-res logical cameras will fail configure or open. It is not "two physical streams on one logical ID" — that is physical outputs on one session.

How does tap-to-focus work in Camera2?

Map the tap to a metering region. Set CONTROL_AF_REGIONS / AE regions on the repeating request, then fire CONTROL_AF_TRIGGER_START on a single request (or the next repeating update). Wait for CONTROL_AF_STATE FOCUSED_LOCKED or FAILED in results. Then still-capture. Unlock with CANCEL or return to CONTINUOUS_PICTURE.

What is a Camera Extension (bokeh / night) at the public API?

Android 12+ CameraExtensionCharacteristics / CameraX Extensions: BOKEH, HDR, NIGHT, FACE_RETOUCH, AUTOMATIC. The app opens an extension session, not a plain session. Internals may burst + fuse + NPU. Name the mode and the session type. Do not draw a proprietary multi-frame graph.

List preview latency sources.

Exposure + readout, ISP (+ preview EIS), extra BufferQueue depth (one frame each), SurfaceFlinger/HWC and vsync, optional GPU blit (TextureView). 3A hunt delays a useful image after a scene change. JPEG is not on this path. Measure with Perfetto camera + display, not a single guessed millisecond.

OIS versus EIS versus preview stabilization?

OIS is LENS_OPTICAL_STABILIZATION_MODE — module hardware. EIS / video stab is CONTROL_VIDEO_STABILIZATION_MODE — digital crop/warp, costs FOV and ISP/GPU. Preview stabilization is a later, separate control. You can have OIS without EIS and the reverse on some modules.

What is a stream use case, and why did Android add it?

OutputConfiguration.setStreamUseCase: PREVIEW, STILL_CAPTURE, VIDEO_RECORD, PREVIEW_VIDEO_STILL, VIDEO_CALL. Size alone is ambiguous (a 1080p stream might be preview or record). The hint lets the HAL pick an ISP path. Wrong hint → quality or fps surprises, not necessarily a crash.

What is SessionConfiguration versus the old createCaptureSession(List<Surface>)?

The old API is just Surfaces. SessionConfiguration carries OutputConfigurations (physical IDs, shared Surfaces, use cases), session parameters, and an executor. Prefer it on Android 10+. HAL still ends in configureStreams.

How does camera eviction work?

CameraService allows one owner per device (plus documented sharing/concurrent cases). A higher-priority client can steal the camera. The loser gets onDisconnected. That is not an ISP crash. dumpsys media.camera shows who holds the device.

Why must the app consume ImageReader images?

The still (or analysis) queue is finite. If you never acquire* and close, the HAL cannot dequeue still buffers. Preview may continue; stills stall or return ERROR_BUFFER. This is a consumer leak, not a dead JPEG encoder — until you prove the HAL also failed.

Advanced

Walk processCaptureRequest to processCaptureResult on AIDL HAL3.

CameraService assigns a frame number and calls ICameraDeviceSession.processCaptureRequest with settings and buffer handles (or stream buffer slots). The HAL exposes, reads CSI, runs ISP, attaches fences, and later calls ICameraDeviceCallback.processCaptureResult (possibly partial) and notify (shutter, errors). HIDL 3.x used the same ideas over HIDL. Confirm AIDL versus HIDL on VINTF; do not recite a frozen minor as universal.

Trace one preview buffer from ISP write to scanout, naming the fence at each hop.

HAL waits acquire, ISP/DMA fills the GraphicBuffer, signals release. BLAST/BufferQueue holds it. SurfaceFlinger waits release, latches on vsync, HWC (or GPU client composition) programs the display; a display fence tracks scanout. When SF is done, the buffer returns and a new acquire fence protects the next ISP write. Zero-copy DMA-BUF the whole way.

How does ZSL reprocess work without becoming a vendor-secret story?

While preview repeats, the HAL (sometimes with a hidden PRIVATE/YUV full-res stream) keeps a ring. A ZSL still request names a recent frame for reprocess: crop, NR, JPEG — no new exposure. Public APIs: TEMPLATE_ZERO_SHUTTER_LAG, reprocess capabilities in characteristics. Flash/precapture abandons the dark ring frame. Stop at "ring + reprocess + JPEG."

Walk sensor to ISP at the kernel/BSP layer.

Sensor programmed over I2C/SPI. Pixels leave on MIPI CSI-2 lanes into the CSI RX. DMA writes into buffers mapped by the IOMMU/SMMU. If the device cannot scatter-gather, CMA supplies large contiguous chunks. Then the ISP reads those buffers (or an on-the-fly path) and writes YUV/JPEG outputs as more DMA-BUFs. Details: Linux Kernel & BSP.

When do you still need CMA on a modern camera stack?

When some hop cannot use IOMMU scatter-gather (old IP, secure heap constraints, huge raw tiles). Cost: a reserved pool that starves the rest of the system if oversized. Interview line: "Prefer IOMMU + DMA-BUF; keep CMA small; green/black on bring-up can be a failed allocation, check dma-heap and CMA logs."

Why does 4K60 fail even when 4K30 and 1080p60 each work?

It is a combination and a bandwidth problem: CSI lane rate, ISP clock, DRAM, encoder throughput, and thermal. The stream map may allow 4K30 preview+video or 1080p60 but not 4K60 plus a large preview. Thermal later drops fps even if configure succeeded. See power-thermal.

Logical zoom that switches physicals — when does the session stay up?

If the HAL can retarget the logical pipeline internally, the app keeps one session and one ID; you may still see a one-frame hitch (sensor mode). If the advertised combination cannot, the framework or app must reconfigure or open a different ID — expensive. Read physical IDs on results and dumpsys media.camera rather than assuming a switch.

How should you talk about NPU extras (face, bokeh, night) in a public interview?

Public: face stats on results, scene modes, Camera Extensions sessions, vendor tags you actually saw in characteristics. The NPU may run extras after or beside the ISP. Do not recite a proprietary fusion graph or chipset cookbook. "Burst of requests plus an extension session" is the ceiling.

Which SELinux domains matter on camera bring-up?

cameraserver, the vendor provider HAL domain, and the clients. Typical denials: dma-heap / ion, /dev/video*, vendor camera device nodes, Binder to the provider. avc: denied in logcat audit. neverallows fail the sepolicy build. This is policy, not AE. If dumps show no provider, also check VINTF and the HAL process.

What is pipeline depth, and how does it affect shutter lag?

Several requests are in flight (exposing N, ISP on N−1, JPEG of N−2). Depth hides ISP cost for preview fps but adds glass-to-glass delay. Shutter lag for non-ZSL includes remaining pipeline plus a new expose. ZSL skips the new expose by grabbing a ring frame that already finished most hops.

ERROR_DEVICE versus ERROR_REQUEST versus ERROR_RESULT versus ERROR_BUFFER?

ERROR_REQUEST: that ticket failed; others may continue. ERROR_RESULT: metadata bad, buffers maybe OK. ERROR_BUFFER: one stream failed (JPEG dead, preview alive). ERROR_DEVICE: session is dead; reopen. Always ask which error before "restart cameraserver."

What is a constrained high-speed session?

A special Camera2 session for high fps (slow-mo class) with a tight set of sizes/requests. Not a normal preview+4K still combo. If you treat it like a regular session, configure fails. Check createConstrainedHighSpeedCaptureSession and the high-speed map in characteristics.

How can two outputs share one Surface, and when must they not?

OutputConfiguration can share or have a surface later (addSurface deferred). Two different sizes/formats cannot share one ImageReader. Preview and video are usually two Surfaces. Sharing the wrong Surface is a configure-time or silent stall bug.

How does thermal mitigation show up on camera?

Thermal HAL / framework / vendor policy can drop fps, shrink streams, disable EIS, or close the session. Apps should read thermal status and back off 4K/60. Sensor+ISP+encoder+DRAM is the heat engine. Dump thermalservice beside media.camera. Power and thermal.

Who allocates camera buffers — framework or HAL?

Usually gralloc via the framework/BufferQueue; the HAL receives handles in configure/request. Some HALs allocate extra private/ZSL rings themselves (still DMA-BUF). Interview-safe: "outputs are Gralloc/DMA-BUF from the queue; the HAL may hold additional private buffers for ZSL. I would confirm with the provider dump and dma-heap stats."

How do physical streams on a logical camera appear in results?

You attach an OutputConfiguration to a physical ID. Results can include physical camera metadata (per-physical CaptureResults on recent APIs). The logical result still exists. Use this for multi-cam algorithms. Concurrent cameras remain a second open, not a physical stream.

Scenario & debugging

Black preview. Walk the bisect.
  1. Permission / AppOps / privacy chip: if open failed, stop. If the chip is on, control likely succeeded.
  2. dumpsys media.camera: session streams, repeating request present?
  3. Preview Surface size > 0 (View laid out)? TextureView vs SurfaceView.
  4. Camera2 logcat: onConfigured, requests, errors.
  5. Perfetto: HAL results vs SurfaceFlinger latch. If HAL produces and SF never latches, it is the display hop.
  6. Provider dump / HAL logs only after the above. Not 3A first.
Preview is fine; the shutter never yields a JPEG.

Still stream missing from the session; still request not targeting the ImageReader; ImageReader never acquired (queue full); HAL ERROR_BUFFER on JPEG; ZSL ring empty after a reconfigure; or the app looks at the wrong file. Dump the request targets and consume the reader. Do not reconfigure the whole session as your first fix.

Preview or analysis frames are green / pink / striped.

Format or stride mismatch (NV12 vs YV12 vs P010), uninitialized buffer queued with a signaled fence, or ISP output not matching what ImageReader/GPU expects. Check Image.getPlanes() row stride and HAL stream format. This is not "AE failed." CSI test-pattern leftover on bring-up is the silicon-adjacent variant — dmesg/CSI.

openCamera fails with a security exception. What is the hop?

Framework permission / AppOps. There will be little or no HAL traffic. Fix the app manifest, runtime request, or a policy manager revoke. Do not debug CSI. If the user granted camera but AppOps is still ignored, dump AppOps for that UID.

Bring-up: provider process dies; logcat shows avc: denied.

SELinux. Grant the HAL domain the dma-heap / device-node / Binder access it needs, or fix a neverallow in the policy build. dumpsys media.camera.provider empty. This is not a 3A or JPEG bug. Pair with kernel if the node never appears in /dev.

Preview works; video recording fails to start MediaCodec.

The video Surface was not in the session (reconfigure needed and failed), the combo is illegal, or the encoder cannot import that gralloc usage. Camera side: stream map and TEMPLATE_RECORD targets. Encoder side: multimedia — do not debug muxers until the camera is actually queuing to that Surface (Perfetto / codec input fences).

4K60 starts, then fps collapses after a minute and the phone is hot.

Thermal, not a sudden CSI disconnect. Sensor+ISP+encoder+DRAM. Check dumpsys thermalservice, cooling devices, and whether the HAL dropped fps or the encoder did. Back off size/fps/EIS. Power and thermal.

Opening front+back concurrent fails on a device that has both cameras.

Check FEATURE_CAMERA_CONCURRENT and getConcurrentCameraIds(). Many devices only allow a reduced pair. Two full-res opens is not concurrent support. dumpsys media.camera.provider lists the legal sets.

Zoom across 1x hits a one-frame black flash.

Logical HAL likely switched physical sensors or sensor mode. If the app also reconfigured the session at that zoom step, you paid the expensive control plane twice. Prefer zoom ratio on a stable session; treat a remaining hitch as a HAL mode switch. Confirm physical IDs on results.

An interviewer says: take a photo and upload it over cellular. Structure the 90-second answer.

Capture (this page): CameraX/Camera2 → CameraService → HAL3 still request → ZSL or new expose → ISP → ImageReader JPEG → app file. Upload: default Network socket, then Android Data Call (or Wi-Fi). Name one tool per stage (dumpsys media.camera, then dumpsys connectivity / tcpdump). The composition map is data-flow.

Privacy indicator is on; the viewfinder is black.

A client is open (CameraService/AppOps are honest). Missing repeating request, invalid Surface, or buffers dying before SF. Do not start at SELinux or CSI. Dump media.camera for session and repeating request, then Perfetto latch.

CameraX preview works in the sample app; the product app using raw Camera2 is black.

Product app likely skipped repeating request, used an illegal combo, opened before the View had a Surface, or leaked an ImageReader. Diff session streams and requests in dumpsys media.camera between the two processes. CameraX is not a different HAL.

Your camera app suddenly gets onDisconnected during a call or another app.

Eviction. Another client stole the device. dumpsys media.camera shows the new owner. Re-open when available callbacks fire. Not an ISP crash unless the provider process also died.

Front camera works; rear is dead after a board spin.

Bring-up: DT/supplies/reset for that module, CSI lanes, I2C probe, IOMMU stream for that port. Provider may omit the ID or mark it absent. Dump provider ID list and dmesg for that CSI/sensor. Do not tune AE on a missing probe. Linux Kernel & BSP.

How do you use Perfetto on a camera jank or shutter-lag bug?

Enable the build's camera data source plus SurfaceFlinger/FrameTimeline and Binder. Align a request frame number to shutter notify, HAL result, and layer latch. If the HAL result is on time and latch is late, it is queue/SF/GPU. If expose-to-result is late, it is sensor/ISP/3A. Do not guess the data-source string — pick it in the Perfetto config on that build.

JPEG is written, upload hangs. Is that still a camera bug?

No. Once bytes leave ImageReader, you are on the network path: bind/Network, DNS, fwmark, cellular or Wi-Fi. Walk Android Data Call or Wi-Fi. Camera tools will look idle. Compose using data-flow.