Repository navigation
Questvision/fase 1 - #649
Open
Johnatan-Freire wants to merge 21 commits into
Open
Johnatan-Freire wants to merge 21 commits into
Johnatan-Freire wants to merge 21 commits into
Conversation
- Novo modulo :questvision-camera (UiState/ViewModel/Controller/Screen + CaptureRepository): preview da camera traseira, status do CameraState, foco por toque, zoom, captura manual otimizada para texto em monitor, armazenamento privado (noBackupFilesDir) e revisao da ultima captura. - :app abre no QuestVision; catalogo de samples so acessivel em debug. Pedido de permissao do catalogo movido para nao concorrer com o da nova tela. applicationId com.questvision.ai. - :core-ui: selo de API opcional no CameraSampleScaffold; strings fixas movidas para resources, com traducao pt-BR. - docs/PROJECT_STATUS.md com arquitetura, status e proximas etapas. Build ainda nao executado (ambiente sem JDK/Android SDK).
- Build validado: spotlessApply, spotlessCheck, :app:assembleDebug e :questvision-camera:testDebugUnitTest (5/5) passando. - Corrige foco por toque: CameraXPreview registra o toque com pointerInput(surfaceRequest), entao os callbacks agora leem o estado atual no momento do toque em vez de serem trocados (podiam ficar null). - Retencao de capturas: so as 20 recentes em captures/; "Manter" move para captures/kept/, que nunca e limpa; "Descartar" apaga; "Voltar" so fecha. Teste PruneOldestTest. - RECORD_AUDIO e WRITE_EXTERNAL_STORAGE movidas para o manifesto de debug (usadas so pelos samples); release pede apenas CAMERA do app. - CapturedImagePreview: parametros opcionais onBack e doneLabel. - PROJECT_STATUS.md atualizado com ambiente, resultados e roteiro de teste no aparelho (ainda pendente).
…tVision - com.google.mlkit:text-recognition 16.0.1 (modelo latino embutido, offline). - kotlinx-coroutines-test para testes de ViewModel; androidx.test para o teste instrumentado de OCR; unitTests.isReturnDefaultValues no modulo.
- TextRecognitionEngine com ML Kit on-device sobre a foto em alta resolucao. - QuestionText: normalizacao Unicode, remocao de texto volatil (relogio, datas, URLs/ids), fingerprint SimHash e comparacao por palavras novas com tolerancia a erros de OCR e a palavras grudadas/separadas. - Testes de matcher com os cenarios da fase e artefatos reais de campo. - RealCapturesOcrTest (instrumentado): relatorio do OCR real sobre fotos de campo; nas 12 fotos de 2026-10-22 mantem 1, 7, 8 e 11.
- ImageAnalysis 640x480 amostrado a 2 fps; assinatura de estrutura (energia do passa-alta) robusta a subpixel, foco e exposicao. - Estabilidade por janela temporal com ancora, outlier tolerado, histerese e limiar adaptativo limitado; janela descartada apos captura ou falha; decisao so em amostra parada; limiares de conteudo coerentes com a estabilidade. - MonitoringSession: estados ate VERIFYING, tickets por sessao, auditoria (MonitoringStats), verificacao por texto e numeracao reiniciada por sessao. - Testes com telas sinteticas e cenas renderizadas (tema escuro, latencia de captura, transiente de exposicao, rolagem).
- Controller com Preview + ImageCapture + ImageAnalysis (fallback sem analise). - ViewModel: captura automatica sem interacao, verificacao do arquivo e do texto (OCR) antes de contar, avisos discretos, um candidato por vez. - Historico de capturas sobreposto a camera, metadados no nome do arquivo (origem, sessao, numero), auditoria da sessao e retencao preservada. - Layout adaptativo portrait/landscape sem recriar o viewfinder; rotacao de 180 graus via DisplayListener. - Testes de repositorio e de ViewModel com camera e OCR simulados.
Investigacoes de campo (estabilizacao, capturas extras, 12 capturas), teste do OCR real nas fotos de campo e teste ao vivo aprovado no Galaxy M52 (3 questoes, 3 fotos, 5 duplicatas rejeitadas, 0 falhas de leitura).
- Responses API client (gpt-6-luna, Structured Outputs, explicit service_tier) - Atomic request claim, persistent 10-per-24h limit, interrupted-request recovery - Estimated vs observed cost; first-call and resend confirmations - Room v2 (ai_requests) with auto-migration - Keep every question the AI was involved with out of the retention cleanup - Refuse discarding a question while the AI is processing it - OCR logs carry metrics only; on-device tests with a simulated OpenAI client
- Local validation of the newest question on screen: titled or untitled, lettered/numbered/judgment formats, cut, low-confidence and visual checks - Text orientation from ML Kit line angles; question region crop that keeps sidebar, browser bars and other messages out of the image mode - Question signatures (negations, numbers, operators, alternatives) so near-identical questions are never merged as duplicates - Automatic analysis coordinator: one request at a time app-wide, per-session and 24-hour limits that stop sending only (capture-only mode) - Real automatic requests stay locked (LockedAutoSendPolicy) - Storage guard, session status panel and per-session limit setting - JVM, on-device and field-capture diagnostic tests with simulated clients
- Image mode always sends only the question's crop; without it nothing is sent, manual or automatic (the whole-photo fallback is gone) - Every manual request asks for confirmation (model, mode, credits, estimate) - A received answer is stored even if a cancel arrives meanwhile; requests without any answer are logged as UNKNOWN, never retried - Answers survive a missing photo; refused or failed discards are reported - Manual cleanup of never-sent pending captures, with preview and confirmation - Database v3 (additive auto-migration): 12-hour cache writes and the size of the image actually sent; cost uses the 1.25x/2.5x cache-write rates
…3.6) - AutoSendPolicy gains a hard per-session cap; TrialAutoSendPolicy (3 per session) is prepared but not bound: the app stays locked - Only questions of the running session are queued: earlier pending captures are never sent automatically - A session that could send for real starts only after explicit consent to its terms; without it the session only captures - Sending stops for the session on an unknown cost, besides key, credit, limit and connection errors
…phase 3.6) - New `trial` build type (same applicationId and debug signing, installs with install -r); BuildConfig.AUTO_TRIAL_ID is 1 there and 0 in debug/release, provided through Hilt. - ArmableTrialPolicy replaces the locked/trial policies: real automatic requests only in the trial build and only while armed in settings (off by default). - One allowance of three requests per trial id, counted in ai_requests since the first arming (manual and unknown-outcome requests included); disarming, re-arming, restarting or reinstalling never renews it. It disarms itself when used up and the switch can't arm it again. - Consent is bound to the session start: arming mid-session sends nothing; disarming stops sending. - New TRIAL_USED_UP pause reason; settings show the requests left. - Tests for the persistent cap, the fourth question, pause/resume, unknown outcomes, re-arming, other builds and settings persistence.
…dation - The settings notice no longer says nothing is sent automatically: it states that real automatic sending only happens during an armed, authorized trial, limited to three requests (en and pt-BR; logic, limits and consent unchanged). - PROJECT_STATUS 3p: the 2026-11-03 validation on the M52 (36 instrumented tests, settings screen disarmed with 3 of 3 left, no real calls, data identical to the backup, temperatures), what is still unvalidated in a real session, and the remaining limitations.
On a bright, flat monitor continuous autofocus kept hunting (the image seemed to zoom in and out) and the frame never settled for the stability detector; CameraX's tap-to-focus released after about 5 seconds. disableAutoCancel() keeps the lock on the tapped text until the next tap. PROJECT_STATUS 3q records the partial real session of phase 3.6 (question 1 answered B, correct; one request of 3 used), the focus issue and this fix.
…on on screen (phase 4)
Telegram (Bot API over HTTPS, no server):
- Bot token encrypted at rest with its own Keystore key (the OpenAI key keeps its alias);
"Detect chat" (getUpdates without offset), "Send test", switch off by default.
- Each stored answer goes once as "Questão N: letter) alternative" (never the statement,
explanation or photo); claimed atomically in questions.telegram_status, never resent
(new UNKNOWN status for a lost reply). No schema change.
- Short framing tips ("Enquadramento / vire ← esquerda", "sem questões"...) while monitoring,
throttled; the screen stays on during a monitoring session.
Reading the screen:
- questionOrder: the alternatives' column in position order, everything beside it (tabs,
bookmarks, side panels, icons, the room) moved out, so it never lands inside the question;
applied to assessment, crop, tips and the stored/sent/compared text.
- A line touching the photo's side edge, too little blank space below the last alternative,
or fewer than three labeled alternatives mean the question may be incomplete: not sent.
- Blank page below the last answer counts as its end (no following text needed with boxes).
- Tap-to-focus stays locked (earlier fix) and repeated questions are recognized by their block.
Automatic sending as the normal mode (user's decision):
- SettingsAutoSendPolicy: a settings switch (off by default) plus one consent when a session
starts; 75 analyses per 24 h (new key), no cap per session; the stop rules, pending-backlog
isolation and no-resend guarantees stay. The trial variant and its 3-request allowance are
removed.
Tests: 319 JVM (Telegram, tips, question order from real field captures, automatic sending);
PROJECT_STATUS 3r-3t record the field sessions and validations.
With no alternatives read but three or more lines running into the photo's left or right
edge, the labels ("A)"...) are just past it: the tip is now "vire ← esquerda" / "vire →
direita" instead of "sem questões" (field photo of 2026-11-05, question 3).
PROJECT_STATUS records the first real automatic session (questions 2-4 answered correctly
and delivered to Telegram with no taps) and the review of the photos that were held back.
…udit
Reading exam sites:
- Cards or radio options without letters (field photo of 2026-11-10) are recognized under a
"Questão N" title as the trailing run of 3-6 short, evenly and widely spaced rows, lettered
A, B, C... in screen order; pieces of one row split by ML Kit are joined first.
- A centered line over the question's text ("É correto o que se afirma em:") belongs to it;
lines that only reach into the column (side panels) stay out and the crop is still refused.
- Tip "vire ← esquerda/→ direita" when labels are cut off at a side.
Delivery and status on Telegram:
- "Questão N: não enviada — reason" (with the framing tip when tips are on) and pause notices
(daily limit, OpenAI error, connection, unknown cost, missing key).
- Messages that may not have arrived are retried after 5 s and 20 s; a delivery cut short by
the app stopping becomes UNKNOWN at start-up; "Resend to Telegram" in the capture's panel.
- Monitoring pauses itself on severe thermal status or <= 15 % battery unplugged, and says so.
Housekeeping:
- Automatic captures still PENDING after 7 days are removed at start-up (answered, manual and
kept ones never are); retention raised from 20 to 100 captures.
- androidx.exifinterface, plurals, KTX; obsolete preference keys removed; dead code removed.
- Release signing read from a local keystore.properties (git-ignored); no key is generated.
Tests: 331 JVM. PROJECT_STATUS 3u-3v and the next steps are updated.
…es B and C) Phase B — the AI reads the photo and judges the capture: - Every automatic capture that shows a question goes as the image (crop, or the whole upright photo when the region isn't found). A question is a statement with alternatives, or a statement that asks something on its own (essay or typed answer); a "Questão N" title alone never is. - The prompt reads past browser chrome and other windows, letters unlabeled alternatives in screen order, answers judgments and open questions, and ignores answers already marked on screen. - The schema adds answer_text, statement_start, capture_status (ok, cut_off, blurry, obstructed, glare, no_question) and capture_tip; all optional when reading stored answers. - Telegram shows the AI's alternative text and, when the photo is the problem, its tip. The same answer to the same statement (as the AI read it) is not sent twice in a session. Phase C — one photo every 10 s, all sent to the AI (user's decision after the 2026-11-19 audit): - The change detector no longer triggers captures: small or corner questions changed only 5-6 % of the frame and were missed. The next photo waits for the previous answer; none is taken while sending is paused, stopped or not consented. - Telegram gets the photo with the tip when the question is cut, blurred, covered or under glare, and "no question in the photo" with the photo, each at most once a minute (sendPhoto, multipart). - Daily limit options up to 1000. Test pages: docs/test-pages/formatos-de-questoes.html (60 formats) and problemas-reais.html (22 screens reproducing the problems found). Tests: 345 JVM. PROJECT_STATUS 3w-3x updated.
Johnatan-Freire
requested review from
donovanfm and
madebymozart
as code owners
December 4, 2026 04:18
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.