Skip to content

Commit

Permalink
OTA ID Fallback (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Feb 5, 2024
1 parent 9861c34 commit 56926a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/app/core/services/device-manager.service.ts
Expand Up @@ -110,14 +110,21 @@ export class DeviceManagerService extends BackendClient {
async getDeviceInfo(device: DeviceLike): Promise<Partial<DeviceInfo>> {
const systemInfo = await this.luna.call<SystemInfo>(device, 'luna://com.webos.service.tv.systemproperty/getSystemInfo', {
keys: ['firmwareVersion', 'modelName', 'sdkVersion', 'otaId']
});
}, true, false);
const osInfo = await this.luna.call<Partial<OsInfo>>(device, 'luna://com.palm.systemservice/osInfo/query', {
parameters: ['webos_manufacturing_version', 'webos_release']
}).catch(() => null);
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
};
}
Expand Down
7 changes: 5 additions & 2 deletions src/app/core/services/remote-luna.service.ts
Expand Up @@ -24,7 +24,8 @@ export class RemoteLunaService {
constructor(private commands: RemoteCommandService) {
}

async call<T extends LunaResponse>(device: DeviceLike, uri: string, param: Record<string, unknown> = {}, pub: boolean = true): Promise<T> {
async call<T extends LunaResponse>(device: DeviceLike, uri: string, param: Record<string, unknown> = {}, pub: boolean = true,
falseAsError: boolean = true): Promise<T> {
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 => {
Expand All @@ -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;
});
Expand Down

0 comments on commit 56926a0

Please sign in to comment.