From f5b75c4bd969f26ad3792b27cf676a7586f312a7 Mon Sep 17 00:00:00 2001 From: Mariotaku Date: Sun, 4 Feb 2024 19:29:16 +0900 Subject: [PATCH 1/2] otaId fallback --- src/app/core/services/device-manager.service.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/core/services/device-manager.service.ts b/src/app/core/services/device-manager.service.ts index e72fb211..19b73f46 100644 --- a/src/app/core/services/device-manager.service.ts +++ b/src/app/core/services/device-manager.service.ts @@ -110,6 +110,13 @@ export class DeviceManagerService extends BackendClient { async getDeviceInfo(device: DeviceLike): Promise> { const systemInfo = await this.luna.call(device, 'luna://com.webos.service.tv.systemproperty/getSystemInfo', { keys: ['firmwareVersion', 'modelName', 'sdkVersion', 'otaId'] + }).catch((reason) => { + if (reason instanceof LunaResponseError) { + return this.luna.call(device, 'luna://com.webos.service.tv.systemproperty/getSystemInfo', { + keys: ['firmwareVersion', 'modelName', 'sdkVersion'] + }); + } + throw reason; }); const osInfo = await this.luna.call>(device, 'luna://com.webos.service.systemservice/osInfo/query', { parameters: ['webos_manufacturing_version', 'webos_release'] @@ -117,7 +124,14 @@ export class DeviceManagerService extends BackendClient { return { modelName: systemInfo.modelName, osVersion: osInfo?.webos_release || systemInfo.sdkVersion, - otaId: systemInfo.otaId, + otaId: systemInfo.otaId || await this.luna.call<{ + billingId?: string + }>(device, 'luna://com.webos.service.sdx/getDeviceUuid', {}).then((ret) => { + if (!ret.billingId) { + return undefined; + } + return new URLSearchParams(ret.billingId).get('modelName') ?? undefined; + }).catch(() => undefined), firmwareVersion: systemInfo.firmwareVersion }; } From 06ffa83e2e1b722370ac67ad080b9cb73e8f11f9 Mon Sep 17 00:00:00 2001 From: Mariotaku Date: Mon, 5 Feb 2024 11:51:44 +0900 Subject: [PATCH 2/2] allow negative response --- src/app/core/services/device-manager.service.ts | 9 +-------- src/app/core/services/remote-luna.service.ts | 7 +++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/app/core/services/device-manager.service.ts b/src/app/core/services/device-manager.service.ts index 19b73f46..07b91ac5 100644 --- a/src/app/core/services/device-manager.service.ts +++ b/src/app/core/services/device-manager.service.ts @@ -110,14 +110,7 @@ export class DeviceManagerService extends BackendClient { async getDeviceInfo(device: DeviceLike): Promise> { const systemInfo = await this.luna.call(device, 'luna://com.webos.service.tv.systemproperty/getSystemInfo', { keys: ['firmwareVersion', 'modelName', 'sdkVersion', 'otaId'] - }).catch((reason) => { - if (reason instanceof LunaResponseError) { - return this.luna.call(device, 'luna://com.webos.service.tv.systemproperty/getSystemInfo', { - keys: ['firmwareVersion', 'modelName', 'sdkVersion'] - }); - } - throw reason; - }); + }, true, false); const osInfo = await this.luna.call>(device, 'luna://com.webos.service.systemservice/osInfo/query', { parameters: ['webos_manufacturing_version', 'webos_release'] }).catch(() => null); diff --git a/src/app/core/services/remote-luna.service.ts b/src/app/core/services/remote-luna.service.ts index 2ea956f7..5e20206d 100644 --- a/src/app/core/services/remote-luna.service.ts +++ b/src/app/core/services/remote-luna.service.ts @@ -24,7 +24,8 @@ export class RemoteLunaService { constructor(private commands: RemoteCommandService) { } - async call(device: DeviceLike, uri: string, param: Record = {}, pub: boolean = true): Promise { + async call(device: DeviceLike, uri: string, param: Record = {}, pub: boolean = true, + falseAsError: boolean = true): Promise { const sendCmd = pub ? 'luna-send-pub' : 'luna-send'; return this.commands.exec(device, `${sendCmd} -n 1 ${uri} ${escapeSingleQuoteString(JSON.stringify(param))}`, 'utf-8') .catch(e => { @@ -45,7 +46,9 @@ export class RemoteLunaService { if (typed['errorText']?.startsWith('Unknown method')) { throw new LunaUnknownMethodError(typed); } - throw new LunaResponseError(typed); + if (falseAsError) { + throw new LunaResponseError(typed); + } } return typed; });