fix(phase-1/m2.4b): encrypted imports were a silent no-op on-device

Manual Waydroid pass (phone exports encrypted -> re-imports the same
file through the real UI) caught it: the confirm dialog closed but no
import ran and no snackbar appeared. PassphraseDialog.onConfirm's
shared preamble nulls all URI slots before routing on mode, and the
IMPORT branch never re-armed pendingImportUri -- so the preview
confirm dialog's Import button read null and skipped viewModel.import
entirely. Plain-JSON imports bypass the passphrase dialog, which is
why every scripted desktop leg (M2.1-2.5) stayed green.

Fix: re-arm pendingImportUri in the IMPORT branch before preview;
wrong-pw/dismiss paths still null it and zero the retained chars.

Verified on-device after rebuild + `waydroid app install`: export
snackbar, magic-sniffed "Decrypt backup" sheet, 4-note preview, and
the dedupe snackbar "Imported 0 note(s), skipped 4 already imported."

Also lands the Waydroid test rig used for the pass (tools/WAYDROID_
TESTING.md + tools/inject2.c: uinput tap/move/key/text/swipe injector)
and the full M2.4b write-up in DESKTOP_FEASIBILITY.md. M2 exit
criteria met: bidirectional lossless round-trip plain+encrypted.
This commit is contained in:
Incido Developer committed 2026-10-06 05:40:44 +13:00
1 parent 29288b0370
commit 561d16eb0c
4 files changed
+412

No files matched your search

