Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,15 @@ private boolean handleTakePhoto(JSONObject data) {
return false;
}

// ARCHIVAL CAPTURE: a save-only request (no upload target) has no delivery leg —
// ARCHIVAL CAPTURE: a save-only request (no delivery target) has no delivery leg —
// no webhook upload, no BLE transfer — so there is nothing for the single-flight
// photo-job gate to protect. Route it down the button-photo path: camera-queue
// serialized, no CAMERA_BUSY, so SDK callers can burst-save to the gallery and
// pull the files later over WiFi sync (each stamped with its requestId).
// transferMethod is deliberately not consulted: it is always "auto" in practice
// and the phone app always supplies a webhookUrl, so this shape is only ever
// produced by direct BT-SDK callers that want exactly this behavior.
if (save && webhookUrl.isEmpty()) {
// A request carrying a bleImgId DOES have a delivery leg (BLE to the phone) and
// must go down the normal pipeline even with save=true and no webhookUrl: that
// shape is phone-delivery with a kept gallery copy, not an archival capture.
if (save && webhookUrl.isEmpty() && bleImgId.isEmpty()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep local-save SDK payloads on the archival path

When a current Bluetooth SDK caller uses the supported requestPhoto({save: true, webhookUrl: null, ...}) shape, both Mentra Live serializers still generate a nonempty bleImgId even though no delivery was requested, and transferMethod defaults to auto. This condition therefore stops routing that request to takePhotoForLocalSave; it instead attempts an upload to an empty URL or an untracked BLE transfer because the phone only registers blePhotoTransfers when a webhook is present, causing the request to fail or time out instead of returning the local capture response. Gate this exception on an explicit BLE delivery method/destination rather than on the automatically generated fallback ID alone.

AGENTS.md reference: AGENTS.md:L136-L138

Useful? React with 👍 / 👎.

Log.i(
TAG,
"PHOTO PIPELINE [ASG 3/3] Local-save capture (no upload target)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -150,4 +151,82 @@ public void takePhoto_invalidTransferMethod_isRejected() throws Exception {
verify(captureService)
.sendPhotoErrorResponse(eq("req-1"), eq("INVALID_TRANSFER_METHOD"), anyString());
}

@Test
public void takePhoto_saveWithBleImgIdAndNoWebhook_ridesBleTransfer() throws Exception {
when(captureService.takePhotoForBleTransfer(
anyString(),
anyString(),
anyString(),
anyBoolean(),
anyString(),
anyString(),
anyBoolean(),
anyBoolean(),
nullable(Long.class),
nullable(Integer.class),
any(PhotoCaptureSettings.class)))
.thenReturn(true);
JSONObject data =
takePhotoData()
.put("webhookUrl", "")
.put("save", true)
.put("transferMethod", "ble");

assertThat(handler.handleCommand("take_photo", data)).isTrue();
verify(captureService)
.takePhotoForBleTransfer(
anyString(),
eq("req-1"),
eq("ble-1"),
eq(true),
eq("medium"),
eq("photo"),
eq(true),
eq(true),
nullable(Long.class),
nullable(Integer.class),
any(PhotoCaptureSettings.class));
verify(captureService, never())
.takePhotoForLocalSave(
anyString(),
anyString(),
anyString(),
anyString(),
anyBoolean(),
anyBoolean(),
nullable(Long.class),
nullable(Integer.class),
any(PhotoCaptureSettings.class));
}

@Test
public void takePhoto_saveWithoutBleImgIdOrWebhook_staysLocalSaveCapture() throws Exception {
when(captureService.takePhotoForLocalSave(
anyString(),
anyString(),
anyString(),
anyString(),
anyBoolean(),
anyBoolean(),
nullable(Long.class),
nullable(Integer.class),
any(PhotoCaptureSettings.class)))
.thenReturn(true);
JSONObject data =
takePhotoData().put("webhookUrl", "").put("bleImgId", "").put("save", true);

assertThat(handler.handleCommand("take_photo", data)).isTrue();
verify(captureService)
.takePhotoForLocalSave(
anyString(),
eq("req-1"),
eq("medium"),
eq("photo"),
eq(true),
eq(true),
nullable(Long.class),
nullable(Integer.class),
any(PhotoCaptureSettings.class));
}
}
Loading