security-union / security-union/remote-shutter

Photo reply shares its wire action with the ack; success flag is misused to tell them apart

Open
#233 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Swift
Stars
19
Forks
3
Avg merge
28m
Merged PRs (30d)
6

Description

Follow-up to #232, which fixed the same shape for video (StopRecordingFinished).

The problem

TakePicAck and TakePicResp are both encoded with CommandAction.TakePicture. The decoder tells them apart by sniffing the payload:

case .takepicture:
    if resp.success && !resp.hasMediaData && nsError == nil {
        return TakePicAck(sender: nil)
    } else {
        return TakePicResp(sender: nil, pic: picData, error: nsError)
    }

With "Send Media to Remote" off, a successful result has no bytes and no error, which would look like the ack. To keep them apart the encoder writes a successful-but-unsent result as a failure:

success: error == nil && pic != nil   // RemoteCmdFlatBuffers.swift, TakePicResp.toFlatBuffer

Nothing is wrong with the photo; the flag lies purely to route the decoder. It works today, but the schema does not say what it means, and any future field on the photo reply has to keep this trick alive.

The fix (same recipe as video)

  • Add TakePictureFinished to CommandAction in FlatBufferSchemas.fbs; regenerate with flatc.
  • TakePicAck stays on .takepicture; TakePicResp encodes on .takepicturefinished with success: error == nil and the still's bytes when present.
  • Decoder: .takepicture → ack, .takepicturefinished → result. No payload sniffing.
  • Rename media_data to photo_data while at it: after #232 the field is only ever a still, and the name should say so.
  • Simplify TakePicResp to one initializer (sender:pic:error: with defaults).
  • Serialization tests: a successful result with no photo must decode as a result, not the ack, and the raw response must read success == true.

Scope notes

  • Breaking wire change; both devices update. No compat shims.
  • Photos legitimately ride inline in the reply (a still is a few MB), so this is a naming/clarity fix, not a memory one.
  • The multicam director's photo collection decodes through the same path; its tests cover it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with FlatBufferSchemas.fbs and the generated handling in RemoteCmdFlatBuffers.swift, then inspect the serialization tests and the multicam director tests mentioned in the issue. Verify that separate take-picture actions decode acknowledgements and results correctly, that photo_data is used consistently, and that a successful result without photo bytes remains a result with success == true.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev, networking
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.