fix(android): the unlock code is asked for, and never undone in silence

Two defects, one feature made useless. The cache did seal under the code,
but nothing on the home screen asked for it: opening without one failed,
the failure was read as corruption, and the device offered to download a
vault it held perfectly well. And the next refresh rewrote the cache in
the old shape, so the code was undone seconds after being set, silently.

The code now lives on the home screen, not among the server settings: it
seals this device's cache, while the other three fields describe the
shared remote. Always visible - hiding it when none is set would remove
the only place to set one - the hint saying which case you are in. An
absent code is no longer attempted, a wrong one is no longer corruption,
and a sealed cache is never rewritten without its code.

The two panels each got an arrow, and only one opens at a time.

Measured end to end on the device: version byte 1, code typed, open, byte
4; cold start says "Unlock code required" and open without the code
leaves the byte at 4; correct code opens the vault, and the refresh that
follows leaves it at 4.
This commit is contained in:
r-zakarya
2026-08-21 13:04:48 +01:00
parent b7125a7373
commit afc6119cf8
3 changed files with 107 additions and 21 deletions
+31 -2
View File
@@ -334,10 +334,19 @@ begin
// Le bouton d'ouverture n'a de sens que si un coffre local existe ET qu'il
// s'est deja laisse ouvrir ; sinon seul le telechargement peut en produire
// un utilisable.
// LE CODE SE DEMANDE ICI, SUR L'ECRAN D'ACCUEIL. Il etait range dans les
// reglages du serveur, ou rien n'indiquait qu'il fallait le retaper : le
// coffre scelle sous un code s'ouvrait donc sans code, echouait, et l'echec
// etait pris pour une corruption - l'appareil proposait de retelecharger un
// coffre qu'il avait parfaitement en main.
WebCall(Format('PM.setPinNeeded(%s)', [LowerCase(BoolToStr(VaultNeedsPin, True))]));
LCanOpen := HasVault and not FVaultUnreadable;
if LCanOpen then
begin
if VaultNeedsAuth then
if VaultNeedsPin then
Status('Vault on this device - unlock code required')
else if VaultNeedsAuth then
Status('Vault on this device - protected')
else
Status('Vault on this device');
@@ -1025,8 +1034,18 @@ begin
begin
// ShowUnlock AVANT le message : il repositionne le statut selon ce que
// l'appareil detient, et ecraserait donc l'explication.
// Un code faux se retape ; le cache, lui, n'a rien perdu. Le marquer
// illisible retirerait le bouton d'ouverture pour le reste de la session.
if VaultNeedsPin then
begin
Log('Vault did not open under this unlock code');
ShowUnlock;
Status('Wrong unlock code');
WebCall('PM.focusPin()');
Exit;
end;
FVaultUnreadable := True;
ShowUnlock;
ShowUnlock;
Log('Local vault unreadable: ' + LastStoreError);
Status('Local vault unreadable - see log');
end;
@@ -1040,6 +1059,16 @@ end;
procedure TForm8.OpenVault(AAuto: Boolean);
begin
if FBusy then Exit;
// NE PAS TENTER CE QUI NE PEUT QUE RATER. Un code absent n'est pas un coffre
// abime : l'essayer quand meme marquait le cache illisible et transformait le
// bouton en "Download vault", ce qui donnait a croire que le code avait
// detruit le cache alors qu'il le protegeait.
if VaultNeedsPin and (FPin = '') then
begin
Status('Unlock code required');
WebCall('PM.focusPin()');
Exit;
end;
// L'authentification affiche un dialogue systeme : elle doit rester sur le
// thread principal, et PRECEDER toute lecture du coffre.
if not VaultNeedsAuth then