Skip to content

Commit ba8227b

Browse files
strzhaoclaude
andcommitted
fix(harmonyos): read the launch target through the lifecycle owner and scope the install-success claim
parseLaunchTarget rebuilt what parseHarmonyLaunchTarget already extracts, so openHarmonyApp calls the lifecycle owner and parseHarmonyBundleDump goes private again. The shapes note now says install success keys on the hdc command result, which never interprets the output, and the verified note describes the inventory re-read it actually recorded. Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent 6b7c195 commit ba8227b

4 files changed

Lines changed: 12 additions & 21 deletions

File tree

‎docs/evidence/harmonyos-uninstall-2026-11-08.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ error: failed to get information and the parameters may be wrong.
4949
## Consequences for the code
5050

5151
`bm dump` misses and `bm` failures carry their verdict in stdout text at exit
52-
code 0 on this build (7.0.0.111). `install` success detection keys on stream
53-
content, and `uninstall` success is proven only by an inventory re-read — an
54-
exit-code check would read every failure as success.
52+
code 0 on this build (7.0.0.111). `install` success keys on the `hdc install`
53+
command result alone (a failing install exits non-zero and refuses; the
54+
output is not interpreted), and `uninstall` success is proven only by an
55+
inventory re-read — an exit-code check would read every `bm` failure as
56+
success.
5557

5658
Addendum 2026-11-13: the uninstall route no longer interprets this per-bundle
5759
dump. Both probes read the `bm dump -a` inventory through the shared

‎docs/evidence/harmonyos-uninstall-verified-2026-11-12.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ A second uninstall answers honestly that nothing was removed:
8686
## What is proven here and what is not
8787

8888
- The public `uninstall` route, the deployment-runtime admission for a physical
89-
`device` denominator, and the post-uninstall dump verification all ran on
89+
`device` denominator, and the post-uninstall inventory re-read all ran on
9090
hardware at a named commit.
91-
- The `wasInstalled: false` branch ran against a genuinely absent record with
92-
the live-transport probe answering.
91+
- The `wasInstalled: false` branch ran against a genuinely absent bundle: the
92+
inventory re-read answered non-empty without the target, which also proves
93+
the transport was live.
9394
- The "inventory still lists the bundle" refusal (a `bm` that answers success
9495
but leaves the bundle) has no hardware reproduction on this build; the unit
9596
test `uninstall refuses to claim removal when the inventory still lists the

‎packages/platform-harmonyos/src/app-lifecycle.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function parseHarmonyIsSystemApp(rawOutput: string): boolean | undefined
7777
return typeof isSystemApp === 'boolean' ? isSystemApp : undefined;
7878
}
7979

80-
export function parseHarmonyBundleDump(rawOutput: string): HarmonyBundleDump | undefined {
80+
function parseHarmonyBundleDump(rawOutput: string): HarmonyBundleDump | undefined {
8181
const jsonStart = rawOutput.indexOf('{');
8282
if (jsonStart === -1) return undefined;
8383
try {

‎packages/platform-harmonyos/src/deployment/runtime.ts‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { DeviceInfo } from '@agent-device/kernel/device';
1111
import { deviceShellArgv, type ShellWord } from '@agent-device/kernel/device-shell';
1212
import { AppError } from '@agent-device/kernel/errors';
1313
import { execFailureDetails } from '@agent-device/host-kit/command';
14-
import { parseHarmonyBundleDump, parseHarmonyBundleList } from '../app-lifecycle.ts';
14+
import { parseHarmonyBundleList, parseHarmonyLaunchTarget } from '../app-lifecycle.ts';
1515
import { setTimeout as sleep } from 'node:timers/promises';
1616

1717
const available = Object.freeze({ available: true } as const);
@@ -191,7 +191,7 @@ async function openHarmonyApp(
191191
signal: AbortSignal,
192192
): Promise<void> {
193193
const dump = await runHdcShell(commands, device, ['bm', 'dump', '-n', bundleId], signal);
194-
const target = parseLaunchTarget(dump.stdout);
194+
const target = parseHarmonyLaunchTarget(dump.stdout);
195195
if (!target) {
196196
throw new AppError(
197197
'COMMAND_FAILED',
@@ -217,18 +217,6 @@ async function openHarmonyApp(
217217
);
218218
}
219219

220-
function parseLaunchTarget(rawOutput: string): { ability: string; module?: string } | undefined {
221-
const modules = parseHarmonyBundleDump(rawOutput)?.hapModuleInfos;
222-
if (!Array.isArray(modules)) return undefined;
223-
const module = modules.find((item) => item.mainElementName);
224-
return module?.mainElementName
225-
? {
226-
ability: module.mainElementName,
227-
...(module.moduleName ? { module: module.moduleName } : {}),
228-
}
229-
: undefined;
230-
}
231-
232220
async function runHdc(
233221
commands: HostCommandRunner,
234222
device: DeviceInfo,

0 commit comments

Comments
 (0)