@ray-js/lock-sdk 1.2.0-beta.1 → 1.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/index.d.ts +3 -1
- package/lib/api/index.js +16 -0
- package/lib/api/screen.d.ts +1 -0
- package/lib/entries/main/exports/ai.d.ts +4 -0
- package/lib/entries/main/exports/ai.js +11 -0
- package/lib/entries/main/exports/index.d.ts +1 -0
- package/lib/entries/main/exports/index.js +1 -0
- package/lib/entries/main/exports/screen/bind.d.ts +6 -3
- package/lib/entries/main/exports/screen/bind.js +7 -0
- package/lib/entries/screen/exports/bind-events.d.ts +4 -0
- package/lib/entries/screen/exports/bind-events.js +8 -0
- package/lib/entries/screen/exports/index.d.ts +1 -0
- package/lib/entries/screen/exports/index.js +1 -0
- package/lib/feature/ai/report.d.ts +5 -0
- package/lib/feature/ai/report.js +37 -0
- package/lib/feature/screen/bind-watch.d.ts +18 -0
- package/lib/feature/screen/bind-watch.js +92 -0
- package/lib/feature/screen/bind.d.ts +2 -2
- package/lib/feature/screen/bind.js +8 -38
- package/lib/feature/screen/list.js +13 -0
- package/lib/feature/state/init-state.js +24 -16
- package/lib/interface.d.ts +4 -0
- package/lib/platform/device.d.ts +1 -1
- package/lib/platform/device.js +1 -1
- package/lib/platform/ipc.js +10 -7
- package/lib/utils/index.d.ts +35 -0
- package/lib/utils/index.js +11 -1
- package/package.json +1 -1
package/lib/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DpValue } from "../interface";
|
|
1
|
+
import { AIReportPopup, DpValue } from "../interface";
|
|
2
2
|
export declare const sendPhoneVerifyCode: (params: {
|
|
3
3
|
account: string;
|
|
4
4
|
devId: string;
|
|
@@ -35,4 +35,6 @@ export declare const getFileRemoteUrl: ({ biz, resources, }: {
|
|
|
35
35
|
}) => Promise<{
|
|
36
36
|
signedUrls: Record<string, string>;
|
|
37
37
|
}>;
|
|
38
|
+
export declare const fetchAIReportPopup: (devId: string) => Promise<AIReportPopup | null>;
|
|
39
|
+
export declare const acknowledgeAIReport: (devId: string, reportId: string) => Promise<void>;
|
|
38
40
|
export {};
|
package/lib/api/index.js
CHANGED
|
@@ -90,3 +90,19 @@ export const getFileRemoteUrl = ({ biz, resources, }) => {
|
|
|
90
90
|
},
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
|
+
export const fetchAIReportPopup = (devId) => {
|
|
94
|
+
return requestApi({
|
|
95
|
+
logName: "fetchAIReportPopup",
|
|
96
|
+
api: "m.lock.ai.report.popup",
|
|
97
|
+
version: "1.0",
|
|
98
|
+
data: { devId },
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
export const acknowledgeAIReport = (devId, reportId) => {
|
|
102
|
+
return requestApi({
|
|
103
|
+
logName: "acknowledgeAIReport",
|
|
104
|
+
api: "m.lock.ai.report.acknowledge",
|
|
105
|
+
version: "1.0",
|
|
106
|
+
data: { devId, reportId },
|
|
107
|
+
});
|
|
108
|
+
};
|
package/lib/api/screen.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { resolveRuntimeFromExportThis } from "../bootstrap/resolve-runtime-from-export-this";
|
|
2
|
+
import { getAIReportForRuntime, acknowledgeAIReportForRuntime, isAIReportEnabledForRuntime, } from "../../../feature/ai/report";
|
|
3
|
+
export async function getAIReport() {
|
|
4
|
+
return getAIReportForRuntime(resolveRuntimeFromExportThis(this));
|
|
5
|
+
}
|
|
6
|
+
export async function acknowledgeAIReport(reportId) {
|
|
7
|
+
return acknowledgeAIReportForRuntime(resolveRuntimeFromExportThis(this), reportId);
|
|
8
|
+
}
|
|
9
|
+
export async function isAIReportEnabled() {
|
|
10
|
+
return isAIReportEnabledForRuntime(resolveRuntimeFromExportThis(this));
|
|
11
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import { type BindLockToScreenEvent, type BindLockToScreenListener } from "../../../../feature/screen/bind-watch";
|
|
2
|
+
import type { AddBindingResult, BindingResult, UnbindingResult } from "../../../../api/screen";
|
|
3
|
+
export type { AddBindingResult, BindingResult, UnbindingResult, BindLockToScreenEvent, BindLockToScreenListener, };
|
|
4
|
+
export declare function bindLockToScreen(lockDevId: string): Promise<AddBindingResult>;
|
|
5
|
+
export declare function onBindLockToScreen(listener: BindLockToScreenListener): void;
|
|
6
|
+
export declare function offBindLockToScreen(listener: BindLockToScreenListener): void;
|
|
4
7
|
export declare function unbindLockFromScreen(relationId: string): Promise<UnbindingResult>;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { bindLockForRuntime, unbindLockForRuntime, } from "../../../../feature/screen/bind";
|
|
2
|
+
import { onBindLockToScreenForRuntime, offBindLockToScreenForRuntime, } from "../../../../feature/screen/bind-watch";
|
|
2
3
|
import { resolveRuntimeFromExportThis } from "../../bootstrap/resolve-runtime-from-export-this";
|
|
3
4
|
export function bindLockToScreen(lockDevId) {
|
|
4
5
|
return bindLockForRuntime(resolveRuntimeFromExportThis(this), lockDevId);
|
|
5
6
|
}
|
|
7
|
+
export function onBindLockToScreen(listener) {
|
|
8
|
+
onBindLockToScreenForRuntime(resolveRuntimeFromExportThis(this), listener);
|
|
9
|
+
}
|
|
10
|
+
export function offBindLockToScreen(listener) {
|
|
11
|
+
offBindLockToScreenForRuntime(resolveRuntimeFromExportThis(this), listener);
|
|
12
|
+
}
|
|
6
13
|
export function unbindLockFromScreen(relationId) {
|
|
7
14
|
return unbindLockForRuntime(resolveRuntimeFromExportThis(this), relationId);
|
|
8
15
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type BindLockToScreenEvent, type BindLockToScreenListener } from "../../../feature/screen/bind-watch";
|
|
2
|
+
export type { BindLockToScreenEvent, BindLockToScreenListener };
|
|
3
|
+
export declare function onBindLockToScreen(listener: BindLockToScreenListener): void;
|
|
4
|
+
export declare function offBindLockToScreen(listener: BindLockToScreenListener): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { onBindLockToScreenForRuntime, offBindLockToScreenForRuntime, } from "../../../feature/screen/bind-watch";
|
|
2
|
+
import { resolveRuntimeFromExportThis } from "../bootstrap/resolve-runtime-from-export-this";
|
|
3
|
+
export function onBindLockToScreen(listener) {
|
|
4
|
+
onBindLockToScreenForRuntime(resolveRuntimeFromExportThis(this), listener);
|
|
5
|
+
}
|
|
6
|
+
export function offBindLockToScreen(listener) {
|
|
7
|
+
offBindLockToScreenForRuntime(resolveRuntimeFromExportThis(this), listener);
|
|
8
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AIReportPopup } from "../../interface";
|
|
2
|
+
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
3
|
+
export declare const isAIReportEnabledForRuntime: (runtime: LockDeviceRuntime) => Promise<boolean>;
|
|
4
|
+
export declare const getAIReportForRuntime: (runtime: LockDeviceRuntime) => Promise<AIReportPopup | null>;
|
|
5
|
+
export declare const acknowledgeAIReportForRuntime: (runtime: LockDeviceRuntime, reportId: string) => Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { fetchAIReportPopup, acknowledgeAIReport as acknowledgeAIReportApi, } from "../../api";
|
|
2
|
+
import { getDeviceProperties } from "../../api/setting";
|
|
3
|
+
import { getDeviceAdvancedAbilitiesForRuntime } from "../misc/capability";
|
|
4
|
+
const LOCK_UNLOCK_REPORT = "LOCK_UNLOCK_REPORT";
|
|
5
|
+
export const isAIReportEnabledForRuntime = async (runtime) => {
|
|
6
|
+
const ability = await getDeviceAdvancedAbilitiesForRuntime(runtime);
|
|
7
|
+
const dataReport = !!ability?.ai?.config?.["ai_data_report"];
|
|
8
|
+
if (!dataReport) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const props = await getDeviceProperties(runtime.devId, [LOCK_UNLOCK_REPORT]);
|
|
13
|
+
return props?.[LOCK_UNLOCK_REPORT] !== "false";
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const getAIReportForRuntime = async (runtime) => {
|
|
20
|
+
const enabled = await isAIReportEnabledForRuntime(runtime);
|
|
21
|
+
if (!enabled) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const res = await fetchAIReportPopup(runtime.devId);
|
|
26
|
+
return res?.reportId ? res : null;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const acknowledgeAIReportForRuntime = async (runtime, reportId) => {
|
|
33
|
+
if (!reportId) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
await acknowledgeAIReportApi(runtime.devId, reportId);
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BindingResult } from "../../api/screen";
|
|
2
|
+
import type { ErrorData } from "../../interface";
|
|
3
|
+
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
4
|
+
export interface BindLockToScreenEvent {
|
|
5
|
+
lockDevId: string;
|
|
6
|
+
success: boolean;
|
|
7
|
+
data?: BindingResult;
|
|
8
|
+
error?: ErrorData;
|
|
9
|
+
}
|
|
10
|
+
export type BindLockToScreenListener = (event: BindLockToScreenEvent) => void;
|
|
11
|
+
export declare function emitBindResult(runtime: LockDeviceRuntime, event: BindLockToScreenEvent): void;
|
|
12
|
+
export declare function onBindLockToScreenForRuntime(runtime: LockDeviceRuntime, listener: BindLockToScreenListener): void;
|
|
13
|
+
export declare function offBindLockToScreenForRuntime(runtime: LockDeviceRuntime, listener: BindLockToScreenListener): void;
|
|
14
|
+
export declare function watchBindResult(runtime: LockDeviceRuntime, params: {
|
|
15
|
+
lockDevId: string;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
export declare function isWatchingBind(runtime: LockDeviceRuntime, sessionId: string): boolean;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { getBindingResultApi } from "../../api/screen";
|
|
2
|
+
import emitter from "../../utils/event";
|
|
3
|
+
import { getError } from "../../utils/errors";
|
|
4
|
+
import { sdkLog } from "../../utils/sdk-log";
|
|
5
|
+
import { handleScreenCloudError } from "./error";
|
|
6
|
+
const POLL_INTERVAL_MS = 2_000;
|
|
7
|
+
const BIND_POLL_TIMEOUT_MS = 30_000;
|
|
8
|
+
const delay = (ms) => new Promise((resolve) => {
|
|
9
|
+
setTimeout(resolve, ms);
|
|
10
|
+
});
|
|
11
|
+
function bindResultEventName(runtime) {
|
|
12
|
+
return `screen_bind_result_${runtime.devId}`;
|
|
13
|
+
}
|
|
14
|
+
export function emitBindResult(runtime, event) {
|
|
15
|
+
emitter.emit(bindResultEventName(runtime), event);
|
|
16
|
+
}
|
|
17
|
+
const watchKey = (runtime, sessionId) => `${runtime.devId}:${sessionId}`;
|
|
18
|
+
const inflight = new Map();
|
|
19
|
+
export function onBindLockToScreenForRuntime(runtime, listener) {
|
|
20
|
+
emitter.on(bindResultEventName(runtime), listener);
|
|
21
|
+
}
|
|
22
|
+
export function offBindLockToScreenForRuntime(runtime, listener) {
|
|
23
|
+
emitter.off(bindResultEventName(runtime), listener);
|
|
24
|
+
}
|
|
25
|
+
async function pollBindResult(runtime, lockDevId, sessionId) {
|
|
26
|
+
const accessoryDevId = runtime.devId;
|
|
27
|
+
const startedAt = Date.now();
|
|
28
|
+
const deadline = startedAt + BIND_POLL_TIMEOUT_MS;
|
|
29
|
+
while (Date.now() < deadline) {
|
|
30
|
+
await delay(POLL_INTERVAL_MS);
|
|
31
|
+
let result;
|
|
32
|
+
try {
|
|
33
|
+
result = await getBindingResultApi({ accessoryDevId, sessionId });
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
const error = handleScreenCloudError(e);
|
|
37
|
+
sdkLog("error", "screen", "bindResultPollError", {
|
|
38
|
+
devId: accessoryDevId,
|
|
39
|
+
duration: Date.now() - startedAt,
|
|
40
|
+
data: { lockDevId },
|
|
41
|
+
error: e,
|
|
42
|
+
});
|
|
43
|
+
emitBindResult(runtime, { lockDevId, success: false, error });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (result.status === "binding") {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (result.status === "bound") {
|
|
50
|
+
sdkLog("info", "screen", "bindResultSettled", {
|
|
51
|
+
devId: accessoryDevId,
|
|
52
|
+
duration: Date.now() - startedAt,
|
|
53
|
+
data: { lockDevId, status: result.status, lanStatus: result.lanStatus },
|
|
54
|
+
});
|
|
55
|
+
emitBindResult(runtime, { lockDevId, success: true, data: result });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
sdkLog("info", "screen", "bindResultSettled", {
|
|
59
|
+
devId: accessoryDevId,
|
|
60
|
+
duration: Date.now() - startedAt,
|
|
61
|
+
data: { lockDevId, status: result.status, lanStatus: result.lanStatus },
|
|
62
|
+
});
|
|
63
|
+
emitBindResult(runtime, {
|
|
64
|
+
lockDevId,
|
|
65
|
+
success: false,
|
|
66
|
+
data: result,
|
|
67
|
+
error: getError(1103),
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
sdkLog("warn", "screen", "bindResultTimeout", {
|
|
72
|
+
devId: accessoryDevId,
|
|
73
|
+
duration: Date.now() - startedAt,
|
|
74
|
+
data: { lockDevId },
|
|
75
|
+
});
|
|
76
|
+
emitBindResult(runtime, { lockDevId, success: false, error: getError(1002) });
|
|
77
|
+
}
|
|
78
|
+
export function watchBindResult(runtime, params) {
|
|
79
|
+
const key = watchKey(runtime, params.sessionId);
|
|
80
|
+
const existing = inflight.get(key);
|
|
81
|
+
if (existing) {
|
|
82
|
+
return existing;
|
|
83
|
+
}
|
|
84
|
+
const task = pollBindResult(runtime, params.lockDevId, params.sessionId).finally(() => {
|
|
85
|
+
inflight.delete(key);
|
|
86
|
+
});
|
|
87
|
+
inflight.set(key, task);
|
|
88
|
+
return task;
|
|
89
|
+
}
|
|
90
|
+
export function isWatchingBind(runtime, sessionId) {
|
|
91
|
+
return inflight.has(watchKey(runtime, sessionId));
|
|
92
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AddBindingResult, type UnbindingResult } from "../../api/screen";
|
|
2
2
|
import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
|
|
3
|
-
export declare function bindLockForRuntime(runtime: LockDeviceRuntime, lockDevId: string): Promise<
|
|
3
|
+
export declare function bindLockForRuntime(runtime: LockDeviceRuntime, lockDevId: string): Promise<AddBindingResult>;
|
|
4
4
|
export declare function unbindLockForRuntime(runtime: LockDeviceRuntime, relationId: string): Promise<UnbindingResult>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { addBindingApi, deleteBindingApi,
|
|
1
|
+
import { addBindingApi, deleteBindingApi, getUnbindingResultApi, } from "../../api/screen";
|
|
2
2
|
import { getDeviceInfo } from "../../platform/device";
|
|
3
3
|
import { getError } from "../../utils/errors";
|
|
4
4
|
import { sdkLog } from "../../utils/sdk-log";
|
|
5
5
|
import { getDeviceStatusForRuntime } from "../state/device-status";
|
|
6
6
|
import { handleScreenCloudError } from "./error";
|
|
7
|
+
import { watchBindResult } from "./bind-watch";
|
|
7
8
|
const POLL_INTERVAL_MS = 2_000;
|
|
8
|
-
const BIND_POLL_TIMEOUT_MS = 25_000;
|
|
9
9
|
const UNBIND_POLL_TIMEOUT_MS = 20_000;
|
|
10
10
|
const delay = (ms) => new Promise((resolve) => {
|
|
11
11
|
setTimeout(resolve, ms);
|
|
@@ -42,48 +42,18 @@ export async function bindLockForRuntime(runtime, lockDevId) {
|
|
|
42
42
|
});
|
|
43
43
|
sdkLog("info", "screen", "bindAddSuccess", {
|
|
44
44
|
devId: accessoryDevId,
|
|
45
|
+
duration: Date.now() - startedAt,
|
|
45
46
|
data: { lockDevId, relationId: sessionData.relationId },
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
catch (e) {
|
|
49
50
|
throw handleScreenCloudError(e);
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
last = await getBindingResultApi({
|
|
57
|
-
accessoryDevId,
|
|
58
|
-
sessionId: sessionData.sessionId,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
catch (e) {
|
|
62
|
-
throw handleScreenCloudError(e);
|
|
63
|
-
}
|
|
64
|
-
if (last.status !== "binding") {
|
|
65
|
-
sdkLog("info", "screen", "bindSettled", {
|
|
66
|
-
devId: accessoryDevId,
|
|
67
|
-
duration: Date.now() - startedAt,
|
|
68
|
-
data: {
|
|
69
|
-
lockDevId,
|
|
70
|
-
relationId: sessionData.relationId,
|
|
71
|
-
status: last.status,
|
|
72
|
-
lanStatus: last.lanStatus,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
if (last.status === "failed") {
|
|
76
|
-
throw getError(1103);
|
|
77
|
-
}
|
|
78
|
-
return last;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
sdkLog("warn", "screen", "bindTimeout", {
|
|
82
|
-
devId: accessoryDevId,
|
|
83
|
-
duration: Date.now() - startedAt,
|
|
84
|
-
data: { lockDevId, relationId: sessionData.relationId },
|
|
85
|
-
});
|
|
86
|
-
throw getError(1002);
|
|
52
|
+
void watchBindResult(runtime, {
|
|
53
|
+
lockDevId,
|
|
54
|
+
sessionId: sessionData.sessionId,
|
|
55
|
+
}).catch(() => { });
|
|
56
|
+
return sessionData;
|
|
87
57
|
}
|
|
88
58
|
catch (error) {
|
|
89
59
|
sdkLog("error", "screen", "bindFail", {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getBoundLockListApi, getBindableLockListApi, } from "../../api/screen";
|
|
2
2
|
import { getDeviceInfo } from "../../platform/device";
|
|
3
3
|
import { sdkLog } from "../../utils/sdk-log";
|
|
4
|
+
import { isWatchingBind, watchBindResult } from "./bind-watch";
|
|
4
5
|
async function resolveLockDeviceInfo(accessoryDevId, lockDevId) {
|
|
5
6
|
try {
|
|
6
7
|
const info = await getDeviceInfo(lockDevId);
|
|
@@ -52,5 +53,17 @@ export async function getBindableLockListForRuntime(runtime) {
|
|
|
52
53
|
duration: Date.now() - startedAt,
|
|
53
54
|
data: { count: items.length, canBindMore: result?.canBindMore },
|
|
54
55
|
});
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
if (item.bindStatus !== "binding" || !item.sessionId) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (isWatchingBind(runtime, item.sessionId)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
void watchBindResult(runtime, {
|
|
64
|
+
lockDevId: item.lockDevId,
|
|
65
|
+
sessionId: item.sessionId,
|
|
66
|
+
}).catch(() => { });
|
|
67
|
+
}
|
|
55
68
|
return { ...result, items };
|
|
56
69
|
}
|
|
@@ -16,6 +16,7 @@ import { fetchDeviceProperties } from "./remote-permissions";
|
|
|
16
16
|
import { ipc, yuChannelSyncSingleSync } from "../../platform";
|
|
17
17
|
import { sdkLog } from "../../utils/sdk-log";
|
|
18
18
|
import { RotateType } from "../../constant";
|
|
19
|
+
import { isHarmony } from "../../utils";
|
|
19
20
|
export const initState = async (runtime) => {
|
|
20
21
|
const { devInfo: { dps, devId, yuNetState }, dpSchema, } = runtime.config;
|
|
21
22
|
const startedAt = Date.now();
|
|
@@ -76,24 +77,31 @@ export const initState = async (runtime) => {
|
|
|
76
77
|
}
|
|
77
78
|
if (ipcConfig.status === "fulfilled" &&
|
|
78
79
|
ipcConfig.value?.audioAttributes?.hardwareCapability?.includes(2)) {
|
|
79
|
-
|
|
80
|
-
const modeRes = await ipc.getCurrentSupportedTalkMode(devId);
|
|
80
|
+
if (isHarmony()) {
|
|
81
81
|
runtime.config.supportTalk = true;
|
|
82
|
-
runtime.config.isTwoWayTalk =
|
|
83
|
-
|
|
84
|
-
devId,
|
|
85
|
-
duration: Date.now() - startedAt,
|
|
86
|
-
data: {
|
|
87
|
-
mode: modeRes.talkbackMode,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
82
|
+
runtime.config.isTwoWayTalk =
|
|
83
|
+
ipcConfig.value?.audioAttributes?.callMode?.includes(2);
|
|
90
84
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
devId
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
else {
|
|
86
|
+
try {
|
|
87
|
+
const modeRes = await ipc.getCurrentSupportedTalkMode(devId);
|
|
88
|
+
runtime.config.supportTalk = true;
|
|
89
|
+
runtime.config.isTwoWayTalk = modeRes.talkbackMode === 2;
|
|
90
|
+
sdkLog("info", "initState", "supportTalk", {
|
|
91
|
+
devId,
|
|
92
|
+
duration: Date.now() - startedAt,
|
|
93
|
+
data: {
|
|
94
|
+
mode: modeRes.talkbackMode,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
sdkLog("error", "initState", "supportTalk", {
|
|
100
|
+
devId,
|
|
101
|
+
duration: Date.now() - startedAt,
|
|
102
|
+
data: {},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
97
105
|
}
|
|
98
106
|
}
|
|
99
107
|
if (!isSEI &&
|
package/lib/interface.d.ts
CHANGED
package/lib/platform/device.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare const onOnlineChange: (func: ParamType<typeof ty.device.onDeviceO
|
|
|
23
23
|
export declare const offOnlineChange: (func: ParamType<typeof ty.device.offDeviceOnlineStatusUpdate>) => void;
|
|
24
24
|
export declare const onBleChange: (func: ParamType<typeof ty.device.onBLEConnectStatusChange>) => void;
|
|
25
25
|
export declare const offBleChange: (func: ParamType<typeof ty.device.offBLEConnectStatusChange>) => void;
|
|
26
|
-
export declare const
|
|
26
|
+
export declare const getSystemInfoSync: () => {
|
|
27
27
|
is24Hour: boolean;
|
|
28
28
|
system: string;
|
|
29
29
|
brand: string;
|
package/lib/platform/device.js
CHANGED
|
@@ -98,7 +98,7 @@ export const onBleChange = (func) => {
|
|
|
98
98
|
export const offBleChange = (func) => {
|
|
99
99
|
ty.device.offBLEConnectStatusChange(func);
|
|
100
100
|
};
|
|
101
|
-
export const
|
|
101
|
+
export const getSystemInfoSync = () => ty.getSystemInfoSync();
|
|
102
102
|
export const showModal = (options) => {
|
|
103
103
|
return ty.showModal(options);
|
|
104
104
|
};
|
package/lib/platform/ipc.js
CHANGED
|
@@ -19,14 +19,17 @@ const connect = (deviceId) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
const getCurrentSupportedTalkMode = (deviceId) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (ty.ipc.getCurrentSupportedTalkMode) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
ty.ipc.getCurrentSupportedTalkMode({
|
|
25
|
+
deviceId,
|
|
26
|
+
extendParam: {},
|
|
27
|
+
success: resolve,
|
|
28
|
+
fail: reject,
|
|
29
|
+
});
|
|
28
30
|
});
|
|
29
|
-
}
|
|
31
|
+
}
|
|
32
|
+
return Promise.reject(new Error("not support"));
|
|
30
33
|
};
|
|
31
34
|
export default {
|
|
32
35
|
wakeUpDoorBell,
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -3,6 +3,40 @@ import type { EffectiveConfig, Week } from "../interface";
|
|
|
3
3
|
import { LoopTypes } from "./constant";
|
|
4
4
|
export declare const get24Time: (time: number) => number[];
|
|
5
5
|
export declare const getNowTime: () => number;
|
|
6
|
+
export declare const getSystemInfo: () => {
|
|
7
|
+
is24Hour: boolean;
|
|
8
|
+
system: string;
|
|
9
|
+
brand: string;
|
|
10
|
+
model: string;
|
|
11
|
+
platform: string;
|
|
12
|
+
timezoneId: string;
|
|
13
|
+
pixelRatio: number;
|
|
14
|
+
screenWidth: number;
|
|
15
|
+
screenHeight: number;
|
|
16
|
+
windowWidth: number;
|
|
17
|
+
windowHeight: number;
|
|
18
|
+
useableWindowWidth: number;
|
|
19
|
+
useableWindowHeight: number;
|
|
20
|
+
statusBarHeight: number;
|
|
21
|
+
language: string;
|
|
22
|
+
safeArea: ty.SafeArea;
|
|
23
|
+
albumAuthorized: boolean;
|
|
24
|
+
cameraAuthorized: boolean;
|
|
25
|
+
locationAuthorized: boolean;
|
|
26
|
+
microphoneAuthorized: boolean;
|
|
27
|
+
notificationAuthorized: boolean;
|
|
28
|
+
notificationAlertAuthorized: boolean;
|
|
29
|
+
notificationBadgeAuthorized: boolean;
|
|
30
|
+
notificationSoundAuthorized: boolean;
|
|
31
|
+
bluetoothEnabled: boolean;
|
|
32
|
+
locationEnabled: boolean;
|
|
33
|
+
wifiEnabled: boolean;
|
|
34
|
+
theme?: ty.Themes;
|
|
35
|
+
deviceOrientation?: ty.Orientation;
|
|
36
|
+
deviceLevel: string;
|
|
37
|
+
isSupportPinShortcut?: boolean;
|
|
38
|
+
deviceType?: string;
|
|
39
|
+
};
|
|
6
40
|
export declare const isOnlineByType: (onlineType: number, type: number) => boolean;
|
|
7
41
|
export declare function isCapability(capability: number, id: number): boolean;
|
|
8
42
|
export declare function getCapabilities(capability: number): ({
|
|
@@ -134,3 +168,4 @@ export declare const getAppUser: () => {
|
|
|
134
168
|
phoneCode: string;
|
|
135
169
|
isTemporaryUser: boolean;
|
|
136
170
|
} | null;
|
|
171
|
+
export declare const isHarmony: () => boolean;
|
package/lib/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoopTypes } from "./constant";
|
|
2
|
-
import { getAppUserInfo, getCurrentHomeInfo } from "../platform/device";
|
|
2
|
+
import { getAppUserInfo, getCurrentHomeInfo, getSystemInfoSync, } from "../platform/device";
|
|
3
3
|
import { getError } from "./errors";
|
|
4
4
|
export const get24Time = (time) => {
|
|
5
5
|
const hours = Math.floor(time / 60);
|
|
@@ -10,6 +10,13 @@ export const getNowTime = () => {
|
|
|
10
10
|
const now = new Date();
|
|
11
11
|
return now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
|
|
12
12
|
};
|
|
13
|
+
let system;
|
|
14
|
+
export const getSystemInfo = () => {
|
|
15
|
+
if (!system) {
|
|
16
|
+
system = getSystemInfoSync();
|
|
17
|
+
}
|
|
18
|
+
return system;
|
|
19
|
+
};
|
|
13
20
|
export const isOnlineByType = (onlineType, type) => {
|
|
14
21
|
const base = 2 ** type;
|
|
15
22
|
return (onlineType & base) >> type === 1;
|
|
@@ -210,3 +217,6 @@ const getAppUserAsync = async () => {
|
|
|
210
217
|
getAppUserAsync().catch(() => {
|
|
211
218
|
getAppUserAsync().catch(() => undefined);
|
|
212
219
|
});
|
|
220
|
+
export const isHarmony = () => {
|
|
221
|
+
return getSystemInfo().platform === "harmony";
|
|
222
|
+
};
|