senza-sdk 4.4.2 → 4.4.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/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DeviceManager as DeviceManagerInterface } from "../interface/deviceManager";
|
|
2
2
|
import { getFCID, sdkLogger, getRestResponse } from "./utils";
|
|
3
3
|
import { sessionInfo } from "./SessionInfo";
|
|
4
|
-
import {EventListenersManager} from "./eventListenersManager";
|
|
5
|
-
import {bus, Events} from "./eventBus";
|
|
6
|
-
import {lifecycle} from "./lifecycle";
|
|
4
|
+
import { EventListenersManager } from "./eventListenersManager";
|
|
5
|
+
import { bus, Events } from "./eventBus";
|
|
6
|
+
import { lifecycle } from "./lifecycle";
|
|
7
7
|
|
|
8
8
|
let wifi_ap_data;
|
|
9
9
|
let wifi_status;
|
|
@@ -80,6 +80,33 @@ class DeviceManager extends DeviceManagerInterface {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Translate the HdmiStatus information to a single HdmiStatus for the application
|
|
85
|
+
* 1) cecStatus is a configuration setting from the client. If false, we always return UNKNOWN to the application
|
|
86
|
+
* 2) If cecStatus is true, we check the hdmiStatus. If not "connected", the HDMI status is definitely INACTIVE.
|
|
87
|
+
* 3) If hdmiStatus is "connected" and cecStatus is true, we rely on the cecActiveSourceStatus to determine the HdmiStatus
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
_translateHdmiStatus(hdmiStatusStr) {
|
|
91
|
+
const hdmiStatusObj = JSON.parse(hdmiStatusStr ?? "{}"); // Object containing the 3 statuses
|
|
92
|
+
let hdmiStatus = this.HdmiStatus.UNKNOWN;
|
|
93
|
+
if (hdmiStatusObj?.cecStatus) {
|
|
94
|
+
if (hdmiStatusObj.hdmiStatus !== "connected") {
|
|
95
|
+
hdmiStatus = this.HdmiStatus.INACTIVE;
|
|
96
|
+
} else {
|
|
97
|
+
const cecActive = this._cecActiveSourceStatusMap[hdmiStatusObj.cecActiveSourceStatus];
|
|
98
|
+
hdmiStatus = cecActive ?? this.HdmiStatus.UNKNOWN;
|
|
99
|
+
if (!cecActive) {
|
|
100
|
+
sdkLogger.warn(`Unknown CEC active source status: ${hdmiStatusObj.cecActiveSourceStatus}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
sdkLogger.warn("cec is disabled or no hdmiStatus");
|
|
105
|
+
}
|
|
106
|
+
sdkLogger.log("HDMI status is:", hdmiStatus);
|
|
107
|
+
return hdmiStatus;
|
|
108
|
+
}
|
|
109
|
+
|
|
83
110
|
/**
|
|
84
111
|
* @private Add event listeners for system events
|
|
85
112
|
*/
|
|
@@ -91,25 +118,7 @@ class DeviceManager extends DeviceManagerInterface {
|
|
|
91
118
|
typeof document !== "undefined" && document.addEventListener("hs/hdmiStatusChanged", async (event) => {
|
|
92
119
|
sdkLogger.info("Got hs/hdmiStatusChanged event with detail", JSON.stringify(event?.detail));
|
|
93
120
|
|
|
94
|
-
|
|
95
|
-
// 1) cecStatus is a configuration setting from the client. If false, we always return UNKNOWN to the application
|
|
96
|
-
// 2) If cecStatus is true, we check the hdmiStatus. If not "connected", the HDMI status is definitely INACTIVE.
|
|
97
|
-
// 3) If hdmiStatus is "connected" and cecStatus is true, we rely on the cecActiveSourceStatus to determine the HdmiStatus
|
|
98
|
-
let hdmiStatus = this.HdmiStatus.UNKNOWN;
|
|
99
|
-
const status = JSON.parse(event?.detail?.hdmiStatus ?? "{}"); // Object containing the 3 statuses
|
|
100
|
-
if (status?.cecStatus) {
|
|
101
|
-
if (status.hdmiStatus !== "connected") {
|
|
102
|
-
hdmiStatus = this.HdmiStatus.INACTIVE;
|
|
103
|
-
} else {
|
|
104
|
-
const cecActive = this._cecActiveSourceStatusMap[status.cecActiveSourceStatus];
|
|
105
|
-
hdmiStatus = cecActive ?? this.HdmiStatus.UNKNOWN;
|
|
106
|
-
if (!cecActive) {
|
|
107
|
-
sdkLogger.warn(`Unknown CEC active source status: ${status.cecActiveSourceStatus}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
sdkLogger.warn("cec is disabled or no hdmiStatus");
|
|
112
|
-
}
|
|
121
|
+
const hdmiStatus = this._translateHdmiStatus(event?.detail?.hdmiStatus);
|
|
113
122
|
|
|
114
123
|
const timeBeforeCallbacks = Date.now();
|
|
115
124
|
|
|
@@ -179,6 +188,16 @@ class DeviceManager extends DeviceManagerInterface {
|
|
|
179
188
|
return super.deviceInfo;
|
|
180
189
|
}
|
|
181
190
|
|
|
191
|
+
async getHdmiStatus() {
|
|
192
|
+
try {
|
|
193
|
+
const response = await getRestResponse("hdmi-status");
|
|
194
|
+
return this._translateHdmiStatus(response);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
sdkLogger.error(e);
|
|
197
|
+
return this.HdmiStatus.UNKNOWN;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
182
201
|
reboot() {
|
|
183
202
|
return new Promise((resolve, reject) => {
|
|
184
203
|
if (window.cefQuery) {
|
|
@@ -54,6 +54,16 @@ export class DeviceManager extends EventTarget {
|
|
|
54
54
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Get the current HDMI status from the connector
|
|
59
|
+
* @return {Promise<HdmiStatus>} Promise which is resolved when getHdmiStatus has been successfully performed
|
|
60
|
+
* Failure to getHdmiStatus for any reason, results in the promise being rejected.
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
getHdmiStatus() {
|
|
64
|
+
return noop("DeviceManager.getHdmiStatus");
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
/**
|
|
58
68
|
* Reboot the device
|
|
59
69
|
* @return {Promise} Promise which is resolved when the reboot command has been successfully processed.
|
package/src/interface/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "4.4.
|
|
1
|
+
export const version = "4.4.3";
|