+183
View File
@@ -0,0 +1,183 @@
/* one-shot uinput click at absolute screen coords (touch-like), then exits */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/uinput.h>
static int fd;
static void ev(unsigned short t, unsigned short c, int v) {
struct input_event e;
memset(&e, 0, sizeof e);
e.type = t; e.code = c; e.value = v;
if (write(fd, &e, sizeof e) < 0) perror("write");
}
static void tapkey(int code) {
ev(EV_KEY, code, 1); ev(EV_SYN, SYN_REPORT, 0); usleep(15000);
ev(EV_KEY, code, 0); ev(EV_SYN, SYN_REPORT, 0); usleep(15000);
}
static int keyfor(char c, int *shift) {
*shift = 0;
if (c >= 'a' && c <= 'z') return KEY_A + (c - 'a');
if (c >= 'A' && c <= 'Z') { *shift = 1; return KEY_A + (c - 'A'); }
if (c >= '1' && c <= '9') return KEY_1 + (c - '1');
if (c == '0') return KEY_0;
switch (c) {
case '-': return KEY_MINUS;
case '_': *shift = 1; return KEY_MINUS;
case '.': return KEY_DOT;
case ',': return KEY_COMMA;
case '/': return KEY_SLASH;
case ' ': return KEY_SPACE;
case '=': return KEY_EQUAL;
case ';': return KEY_SEMICOLON;
case '~': return KEY_BACKSPACE;
}
return -1;
}
int main(int argc, char **argv) {
if (argc < 2) { fprintf(stderr, "usage: inject2 x y | move x y | key KEYCODE\n"); return 1; }
fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
if (fd < 0) { perror("uinput"); return 1; }
if (!strcmp(argv[1], "key")) {
if (argc < 3) return 1;
ioctl(fd, UI_DEV_SETUP, &(struct uinput_setup){ .id.bustype = 0x11, .id.vendor = 2, .id.product = 3, .id.version = 4, .name = "vkbd" });
for (int k = KEY_A; k <= KEY_Z; k++) ioctl(fd, UI_SET_EVBIT, EV_KEY), ioctl(fd, UI_SET_KEYBIT, k);
for (int k = KEY_1; k <= KEY_9; k++) ioctl(fd, UI_SET_KEYBIT, k);
ioctl(fd, UI_SET_KEYBIT, KEY_0); ioctl(fd, UI_SET_KEYBIT, KEY_TAB); ioctl(fd, UI_SET_KEYBIT, KEY_ENTER);
ioctl(fd, UI_DEV_CREATE, NULL);
usleep(300000);
int code = atoi(argv[2]);
ev(EV_KEY, code, 1); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_KEY, code, 0); ev(EV_SYN, SYN_REPORT, 0);
usleep(100000);
ioctl(fd, UI_DEV_DESTROY, NULL);
close(fd);
return 0;
}
if (!strcmp(argv[1], "paste")) {
ioctl(fd, UI_DEV_SETUP, &(struct uinput_setup){ .id.bustype = 0x11, .id.vendor = 2, .id.product = 3, .id.version = 4, .name = "vkbd" });
ioctl(fd, UI_SET_EVBIT, EV_KEY);
for (int k = KEY_A; k <= KEY_Z; k++) ioctl(fd, UI_SET_KEYBIT, k);
ioctl(fd, UI_SET_KEYBIT, KEY_LEFTCTRL); ioctl(fd, UI_SET_KEYBIT, KEY_ENTER);
ioctl(fd, UI_DEV_CREATE, NULL);
usleep(300000);
ev(EV_KEY, KEY_LEFTCTRL, 1); ev(EV_SYN, SYN_REPORT, 0); usleep(20000);
tapkey(KEY_V);
ev(EV_KEY, KEY_LEFTCTRL, 0); ev(EV_SYN, SYN_REPORT, 0);
usleep(100000);
ioctl(fd, UI_DEV_DESTROY, NULL);
close(fd);
return 0;
}
if (!strcmp(argv[1], "text")) {
if (argc < 3) return 1;
ioctl(fd, UI_DEV_SETUP, &(struct uinput_setup){ .id.bustype = 0x11, .id.vendor = 2, .id.product = 3, .id.version = 4, .name = "vkbd" });
ioctl(fd, UI_SET_EVBIT, EV_KEY);
for (int k = KEY_A; k <= KEY_Z; k++) ioctl(fd, UI_SET_KEYBIT, k);
for (int k = KEY_1; k <= KEY_9; k++) ioctl(fd, UI_SET_KEYBIT, k);
ioctl(fd, UI_SET_KEYBIT, KEY_0); ioctl(fd, UI_SET_KEYBIT, KEY_TAB); ioctl(fd, UI_SET_KEYBIT, KEY_ENTER);
ioctl(fd, UI_SET_KEYBIT, KEY_LEFTSHIFT); ioctl(fd, UI_SET_KEYBIT, KEY_RIGHTSHIFT);
ioctl(fd, UI_SET_KEYBIT, KEY_MINUS); ioctl(fd, UI_SET_KEYBIT, KEY_DOT);
ioctl(fd, UI_SET_KEYBIT, KEY_COMMA); ioctl(fd, UI_SET_KEYBIT, KEY_SLASH);
ioctl(fd, UI_SET_KEYBIT, KEY_SPACE); ioctl(fd, UI_SET_KEYBIT, KEY_EQUAL);
ioctl(fd, UI_SET_KEYBIT, KEY_SEMICOLON); ioctl(fd, UI_SET_KEYBIT, KEY_BACKSPACE);
ioctl(fd, UI_DEV_CREATE, NULL);
usleep(300000);
for (char *p = argv[2]; *p; p++) {
int sh, code = keyfor(*p, &sh);
if (code < 0) continue;
if (sh) ev(EV_KEY, KEY_LEFTSHIFT, 1);
tapkey(code);
if (sh) { ev(EV_KEY, KEY_LEFTSHIFT, 0); ev(EV_SYN, SYN_REPORT, 0); usleep(15000); }
usleep(45000);
}
usleep(100000);
ioctl(fd, UI_DEV_DESTROY, NULL);
close(fd);
return 0;
}
if (!strcmp(argv[1], "swipe") && argc >= 6) {
int x1 = atoi(argv[2]), y1 = atoi(argv[3]), x2 = atoi(argv[4]), y2 = atoi(argv[5]);
ioctl(fd, UI_DEV_SETUP, &(struct uinput_setup){ .id.bustype = 0x11, .id.vendor = 2, .id.product = 3, .id.version = 4, .name = "vt" });
ioctl(fd, UI_SET_EVBIT, EV_KEY);
ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH);
ioctl(fd, UI_SET_EVBIT, EV_ABS);
int codes[4] = { ABS_X, ABS_Y, ABS_MT_POSITION_X, ABS_MT_POSITION_Y };
for (int i = 0; i < 4; i++) {
ioctl(fd, UI_SET_ABSBIT, codes[i]);
struct uinput_abs_setup s = { .code = codes[i], .absinfo = { .minimum = 0, .maximum = 1079, .resolution = 10 } };
ioctl(fd, UI_ABS_SETUP, &s);
}
ioctl(fd, UI_SET_ABSBIT, ABS_MT_SLOT);
ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);
ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT);
ioctl(fd, UI_DEV_CREATE, NULL);
usleep(300000);
ev(EV_ABS, ABS_MT_TRACKING_ID, 0);
ev(EV_ABS, ABS_MT_POSITION_X, x1); ev(EV_ABS, ABS_MT_POSITION_Y, y1);
ev(EV_KEY, BTN_TOUCH, 1); ev(EV_SYN, SYN_REPORT, 0); usleep(40000);
for (int t = 1; t <= 10; t++) {
ev(EV_ABS, ABS_MT_POSITION_X, x1 + (x2 - x1) * t / 10);
ev(EV_ABS, ABS_MT_POSITION_Y, y1 + (y2 - y1) * t / 10);
ev(EV_SYN, SYN_REPORT, 0); usleep(25000);
}
ev(EV_KEY, BTN_TOUCH, 0); ev(EV_ABS, ABS_MT_TRACKING_ID, -1); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ioctl(fd, UI_DEV_DESTROY, NULL);
close(fd);
return 0;
}
if (argc < 3) return 1;
int x = atoi(argv[2]), y = atoi(argv[3]);
ioctl(fd, UI_DEV_SETUP, &(struct uinput_setup){ .id.bustype = 0x11, .id.vendor = 2, .id.product = 3, .id.version = 4, .name = "vt" });
ioctl(fd, UI_SET_EVBIT, EV_KEY);
ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH);
ioctl(fd, UI_SET_EVBIT, EV_ABS);
int codes[4] = { ABS_X, ABS_Y, ABS_MT_POSITION_X, ABS_MT_POSITION_Y };
int maxs[4] = { 1919, 1079, 1919, 1079 };
for (int i = 0; i < 4; i++) {
ioctl(fd, UI_SET_ABSBIT, codes[i]);
struct uinput_abs_setup s = { .code = codes[i], .absinfo = { .minimum = 0, .maximum = maxs[i], .resolution = 10 } };
ioctl(fd, UI_ABS_SETUP, &s);
}
ioctl(fd, UI_SET_ABSBIT, ABS_MT_SLOT);
ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);
ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT);
ioctl(fd, UI_DEV_CREATE, NULL);
usleep(300000); /* let InputReader settle */
if (!strcmp(argv[1], "move")) {
ev(EV_ABS, ABS_MT_POSITION_X, x); ev(EV_ABS, ABS_MT_POSITION_Y, y); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_KEY, BTN_TOUCH, 1); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_ABS, ABS_MT_POSITION_X, x + 6); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_ABS, ABS_MT_POSITION_X, x + 10); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_ABS, ABS_MT_POSITION_X, x); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_KEY, BTN_TOUCH, 0); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_ABS, ABS_MT_TRACKING_ID, -1); ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
} else {
ev(EV_ABS, ABS_MT_TRACKING_ID, 0);
ev(EV_ABS, ABS_MT_POSITION_X, x);
ev(EV_ABS, ABS_MT_POSITION_Y, y);
ev(EV_KEY, BTN_TOUCH, 1);
ev(EV_SYN, SYN_REPORT, 0);
usleep(120000);
ev(EV_KEY, BTN_TOUCH, 0);
ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
ev(EV_ABS, ABS_MT_TRACKING_ID, -1);
ev(EV_SYN, SYN_REPORT, 0);
usleep(50000);
}
ioctl(fd, UI_DEV_DESTROY, NULL);
close(fd);
return 0;
}