Repository navigation
Commit 1c99f20
committed
feat(local-terminal): decide availability by a runtime PTY probe
The gate was `deviceInfo.deviceType === '2in1'` on the ArkTS side. That was a
form-factor guess, and it could not see the failure that matters: a device that
reports 2in1, loads the addon fine, and still gets `forkpty(3) failed.`.
Now the backend probes for real at boot — allocate a pty (openpty), then fork a
shell into it — and offers the local terminal only if that worked:
openpty fails -> the sandbox exposes no usable /dev/ptmx or devpts
forkpty fails -> the pty is fine, creating the child was refused
both succeed -> the terminal works here
That is more permissive than the device type (a phone has the same sandbox as a
2-in-1, so it is enabled exactly when it can really fork a shell) and stricter
(a broken 2-in-1 no longer advertises a tab that dies on connect).
Measured: 2-in-1 emulator -> enabled (openpty + forkpty ok), session runs.
Phone emulator -> openpty(3) failed., disabled; the report shows the cause —
/dev/ptmx stat = FAIL EACCES (app domain denied the pty node entirely), and
even `spawnSync /bin/sh` is EACCES there.
Because a hidden feature leaves nothing to print into, and on a real ROM the
sandbox is unreadable from outside, the probe result is published to
<dataDir>/local-terminal.json and the ArkTS side echoes it to hilog
(`hdc shell hilog -x | grep 'lt[0-9]:'`) — the one channel that survives a
sealed device.
Also consolidates the pty diagnosis into app/server/local-terminal.js, shared by
the probe and a failed session spawn, and drops the now-unused deviceInfo import.1 parent 7b89732 commit 1c99f20
6 files changed
Lines changed: 521 additions & 121 deletions
File tree
- build-src
- replace/app
- lib
- server
- web
- entry/src/main/ets
- pages
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | | - | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
40 | 46 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 47 | + | |
| 48 | + | |
62 | 49 | | |
63 | 50 | | |
64 | 51 | | |
65 | 52 | | |
66 | 53 | | |
67 | 54 | | |
68 | 55 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
87 | 59 | | |
88 | 60 | | |
89 | 61 | | |
90 | 62 | | |
91 | 63 | | |
92 | | - | |
| 64 | + | |
93 | 65 | | |
94 | 66 | | |
95 | 67 | | |
| |||
0 commit comments