fix(harmony): discover devices and release disconnected sessions asynchronously
Use USB descriptors and MTP identity instead of the static libmtp product label. Monitor attachment, discard stale UI responses, clear disconnected views, and release slow MTP sessions in the background while preserving operation serialization. Publish 0.1.1 with immutable source history. Cover discovery, names, unplugging and slow disconnect with native and UI regressions. Verify real Pura 70 Ultra identity and prompt disconnect; run the newest published backend during Git-source checks.
This commit is contained in:
@@ -3,13 +3,15 @@ import { createMockBridge } from "./sdk/index.js";
|
||||
const root = 0xffffffff;
|
||||
const device = {
|
||||
id: "fixture",
|
||||
name: "HarmonyOS 6 · 界面测试",
|
||||
name: "daniel",
|
||||
model: "HUAWEI Pura 70 Ultra",
|
||||
manufacturer: "模拟设备",
|
||||
};
|
||||
const storages = [
|
||||
{ id: 1, name: "内部存储", capacity: 256 * 1024 ** 3, free: 128 * 1024 ** 3 },
|
||||
];
|
||||
let connection = null,
|
||||
let attached = true,
|
||||
connection = null,
|
||||
job = null,
|
||||
next = 30;
|
||||
const entries = [
|
||||
@@ -61,16 +63,22 @@ const entries = [
|
||||
];
|
||||
window.__TROVE_CONTEXT__ = {
|
||||
curioId: "dev.trove.harmony-connector",
|
||||
version: "0.1.0",
|
||||
version: "0.1.1",
|
||||
instanceId: "ui-fixture",
|
||||
platform: "macos",
|
||||
};
|
||||
window.__TROVE_BRIDGE__ = createMockBridge({
|
||||
"@self.info": () => ({ connection, busy: false }),
|
||||
"@self.devices": () => ({ devices: [device] }),
|
||||
"@self.devices": () => ({ devices: attached ? [device] : [] }),
|
||||
"@self.monitor": () => ({
|
||||
connection,
|
||||
devices: attached ? [device] : [],
|
||||
busy: job?.state === "running",
|
||||
}),
|
||||
"@self.connect": () => (connection = { device, storages }),
|
||||
"@self.disconnect": () => {
|
||||
connection = null;
|
||||
job = null;
|
||||
return { disconnected: true };
|
||||
},
|
||||
"@self.list": ({ parent, offset = 0 }) => {
|
||||
@@ -117,4 +125,20 @@ badge.textContent = "界面测试 · 模拟设备,不执行真实文件传输"
|
||||
badge.style.cssText =
|
||||
"position:fixed;bottom:3px;left:240px;z-index:10;background:#805800;color:white;padding:4px 8px;border-radius:5px;font-size:10px";
|
||||
document.body.append(badge);
|
||||
const toggle = document.createElement("button");
|
||||
toggle.textContent = "模拟拔掉 USB";
|
||||
toggle.style.cssText =
|
||||
"position:fixed;bottom:30px;left:16px;z-index:10;background:#805800;color:white";
|
||||
toggle.addEventListener("click", () => {
|
||||
attached = !attached;
|
||||
if (!attached) {
|
||||
connection = null;
|
||||
if (job?.state === "running") {
|
||||
job.state = "failed";
|
||||
job.error = { message: "设备已断开(模拟)" };
|
||||
}
|
||||
}
|
||||
toggle.textContent = attached ? "模拟拔掉 USB" : "模拟接入 USB";
|
||||
});
|
||||
document.body.append(toggle);
|
||||
await import("./app.js");
|
||||
|
||||
Reference in New Issue
Block a user