diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 0000000..0550479 --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,13 @@ +name: "CLA" +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened,closed,synchronize] + +jobs: + CLA-Lite: + name: "Signature" + uses: rdkcentral/cmf-actions/.github/workflows/cla.yml@main + secrets: + PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_ASSISTANT }} \ No newline at end of file diff --git a/accelerator-home-ui/settings.json b/accelerator-home-ui/settings.json index f0a76e6..bb47d7c 100644 --- a/accelerator-home-ui/settings.json +++ b/accelerator-home-ui/settings.json @@ -13,6 +13,6 @@ "log": true, "enableAppSuspended": true, "showVersion": false, - "version": "4.7.19" + "version": "5.0.1" } } diff --git a/accelerator-home-ui/src/App.js b/accelerator-home-ui/src/App.js index 8100928..931730a 100644 --- a/accelerator-home-ui/src/App.js +++ b/accelerator-home-ui/src/App.js @@ -52,6 +52,7 @@ import { Localization, Metrics } from '@firebolt-js/sdk'; import RDKShellApis from './api/RDKShellApis.js'; import Miracast from './api/Miracast.js'; import MiracastNotification from './screens/MiracastNotification.js'; +import NetworkManager from './api/NetworkManagerAPI.js'; var powerState = 'ON'; @@ -66,6 +67,14 @@ var miracast = new Miracast(); export default class App extends Router.App { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _handleAppClose() { this.application.closeApp(); } @@ -75,8 +84,8 @@ export default class App extends Router.App { _setup() { - console.log("accelerator-home-ui version: " + Settings.get("platform", "version")); - console.log("UI setup selfClientName:" + GLOBALS.selfClientName + ", current topmostApp:", GLOBALS.topmostApp); + this.LOG("accelerator-home-ui version: " + JSON.stringify(Settings.get("platform", "version"))); + this.LOG("UI setup selfClientName:" + JSON.stringify(GLOBALS.selfClientName) + ", current topmostApp:" + JSON.stringify(GLOBALS.topmostApp)); Storage.set("ResolutionChangeInProgress", false); Router.startRouter(routes, this); document.onkeydown = e => { @@ -87,10 +96,9 @@ export default class App extends Router.App { function updateAddress() { if (window.navigator.onLine) { - console.log(`is online`); + console.log("is online"); } else { - Storage.set("ipAddress", null); console.log(`is offline`) } } @@ -169,11 +177,11 @@ export default class App extends Router.App { } _captureKey(key) { - console.log("Got keycode : " + JSON.stringify(key.keyCode)) - console.log("powerState ===>", GLOBALS.powerState) + this.LOG("Got keycode : " + JSON.stringify(key.keyCode)) + this.LOG("powerState ===>" + JSON.stringify(GLOBALS.powerState)) if(GLOBALS.powerState !=="ON") { appApi.setPowerState("ON").then(res => { - res.success ? console.log("successfully set the power state to ON from ", GLOBALS.powerState) : console.log("Failure while turning ON the device") + res.success ? this.LOG("successfully set the power state to ON from " + JSON.stringify(GLOBALS.powerState)) : this.LOG("Failure while turning ON the device") }) return true } @@ -312,14 +320,14 @@ export default class App extends Router.App { if (GLOBALS.topmostApp === GLOBALS.selfClientName) { this.tag("Volume").onVolumeMute(); } else { - console.log("muting on some app") + this.LOG("muting on some app") if (Router.getActiveHash() === "applauncher") { - console.log("muting on some app while route is app launcher") + this.LOG("muting on some app while route is app launcher") RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setVisibility(GLOBALS.selfClientName, true) this.tag("Volume").onVolumeMute(); } else { - console.log("muting on some app while route is NOT app launcher") + this.LOG("muting on some app while route is NOT app launcher") RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setVisibility(GLOBALS.selfClientName, true) Router.navigate("applauncher"); @@ -331,14 +339,14 @@ export default class App extends Router.App { if (GLOBALS.topmostApp === GLOBALS.selfClientName) { this.tag("Volume").onVolumeKeyUp(); } else { - console.log("muting on some app") + this.LOG("muting on some app") if (Router.getActiveHash() === "applauncher") { - console.log("muting on some app while route is app launcher") + this.LOG("muting on some app while route is app launcher") RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setVisibility(GLOBALS.selfClientName, true) this.tag("Volume").onVolumeKeyUp(); } else { - console.log("muting on some app while route is NOT app launcher") + this.LOG("muting on some app while route is NOT app launcher") RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setVisibility(GLOBALS.selfClientName, true) Router.navigate("applauncher"); @@ -350,14 +358,14 @@ export default class App extends Router.App { if (GLOBALS.topmostApp === GLOBALS.selfClientName) { this.tag("Volume").onVolumeKeyDown(); } else { - console.log("muting on some app") + this.LOG("muting on some app") if (Router.getActiveHash() === "applauncher") { - console.log("muting on some app while route is app launcher") + this.LOG("muting on some app while route is app launcher") RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setVisibility(GLOBALS.selfClientName, true) this.tag("Volume").onVolumeKeyDown(); } else { - console.log("muting on some app while route is NOT app launcher") + this.LOG("muting on some app while route is NOT app launcher") RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setVisibility(GLOBALS.selfClientName, true) Router.navigate("applauncher"); @@ -372,7 +380,7 @@ export default class App extends Router.App { AvDecodernotificationcall() { thunder.on('org.rdk.DeviceDiagnostics', 'onAVDecoderStatusChanged', notification => { - console.log(new Date().toISOString() + "AvDecoderStatusNotification: ", JSON.stringify(notification)) + this.LOG(new Date().toISOString() + "AvDecoderStatusNotification: " + JSON.stringify(notification)) }) } @@ -381,13 +389,13 @@ export default class App extends Router.App { PersistentStoreApi.get().getValue('ScreenSaverTime', 'timerValue').then(result => { // check if result has value property and if it is not undefined^M if (result && result.value && result.value !== undefined && result.value !== "Off") { - console.log("App PersistentStoreApi screensaver timer value is: " + result.value); + this.LOG("App PersistentStoreApi screensaver timer value is: " + JSON.stringify(result.value)); RDKShellApis.enableInactivityReporting(true).then(() => { RDKShellApis.setInactivityInterval(result.value).then(() => { this.userInactivity = thunder.on('org.rdk.RDKShell', 'onUserInactivity', notification => { - console.log("UserInactivityStatusNotification: ", JSON.stringify(notification)) + this.LOG("UserInactivityStatusNotification: " + JSON.stringify(notification)) appApi.getAvCodeStatus().then(result => { - console.log("Avdecoder", result.avDecoderStatus); + this.LOG("Avdecoder" + JSON.stringify(result.avDecoderStatus)); if ((result.avDecoderStatus === "IDLE" || result.avDecoderStatus === "PAUSE") && GLOBALS.topmostApp === "") { this.$hideImage(1); } @@ -396,19 +404,19 @@ export default class App extends Router.App { }) }); } else { - console.warn("App PersistentStoreApi screensaver timer value is not set or is Off.") + this.WARN("App PersistentStoreApi screensaver timer value is not set or is Off.") RDKShellApis.enableInactivityReporting(false).then(() => { this.userInactivity.dispose(); }) } }).catch(err => { - console.error("App PersistentStoreApi getValue error: " + JSON.stringify(err)); + this.ERR("App PersistentStoreApi getValue error: " + JSON.stringify(err)); RDKShellApis.enableInactivityReporting(false).then(() => { this.userInactivity.dispose(); }) }); }).catch(err => { - console.error("App PersistentStoreApi activation error: " + JSON.stringify(err)); + this.ERR("App PersistentStoreApi activation error: " + JSON.stringify(err)); reject(err); }); } @@ -446,33 +454,34 @@ export default class App extends Router.App { } }).catch(err => this._getPowerStatebeforeReboot()); keyIntercept(GLOBALS.selfClientName).catch(err => { - console.error("App _init keyIntercept err:", JSON.stringify(err)); + this.ERR("App _init keyIntercept err:" + JSON.stringify(err)); }); this.userInactivity(); this._registerFireboltListeners() Keyboard.provide('xrn:firebolt:capability:input:keyboard', new KeyboardUIProvider(this)) - console.log("Keyboard provider registered") + this.LOG("Keyboard provider registered") PinChallenge.provide('xrn:firebolt:capability:usergrant:pinchallenge', new PinChallengeProvider(this)) - console.log("PinChallenge provider registered") + this.LOG("PinChallenge provider registered") AcknowledgeChallenge.provide('xrn:firebolt:capability:usergrant:acknowledgechallenge', new AckChallengeProvider(this)) - console.log("Acknowledge challenge provider registered") + this.LOG("Acknowledge challenge provider registered") appApi.deviceType().then(result => { - console.log("App detected deviceType as:", ((result.devicetype != null) ? result.devicetype : "tv")); - Storage.set("deviceType", ((result.devicetype != null) ? result.devicetype : "tv")); + this.LOG("App detected deviceType as:" + JSON.stringify(((result.devicetype != null) ? result.devicetype : "IpTv"))); + GLOBALS.deviceType = ((result.devicetype != null) ? result.devicetype : "IpTv"); + Storage.set("deviceType", ((result.devicetype != null) ? result.devicetype : "IpTv")); }); thunder.Controller.activate({ callsign: 'org.rdk.UserPreferences' }).then(result => { - console.log("App UserPreferences plugin activation result: " + result) + this.LOG("App UserPreferences plugin activation result: " + JSON.stringify(result)) }).catch(err => { - console.error("App UserPreferences plugin activation error: " + JSON.stringify(err)); + this.ERR("App UserPreferences plugin activation error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, 'PluginError', "Thunder Controller Activate error " + JSON.stringify(err), false, null) }) thunder.Controller.activate({ callsign: 'org.rdk.System' }).then(result => { - console.log("App System plugin activation result: " + result) + this.LOG("App System plugin activation result: " + JSON.stringify(result)) appApi.setNetworkStandbyMode().then(result => { if (!result.success) { - console.warn("App RFC setNetworkStandbyMode returned false; trying updated API.") + this.WARN("App RFC setNetworkStandbyMode returned false; trying updated API.") let param = { wakeupSources: [ { @@ -488,15 +497,15 @@ export default class App extends Router.App { } }) }).catch(err => { - console.error("App System plugin activation error: " + JSON.stringify(err)); + this.ERR("App System plugin activation error: " + JSON.stringify(err)); }) appApi.getPluginStatus("org.rdk.DeviceDiagnostics").then(res => { - console.log("App DeviceDiagnostics state:", res[0].state) + this.LOG("App DeviceDiagnostics state:" + JSON.stringify(res[0].state)) if (res[0].state === "deactivated") { thunder.Controller.activate({ callsign: 'org.rdk.DeviceDiagnostics' }).then(() => { this.AvDecodernotificationcall(); }).catch(err => { - console.error("App DeviceDiagnostics plugin activation error: " + JSON.stringify(err)); + this.ERR("App DeviceDiagnostics plugin activation error: " + JSON.stringify(err)); }) } else { @@ -515,8 +524,8 @@ export default class App extends Router.App { GLOBALS.Setup=Storage.get("setup") Storage.set("lastVisitedRoute", "menu"); //setting to menu so that it will be always defaulted to #menu GLOBALS.LastvisitedRoute="menu"; - appApi.enableDisplaySettings().then(res => { console.log(`results : ${JSON.stringify(res)}`) }).catch(err => { - console.error("error while enabling displaysettings:" + JSON.stringify(err)); + appApi.enableDisplaySettings().then(res => { this.LOG("results : " + JSON.stringify(res)) }).catch(err => { + this.ERR("error while enabling displaysettings:" + JSON.stringify(err)); }) appApi.cobaltStateChangeEvent() @@ -526,7 +535,7 @@ export default class App extends Router.App { try { appApi.getSerialNumber().then(res => { serialNumber = res; - console.log("App getSerialNumber result:", serialNumber); + this.LOG("App getSerialNumber result:" + JSON.stringify(serialNumber)); appApi.getModelName().then(modelName => { let friendlyName = modelName + "_" + serialNumber; this.xcastApi.setFriendlyName(friendlyName).then( async (result) => { @@ -568,23 +577,23 @@ export default class App extends Router.App { await xcastApi.registerApplications(params).then(res=>{ }) }) - console.log("Xcast register app param " + JSON.stringify(params)) + this.LOG("Xcast register app param " + JSON.stringify(params)) }) } catch (error) { - console.error( "plugin check and registerapllication error for register" +error) + this.ERR("plugin check and registerapllication error for register" + JSON.stringify(error)) } - console.log("App XCAST setFriendlyName result:", result); + this.LOG("App XCAST setFriendlyName result:" + JSON.stringify(result)); }).catch(error => { - console.error("App Error setting friendlyName:", error); + this.ERR("App Error setting friendlyName:" + JSON.stringify(error)); }); }).catch(error => { - console.error("App Error retrieving modelName:", error); + this.ERR("App Error retrieving modelName:" + JSON.stringify(error)); }); }).catch(error => { - console.error("App Error getSerialNumber:", error); + this.ERR("App Error getSerialNumber:" + JSON.stringify(error)); }); } catch (error) { - console.log(error); + this.ERR(JSON.stringify(error)); } if (result) { this.registerXcastListeners() @@ -592,7 +601,7 @@ export default class App extends Router.App { }) thunder.on('Controller.1', 'all', noti => { - console.log("App controller notification:", noti) + this.LOG("App controller notification:" + JSON.stringify(noti)) if ((noti.data.url && noti.data.url.slice(-5) === "#boot") || (noti.data.httpstatus && noti.data.httpstatus != 200 && noti.data.httpstatus != -1)) { // to exit metro apps by pressing back key & to auto exit webapp if httpstatus is not 200 appApi.exitApp(GLOBALS.topmostApp); } @@ -619,7 +628,7 @@ export default class App extends Router.App { if (noti.callsign.startsWith("Amazon")) { params.applicationName = "AmazonInstantVideo"; } - console.log("App Controller state change to xcast: ", JSON.stringify(params)); + this.LOG("App Controller state change to xcast: " + JSON.stringify(params)); this.xcastApi.onApplicationStateChanged(params); params = null; } @@ -628,16 +637,21 @@ export default class App extends Router.App { } if (noti.callsign === "org.rdk.MiracastPlayer") { if(noti.data.state==="activated"){ - console.log("subscribing the events for player") + this.LOG("subscribing the events for player") this.SubscribeToMiracastPlayer() } } if (noti.callsign === "org.rdk.MiracastService") { if(noti.data.state==="activated"){ - console.log("subscribing the events for Service") + this.LOG("subscribing the events for Service") this.SubscribeToMiracastService() } } + if (noti.callsign === "org.rdk.NetworkManager") { + if(noti.data.state==="activated"){ + this.SubscribeToNetworkManager() + } + } }) this._subscribeToRDKShellNotifications() appApi.getPluginStatus("Cobalt").then(() => { @@ -645,9 +659,9 @@ export default class App extends Router.App { JSON.parse(JSON.stringify(appListInfo)).forEach(appInfo => { if (Object.prototype.hasOwnProperty.call(appInfo, "applicationType") && appInfo.applicationType.startsWith("YouTube") && Object.prototype.hasOwnProperty.call(appInfo, "uri") && appInfo.uri.length) { thunder.Controller.clone({ callsign: "Cobalt", newcallsign: appInfo.applicationType }).then(result => { - console.log("App Controller.clone Cobalt as " + appInfo.applicationType + " done.", result); + this.LOG("App Controller.clone Cobalt as " + JSON.stringify(appInfo.applicationType) + " done." + JSON.stringify(result)); }).catch(err => { - console.error("App Controller clone Cobalt for " + appInfo.applicationType + " failed: ", err); + this.ERR("App Controller clone Cobalt for " + JSON.stringify(appInfo.applicationType) + " failed: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", `Controller clone Cobalt for ${appInfo.applicationType} failed: ${err}`, false, null) // TODO: hide YouTube Icon and listing from Menu, AppCarousel, Channel overlay and EPG page. }) @@ -655,7 +669,7 @@ export default class App extends Router.App { appApi.getPluginStatus(appInfo.applicationType).then(res => { if (res[0].state !== "deactivated") { thunder.Controller.deactivate({ callsign: appInfo.applicationType }).catch(err => { - console.error("App Controller.deactivate " + appInfo.applicationType + " failed. It may not work.", err); + this.ERR("App Controller.deactivate " + JSON.stringify(appInfo.applicationType) + " failed. It may not work." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "pluginError", `App Controller.deactivate failed for ${appInfo.applicationType} with ${err}`, false, null) }) } @@ -667,11 +681,11 @@ export default class App extends Router.App { thunder.call('Controller', `configuration@${appInfo.applicationType}`, result).then(() => { Storage.set(appInfo.applicationType + "DefaultURL", appInfo.uri + "?"); // Make sure that appListInfo.js has only base url. }).catch(err => { - console.error("App Controller.configuration@" + appInfo.applicationType + " set failed. It may not work." + JSON.stringify(err)); + this.ERR("App Controller.configuration@" + JSON.stringify(appInfo.applicationType) + " set failed. It may not work." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "pluginError", `App Controller.configuration for ${appInfo.applicationType} set failed. It may not work. ${JSON.stringify(err)}`, false, null) }) }).catch(err => { - console.error("App Controller.configuration@" + appInfo.applicationType + " get failed. It may not work." + JSON.stringify(err)); + this.ERR("App Controller.configuration@" + JSON.stringify(appInfo.applicationType) + " get failed. It may not work." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "pluginError", `App Controller.configuration@ for ${appInfo.applicationType} failed with ${JSON.stringify(err)}`, false, null) }) } else { @@ -679,19 +693,19 @@ export default class App extends Router.App { Storage.set(appInfo.applicationType + "DefaultURL", (res[0].configuration.url.includes('?') ? res[0].configuration.url : res[0].configuration.url + "?")); } }).catch(err => { - console.error("App getPluginStatus " + appInfo.applicationType + " Error: " + JSON.stringify(err)); + this.ERR("App getPluginStatus " + JSON.stringify(appInfo.applicationType) + " Error: " + JSON.stringify(err)); }) } }); }).catch(err => { - console.error("App getPluginStatus Cobalt error: ", err); + this.ERR("App getPluginStatus Cobalt error: " + JSON.stringify(err)); }) //video info change events begin here--------------------- /******************** RDKUI-341 CHANGES - DEEP SLEEP/LIGHT SLEEP **************************/ this._subscribeToControlNotifications() let cachedPowerState = Storage.get('SLEEPING'); - console.log('cached power state', cachedPowerState) - console.log(typeof cachedPowerState) + this.LOG("cached power state" + JSON.stringify(cachedPowerState)) + this.LOG(typeof cachedPowerState) if (cachedPowerState) { appApi.getWakeupReason().then(result => { if (result.result.wakeupReason !== 'WAKEUP_REASON_UNKNOWN') { @@ -700,10 +714,21 @@ export default class App extends Router.App { }) appApi.setPowerState(cachedPowerState).then(result => { if (result.success) { - console.log("successfully set powerstate to: " + cachedPowerState) + this.LOG("successfully set powerstate to: " + JSON.stringify(cachedPowerState)) } }) } + appApi.getPluginStatus('org.rdk.NetworkManager').then(result => { + if (result[0].state === "activated") + { + this.SubscribeToNetworkManager() + } + else + { + NetworkManager.activate().then((res)=>{ + }).catch((err) => console.error(err)) + } + }) appApi.getPluginStatus('org.rdk.MiracastPlayer').then(result => { if (result[0].state === "activated") { @@ -712,8 +737,8 @@ export default class App extends Router.App { else { miracast.activatePlayer().then((res)=>{ - console.log("activating the miracst player from app.js "+ res) - }).catch((err) => console.error(err)) + this.LOG("activating the miracst player from app.js " + JSON.stringify(res)) + }).catch((err) => this.ERR(JSON.stringify(err))) } }) appApi.getPluginStatus('org.rdk.MiracastService').then(result => { @@ -736,8 +761,8 @@ export default class App extends Router.App { await miracast.setEnable(true) } }) - console.log("activating the miracst Service from app.js "+ res) - }).catch((err) => console.error(err)) + this.LOG("activating the miracst Service from app.js " + JSON.stringify(res)) + }).catch((err) => this.ERR(JSON.stringify(err))) } }) /******************** RDKUI-303 - PAGE VISIBILITY API **************************/ @@ -751,23 +776,23 @@ export default class App extends Router.App { setTimeout(() => { xcastApi.getFriendlyName().then(res => { getfriendlyname = res.friendlyname; - console.log("XcastApi getFriendlyName :" + getfriendlyname); + this.LOG("XcastApi getFriendlyName :" + JSON.stringify(getfriendlyname)); }).catch(err => { - console.error('XcastApi getFriendlyName Error: ', err); + this.ERR("XcastApi getFriendlyName Error: " + JSON.stringify(err)); }) cecApi.getOSDName().then(result => { getosdname = result.name; - console.log("CECApi getOSDName :" + getosdname); + this.LOG("CECApi getOSDName :" + JSON.stringify(getosdname)); if (getfriendlyname !== getosdname) { cecApi.setOSDName(getfriendlyname); } }).catch(err => { - console.error('CECApi getOSDName Error :', err); + this.ERR("CECApi getOSDName Error :" + JSON.stringify(err)); }) }, 5000); cecApi.getActiveSourceStatus().then((res) => { Storage.set("UICacheCECActiveSourceStatus", res); - console.log("App getActiveSourceStatus: " + res + " UICacheCECActiveSourceStatus:" + Storage.get("UICacheCECActiveSourceStatus")); + this.LOG("App getActiveSourceStatus: " + JSON.stringify(res) + " UICacheCECActiveSourceStatus:" + JSON.stringify(Storage.get("UICacheCECActiveSourceStatus"))); }); } else @@ -777,25 +802,25 @@ export default class App extends Router.App { setTimeout(() => { xcastApi.getFriendlyName().then(res => { getfriendlyname = res.friendlyname; - console.log("XcastApi getFriendlyName :" + getfriendlyname); + this.LOG("XcastApi getFriendlyName :" + JSON.stringify(getfriendlyname)); }).catch(err => { - console.error('XcastApi getFriendlyName Error: ', err); + this.ERR("XcastApi getFriendlyName Error: " + JSON.stringify(err)); }) cecApi.getOSDName().then(result => { getosdname = result.name; - console.log("CECApi getOSDName :" + getosdname); + this.LOG("CECApi getOSDName :" + JSON.stringify(getosdname)); if (getfriendlyname !== getosdname) { cecApi.setOSDName(getfriendlyname); } }).catch(err => { - console.error('CECApi getOSDName Error :', err); + this.ERR("CECApi getOSDName Error :" + JSON.stringify(err)); }) }, 5000); cecApi.getActiveSourceStatus().then((res) => { Storage.set("UICacheCECActiveSourceStatus", res); - console.log("App getActiveSourceStatus: " + res + " UICacheCECActiveSourceStatus:" + Storage.get("UICacheCECActiveSourceStatus")); + this.LOG("App getActiveSourceStatus: " + JSON.stringify(res) + " UICacheCECActiveSourceStatus:" + JSON.stringify(Storage.get("UICacheCECActiveSourceStatus"))); }); - }).catch((err) => console.log(err)) + }).catch((err) => this.ERR(JSON.stringify(err))) } }) this._subscribeToIOPortNotifications() @@ -803,23 +828,50 @@ export default class App extends Router.App { this._updateLanguageToDefault() } + SubscribeToNetworkManager(){ + thunder.on('org.rdk.NetworkManager', 'onInterfaceStateChange', data => { + console.warn("onInterfaceStateChange:", data); + }); + thunder.on('org.rdk.NetworkManager', 'onAddressChange', data => { + console.warn(" onAddressChange:", data); + }); + thunder.on('org.rdk.NetworkManager', 'onActiveInterfaceChange', data => { + console.warn("onActiveInterfaceChange:", data); + }); + thunder.on('org.rdk.NetworkManager', 'onInternetStatusChange', data => { + if(data.status === "FULLY_CONNECTED") + { + GLOBALS.IsConnectedToInternet = true + } + console.warn("onInternetStatusChange:", data); + }); + thunder.on('org.rdk.NetworkManager', 'onAvailableSSIDs', data => { + console.warn(" onAvailableSSIDs:", data); + }); + thunder.on('org.rdk.NetworkManager', 'onWiFiStateChange', data => { + console.warn("onWiFiStateChange:", data); + }); + thunder.on('org.rdk.NetworkManager', 'onWiFiSignalStrengthChange', data => { + console.warn("onWiFiSignalStrengthChange:", data); + }); + + } SubscribeToMiracastService() { thunder.on('org.rdk.MiracastService.1', 'onClientConnectionRequest', data => { - console.log('onClientConnectionRequest ' + JSON.stringify(data)); - this.tag("MiracastNotification").notify(data) - if(GLOBALS.topmostApp===GLOBALS.selfClientName) - { - Router.focusWidget("MiracastNotification") - } - - else{ - this._moveApptoFront(GLOBALS.selfClientName, true) - Router.navigate("applauncher"); - Router.focusWidget("MiracastNotification") - } + this.LOG('onClientConnectionRequest ' + JSON.stringify(data)); + this.tag("MiracastNotification").notify(data) + if(GLOBALS.topmostApp===GLOBALS.selfClientName) + { + Router.focusWidget("MiracastNotification") + } + else{ + this._moveApptoFront(GLOBALS.selfClientName, true) + Router.navigate("applauncher"); + Router.focusWidget("MiracastNotification") + } }); thunder.on('org.rdk.MiracastService.1', 'onLaunchRequest', data => { - miracast.playRequest( + miracast.playRequest( data.device_parameters.source_dev_ip, data.device_parameters.source_dev_mac , data.device_parameters.source_dev_name, @@ -828,8 +880,8 @@ export default class App extends Router.App { 0, 1920, 1080, - ) - console.log('onLaunchRequest ' + JSON.stringify(data)); + ) + this.LOG('onLaunchRequest ' + JSON.stringify(data)); }); thunder.on('org.rdk.MiracastService.1', 'onClientConnectionError', data => { if(data.name===GLOBALS.Miracastclientdevicedetails.name) @@ -841,33 +893,34 @@ export default class App extends Router.App { this.tag("Fail").notify({title:Language.translate("Miracast Status"),msg:`${Language.translate("Reason Code :")} ${data.error_code} ${Language.translate("Reason :")}${data.reason} `}) Router.focusWidget("Fail") } - else{ this._moveApptoFront(GLOBALS.selfClientName, true) Router.navigate("applauncher"); this.tag("Fail").notify({title:Language.translate("Miracast Status"),msg:`${Language.translate("Reason Code :")} ${data.error_code} ${Language.translate("Reason :")}${data.reason} `}) Router.focusWidget("Fail") } - console.log('onClientConnectionError ' + JSON.stringify(data)); + this.LOG('onClientConnectionError ' + JSON.stringify(data)); }); } SubscribeToMiracastPlayer() { thunder.on('org.rdk.MiracastPlayer.1', 'onStateChange', data => { + this.LOG('onStateChange ' + JSON.stringify(data)); GLOBALS.Miracastclientdevicedetails=data if(data.state==="PLAYING") { if (GLOBALS.topmostApp != GLOBALS.selfClientName) { appApi.exitApp(GLOBALS.topmostApp).then(()=>{ - RDKShellApis.setVisibility(GLOBALS.topmostApp,GLOBALS.topmostApp,false) miracast.updatePlayerState(data.mac,data.state,data.reason_code,data.reason) + GLOBALS.topmostApp="MiracastPlayer" }).catch(err => { - console.log("exitapp err: " + err) + this.ERR("exitapp err: " + JSON.stringify(err)) });} else{ RDKShellApis.setVisibility(GLOBALS.selfClientName,GLOBALS.selfClientName,false) miracast.updatePlayerState(data.mac,data.state,data.reason_code,data.reason) + GLOBALS.topmostApp="MiracastPlayer" } } @@ -876,57 +929,47 @@ export default class App extends Router.App { RDKShellApis.setVisibility(GLOBALS.selfClientName,true) Router.navigate(GLOBALS.LastvisitedRoute); if(data.reason_code!=200){ - if(GLOBALS.topmostApp===GLOBALS.selfClientName) - { - this.tag("Fail").notify({title:Language.translate("Miracast Status"),msg:`${Language.translate("Reason Code :")} ${data.reason_code} ${Language.translate("Reason :")}${data.reason} `}) - Router.focusWidget("Fail") - } - - else{ - this._moveApptoFront(GLOBALS.selfClientName, true) - Router.navigate("applauncher"); this.tag("Fail").notify({title:Language.translate("Miracast Status"),msg:`${Language.translate("Reason Code :")} ${data.reason_code} ${Language.translate("Reason :")}${data.reason} `}) Router.focusWidget("Fail") - } } miracast.updatePlayerState(data.mac,data.state,data.reason_code,data.reason) + GLOBALS.Miracastclientdevicedetails={mac: null,name: null,reason_code: null,state:null} + GLOBALS.topmostApp=GLOBALS.selfClientName } - console.log('onStateChange ' + JSON.stringify(data)); }); } - _subscribeToRDKShellNotifications() { thunder.on('org.rdk.RDKShell', 'onApplicationActivated', data => { - console.warn("[RDKSHELLEVT] onApplicationActivated:", data); + this.WARN("[RDKSHELLEVT] onApplicationActivated:" + JSON.stringify(data)); }); thunder.on('org.rdk.RDKShell', 'onApplicationConnected', data => { - console.warn("[RDKSHELLEVT] onApplicationConnected:", data); + this.WARN("[RDKSHELLEVT] onApplicationConnected:" + JSON.stringify(data)); }); thunder.on('org.rdk.RDKShell', 'onApplicationDisconnected', data => { - console.warn("[RDKSHELLEVT] onApplicationDisconnected:", data); + this.WARN("[RDKSHELLEVT] onApplicationDisconnected:" + JSON.stringify(data)); }); thunder.on('org.rdk.RDKShell', 'onApplicationFirstFrame', data => { - console.warn("[RDKSHELLEVT] onApplicationFirstFrame:", data); + this.WARN("[RDKSHELLEVT] onApplicationFirstFrame:" + JSON.stringify(data)); }); thunder.on('org.rdk.RDKShell', 'onApplicationLaunched', data => { - console.warn("[RDKSHELLEVT] onApplicationLaunched:", data); + this.WARN("[RDKSHELLEVT] onApplicationLaunched:" + JSON.stringify(data)); if ((data.client != GLOBALS.selfClientName) && (GLOBALS.topmostApp === GLOBALS.selfClientName)) { RDKShellApis.setVisibility(GLOBALS.selfClientName, false); GLOBALS.topmostApp = data.client; } }); thunder.on('org.rdk.RDKShell', 'onApplicationResumed', data => { - console.warn("[RDKSHELLEVT] onApplicationResumed:", data); + this.WARN("[RDKSHELLEVT] onApplicationResumed:" + JSON.stringify(data)); if ((data.client != GLOBALS.selfClientName) && (GLOBALS.topmostApp === GLOBALS.selfClientName)) { RDKShellApis.setVisibility(GLOBALS.selfClientName, false); GLOBALS.topmostApp = data.client; } }); thunder.on('org.rdk.RDKShell', 'onApplicationSuspended', data => { - console.warn("[RDKSHELLEVT] onApplicationSuspended:", data); + this.WARN("[RDKSHELLEVT] onApplicationSuspended:" + JSON.stringify(data)); }); thunder.on('org.rdk.RDKShell', 'onApplicationTerminated', data => { - console.warn("[RDKSHELLEVT] onApplicationTerminated:", data); + this.WARN("[RDKSHELLEVT] onApplicationTerminated:" + JSON.stringify(data)); if ((data.client != GLOBALS.selfClientName) && (GLOBALS.topmostApp != GLOBALS.selfClientName)) { appApi.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); @@ -934,17 +977,17 @@ export default class App extends Router.App { } }); thunder.on('org.rdk.RDKShell', 'onHibernated', data => { - console.warn("[RDKSHELLEVT] onHibernated:", data); - if(data.callsign.startsWith('YouTube')) + this.WARN("[RDKSHELLEVT] onHibernated:" + JSON.stringify(data)); + if(data.callsign && data.callsign.startsWith('YouTube')) { - RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.callsign }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.callsign }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.callsign }).then(res=>{console.warn(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.callsign }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.callsign }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.callsign }).then(res=>{this.WARN(JSON.stringify(res))}) } if(data.success) { if ((GLOBALS.topmostApp === data.client) - && (GLOBALS.selfClientName === "ResidentApp"|| GLOBALS.selfClientName === "FireboltMainApp-refui")) { + && (GLOBALS.selfClientName === "ResidentApp"|| GLOBALS.selfClientName === "FireboltMainApp-refui") && GLOBALS.Miracastclientdevicedetails.state != "PLAYING") { appApi.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); }); @@ -952,36 +995,39 @@ export default class App extends Router.App { } }); thunder.on('org.rdk.RDKShell', 'onRestored', data => { - console.warn("[RDKSHELLEVT] onRestored:", data); - if(data.callsign.startsWith('YouTube') ) + this.WARN("[RDKSHELLEVT] onRestored:" + JSON.stringify(data)); + if(data.callsign && data.callsign.startsWith('YouTube') ) { - RDKShellApis.addKeyIntercepts({"intercepts":[{"keys":[{"keyCode":173,"modifiers":[]},{"keyCode":174,"modifiers":[]},{"keyCode":175,"modifiers":[]}],"client": data.callsign }]}).then(res=>{console.warn(JSON.stringify(res))}) + RDKShellApis.addKeyIntercepts({"intercepts":[{"keys":[{"keyCode":173,"modifiers":[]},{"keyCode":174,"modifiers":[]},{"keyCode":175,"modifiers":[]}],"client": data.callsign }]}).then(res=>{this.WARN(JSON.stringify(res))}) } }); thunder.on('org.rdk.RDKShell', 'onDestroyed', data => { - console.warn("[RDKSHELLEVT] onDestroyed:", data); + this.WARN("[RDKSHELLEVT] onDestroyed:" + JSON.stringify(data)); // No need to handle this when UI is in Firebolt compatible mode. - if(data.client.startsWith('YouTube')) + if(data.client && data.client.startsWith('YouTube')) { - RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) } if ((GLOBALS.topmostApp === data.client) - && (GLOBALS.selfClientName === "ResidentApp"|| GLOBALS.selfClientName === "FireboltMainApp-refui")) { + && (GLOBALS.selfClientName === "ResidentApp"|| GLOBALS.selfClientName === "FireboltMainApp-refui") && GLOBALS.Miracastclientdevicedetails.state != "PLAYING") { appApi.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); }); } }); thunder.on('org.rdk.RDKShell', 'onLaunched', data => { - console.warn("[RDKSHELLEVT] onLaunched:", data); - miracast.stopRequest(GLOBALS.Miracastclientdevicedetails.mac,GLOBALS.Miracastclientdevicedetails.name,300) + this.WARN("[RDKSHELLEVT] onLaunched:" + JSON.stringify(data)); + if(GLOBALS.Miracastclientdevicedetails.mac !=null && GLOBALS.Miracastclientdevicedetails.name !=null) + { + miracast.stopRequest(GLOBALS.Miracastclientdevicedetails.mac,GLOBALS.Miracastclientdevicedetails.name,300) + } if ((data.launchType === "activate") || (data.launchType === "resume")) { // Change (Tracked TopMost) UI's visibility to false only for other apps. if(data.client.startsWith('YouTube') ) { - RDKShellApis.addKeyIntercepts({"intercepts":[{"keys":[{"keyCode":173,"modifiers":[]},{"keyCode":174,"modifiers":[]},{"keyCode":175,"modifiers":[]}],"client": data.client }]}).then(res=>{console.warn(JSON.stringify(res))}) + RDKShellApis.addKeyIntercepts({"intercepts":[{"keys":[{"keyCode":173,"modifiers":[]},{"keyCode":174,"modifiers":[]},{"keyCode":175,"modifiers":[]}],"client": data.client }]}).then(res=>{this.WARN(JSON.stringify(res))}) } if ((data.client != GLOBALS.selfClientName) && ((GLOBALS.topmostApp === "ResidentApp") @@ -1001,12 +1047,12 @@ export default class App extends Router.App { // It will be done at RefUI's 'foreground' event handler. if(data.client.startsWith('YouTube')) { - RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) } if ((GLOBALS.topmostApp === data.client) - && (GLOBALS.selfClientName === "ResidentApp")) { + && (GLOBALS.selfClientName === "ResidentApp") && GLOBALS.Miracastclientdevicedetails.state != "PLAYING") { appApi.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); }); @@ -1014,50 +1060,49 @@ export default class App extends Router.App { } }); thunder.on('org.rdk.RDKShell', 'onSuspended', data => { - console.warn("[RDKSHELLEVT] onSuspended:", data); + this.WARN("[RDKSHELLEVT] onSuspended:" + JSON.stringify(data)); // No need to handle this here when UI is in Firebolt compatible mode. if(data.client.startsWith('YouTube')) { - RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) } if ((GLOBALS.topmostApp === data.client) - && (GLOBALS.selfClientName === "ResidentApp" || GLOBALS.selfClientName === "FireboltMainApp-refui")) { + && (GLOBALS.selfClientName === "ResidentApp" || GLOBALS.selfClientName === "FireboltMainApp-refui") && GLOBALS.Miracastclientdevicedetails.state != "PLAYING") { appApi.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); }); } }); thunder.on('org.rdk.RDKShell', 'onWillDestroy', data => { - console.warn("[RDKSHELLEVT] onWillDestroy:", data); + this.WARN("[RDKSHELLEVT] onWillDestroy:" + JSON.stringify(data)); }); thunder.on('org.rdk.RDKShell', 'onPluginSuspended', data => { - console.warn("[RDKSHELLEVT] onPluginSuspended:", data); + this.WARN("[RDKSHELLEVT] onPluginSuspended:" + JSON.stringify(data)); if(data.client.startsWith('YouTube')) { - RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) - RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{console.warn(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 173, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 174, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) + RDKShellApis.removeKeyIntercept({"keyCode": 175, "modifiers": [],"client": data.client }).then(res=>{this.WARN(JSON.stringify(res))}) } if ((GLOBALS.topmostApp === data.client) - && (GLOBALS.selfClientName === "ResidentApp" || GLOBALS.selfClientName === "FireboltMainApp-refui")) { + && (GLOBALS.selfClientName === "ResidentApp" || GLOBALS.selfClientName === "FireboltMainApp-refui") && GLOBALS.Miracastclientdevicedetails.state != "PLAYING") { appApi.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); }); } }); thunder.on('org.rdk.RDKShell', 'onBlur', data => { - console.warn("[RDKSHELLEVT] onBlur:", data); + this.WARN("[RDKSHELLEVT] onBlur:" + JSON.stringify(data)); }); thunder.on('org.rdk.RDKShell', 'onFocus', data => { - console.warn("[RDKSHELLEVT] onFocus:", data); + this.WARN("[RDKSHELLEVT] onFocus:" + JSON.stringify(data)); }); } - _subscribeToControlNotifications() { thunder.on('org.rdk.tv.ControlSettings.1', 'videoFormatChanged', notification => { - console.log("videoFormatChangedNotification: ", JSON.stringify(notification)) + this.LOG("videoFormatChangedNotification: " + JSON.stringify(notification)) if (Router.getActiveWidget() == this.widgets.videoinfochange) { this.widgets.videoinfochange.update(" New videoFormat : " + notification.currentVideoFormat, true) } @@ -1068,7 +1113,7 @@ export default class App extends Router.App { }) thunder.on('org.rdk.tv.ControlSettings.1', 'videoFrameRateChanged', notification => { - console.log("videoFrameRateChangedNotification: ", JSON.stringify(notification)) + this.LOG("videoFrameRateChangedNotification: " + JSON.stringify(notification)) if (Router.getActiveWidget() == this.widgets.videoinfochange) { this.widgets.videoinfochange.update(" New videoFrameRate : " + notification.currentVideoFrameRate, true) } @@ -1079,7 +1124,7 @@ export default class App extends Router.App { }) thunder.on('org.rdk.tv.ControlSettings.1', 'videoResolutionChanged', notification => { - console.log("videoResolutionChangedNotification: ", JSON.stringify(notification)) + this.LOG("videoResolutionChangedNotification: " + JSON.stringify(notification)) if (Router.getActiveWidget() == this.widgets.videoinfochange) { this.widgets.videoinfochange.update(" New video resolution : " + notification.currentVideoFormat, true) } @@ -1091,16 +1136,16 @@ export default class App extends Router.App { thunder.on('Controller', 'statechange', notification => { // get plugin status - console.warn("Controller statechange Notification : " + JSON.stringify(notification)) + this.WARN("Controller statechange Notification : " + JSON.stringify(notification)) if (notification && (notification.callsign.startsWith("YouTube") || notification.callsign === 'Amazon' || notification.callsign === 'LightningApp' || notification.callsign === 'HtmlApp' || notification.callsign === 'Netflix') && (notification.state == 'Deactivation' || notification.state == 'Deactivated')) { - console.log(`${notification.callsign} status = ${notification.state}`) - console.log(">>notification.callsign: ", notification.callsign, " applicationType: ", GLOBALS.topmostApp); + this.LOG(notification.callsign + " status = " + notification.state) + this.LOG(">>notification.callsign: " + notification.callsign + " applicationType: " + GLOBALS.topmostApp); if (Router.getActiveHash().startsWith("tv-overlay") || Router.getActiveHash().startsWith("overlay") || Router.getActiveHash().startsWith("applauncher")) { //navigate to last visited route when exiting from any app - console.log("navigating to lastVisitedRoute") + this.LOG("navigating to lastVisitedRoute") Router.navigate((GLOBALS.LastvisitedRoute)); } if (notification.callsign === GLOBALS.topmostApp) { //only launch residentApp iff notification is from currentApp - console.log(notification.callsign + " is in: " + notification.state + " state, and application type in Storage is still: " + GLOBALS.topmostApp + " calling launchResidentApp") + this.LOG(notification.callsign + " is in: " + notification.state + " state, and application type in Storage is still: " + GLOBALS.topmostApp + " calling launchResidentApp") appApi.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); }); @@ -1109,7 +1154,7 @@ export default class App extends Router.App { if (notification && (notification.callsign === 'org.rdk.HdmiCecSource' && notification.state === 'Activated')) { this.advanceScreen = Router.activePage() if (typeof this.advanceScreen.performOTPAction === 'function') { - console.log('otp action') + this.LOG('otp action') this.advanceScreen.performOTPAction() } } @@ -1122,30 +1167,30 @@ export default class App extends Router.App { Storage.set('Netflix_ESN', res) }) thunder.on('Netflix', 'notifyeventchange', notification => { - console.log(`NETFLIX : notifyEventChange notification = `, JSON.stringify(notification)); + this.LOG("NETFLIX : notifyEventChange notification = " + JSON.stringify(notification)); if (notification.EventName === "rendered") { Router.navigate('menu') if (Storage.get("NFRStatus")) { thunder.call("Netflix.1", "nfrstatus", { "params": "enable" }).then(nr => { - console.log(`Netflix : nfr enable results in ${nr}`) + this.LOG("Netflix : nfr enable results in " + JSON.stringify(nr)) }).catch(nerr => { - console.error(`Netflix : error while updating nfrstatus ${nerr}`) + this.ERR("Netflix : error while updating nfrstatus " + JSON.stringify(nerr)) }) } else { thunder.call("Netflix.1", "nfrstatus", { "params": "disable" }).then(nr => { - console.log(`Netflix : nfr disable results in ${nr}`) + this.LOG("Netflix : nfr disable results in " + JSON.stringify(nr)) }).catch(nerr => { - console.error(`Netflix : error while updating nfrstatus ${nerr}`) + this.ERR("Netflix : error while updating nfrstatus " + JSON.stringify(nerr)) }) } - RDKShellApis.setVisibility(GLOBALS.selfClientName, false); + RDKShellApis.setVisibility(GLOBALS.selfClientName, false); } if (notification.EventName === "requestsuspend") { this.deactivateChildApp('Netflix') } if (notification.EventName === "updated") { - console.log(`Netflix : xxxxxxxxxxxxxxxxxx Updated Event Trigger xxxxxxxxxxxxxxxxxxxx`) + this.LOG("Netflix : xxxxxxxxxxxxxxxxxx Updated Event Trigger xxxxxxxxxxxxxxxxxxxx") appApi.getNetflixESN() .then(res => { Storage.set('Netflix_ESN', res) @@ -1158,185 +1203,184 @@ export default class App extends Router.App { } }); } - _subscribeToIOPortNotifications() { //UNPLUG/PLUG HDMI let self = this; thunder.on("org.rdk.HdcpProfile", "onDisplayConnectionChanged", notification => { - GLOBALS.previousapp_onActiveSourceStatusUpdated=null - console.log(new Date().toISOString() + " onDisplayConnectionChanged " + notification.HDCPStatus) + GLOBALS.previousapp_onActiveSourceStatusUpdated = null + this.LOG(new Date().toISOString() + " onDisplayConnectionChanged " + JSON.stringify(notification.HDCPStatus)) let temp = notification.HDCPStatus if (!Storage.get("ResolutionChangeInProgress") && (temp.isConnected != Storage.get("UICacheonDisplayConnectionChanged"))) { if (temp.isConnected) { let currentApp = GLOBALS.topmostApp - if(GLOBALS.previousapp_onDisplayConnectionChanged !== null) { - currentApp=GLOBALS.previousapp_onDisplayConnectionChanged - } - if(currentApp === "ResidentApp" && GLOBALS.Setup) { + if (GLOBALS.previousapp_onDisplayConnectionChanged !== null) { + currentApp = GLOBALS.previousapp_onDisplayConnectionChanged + } + if (currentApp === "ResidentApp" && GLOBALS.Setup) { Router.navigate(GLOBALS.LastvisitedRoute); } let launchLocation = Storage.get(currentApp + "LaunchLocation") - console.log("App HdcpProfile onDisplayConnectionChanged current app is:" + currentApp) + this.LOG("App HdcpProfile onDisplayConnectionChanged current app is:" + JSON.stringify(currentApp)) let params = { launchLocation: launchLocation, appIdentifier: self.appIdentifiers[currentApp] } - if (currentApp.startsWith("YouTube")||currentApp.startsWith("Netflix")) { + if (currentApp.startsWith("YouTube") || currentApp.startsWith("Netflix")) { params["url"] = Storage.get(currentApp + "DefaultURL"); appApi.getPluginStatus(currentApp).then(result => { const isAppSuspendedEnabled = Settings.get("platform", "enableAppSuspended"); const expectedState = isAppSuspendedEnabled ? ["hibernated", "suspended"] : ["deactivated"]; - if (expectedState.includes(result[0].state)) { - appApi.launchApp(currentApp, params) - .then(()=>GLOBALS.previousapp_onDisplayConnectionChanged=null) - .catch(err => { - Router.navigate(GLOBALS.LastvisitedRoute) - console.error(`Error in launching ${currentApp} : ` + JSON.stringify(err)) - }); + if (expectedState.includes(result[0].state)) { + appApi.launchApp(currentApp, params) + .then(() => GLOBALS.previousapp_onDisplayConnectionChanged = null) + .catch(err => { + Router.navigate(GLOBALS.LastvisitedRoute) + this.ERR("Error in launching " + JSON.stringify(currentApp) + " : " + JSON.stringify(err)) + }); } else { - console.log("App HdcpProfile onDisplayConnectionChanged skipping; " + currentApp + " is already: " + JSON.stringify(result[0].state)); + this.LOG("App HdcpProfile onDisplayConnectionChanged skipping; " + currentApp + " is already: " + JSON.stringify(result[0].state)); } }) } } else { let currentApp = GLOBALS.topmostApp - if (currentApp.startsWith("YouTube")||currentApp.startsWith("Netflix")) { + if (currentApp.startsWith("YouTube") || currentApp.startsWith("Netflix")) { appApi.getPluginStatus(currentApp).then(result => { if (result[0].state !== (Settings.get("platform", "enableAppSuspended") ? "suspended" : "deactivated")) { appApi.exitApp(currentApp, true) - .then(()=>GLOBALS.previousapp_onDisplayConnectionChanged=currentApp) - .catch(err => { - Router.navigate(GLOBALS.LastvisitedRoute) - console.error(`Error in exit app ${currentApp} : ` + JSON.stringify(err)) - }); + .then(() => GLOBALS.previousapp_onDisplayConnectionChanged = currentApp) + .catch(err => { + Router.navigate(GLOBALS.LastvisitedRoute) + this.ERR("Error in exit app " + JSON.stringify(currentApp) + " : " + JSON.stringify(err)) + }); } else { - console.log("App HdcpProfile onDsisplayConnectionChanged skipping; " + currentApp + " is already: ", JSON.stringify(result[0].state)); + this.LOG("App HdcpProfile onDsisplayConnectionChanged skipping; " + currentApp + " is already: " + JSON.stringify(result[0].state)); } }) } - Storage.set("lastVisitedRoute",Router.getActiveHash()) - GLOBALS.LastvisitedRoute= Router.getActiveHash() + Storage.set("lastVisitedRoute", Router.getActiveHash()) + GLOBALS.LastvisitedRoute = Router.getActiveHash() } Storage.set("UICacheonDisplayConnectionChanged", temp.isConnected) } else { - console.warn("App HdcpProfile onDisplayConnectionChanged discarding."); - console.log("App HdcpProfile ResolutionChangeInProgress: " + Storage.get("ResolutionChangeInProgress") + " UICacheonDisplayConnectionChanged: " + Storage.get("UICacheonDisplayConnectionChanged")); + this.WARN("App HdcpProfile onDisplayConnectionChanged discarding."); + this.LOG("App HdcpProfile ResolutionChangeInProgress: " + JSON.stringify(Storage.get("ResolutionChangeInProgress")) + " UICacheonDisplayConnectionChanged: " + JSON.stringify(Storage.get("UICacheonDisplayConnectionChanged"))); } }) } - SubscribeToHdmiCecSourcevent(state,appIdentifiers){ + SubscribeToHdmiCecSourcevent(state, appIdentifiers) { switch (state) { case "activated": - this.onApplicationStateChanged=thunder.on("org.rdk.HdmiCecSource", "onActiveSourceStatusUpdated", notification => { - console.log(new Date().toISOString() + " onActiveSourceStatusUpdated "+ JSON.stringify(notification)) + this.onApplicationStateChanged = thunder.on("org.rdk.HdmiCecSource", "onActiveSourceStatusUpdated", notification => { + this.LOG(new Date().toISOString() + " onActiveSourceStatusUpdated " + JSON.stringify(notification)) if (notification.status != Storage.get("UICacheCECActiveSourceStatus")) { if (notification.status) { let currentApp = GLOBALS.topmostApp - if(GLOBALS.previousapp_onActiveSourceStatusUpdated !== null) { - currentApp=GLOBALS.previousapp_onActiveSourceStatusUpdated + if (GLOBALS.previousapp_onActiveSourceStatusUpdated !== null) { + currentApp = GLOBALS.previousapp_onActiveSourceStatusUpdated } - if(currentApp === "ResidentApp" && GLOBALS.Setup) { + if (currentApp === "ResidentApp" && GLOBALS.Setup) { Router.navigate(GLOBALS.LastvisitedRoute); } let launchLocation = Storage.get(currentApp + "LaunchLocation") - console.log("current app is " + JSON.stringify(currentApp)) + this.LOG("current app is " + JSON.stringify(currentApp)) let params = { launchLocation: launchLocation, appIdentifier: appIdentifiers[currentApp] } - if (currentApp.startsWith("YouTube")||currentApp.startsWith("Netflix")) { + if (currentApp.startsWith("YouTube") || currentApp.startsWith("Netflix")) { params["url"] = Storage.get(currentApp + "DefaultURL"); appApi.getPluginStatus(currentApp).then(result => { const isAppSuspendedEnabled = Settings.get("platform", "enableAppSuspended"); const expectedState = isAppSuspendedEnabled ? ["hibernated", "suspended"] : ["deactivated"]; if (expectedState.includes(result[0].state)) { appApi.launchApp(currentApp, params) - .then(()=>GLOBALS.previousapp_onActiveSourceStatusUpdated=null) - .catch(err => { - Router.navigate(GLOBALS.LastvisitedRoute) - console.error(`Error in launching ${currentApp} : ` + JSON.stringify(err)) - }); + .then(() => GLOBALS.previousapp_onActiveSourceStatusUpdated = null) + .catch(err => { + Router.navigate(GLOBALS.LastvisitedRoute) + this.ERR("Error in launching " + JSON.stringify(currentApp) + " : " + JSON.stringify(err)) + }); } else { - console.log("App HdmiCecSource onActiveSourceStatusUpdated skipping; " + currentApp + " is already:" + JSON.stringify(result[0].state)); + this.LOG("App HdmiCecSource onActiveSourceStatusUpdated skipping; " + currentApp + " is already:" + JSON.stringify(result[0].state)); } }) } } else { let currentApp = GLOBALS.topmostApp - if (currentApp.startsWith("YouTube")||currentApp.startsWith("Netflix")) { + if (currentApp.startsWith("YouTube") || currentApp.startsWith("Netflix")) { appApi.getPluginStatus(currentApp).then(result => { if (result[0].state !== (Settings.get("platform", "enableAppSuspended") ? "suspended" : "deactivated")) { appApi.exitApp(currentApp, true) - .then(()=>GLOBALS.previousapp_onActiveSourceStatusUpdated=currentApp) - .catch(err => { - Router.navigate(GLOBALS.LastvisitedRoute) - console.error(`Error in launching ${currentApp} : ` + JSON.stringify(err)) - }); + .then(() => GLOBALS.previousapp_onActiveSourceStatusUpdated = currentApp) + .catch(err => { + Router.navigate(GLOBALS.LastvisitedRoute) + this.ERR("Error in launching " + JSON.stringify(currentApp) + " : " + JSON.stringify(err)) + }); } else { - console.log("App HdmiCecSource onActiveSourceStatusUpdated skipping; " + currentApp + " is already:"+ JSON.stringify(result[0].state)); + this.LOG("App HdmiCecSource onActiveSourceStatusUpdated skipping; " + currentApp + " is already:" + JSON.stringify(result[0].state)); } }) } - Storage.set("lastVisitedRoute",Router.getActiveHash()) - GLOBALS.LastvisitedRoute= Router.getActiveHash() + Storage.set("lastVisitedRoute", Router.getActiveHash()) + GLOBALS.LastvisitedRoute = Router.getActiveHash() } Storage.set("UICacheCECActiveSourceStatus", notification.status); - console.log("App HdmiCecSource onActiveSourceStatusUpdated UICacheCECActiveSourceStatus:"+ JSON.stringify(Storage.get("UICacheCECActiveSourceStatus"))); + this.LOG("App HdmiCecSource onActiveSourceStatusUpdated UICacheCECActiveSourceStatus:" + JSON.stringify(Storage.get("UICacheCECActiveSourceStatus"))); } else { - console.warn("App HdmiCecSource onActiveSourceStatusUpdated discarding."); + this.WARN("App HdmiCecSource onActiveSourceStatusUpdated discarding."); } }) - break; + break; case "deactivated": this.onApplicationStateChanged.dispose() - break; - } + break; + } } _getPowerStateWhileReboot() { appApi.getPowerState().then(res => { - console.log("_getPowerStateWhileReboot: Current power state while reboot ".concat(res.powerState)); + this.LOG("_getPowerStateWhileReboot: Current power state while reboot " + JSON.stringify(res.powerState)); this._powerStateWhileReboot = res.powerState; this._PowerStateHandlingWhileReboot(); }).catch(err => { - console.log("_getPowerStateWhileReboot: Error in getting current power state while reboot ".concat(err)); + this.LOG("_getPowerStateWhileReboot: Error in getting current power state while reboot " + JSON.stringify(err)); this._powerStateWhileReboot = 'STANDBY'; this._PowerStateHandlingWhileReboot(); }); } _PowerStateHandlingWhileReboot() { - console.log("_PowerStateHandlingWhileReboot: this._oldPowerStateWhileReboot , ".concat(this._oldPowerStateWhileReboot, " this._powerStateWhileReboot, ").concat(this._powerStateWhileReboot, " ")); + this.LOG("_PowerStateHandlingWhileReboot: this._oldPowerStateWhileReboot , " + JSON.stringify(this._oldPowerStateWhileReboot) + " this._powerStateWhileReboot, " + JSON.stringify(this._powerStateWhileReboot) + " "); if (this._oldPowerStateWhileReboot != this._powerStateWhileReboot) { - console.log("_PowerStateHandlingWhileReboot: old power state is not equal to powerstate while reboot ".concat(this._oldPowerStateWhileReboot, " ").concat(this._powerStateWhileReboot)); + this.LOG("_PowerStateHandlingWhileReboot: old power state is not equal to powerstate while reboot " + JSON.stringify(this._oldPowerStateWhileReboot) + " " + JSON.stringify(this._powerStateWhileReboot)); appApi.setPowerState(this._oldPowerStateWhileReboot).then(res => { - console.log("_PowerStateHandlingWhileReboot: successfully set powerstate to old powerstate ".concat(this._oldPowerStateWhileReboot)); + this.LOG("_PowerStateHandlingWhileReboot: successfully set powerstate to old powerstate " + JSON.stringify(this._oldPowerStateWhileReboot)); if (res.success) { appApi.getPowerState().then(res => { GLOBALS.powerState = res.powerState; }); - console.log("_PowerStateHandlingWhileReboot: powerstate after setting to new powerstate ".concat(GLOBALS.powerState, " and ")); + this.LOG("_PowerStateHandlingWhileReboot: powerstate after setting to new powerstate " + JSON.stringify(GLOBALS.powerState) + " and "); } }).catch(err => { - console.log("_PowerStateHandlingWhileReboot: Rebooting the device as set PowerState failed due to ".concat(err)); + this.LOG("_PowerStateHandlingWhileReboot: Rebooting the device as set PowerState failed due to " + JSON.stringify(err)); appApi.reboot("setPowerState Api Failure"); }); } else { - console.log("_PowerStateHandlingWhileReboot: power state before reboot and curren tpowerstate is same ".concat(this._oldPowerStateWhileReboot, " ").concat(this._powerStateWhileReboot)); + this.LOG("_PowerStateHandlingWhileReboot: power state before reboot and curren tpowerstate is same " + JSON.stringify(this._oldPowerStateWhileReboot) + " " + JSON.stringify(this._powerStateWhileReboot)); GLOBALS.powerState = this._powerStateWhileReboot; } } _getPowerStatebeforeReboot() { appApi.getPowerStateBeforeReboot().then(res => { - console.log("_getPowerStatebeforeReboot: getpowerstate before reboot ".concat(res.state)); + this.LOG("_getPowerStatebeforeReboot: getpowerstate before reboot " + JSON.stringify(res.state)); this._oldPowerStateWhileReboot = res.state; this._getPowerStateWhileReboot(); }).catch(err => { - console.log("_getPowerStatebeforeReboot: getPowerStateBeforeReboot error ".concat(err) + " setting powerstate to ON"); + this.LOG("_getPowerStatebeforeReboot: getPowerStateBeforeReboot error " + JSON.stringify(err) + " setting powerstate to ON"); this._oldPowerStateWhileReboot = 'ON'; this._getPowerStateWhileReboot(); }); @@ -1346,7 +1390,7 @@ export default class App extends Router.App { FireBoltApi.get().lifecycle.ready() FireBoltApi.get().lifecycle.registerEvent('foreground', value => { - console.log("FireBoltApi[foreground] value:" + JSON.stringify(value) + ", launchResidentApp with:" + JSON.stringify(GLOBALS.selfClientName)); + this.LOG("FireBoltApi[foreground] value:" + JSON.stringify(value) + ", launchResidentApp with:" + JSON.stringify(GLOBALS.selfClientName)); // Ripple launches refui with this rdkshell client name. GLOBALS.topmostApp = GLOBALS.selfClientName; FireBoltApi.get().discovery.launch("refui",{ "action": "home", "context": { "source": "device" } } ).then(() => { @@ -1356,97 +1400,98 @@ export default class App extends Router.App { FireBoltApi.get().lifecycle.registerEvent('background', value => { // Ripple changed app states; it will be a 'FireboltApp' GLOBALS.topmostApp = "FireboltApp"; - console.log("FireBoltApi[foreground] value:" + JSON.stringify(value) + ", Updating top app as:" + GLOBALS.topmostApp); + this.LOG("FireBoltApi[foreground] value:" + JSON.stringify(value) + ", Updating top app as:" + JSON.stringify(GLOBALS.topmostApp)); }) FireBoltApi.get().lifecycle.state().then(res => { - console.log("Lifecycle.state result:" + res) + this.LOG("Lifecycle.state result:" + JSON.stringify(res)) }); } _firstEnable() { thunder.on("org.rdk.System", "onSystemPowerStateChanged", notification => { - console.log(new Date().toISOString() + " onSystemPowerStateChanged Notification: ", notification); + this.LOG(new Date().toISOString() + " onSystemPowerStateChanged Notification: " + JSON.stringify(notification)); appApi.getPowerState().then(res =>{ GLOBALS.powerState = res.success ? res.powerState : notification.powerState }).catch( e => GLOBALS.powerState = notification.powerState) if (notification.powerState !== "ON" && notification.currentPowerState === "ON") { - console.log("onSystemPowerStateChanged Notification: power state was changed from ON to " + notification.powerState) + this.LOG("onSystemPowerStateChanged Notification: power state was changed from ON to " + JSON.stringify(notification.powerState)) //TURNING OFF THE DEVICE Storage.set('SLEEPING', notification.powerState) - let currentApp = GLOBALS.topmostApp if (currentApp !== "") { appApi.exitApp(currentApp); //will suspend/destroy the app depending on the setting. } Router.navigate('menu'); } - else if (notification.powerState === "ON" && notification.currentPowerState !== "ON") { //TURNING ON THE DEVICE Storage.remove('SLEEPING') } }) - console.log("App Calling listenToVoiceControl method to activate VoiceControl Plugin") + this.LOG("App Calling listenToVoiceControl method to activate VoiceControl Plugin") this.listenToVoiceControl(); this._updateLanguageToDefault() /* Subscribe to Volume status events to report to Alexa. */ this._subscribeToAlexaNotifications() } - + async listenToVoiceControl() { - console.log("App listenToVoiceControl method got called, configuring VoiceControl Plugin") + this.LOG("App listenToVoiceControl method got called, configuring VoiceControl Plugin") await voiceApi.activate().then(() => { voiceApi.voiceStatus().then(voiceStatusResp => { - if(voiceStatusResp.success){ - if(voiceStatusResp.urlPtt.includes("avs://")) - { - GLOBALS.AlexaAvsstatus(true) - } - if (voiceStatusResp.ptt.status != "ready" || !voiceStatusResp.urlPtt.includes("avs://")) { - GLOBALS.AlexaAvsstatus(false) - console.error("App voiceStatus says PTT/AVS not ready, enabling it."); + if (voiceStatusResp.success){ + if(voiceStatusResp.urlPtt.includes("avs://")) + { + GLOBALS.AlexaAvsstatus(true) + } + if (voiceStatusResp.ptt.status != "ready" || !voiceStatusResp.urlPtt.includes("avs://")) { + GLOBALS.AlexaAvsstatus(false) + this.ERR("App voiceStatus says PTT/AVS not ready, enabling it."); // TODO: Future -> add option for user to select which Voice service provider. // Then configure VoiceControl plugin for that end point. // TODO: voiceApi.configureVoice() - if (AlexaApi.get().checkAlexaAuthStatus() != "AlexaUserDenied") { - AlexaApi.get().setAlexaAuthStatus("") - voiceApi.configureVoice({ "enable": true }).then(() => { - AlexaApi.get().setAlexaAuthStatus("AlexaAuthPending") - }); + if (AlexaApi.get().checkAlexaAuthStatus() != "AlexaUserDenied") { + AlexaApi.get().setAlexaAuthStatus("") + voiceApi.configureVoice({ "enable": true }).then(() => { + AlexaApi.get().setAlexaAuthStatus("AlexaAuthPending") + }); + } } } - } - }); if (AlexaApi.get().checkAlexaAuthStatus() === "AlexaAuthPending") { /* AVS SDK might be awaiting a ping packet to start. */ AlexaApi.get().pingAlexaSDK(); } else if (AlexaApi.get().checkAlexaAuthStatus() === "AlexaHandleError") { - console.log("App checkAlexaAuthStatus is AlexaHandleError; enableSmartScreen."); + this.LOG("App checkAlexaAuthStatus is AlexaHandleError; enableSmartScreen."); AlexaApi.get().enableSmartScreen(); AlexaApi.get().getAlexaDeviceSettings(); /* Alexa device volume state report. */ appApi.getConnectedAudioPorts().then(audioport => { for (let i = 0; i < audioport.connectedAudioPorts.length && !audioport.connectedAudioPorts[i].startsWith("SPDIF"); i++) { - if ((Storage.get("deviceType") == "tv" && audioport.connectedAudioPorts[i].startsWith("SPEAKER")) || - (Storage.get("deviceType") != "tv" && audioport.connectedAudioPorts[i].startsWith("HDMI"))) { + if ( + (GLOBALS.deviceType == "IpTv" && audioport.connectedAudioPorts[i].startsWith("SPEAKER")) || + (GLOBALS.deviceType != "IpTv" && audioport.connectedAudioPorts[i].startsWith("HDMI")) + ) { appApi.getMuted(audioport.connectedAudioPorts[i]).then(muteRes => { appApi.getVolumeLevel(audioport.connectedAudioPorts[i]).then(volres => { - AlexaApi.get().reportVolumeState((volres.success ? (Number.isInteger(volres.volumeLevel) ? volres.volumeLevel : parseInt(volres.volumeLevel)) : undefined), (muteRes.success ? muteRes.muted : undefined)) + AlexaApi.get().reportVolumeState( + (volres.success ? (Number.isInteger(volres.volumeLevel) ? volres.volumeLevel : parseInt(volres.volumeLevel)) : undefined), + (muteRes.success ? muteRes.muted : undefined) + ) }) }) } } }) - - /* Report device language */ + // Report device language if (availableLanguageCodes[Language.get()].length) { AlexaApi.get().updateDeviceLanguageInAlexa(availableLanguageCodes[Language.get()]); } - /* Report device timeZone */ + // Report device timeZone if ("ResidentApp" === GLOBALS.selfClientName) { appApi.getZone().then(timezone => { this.updateAlexaTimeZone(timezone) @@ -1457,21 +1502,20 @@ export default class App extends Router.App { }) } } - console.log("App VoiceControl check if user has denied ALEXA:" + JSON.stringify(AlexaApi.get().checkAlexaAuthStatus())) - + this.LOG("App VoiceControl check if user has denied ALEXA:" + JSON.stringify(AlexaApi.get().checkAlexaAuthStatus())) /* Handle VoiceControl Notifications */ this._registerVoiceApiEvents() }).catch(err => { - console.error("App VoiceControl Plugin activation error:", err); + this.ERR("App VoiceControl Plugin activation error: " + JSON.stringify(err)); }) } updateAlexaTimeZone(updatedTimeZone){ if (updatedTimeZone.length) { - console.log("App: updateDeviceTimeZoneInAlexa with zone:", updatedTimeZone) + this.LOG("App: updateDeviceTimeZoneInAlexa with zone:" + JSON.stringify(updatedTimeZone)) AlexaApi.get().updateDeviceTimeZoneInAlexa(updatedTimeZone); } else { - console.error("App getTimezoneDST returned:", updatedTimeZone) + this.ERR("App getTimezoneDST returned: " + JSON.stringify(updatedTimeZone)) } } @@ -1482,16 +1526,16 @@ export default class App extends Router.App { break; case 'YouTube': appApi.suspendPremiumApp("YouTube").then(() => { - console.log(`YouTube : suspend YouTube request`); + this.LOG("YouTube : suspend YouTube request"); }).catch((err) => { - console.error(err) + this.ERR(JSON.stringify(err)); }); break; case 'YouTubeTV': appApi.suspendPremiumApp("YouTubeTV").then(() => { - console.log(`YouTubeTV : suspend YouTubeTV request`); + this.LOG("YouTubeTV : suspend YouTubeTV request"); }).catch((err) => { - console.error(err) + this.ERR(JSON.stringify(err)); }); break; case 'Lightning': @@ -1531,11 +1575,9 @@ export default class App extends Router.App { return new Promise((resolve, reject) => { appApi.getPluginStatus('Netflix') .then(result => { - console.log(`netflix plugin status is :`, JSON.stringify(result)); - console.log(`netflix plugin status is :`, result); - + this.LOG("netflix plugin status is : " + JSON.stringify(result)); + this.LOG("netflix plugin status is : " + JSON.stringify(result)); if (result[0].state === 'deactivated' || result[0].state === 'deactivation') { - Router.navigate('image', { src: Utils.asset('images/apps/App_Netflix_Splash.png') }) if (url) { appApi.configureApplication('Netflix', url).then(() => { @@ -1544,9 +1586,8 @@ export default class App extends Router.App { resolve(true) }).catch(() => { reject(false) });// ie. org.rdk.RDKShell.launch }).catch(err => { - console.error("Netflix : error while fetching configuration data : ", JSON.stringify(err)) + this.ERR("Netflix : error while fetching configuration data : " + JSON.stringify(err)); reject(err) - })// gets configuration object and sets configuration } else { @@ -1560,13 +1601,11 @@ export default class App extends Router.App { /* Not in deactivated; could be suspended */ if (url) { appApi.launchPremiumApp("Netflix").then(() => { - thunder.call("Netflix", "systemcommand", - { "command": url }) - .then(() => { - - }).catch(err => { - console.error("Netflix : error while sending systemcommand : ", JSON.stringify(err)) - Metrics.error(Metrics.ErrorType.OTHER, 'AppError', `Netflix : error while sending systemcommand : ${JSON.stringify(err)}`, false, null) + thunder.call("Netflix", "systemcommand", { "command": url }) + .then(() => {}) + .catch(err => { + this.ERR("Netflix : error while sending systemcommand : " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.OTHER, 'AppError', "Netflix : error while sending systemcommand : " + JSON.stringify(err), false, null) reject(false); }); RDKShellApis.setVisibility(GLOBALS.selfClientName, false); @@ -1575,16 +1614,15 @@ export default class App extends Router.App { } else { appApi.launchPremiumApp("Netflix").then(res => { - console.log(`Netflix : launch premium app resulted in `, JSON.stringify(res)); + this.LOG("Netflix : launch premium app resulted in " + JSON.stringify(res)); RDKShellApis.setVisibility(GLOBALS.selfClientName, false); resolve(true) }); } - } }) .catch(err => { - console.log('Netflix plugin error', err) + this.ERR("Netflix plugin error: " + JSON.stringify(err)); GLOBALS.topmostApp = GLOBALS.selfClientName; reject(false) }) @@ -1593,24 +1631,24 @@ export default class App extends Router.App { _powerKeyPressed() { appApi.getPowerState().then(res => { - console.log("getPowerState: ", res) + this.LOG("getPowerState: " + JSON.stringify(res)); if (res.success) { if (res.powerState === "ON") { - console.log("current powerState is ON so setting power state to LIGHT_SLEEP/DEEP_SLEEP depending of preferred option"); + this.LOG("current powerState is ON so setting power state to LIGHT_SLEEP/DEEP_SLEEP depending of preferred option"); appApi.getPreferredStandbyMode().then(res => { - console.log("getPreferredStandbyMode: ", res.preferredStandbyMode); + this.LOG("getPreferredStandbyMode: " + JSON.stringify(res.preferredStandbyMode)); appApi.setPowerState(res.preferredStandbyMode).then(result => { if (result.success) { - console.log("successfully set powerstate to: " + res.preferredStandbyMode) + this.LOG("successfully set powerstate to: " + JSON.stringify(res.preferredStandbyMode)) return result.success } }) }) } else { - console.log("current powerState is " + res.powerState + " so setting power state to ON"); + this.LOG("current powerState is " + JSON.stringify(res.powerState) + " so setting power state to ON"); appApi.setPowerState("ON").then(res => { if (res.success) { - console.log("successfully set powerstate to: ON") + this.LOG("successfully set powerstate to: ON") return res.success } }) @@ -1618,17 +1656,20 @@ export default class App extends Router.App { } }) } + _updateLanguageToDefault() { if ("ResidentApp" === GLOBALS.selfClientName) { if (availableLanguageCodes[Language.get()].length) { appApi.setUILanguage(availableLanguageCodes[Language.get()]) - localStorage.setItem('Language',Language.get()) + localStorage.setItem('Language', Language.get()) } } else { FireBoltApi.get().localization.language().then(lang => { if (lang) { - FireBoltApi.get().localization.language(lang).then(`language ${lang} set succesfully`) - localStorage.setItem('Language',lang) + FireBoltApi.get().localization.language(lang).then(() => { + this.LOG("language " + JSON.stringify(lang) + " set succesfully") + }) + localStorage.setItem('Language', lang) } }) } @@ -1639,19 +1680,19 @@ export default class App extends Router.App { RDKShellApis.setVisibility(appName, visibility); RDKShellApis.setFocus(appName).then(() => { }).catch((err) => { - console.log(`Error : can't set focus to the ${appName}`, err); - Metrics.error(Metrics.ErrorType.OTHER, 'APPError', "RDKShell setFocus error" + err, false, null) + this.ERR("Error : can't set focus to the " + JSON.stringify(appName) + " " + JSON.stringify(err)); + Metrics.error(Metrics.ErrorType.OTHER, 'APPError', "RDKShell setFocus error" + JSON.stringify(err), false, null) }); }); } - launchFeaturedApp = (appName) =>{ + launchFeaturedApp = (appName) => { let params = { launchLocation: "dedicatedButton", - appIdentifier:this.appIdentifiers[appName] + appIdentifier: this.appIdentifiers[appName] } appApi.launchApp(appName, params).catch(err => { - console.error(`Error in launching ${appName} via dedicated key: ` + JSON.stringify(err)) + this.ERR("Error in launching " + JSON.stringify(appName) + " via dedicated key: " + JSON.stringify(err)) }); } @@ -1662,60 +1703,63 @@ export default class App extends Router.App { let self = this; this.xcastApi.registerEvent('onApplicationLaunchRequest', notification => { //power check - console.log('App onApplicationLaunchRequest: ' + JSON.stringify(notification)); - appApi.getPowerState().then(res =>{ - if(res.powerState === 'STANDBY') { - appApi.getPreferredStandbyMode().then(result =>{ - if(result.preferredStandbyMode === "LIGHT_SLEEP") appApi.setPowerState('ON') - }) + this.LOG('App onApplicationLaunchRequest: ' + JSON.stringify(notification)); + appApi.getPowerState().then(res => { + if (res.powerState === 'STANDBY') { + appApi.getPreferredStandbyMode().then(result => { + if (result.preferredStandbyMode === "LIGHT_SLEEP") appApi.setPowerState('ON') + }) } }) if (this.xcastApps(notification.applicationName)) { let applicationName = this.xcastApps(notification.applicationName); let baseUrl = Storage.get(notification.applicationName + "DefaultURL"); - let pairingCode = notification.parameters.payload; + let pairingCode = notification.parameters.payload; let additionalDataUrl = notification.parameters.additionalDataUrl; let url = `${baseUrl}${pairingCode}&additionalDataUrl=${additionalDataUrl}`; - let params = { - url: applicationName.startsWith("YouTube") ? url : notification.parameters.pluginUrl , - launchLocation: "dial", - appIdentifier: self.appIdentifiers[applicationName] - } - appApi.launchApp(applicationName, params).then(res => { - console.log("App onApplicationLaunchRequest: launched " + applicationName + " : ", res); - GLOBALS.topmostApp = applicationName; - // TODO: move to Controller.statuschange event - let params = { applicationName: notification.applicationName, state: 'running' }; - this.xcastApi.onApplicationStateChanged(params); - }).catch(err => { - console.log("App onApplicationLaunchRequest: error ", err) - }) + if (applicationName.startsWith("Netflix")) { + url = `${baseUrl}&dial=${pairingCode}&additionalDataUrl=${additionalDataUrl}` + } + let params = { + url: applicationName.startsWith("YouTube") || applicationName.startsWith("Netflix") ? url : notification.parameters.pluginUrl, + launchLocation: "dial", + appIdentifier: self.appIdentifiers[applicationName] + } + appApi.launchApp(applicationName, params).then(res => { + this.LOG("App onApplicationLaunchRequest: launched " + JSON.stringify(applicationName) + " : " + JSON.stringify(res)); + GLOBALS.topmostApp = applicationName; + // TODO: move to Controller.statuschange event + let params = { applicationName: notification.applicationName, state: 'running' }; + this.xcastApi.onApplicationStateChanged(params); + }).catch(err => { + this.ERR("App onApplicationLaunchRequest: error " + JSON.stringify(err)) + }) } else { - console.log("App onApplicationLaunchRequest: " + notification.applicationName + " is not supported.") + this.LOG("App onApplicationLaunchRequest: " + JSON.stringify(notification.applicationName) + " is not supported.") } }); this.xcastApi.registerEvent('onApplicationHideRequest', notification => { - console.log('App onApplicationHideRequest: ' + JSON.stringify(notification)); + this.LOG('App onApplicationHideRequest: ' + JSON.stringify(notification)); if (this.xcastApps(notification.applicationName)) { let applicationName = this.xcastApps(notification.applicationName); - console.log('App onApplicationHideRequest: ' + this.xcastApps(notification.applicationName)); + this.LOG('App onApplicationHideRequest: ' + JSON.stringify(this.xcastApps(notification.applicationName))); //second argument true means resident app won't be launched the required app will be exited in the background. //only bring up the resident app when the notification is from the current app(ie app in focus) - console.log("App onApplicationHideRequest: exitApp as " + applicationName + "!==" + GLOBALS.topmostApp); - appApi.exitApp(applicationName, applicationName !== GLOBALS.topmostApp); + this.LOG("App onApplicationHideRequest: exitApp as " + JSON.stringify(applicationName) + "!==" + JSON.stringify(GLOBALS.topmostApp)); + appApi.exitApp(applicationName, applicationName !== GLOBALS.topmostApp); } else { - console.log("App onApplicationHideRequest: " + notification.applicationName + " is not supported.") + this.LOG("App onApplicationHideRequest: " + JSON.stringify(notification.applicationName) + " is not supported.") } }); this.xcastApi.registerEvent('onApplicationResumeRequest', notification => { - console.log('App onApplicationResumeRequest: ' + JSON.stringify(notification)); + this.LOG('App onApplicationResumeRequest: ' + JSON.stringify(notification)); appApi.getPowerState().then(res => { - if(res.powerState === 'STANDBY') { - appApi.getPreferredStandbyMode().then(result =>{ - if(result.preferredStandbyMode === "LIGHT_SLEEP") appApi.setPowerState('ON') - }) + if (res.powerState === 'STANDBY') { + appApi.getPreferredStandbyMode().then(result => { + if (result.preferredStandbyMode === "LIGHT_SLEEP") appApi.setPowerState('ON') + }) } }) if (this.xcastApps(notification.applicationName)) { @@ -1725,27 +1769,25 @@ export default class App extends Router.App { launchLocation: "dial", appIdentifier: self.appIdentifiers[applicationName] } - - console.log('App onApplicationResumeRequest: launchApp ', applicationName, " with params: ", params); + this.LOG('App onApplicationResumeRequest: launchApp ' + JSON.stringify(applicationName) + " with params: " + JSON.stringify(params)); appApi.launchApp(applicationName, params).then(res => { GLOBALS.topmostApp = applicationName; - console.log("App onApplicationResumeRequest: launched ", applicationName, " result: ", res); + this.LOG("App onApplicationResumeRequest: launched " + JSON.stringify(applicationName) + " result: " + JSON.stringify(res)); }).catch(err => { - console.log("Error in launching ", applicationName, " on casting resume request: ", err); + this.ERR("Error in launching " + JSON.stringify(applicationName) + " on casting resume request: " + JSON.stringify(err)); }) } else { - console.log("App onApplicationResumeRequest: " + notification.applicationName + " is not supported.") + this.LOG("App onApplicationResumeRequest: " + JSON.stringify(notification.applicationName) + " is not supported.") } }); this.xcastApi.registerEvent('onApplicationStopRequest', notification => { - console.log('App onApplicationStopRequest: ' + JSON.stringify(notification)); - + this.LOG('App onApplicationStopRequest: ' + JSON.stringify(notification)); if (this.xcastApps(notification.applicationName)) { let applicationName = this.xcastApps(notification.applicationName); appApi.exitApp(applicationName, true, true); } else { - console.log("App onApplicationStopRequest: " + notification.applicationName + " is not supported.") + this.LOG("App onApplicationStopRequest: " + JSON.stringify(notification.applicationName) + " is not supported.") } }); @@ -1755,7 +1797,7 @@ export default class App extends Router.App { let applicationName = this.xcastApps(notification.applicationName); let appState = { "applicationName": notification.applicationName, "state": "stopped" }; appApi.checkStatus(applicationName).then(result => { - console.log("result of xcast app status", result[0].state) + this.LOG("result of xcast app status" + JSON.stringify(result[0].state)) switch (result[0].state) { case "activated": case "resumed": @@ -1774,10 +1816,10 @@ export default class App extends Router.App { } this.xcastApi.onApplicationStateChanged(appState); }).catch(error => { - console.error("App onApplicationStateRequest: checkStatus error ", error); + this.ERR("App onApplicationStateRequest: checkStatus error " + JSON.stringify(error)); }) } else { - console.log("App onApplicationStateRequest: " + notification.applicationName + " is not supported.") + this.LOG("App onApplicationStateRequest: " + JSON.stringify(notification.applicationName) + " is not supported.") } }); } @@ -1792,36 +1834,33 @@ export default class App extends Router.App { } else return false; } - $mountEventConstructor(fun) { this.ListenerConstructor = fun; - console.log(`MountEventConstructor was initialized`) + this.LOG("MountEventConstructor was initialized") // console.log(`listener constructor was set t0 = ${this.ListenerConstructor}`); } $registerUsbMount() { this.disposableListener = this.ListenerConstructor(); - console.log(`Successfully registered the usb Mount`) + this.LOG("Successfully registered the usb Mount") } $deRegisterUsbMount() { - console.log(`the current usbListener = ${this.disposableListener}`) + this.LOG("the current usbListener = " + JSON.stringify(this.disposableListener)) this.disposableListener.dispose(); - console.log(`successfully deregistered usb listener`); + this.LOG("successfully deregistered usb listener"); } - standby(value) { - console.log(`standby call`); + this.LOG("standby call"); if (value == 'Back') { // TODO: Identify what to do here. } else { if (powerState == 'ON') { - console.log(`Power state was on trying to set it to standby`); + this.LOG("Power state was on trying to set it to standby"); appApi.setPowerState(value).then(res => { - if (res.success) { - console.log(`successfully set to standby`); + this.LOG("successfully set to standby"); powerState = 'STANDBY' if (GLOBALS.topmostApp !== GLOBALS.selfClientName) { appApi.exitApp(GLOBALS.topmostApp); @@ -1839,7 +1878,7 @@ export default class App extends Router.App { $registerInactivityMonitoringEvents() { return new Promise((resolve, reject) => { - console.log(`registered inactivity listener`); + this.LOG("registered inactivity listener"); appApi.setPowerState('ON').then(res => { if (res.success) { powerState = 'ON' @@ -1850,47 +1889,47 @@ export default class App extends Router.App { callsign: 'org.rdk.RDKShell.1' }) .then(res => { - console.log(`activated the rdk shell plugin trying to set the inactivity listener; res = ${JSON.stringify(res)}`); + this.LOG("activated the rdk shell plugin trying to set the inactivity listener; res = " + JSON.stringify(res)); thunder.on("org.rdk.RDKShell.1", "onUserInactivity", notification => { - console.log('onUserInactivity: ' + JSON.stringify(notification)); + this.LOG('onUserInactivity: ' + JSON.stringify(notification)); if (powerState === "ON" && (GLOBALS.topmostApp === GLOBALS.selfClientName)) { this.standby("STANDBY"); } }, err => { - console.error(`error while inactivity monitoring , ${err}`) + this.ERR("error while inactivity monitoring , " + JSON.stringify(err)) }) resolve(res) }).catch((err) => { - Metrics.error(Metrics.ErrorType.OTHER, 'AppError', `Controller.activate error with ${err}`, false, null) + Metrics.error(Metrics.ErrorType.OTHER, 'AppError', "Controller.activate error with " + JSON.stringify(err), false, null) reject(err) - console.error(`error while activating the displaysettings plugin; err = ${err}`) + this.ERR("error while activating the displaysettings plugin; err = " + JSON.stringify(err)) }) }) } $resetSleepTimer(t) { - console.log(`reset sleep timer call ${t}`); + this.LOG("reset sleep timer call " + JSON.stringify(t)); var arr = t.split(" "); function setTimer() { - console.log('Timer ', arr) + this.LOG('Timer ' + JSON.stringify(arr)) var temp = arr[1].substring(0, 1); if (temp === 'H') { let temp1 = parseFloat(arr[0]) * 60; RDKShellApis.setInactivityInterval(temp1).then(() => { Storage.set('TimeoutInterval', t) - console.log(`successfully set the timer to ${t} hours`) + this.LOG("successfully set the timer to " + JSON.stringify(t) + " hours") }).catch(err => { - console.error('error while setting the timer' + JSON.stringify(err)) + this.ERR("error while setting the timer " + JSON.stringify(err)) }); } else if (temp === 'M') { - console.log(`minutes`); + this.LOG("minutes"); let temp1 = parseFloat(arr[0]); RDKShellApis.setInactivityInterval(temp1).then(() => { Storage.set('TimeoutInterval', t) - console.log(`successfully set the timer to ${t} minutes`); + this.LOG("successfully set the timer to " + JSON.stringify(t) + " minutes"); }).catch(err => { - console.error('error while setting the timer' + JSON.stringify(err)) + this.ERR("error while setting the timer " + JSON.stringify(err)) }); } } @@ -1899,25 +1938,26 @@ export default class App extends Router.App { RDKShellApis.enableInactivityReporting(false).then((res) => { if (res === true) { Storage.set('TimeoutInterval', false) - console.log(`Disabled inactivity reporting`); + this.LOG("Disabled inactivity reporting"); // this.timerIsOff = true; } }).catch(err => { - console.error(`error : unable to set the reset; error = ${err}`) + this.ERR("error : unable to set the reset; error = " + JSON.stringify(err)) }); } else { RDKShellApis.enableInactivityReporting(true).then(res => { if (res === true) { - console.log(`Enabled inactivity reporting; trying to set the timer to ${t}`); + this.LOG("Enabled inactivity reporting; trying to set the timer to " + JSON.stringify(t)); // this.timerIsOff = false; setTimer(); } - }).catch(err => { console.error('error while enabling inactivity reporting' + JSON.stringify(err)) }); + }).catch(err => { this.ERR("error while enabling inactivity reporting " + JSON.stringify(err)) }); } } + _subscribeToAlexaNotifications() { thunder.on('org.rdk.DisplaySettings', 'connectedAudioPortUpdated', notification => { - console.log("App got connectedAudioPortUpdated: ", notification) + this.LOG("App got connectedAudioPortUpdated: " + JSON.stringify(notification)) // TODO: future -> can be used for volume adjustments ? }); thunder.on('org.rdk.DisplaySettings', 'muteStatusChanged', notification => { @@ -1940,27 +1980,27 @@ export default class App extends Router.App { _registerVoiceApiEvents() { let self = this; voiceApi.registerEvent('onServerMessage', notification => { - console.log('App onServerMessage: ' + JSON.stringify(notification)); + this.LOG('App onServerMessage: ' + JSON.stringify(notification)); if (Storage.get("appSwitchingInProgress")) { - console.warn("App is appSwitchingInProgress? " + Storage.get("appSwitchingInProgress") + ", dropping processing the server notification."); + this.WARN("App is appSwitchingInProgress? " + JSON.stringify(Storage.get("appSwitchingInProgress")) + ", dropping processing the server notification."); return; } if (AlexaApi.get().checkAlexaAuthStatus() !== "AlexaUserDenied") { if (notification.xr_speech_avs.state_reporter === "authorization_req" || notification.xr_speech_avs.code) { - console.log("Alexa Auth URL is ", notification.xr_speech_avs.url) + this.LOG("Alexa Auth URL is " + JSON.stringify(notification.xr_speech_avs.url)) if (!Router.isNavigating() && !AlexaApi.get().isSmartScreenActiavated() && Router.getActiveHash() === "menu") { - console.log("App enableSmartScreen"); + this.LOG("App enableSmartScreen"); AlexaApi.get().enableSmartScreen(); } if ((Router.getActiveHash() === "menu") && (GLOBALS.topmostApp === GLOBALS.selfClientName)) { if (Router.getActiveHash() != "AlexaLoginScreen" && Router.getActiveHash() != "CodeScreen" && !Router.isNavigating()) { - console.log("Routing to Alexa login page") + this.LOG("Routing to Alexa login page") Router.navigate("AlexaLoginScreen") } } - console.log("Alexa Auth OTP is ", notification.xr_speech_avs.code) + this.LOG("Alexa Auth OTP is " + JSON.stringify(notification.xr_speech_avs.code)) } else if (notification.xr_speech_avs.state_reporter === "authendication") { - console.log("Alexa Auth State is now at ", notification.xr_speech_avs.state) + this.LOG("Alexa Auth State is now at " + JSON.stringify(notification.xr_speech_avs.state)) if (notification.xr_speech_avs.state === "refreshed") { AlexaApi.get().setAlexaAuthStatus("AlexaHandleError") Router.navigate("SuccessScreen") @@ -1994,7 +2034,7 @@ export default class App extends Router.App { RDKShellApis.setFocus(GLOBALS.topmostApp === "" ? GLOBALS.selfClientName : GLOBALS.topmostApp); } if (notification.xr_speech_avs.state.dialogUX === "idle" && notification.xr_speech_avs.state.audio === "stopped") { - console.log("App current AlexaAudioplayerActive state:" + AlexaAudioplayerActive); + this.LOG("App current AlexaAudioplayerActive state:" + JSON.stringify(AlexaAudioplayerActive)); if (AlexaAudioplayerActive && notification.xr_speech_avs.state.guiManager === "DEACTIVATED" || !AlexaAudioplayerActive) { AlexaAudioplayerActive = false; RDKShellApis.setFocus(GLOBALS.topmostApp === "" ? GLOBALS.selfClientName : GLOBALS.topmostApp); @@ -2033,22 +2073,21 @@ export default class App extends Router.App { } // Send AVS State report: STOP request if "playing" to end the Smartscreen App instance. if (AlexaApi.get().checkAlexaSmartscreenAudioPlaybackState() == "playing") { - console.log("Sending playbackstatereport to Pause:", PlaybackStateReport) + this.LOG("Sending playbackstatereport to Pause: " + JSON.stringify(PlaybackStateReport)) AlexaApi.get().reportPlaybackState("PAUSED"); } - console.log("Alexa is trying to launch " + appCallsign + " using params: " + JSON.stringify(params)) + this.LOG("Alexa is trying to launch " + JSON.stringify(appCallsign) + " using params: " + JSON.stringify(params)) if (appCallsign) { //appCallsign is valid means target is an app and it needs to be launched appApi.launchApp(appCallsign, params).catch(err => { - console.log("Alexa.Launcher LaunchTarget checkerrstatusAlexa", err) + this.ERR("Alexa.Launcher LaunchTarget Error in launching " + JSON.stringify(appCallsign) + " via Alexa: " + JSON.stringify(err)) if (err.includes("Netflix")) { AlexaApi.get().reportErrorState(notification.xr_speech_avs.directive, "INVALID_VALUE", "Unsupported AppID") } else { AlexaApi.get().reportErrorState(notification.xr_speech_avs.directive) } - console.error("Alexa.Launcher LaunchTarget Error in launching " + appCallsign + " via Alexa: " + JSON.stringify(err)) }); } else if (targetRoute) { - console.log("Alexa.Launcher is trying to route to ", JSON.stringify(targetRoute)) + this.LOG("Alexa.Launcher is trying to route to " + JSON.stringify(targetRoute)) // exits the app if any and navigates to the specific route. Storage.set("appSwitchingInProgress", true); this.jumpToRoute(targetRoute); @@ -2056,15 +2095,15 @@ export default class App extends Router.App { Storage.set("appSwitchingInProgress", false); } } else { - console.log("Alexa.Launcher is trying to launch an unsupported app : " + JSON.stringify(payload)) + this.LOG("Alexa.Launcher is trying to launch an unsupported app : " + JSON.stringify(payload)) AlexaApi.get().reportErrorState(notification.xr_speech_avs.directive) } } }/////////Alexa.Launcher END else if (header.namespace === "Alexa.RemoteVideoPlayer") { //alexa remote video player will search on youtube for now - console.log("Alexa.RemoteVideoPlayer: " + JSON.stringify(header)) + this.LOG("Alexa.RemoteVideoPlayer: " + JSON.stringify(header)) if (header.name === "SearchAndDisplayResults" || header.name === "SearchAndPlay") { - console.log("Alexa.RemoteVideoPlayer: SearchAndDisplayResults || SearchAndPlay: " + JSON.stringify(header)) + this.LOG("Alexa.RemoteVideoPlayer: SearchAndDisplayResults || SearchAndPlay: " + JSON.stringify(header)) /* Find if payload contains Destination App */ if (Object.prototype.hasOwnProperty.call(payload, "entities")) { let entityId = payload.entities.filter(obj => Object.keys(obj).some(key => Object.prototype.hasOwnProperty.call(obj[key], "ENTITY_ID"))); @@ -2083,18 +2122,18 @@ export default class App extends Router.App { } else if (appCallsign.startsWith("YouTube")) { launchParams.url = Storage.get(appCallsign + "DefaultURL") + "&va=" + ((header.name === "SearchAndPlay") ? "play" : "search") + "&vq=" + encodeURI(replacedText); } - console.log("Alexa.RemoteVideoPlayer: launchApp " + appCallsign + " with params " + launchParams) + this.LOG("Alexa.RemoteVideoPlayer: launchApp " + JSON.stringify(appCallsign) + " with params " + JSON.stringify(launchParams)) appApi.launchApp(appCallsign, launchParams).then(res => { - console.log("Alexa.RemoteVideoPlayer:" + appCallsign + " launched successfully using alexa search: " + JSON.stringify(res)) + this.LOG("Alexa.RemoteVideoPlayer:" + JSON.stringify(appCallsign) + " launched successfully using alexa search: " + JSON.stringify(res)) }).catch(err => { - console.log("Alexa.RemoteVideoPlayer:" + appCallsign + " launch FAILED using alexa search: " + JSON.stringify(err)) + this.ERR("Alexa.RemoteVideoPlayer:" + JSON.stringify(appCallsign) + " launch FAILED using alexa search: " + JSON.stringify(err)) }) replacedText = null; appCallsign = null; launchParams = null; } else if (!entityId.length && (GLOBALS.topmostApp != GLOBALS.selfClientName)) { /* give it to current focused app */ - console.warn("Alexa.RemoteVideoPlayer: " + GLOBALS.topmostApp + " is the focued app; need Voice search integration support to it."); + this.WARN("Alexa.RemoteVideoPlayer: " + JSON.stringify(GLOBALS.topmostApp) + " is the focued app; need Voice search integration support to it."); } else if (!entityId.length && (GLOBALS.topmostApp == GLOBALS.selfClientName)) { /* Generic global search without a target app; redirect to Youtube as of now. */ let replacedText = payload.searchText.transcribed.trim(); @@ -2105,21 +2144,21 @@ export default class App extends Router.App { appIdentifier: self.appIdentifiers[appCallsign] } launchParams.url = Storage.get(appCallsign + "DefaultURL") + "&va=" + ((header.name === "SearchAndPlay") ? "play" : "search") + "&vq=" + encodeURI(replacedText); - console.log("Alexa.RemoteVideoPlayer: global search launchApp " + appCallsign + " with params " + launchParams) + this.LOG("Alexa.RemoteVideoPlayer: global search launchApp " + JSON.stringify(appCallsign) + " with params " + JSON.stringify(launchParams)) appApi.launchApp(appCallsign, launchParams).then(res => { - console.log("Alexa.RemoteVideoPlayer:" + appCallsign + " launched successfully using alexa search: " + JSON.stringify(res)) + this.LOG("Alexa.RemoteVideoPlayer:" + JSON.stringify(appCallsign) + " launched successfully using alexa search: " + JSON.stringify(res)) }).catch(err => { - console.log("Alexa.RemoteVideoPlayer:" + appCallsign + " launch FAILED using alexa search: " + JSON.stringify(err)) + this.ERR("Alexa.RemoteVideoPlayer:" + JSON.stringify(appCallsign) + " launch FAILED using alexa search: " + JSON.stringify(err)) }) replacedText = null; appCallsign = null; launchParams = null; } else { /* Possibly an unsupported App. */ - console.warn("Alexa.RemoteVideoPlayer: got ENTITY_ID " + entityId[0].externalIds.ENTITY_ID + "but no match in AlexaLauncherKeyMap."); + this.WARN("Alexa.RemoteVideoPlayer: got ENTITY_ID " + JSON.stringify(entityId[0]?.externalIds?.ENTITY_ID) + " but no match in AlexaLauncherKeyMap."); } } else { - console.warn("Alexa.RemoteVideoPlayer: payload does not have entities; may not work."); + this.WARN("Alexa.RemoteVideoPlayer: payload does not have entities; may not work."); } } } @@ -2140,7 +2179,7 @@ export default class App extends Router.App { if (header.name === "Play") { AlexaApi.get().displaySmartScreenOverlay(true) AlexaAudioplayerActive = true; - console.log("App AudioPlayer: Suspending the current app:'" + GLOBALS.topmostApp + "'"); + this.LOG("App AudioPlayer: Suspending the current app:'" + JSON.stringify(GLOBALS.topmostApp) + "'"); if (GLOBALS.topmostApp != GLOBALS.selfClientName) { appApi.exitApp(GLOBALS.topmostApp); } @@ -2153,18 +2192,17 @@ export default class App extends Router.App { } } else if (header.namespace === "Speaker") { - console.log("Speaker") + this.LOG("Speaker") if (header.name === "AdjustVolume") { VolumePayload.msgPayload.event.header.messageId = header.messageId appApi.getConnectedAudioPorts().then(audioport => { for (let i = 0; i < audioport.connectedAudioPorts.length && !audioport.connectedAudioPorts[i].startsWith("SPDIF"); i++) { - if ((Storage.get("deviceType") == "tv" && audioport.connectedAudioPorts[i].startsWith("SPEAKER")) || - (Storage.get("deviceType") != "tv" && audioport.connectedAudioPorts[i].startsWith("HDMI"))) { + if ((GLOBALS.deviceType == "IpTv" && audioport.connectedAudioPorts[i].startsWith("SPEAKER")) || (GLOBALS.deviceType != "IpTv" && audioport.connectedAudioPorts[i].startsWith("HDMI"))) { appApi.getVolumeLevel(audioport.connectedAudioPorts[i]).then(volres => { - console.log("getVolumeLevel[" + audioport.connectedAudioPorts[i] + "] is:" + parseInt(volres.volumeLevel)) + this.LOG("getVolumeLevel[" + JSON.stringify(audioport.connectedAudioPorts[i]) + "] is:" + JSON.stringify(parseInt(volres.volumeLevel))) if ((parseInt(volres.volumeLevel) >= 0) || (parseInt(volres.volumeLevel) <= 100)) { VolumePayload.msgPayload.event.payload.volume = parseInt(volres.volumeLevel) + payload.volume - console.log("volumepayload", VolumePayload.msgPayload.event.payload.volume) + this.LOG("volumepayload" + JSON.stringify(VolumePayload.msgPayload.event.payload.volume)) if (VolumePayload.msgPayload.event.payload.volume < 0) { VolumePayload.msgPayload.event.payload.volume = 0 } else if (VolumePayload.msgPayload.event.payload.volume > 100) { @@ -2180,12 +2218,12 @@ export default class App extends Router.App { this.tag("Volume").onVolumeChanged(volumeIncremented); } else { if (Router.getActiveHash() === "applauncher") { - RDKShellApis.moveToFront(GLOBALS.selfClientName) - RDKShellApis.setVisibility(GLOBALS.selfClientName, true) + RDKShellApis.moveToFront(GLOBALS.selfClientName) + RDKShellApis.setVisibility(GLOBALS.selfClientName, true) this.tag("Volume").onVolumeChanged(volumeIncremented); } else { - RDKShellApis.moveToFront(GLOBALS.selfClientName) - RDKShellApis.setVisibility(GLOBALS.selfClientName, true) + RDKShellApis.moveToFront(GLOBALS.selfClientName) + RDKShellApis.setVisibility(GLOBALS.selfClientName, true) Router.navigate("applauncher"); this.tag("Volume").onVolumeChanged(volumeIncremented); } @@ -2199,8 +2237,8 @@ export default class App extends Router.App { if (header.name === "SetVolume") { VolumePayload.msgPayload.event.header.messageId = header.messageId VolumePayload.msgPayload.event.payload.volume = payload.volume - console.log("adjust volume", VolumePayload) - console.log("checkvolume", VolumePayload.msgPayload.event.payload.volume) + this.LOG("adjust volume" + JSON.stringify(VolumePayload)) + this.LOG("checkvolume" + JSON.stringify(VolumePayload.msgPayload.event.payload.volume)) if (VolumePayload.msgPayload.event.payload.volume > 100) { VolumePayload.msgPayload.event.payload.volume = 100 } else if (VolumePayload.msgPayload.event.payload.volume < 0) { @@ -2208,9 +2246,9 @@ export default class App extends Router.App { } appApi.getConnectedAudioPorts().then(audioport => { for (let i = 0; i < audioport.connectedAudioPorts.length && !audioport.connectedAudioPorts[i].startsWith("SPDIF"); i++) { - if ((Storage.get("deviceType") == "tv" && audioport.connectedAudioPorts[i].startsWith("SPEAKER")) || - (Storage.get("deviceType") != "tv" && audioport.connectedAudioPorts[i].startsWith("HDMI"))) { - let volumeIncremented + if ((GLOBALS.deviceType == "IpTv" && audioport.connectedAudioPorts[i].startsWith("SPEAKER")) || + (GLOBALS.deviceType != "IpTv" && audioport.connectedAudioPorts[i].startsWith("HDMI"))) { + let volumeIncremented appApi.getVolumeLevel(audioport.connectedAudioPorts[i]).then(volres => { volumeIncremented = parseInt(volres.volumeLevel) < VolumePayload.msgPayload.event.payload.volume ? true : false if(volumeIncremented && VolumePayload.msgPayload.event.payload.muted) { @@ -2222,12 +2260,12 @@ export default class App extends Router.App { this.tag("Volume").onVolumeChanged(volumeIncremented); } else { if (Router.getActiveHash() === "applauncher") { - RDKShellApis.moveToFront(GLOBALS.selfClientName) - RDKShellApis.setVisibility(GLOBALS.selfClientName, true) + RDKShellApis.moveToFront(GLOBALS.selfClientName) + RDKShellApis.setVisibility(GLOBALS.selfClientName, true) this.tag("Volume").onVolumeChanged(volumeIncremented); } else { - RDKShellApis.moveToFront(GLOBALS.selfClientName) - RDKShellApis.setVisibility(GLOBALS.selfClientName, true) + RDKShellApis.moveToFront(GLOBALS.selfClientName) + RDKShellApis.setVisibility(GLOBALS.selfClientName, true) Router.navigate("applauncher"); this.tag("Volume").onVolumeChanged(volumeIncremented); } @@ -2245,18 +2283,18 @@ export default class App extends Router.App { this.tag("Volume").onVolumeMute(payload.mute); } else { if (Router.getActiveHash() === "applauncher") { - RDKShellApis.moveToFront(GLOBALS.selfClientName) - RDKShellApis.setVisibility(GLOBALS.selfClientName, true) + RDKShellApis.moveToFront(GLOBALS.selfClientName) + RDKShellApis.setVisibility(GLOBALS.selfClientName, true) this.tag("Volume").onVolumeMute(payload.mute); } else { - RDKShellApis.moveToFront(GLOBALS.selfClientName) - RDKShellApis.setVisibility(GLOBALS.selfClientName, true) + RDKShellApis.moveToFront(GLOBALS.selfClientName) + RDKShellApis.setVisibility(GLOBALS.selfClientName, true) Router.navigate("applauncher"); this.tag("Volume").onVolumeMute(payload.mute); } } } - } + } else if (header.namespace === "ExternalMediaPlayer") { appApi.deeplinkToApp(GLOBALS.topmostApp, payload, "alexa", header.namespace); } @@ -2278,7 +2316,7 @@ export default class App extends Router.App { }); voiceApi.registerEvent('onSessionEnd', notification => { if (notification.result === "success" && notification.success.transcription === "User request to disable Alexa") { - console.warn("App VoiceControl.onSessionEnd got disable Alexa.") + this.WARN("App VoiceControl.onSessionEnd got disable Alexa.") AlexaApi.get().resetAVSCredentials() // To avoid Audio Feedback AlexaApi.get().setAlexaAuthStatus("AlexaUserDenied") // Reset back to disabled as resetAVSCredentials() sets to ErrorHandling. } @@ -2294,7 +2332,7 @@ export default class App extends Router.App { jumpToRoute(route) { if (GLOBALS.topmostApp != GLOBALS.selfClientName) { appApi.exitApp(GLOBALS.topmostApp).catch(err => { - console.log("jumpToRoute err: " + err) + this.ERR("jumpToRoute err: " + JSON.stringify(err)) }); Storage.set("lastVisitedRoute", route);// incase any state change event tries to navigate, it need to be navigated to alexa requested route GLOBALS.LastvisitedRoute= route @@ -2305,10 +2343,10 @@ export default class App extends Router.App { dtvApi .exitChannel() .then((res) => { - console.log("exit channel: ", JSON.stringify(res)); + this.LOG("exit channel: " + JSON.stringify(res)); }) .catch((err) => { - console.log("failed to exit channel: ", JSON.stringify(err)); + this.ERR("failed to exit channel: " + JSON.stringify(err)); }); if (Router.getActiveWidget()) { Router.getActiveWidget()._setState("IdleState"); diff --git a/accelerator-home-ui/src/Config/Config.js b/accelerator-home-ui/src/Config/Config.js index 879da00..f26a45d 100644 --- a/accelerator-home-ui/src/Config/Config.js +++ b/accelerator-home-ui/src/Config/Config.js @@ -68,11 +68,14 @@ export var CONFIG = { } export const GLOBALS = { + _Wificonnectinprogress:false, + _deviceType:null, _LastvisitedRoute:null, _Setup:null, _TofocusVOD:false, _AlexaAvsstatus:false, _RCSkipStatus:false, + _IsinternetConnected:false, _Miracastclientdevicedetails:{mac: null,name: null,reason_code: null,state:null}, _previousapp_onActiveSourceStatusUpdated:null, _previousapp_onDisplayConnectionChanged:null, @@ -128,6 +131,14 @@ export const GLOBALS = { { return this._RCSkipStatus }, + set IsConnectedToInternet(status) + { + this._IsinternetConnected =status + }, + get IsConnectedToInternet() + { + return this._IsinternetConnected + }, set TofocusVOD(status) { this._TofocusVOD = status @@ -144,6 +155,14 @@ export const GLOBALS = { { return this._LastvisitedRoute }, + set Wificonnectinprogress(state) + { + this._Wificonnectinprogress = state + }, + get Wificonnectinprogress() + { + return this._Wificonnectinprogress + }, set Setup(status) { this._Setup = status @@ -152,4 +171,10 @@ export const GLOBALS = { { return this._Setup }, + set deviceType(type) { + this._deviceType = type; + }, + get deviceType() { + return this._deviceType; + } } diff --git a/accelerator-home-ui/src/MediaPlayer/AAMPVideoPlayer.js b/accelerator-home-ui/src/MediaPlayer/AAMPVideoPlayer.js index ab40070..fbe8664 100644 --- a/accelerator-home-ui/src/MediaPlayer/AAMPVideoPlayer.js +++ b/accelerator-home-ui/src/MediaPlayer/AAMPVideoPlayer.js @@ -28,6 +28,13 @@ let position = null * Class to render AAMP video player. */ export default class AAMPVideoPlayer extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } /** * Function to render player controls. */ @@ -57,7 +64,7 @@ export default class AAMPVideoPlayer extends Lightning.Component { }) this.setVideoRect(0, 0, 1920, 1080) } catch (error) { - console.error('Playback Failed ' + error) + this.ERR('Playback Failed ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.MEDIA,"PlaybackError", "Playback Failed"+JSON.stringify(error), false, null) } } @@ -280,7 +287,7 @@ export default class AAMPVideoPlayer extends Lightning.Component { player.addEventListener('durationChanged', this._mediaDurationChanged) this.playerState = this.playerStatesEnum.idle } catch (error) { - console.error('AAMPMediaPlayer is not defined') + this.ERR('AAMPMediaPlayer is not defined ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.MEDIA,"PlaybackError", "AAMPMediaPlayer is not defined" +JSON.stringify(error), false, null) } } @@ -299,7 +306,7 @@ export default class AAMPVideoPlayer extends Lightning.Component { this.tag('PlayerControls').title = videoInfo.title this.tag('PlayerControls').duration = player.getDurationSec() - console.log('Duration of video', player.getDurationSec()) + this.LOG('Duration of video: ' + JSON.stringify(player.getDurationSec())) this.tag('PlayerControls').currentTime = 0 this.play() } @@ -340,7 +347,7 @@ export default class AAMPVideoPlayer extends Lightning.Component { this.tag('ChannelName').text.text = channelName this.setVideoRect(0, 0, 1920, 1080) } catch (error) { - console.error('Playback Failed ' + error) + this.ERR('Playback Failed ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.MEDIA,"PlaybackError", "Playback Failed "+JSON.stringify(error), false, null) } } @@ -371,7 +378,7 @@ export default class AAMPVideoPlayer extends Lightning.Component { this.updateInfo() this.setVideoRect(0, 0, 1920, 1080) } catch (error) { - console.error('Playback Failed ' + error) + this.ERR('Playback Failed ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.MEDIA,"PlaybackError", 'Playback Failed ' + JSON.stringify(error), false, null) } } @@ -391,7 +398,7 @@ export default class AAMPVideoPlayer extends Lightning.Component { this.updateInfo() this.setVideoRect(0, 0, 1920, 1080) } catch (error) { - console.error('Playback Failed ' + error) + this.ERR('Playback Failed ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.MEDIA,"PlaybackError", 'Playback Failed '+JSON.stringify(error), false, null) } } diff --git a/accelerator-home-ui/src/MediaPlayer/ChannelOverlay.js b/accelerator-home-ui/src/MediaPlayer/ChannelOverlay.js index 012437d..4c59483 100644 --- a/accelerator-home-ui/src/MediaPlayer/ChannelOverlay.js +++ b/accelerator-home-ui/src/MediaPlayer/ChannelOverlay.js @@ -23,6 +23,13 @@ import ChannelItem from './ChannelItem' import HomeApi from '../api/HomeApi'; export default class ChannelOverlay extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } /** * Function to create components for the player controls. */ @@ -75,7 +82,7 @@ export default class ChannelOverlay extends Lightning.Component { } }) }).catch(err => { - console.log("Failed to fetch channels: ", JSON.stringify(err)) + this.ERR("Failed to fetch channels: " + JSON.stringify(err)) }) this._overlayAnimation = this.tag("Wrapper").animation({ delay: 0.3, @@ -178,18 +185,18 @@ export default class ChannelOverlay extends Lightning.Component { } else { if (focusedChannelIdx !== this.activeChannelIdx) { this.dtvApi.exitChannel().then(res => { - console.log("Current channel exit successful, launching new channel: ", JSON.stringify(res)); + this.LOG("Current channel exit successful, launching new channel: " + JSON.stringify(res)); this.dtvApi .launchChannel(this.options[focusedChannelIdx].dvburi) .then((res) => { - console.log("Change Channel successfull: ", JSON.stringify(res)); + this.LOG("Change Channel successfull: " + JSON.stringify(res)); this.activeChannelIdx = focusedChannelIdx; }) .catch((err) => { - console.log("Failed to launch new channel", JSON.stringify(err)); + this.ERR("Failed to launch new channel: " + JSON.stringify(err)); }); }).catch(err => { - console.log("Failed to exit current playing channel: ", JSON.stringify(err)); + this.ERR("Failed to exit current playing channel: " + JSON.stringify(err)); }) } } diff --git a/accelerator-home-ui/src/MediaPlayer/DTVPlayer.js b/accelerator-home-ui/src/MediaPlayer/DTVPlayer.js index f199ef2..3d2fa39 100644 --- a/accelerator-home-ui/src/MediaPlayer/DTVPlayer.js +++ b/accelerator-home-ui/src/MediaPlayer/DTVPlayer.js @@ -20,6 +20,14 @@ import { Lightning, Router } from "@lightningjs/sdk"; import AppApi from "../api/AppApi"; import DTVApi from "../api/DTVApi"; export default class DTVPlayer extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Player: { @@ -38,10 +46,10 @@ export default class DTVPlayer extends Lightning.Component { this.dtvApi .exitChannel() .then((res) => { - console.log("exit channel: ", JSON.stringify(res)); + this.LOG("exit channel: " + JSON.stringify(res)); }) .catch((err) => { - console.log("failed to exit channel: ", JSON.stringify(err)); + this.ERR("failed to exit channel: " + JSON.stringify(err)); }); Router.back(); } diff --git a/accelerator-home-ui/src/MediaPlayer/LightningPlayerControl.js b/accelerator-home-ui/src/MediaPlayer/LightningPlayerControl.js index 2d8a6ce..07ce8cc 100644 --- a/accelerator-home-ui/src/MediaPlayer/LightningPlayerControl.js +++ b/accelerator-home-ui/src/MediaPlayer/LightningPlayerControl.js @@ -28,6 +28,13 @@ var timeout * Class to render the UI controls for the video player. */ export default class LightningPlayerControls extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } /** * Function to create components for the player controls. */ @@ -139,7 +146,7 @@ export default class LightningPlayerControls extends Lightning.Component { * @param {String} duration video duration to be set. */ set duration(duration) { - console.log(`duration was set = ${duration}`); + this.LOG("duration was set = " + JSON.stringify(duration)); this.videoDuration = duration this.tag('Duration').text.text = this.SecondsTohhmmss(duration) } diff --git a/accelerator-home-ui/src/api/AlexaApi.js b/accelerator-home-ui/src/api/AlexaApi.js index 44ac4a6..ec863a6 100644 --- a/accelerator-home-ui/src/api/AlexaApi.js +++ b/accelerator-home-ui/src/api/AlexaApi.js @@ -36,11 +36,19 @@ export default class AlexaApi extends VoiceApi { return instance } + constructor() { + super(); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + /* Can be used to reduce enableSmartScreen() call */ isSmartScreenActiavated() { let appApi = new AppApi(); appApi.checkStatus('SmartScreen').then(result => { - console.log("AlexaAPI: isSmartScreenActiavated result-" + JSON.stringify(result[0].state.toLowerCase())); + this.LOG("AlexaAPI: isSmartScreenActiavated result-" + JSON.stringify(result[0].state.toLowerCase())); switch (result[0].state.toLowerCase()) { case "resumed": case "activated": break; @@ -49,26 +57,26 @@ export default class AlexaApi extends VoiceApi { } return true; }).catch(err => { - console.error("AlexaAPI: isSmartScreenActiavated error-", err); + this.ERR("AlexaAPI: isSmartScreenActiavated error-" + JSON.stringify(err)); return (false); }); } enableSmartScreen() { thunder.Controller.activate({ callsign: 'SmartScreen' }).then(res => { - console.log("AlexaAPI: Activate SmartScreen result: " + res); + this.LOG("AlexaAPI: Activate SmartScreen result: " + JSON.stringify(res)); }).catch(err => { - console.error("AlexaAPI: Activate SmartScreen ERROR!: ", err) + this.ERR("AlexaAPI: Activate SmartScreen ERROR!: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", `Thunder Controller AlexaAPI: Activate SmartScreen error with ${err}`, false, null) }) } disableSmartScreen() { thunder.Controller.deactivate({ callsign: 'SmartScreen' }).then(res => { - console.log("AlexaAPI: Deactivate SmartScreen result: " + res); + this.LOG("AlexaAPI: Deactivate SmartScreen result: " + JSON.stringify(res)); }).catch(err => { - console.error("AlexaAPI: Deactivate SmartScreen ERROR!: ", err) - Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", `Thunder Controller AlexaAPI: Deactivate SmartScreen error with ${err}`, false, null) + this.ERR("AlexaAPI: Deactivate SmartScreen ERROR!: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", "Thunder Controller AlexaAPI: Deactivate SmartScreen error with " + JSON.stringify(err), false, null) }) } @@ -100,14 +108,14 @@ export default class AlexaApi extends VoiceApi { } /* Send the new app state object if its a known app. */ if (isListedApp) { - console.warn("Sending app statereport to Alexa:" + JSON.stringify(appStateReportPayload)); + this.WARN("Sending app statereport to Alexa:" + JSON.stringify(appStateReportPayload)); this.sendVoiceMessage(appStateReportPayload); } else { - console.error("Alexa reportApplicationState; no match found, won't send state report."); - Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", 'Alexa reportApplicationState; no match found, wont send state report.', false, null) + this.ERR("Alexa reportApplicationState; no match found, won't send state report."); + Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", "Alexa reportApplicationState; no match found, wont send state report.", false, null) } } else { - console.log("Alexa reportApplicationState: AlexaUserDenied/AlexaAuthPending, skip state reporting."); + this.LOG("Alexa reportApplicationState: AlexaUserDenied/AlexaAuthPending, skip state reporting."); } } @@ -118,7 +126,7 @@ export default class AlexaApi extends VoiceApi { VolumePayload.msgPayload.event.payload.muted = muteStatus if (messageId != undefined) VolumePayload.msgPayload.event.header.messageId = messageId - console.log("Sending volume statereport to Alexa:", VolumePayload); + this.LOG("Sending volume statereport to Alexa:" + JSON.stringify(VolumePayload)); this.sendVoiceMessage(VolumePayload); } @@ -126,13 +134,13 @@ export default class AlexaApi extends VoiceApi { let updatedLan = [] updatedLan.push(updatedLanguage) let payload = { "msgPayload": { "DeviceSettings": "Set Device Settings", "values": { "locale": updatedLan } } } - console.log("Sending language statereport to Alexa:", updatedLan); + this.LOG("Sending language statereport to Alexa:" + JSON.stringify(updatedLan)); this.sendVoiceMessage(payload); } //reportDeviceTimeZone(updatedTimeZone) { updateDeviceTimeZoneInAlexa(updatedTimeZone) { - console.log("updateDeviceTimeZoneInAlexa sending :" + updatedTimeZone) + this.LOG("updateDeviceTimeZoneInAlexa sending :" + JSON.stringify(updatedTimeZone)) let payload = { "msgPayload": { "DeviceSettings": "Set Device Settings", "values": { "timezone": updatedTimeZone } } } this.sendVoiceMessage(payload); } @@ -144,13 +152,13 @@ export default class AlexaApi extends VoiceApi { errorPayload.msgPayload.event.header.payloadVersion = directive.header.payloadVersion errorPayload.msgPayload.event.endpoint.endpointId = directive.endpoint.endpointId errorPayload.msgPayload.event.header.messageId = directive.header.messageId - console.log("AlexaAPI: reportErrorState payload:", errorPayload) + this.LOG("AlexaAPI: reportErrorState payload:" + JSON.stringify(errorPayload)) this.sendVoiceMessage(errorPayload); } reportPlaybackState(state = "STOPPED") { PlaybackStateReport.msgPayload.event.header.value = state; - console.log("AlexaAPI: reportPlaybackState payload:", PlaybackStateReport) + this.LOG("AlexaAPI: reportPlaybackState payload:" + JSON.stringify(PlaybackStateReport)) this.sendVoiceMessage(PlaybackStateReport); } @@ -169,16 +177,16 @@ export default class AlexaApi extends VoiceApi { return new Promise((resolve) => { Storage.set("AlexaVoiceAssitantState", "AlexaAuthPending"); thunder.Controller.activate({ callsign: 'SmartScreen' }).then(() => { - console.log("AlexaAPI: resetAVSCredentials activating SmartScreen instance.") + this.LOG("AlexaAPI: resetAVSCredentials activating SmartScreen instance.") }).catch(err => { - console.error("AlexaAPI: resetAVSCredentials activate SmartScreen ERROR!: ", err) - Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", `Thunder Controller AlexaAPI: resetAVSCredentials activating SmartScreen error with ${JSON.stringify(err)}`, false, null) + this.ERR("AlexaAPI: resetAVSCredentials activate SmartScreen ERROR!: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", "Thunder Controller AlexaAPI: resetAVSCredentials activating SmartScreen error with " + JSON.stringify(err), false, null) }) this.sendVoiceMessage({ "msgPayload": { "event": "ResetAVS" } }).then(result => { resolve(result) }).catch(err => { - console.error("AlexaAPI: resetAVSCredentials ERROR!: " + JSON.stringify(err)) - Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", `Thunder Controller AlexaAPI: resetAVSCredentials Activate ERROR!: ${JSON.stringify(err)}`, false, null) + this.ERR("AlexaAPI: resetAVSCredentials ERROR!: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", "Thunder Controller AlexaAPI: resetAVSCredentials Activate ERROR!: " + JSON.stringify(err), false, null) resolve(false) }) }); @@ -201,15 +209,15 @@ export default class AlexaApi extends VoiceApi { this.configureVoice({ "enable": false }); /* Free up Smartscreen resources */ thunder.Controller.deactivate({ callsign: 'SmartScreen' }).then(() => { - console.log("AlexaAPI: deactivated SmartScreen instance.") + this.LOG("AlexaAPI: deactivated SmartScreen instance.") }).catch(err => { - console.error("AlexaAPI: deactivate SmartScreen ERROR!: ", err) - Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", `Thunder Controller AlexaAPI: deactivate SmartScreen ERROR: ${JSON.stringify(err)}`, true, null) + this.ERR("AlexaAPI: deactivate SmartScreen ERROR!: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.OTHER, "AlexaAPIError", "Thunder Controller AlexaAPI: deactivate SmartScreen ERROR: " + JSON.stringify(err), true, null) }) } else { this.configureVoice({ "enable": true }); } - console.warn("setAlexaAuthStatus with ", newState) + this.WARN("setAlexaAuthStatus with " + JSON.stringify(newState)) } /** @@ -223,6 +231,6 @@ export default class AlexaApi extends VoiceApi { } setAlexaSmartscreenAudioPlaybackState(newState = false) { Storage.set("AlexaSmartscreenAudioPlaybackState", newState) - console.log("setAlexaSmartscreenAudioPlaybackState with ", newState) + this.LOG("setAlexaSmartscreenAudioPlaybackState with " + JSON.stringify(newState)) } } diff --git a/accelerator-home-ui/src/api/AppApi.js b/accelerator-home-ui/src/api/AppApi.js index 026469e..78d6c39 100644 --- a/accelerator-home-ui/src/api/AppApi.js +++ b/accelerator-home-ui/src/api/AppApi.js @@ -36,6 +36,10 @@ export default class AppApi { constructor() { this.activatedForeground = false this._events = new Map() + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; } /** @@ -55,7 +59,7 @@ export default class AppApi { resolve(result.zoneinfo) }) .catch(err => { - console.error('AppAPI Cannot fetch time zone', err) + this.ERR('AppAPI Cannot fetch time zone', err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getTimeZones" + err, false, null) resolve({}) }) @@ -77,13 +81,13 @@ export default class AppApi { resolve(result.success) }) .catch(err => { - console.error("AppAPI System getDeviceInfo estb_ip failed." + JSON.stringify(err)); + this.ERR("AppAPI System getDeviceInfo estb_ip failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.NETWORK, "Network Error", "Error in Thunder system getDeviceInfo" + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.error("AppAPI activate System failed." + JSON.stringify(err)); + this.ERR("AppAPI activate System failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.NETWORK, "Network Error", "Error in Thunder system activation " + JSON.stringify(err), false, null) }) }) @@ -98,7 +102,7 @@ export default class AppApi { resolve(result.timeZone) }) .catch(err => { - console.error('AppAPI System plugin getTimeZoneDST failed.' + JSON.stringify(err)); + this.ERR('AppAPI System plugin getTimeZoneDST failed.' + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getTimeZoneDST" + JSON.stringify(err), false, null) resolve(undefined) }) @@ -106,20 +110,20 @@ export default class AppApi { } setZone(zone) { - console.log(zone) + this.LOG(zone) return new Promise((resolve) => { thunder .call('org.rdk.System', 'setTimeZoneDST', { timeZone: zone }) .then(result => { resolve(result.success) }).catch(err => { - console.error("AppAPI System plugin setTimeZoneDST failed." + JSON.stringify(err)); + this.ERR("AppAPI System plugin setTimeZoneDST failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system setTimeZoneDSt" + JSON.stringify(err), false, null) resolve(false) }) }).catch(err => { Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system setTimeZoneDST " + JSON.stringify(err), false, null) - console.error("AppAPI activate System failed." + JSON.stringify(err)); + this.ERR("AppAPI activate System failed." + JSON.stringify(err)); }) } @@ -131,7 +135,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI Controller plugin '" + plugin + "' status check failed."); + this.ERR("AppAPI Controller plugin '" + plugin + "' status check failed."); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system status " + JSON.stringify(err), false, null) reject(err) }) @@ -152,7 +156,7 @@ export default class AppApi { resolve(result.resolution) }) .catch(err => { - console.error("AppAPI DisplaySettings plugin getCurrentResolution failed." + JSON.stringify(err)); + this.ERR("AppAPI DisplaySettings plugin getCurrentResolution failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "ApiError", "Error in Thunder displaySettings getCurrentResolution " + JSON.stringify(err), false, null) resolve('NA') }); @@ -168,7 +172,7 @@ export default class AppApi { resolve(res) }) .catch(err => { - console.error('AppAPI activate DisplaySettings failed.' + JSON.stringify(err)) + this.ERR('AppAPI activate DisplaySettings failed.' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "ApiError", 'Error while Thunder Controller displaysettings activate ' + JSON.stringify(err), false, null) // change from here on monday }) }); @@ -184,13 +188,13 @@ export default class AppApi { resolve(result.supportedResolutions) }) .catch(err => { - console.error("AppAPI DisplaySettings getSupportedResolutions failed." + JSON.stringify(err)); + this.ERR("AppAPI DisplaySettings getSupportedResolutions failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "ApiError", "Error in Thunder displaySettings getSupportedResolutions " + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.error('AppAPI activate DisplaySettings Error', JSON.stringify(err)); + this.ERR('AppAPI activate DisplaySettings Error', JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "ApiError", 'Error while Thunder Controller displaysettings activate ' + JSON.stringify(err), false, null) }) }) @@ -213,13 +217,13 @@ export default class AppApi { resolve(result.success) }) .catch(err => { - console.error("AppAPI DisplaySettings setCurrentResolution failed." + JSON.stringify(err)); + this.ERR("AppAPI DisplaySettings setCurrentResolution failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "ApiError", 'Error in Thunder displaysettings setCurrentResolution ' + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.error('AppAPI activate DisplaySettings Error', JSON.stringify(err)); + this.ERR('AppAPI activate DisplaySettings Error', JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "ApiError", 'Error while Thunder Controller displaysettings activate ' + JSON.stringify(err), false, null) }) }) @@ -235,17 +239,17 @@ export default class AppApi { thunder .call('org.rdk.HdcpProfile', 'getHDCPStatus') .then(result => { - console.log("AppAPI HdcpProfile getHDCPStatus : " + JSON.stringify(result.HDCPStatus)); + this.LOG("AppAPI HdcpProfile getHDCPStatus : " + JSON.stringify(result.HDCPStatus)); resolve(result.HDCPStatus) }) .catch(err => { - console.error("AppAPI HdcpProfile getHDCPStatus failed." + JSON.stringify(err)); + this.ERR("AppAPI HdcpProfile getHDCPStatus failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "HDCPError", 'Error in Thunder HdcpProfile getHDCPStatus ' + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.error('AppAPI activate HdcpProfile ', JSON.stringify(err)) + this.ERR('AppAPI activate HdcpProfile ', JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "HDCPError", 'Error while Thunder Controller HdcpProfile activate ' + JSON.stringify(err), false, null) }) }) @@ -261,17 +265,17 @@ export default class AppApi { thunder .call('org.rdk.DisplaySettings', 'getTvHDRSupport') .then(result => { - console.log("AppAPI DisplaySettings getTvHDRSupport : " + JSON.stringify(result)); + this.LOG("AppAPI DisplaySettings getTvHDRSupport : " + JSON.stringify(result)); resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings getTvHDRSupport failed." + JSON.stringify(err)); + this.ERR("AppAPI DisplaySettings getTvHDRSupport failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "ApiError", 'Error in Thunder DisplaySettings getTvHDRSupport ' + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.error('AppAPI activate DisplaySettings Error', JSON.stringify(err)); + this.ERR('AppAPI activate DisplaySettings Error', JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "ApiError", 'Error while Thunder Controller DisplaySettings activate ' + JSON.stringify(err), false, null) }) }) @@ -287,17 +291,17 @@ export default class AppApi { thunder .call('org.rdk.DisplaySettings', 'getSettopHDRSupport') .then(result => { - console.log("AppAPI DisplaySettings getSettopHDRSupport : " + JSON.stringify(result)); + this.LOG("AppAPI DisplaySettings getSettopHDRSupport : " + JSON.stringify(result)); resolve(result) }) .catch(err => { - console.error('AppAPI DisplaySettings getSettopHDRSupport failed ', JSON.stringify(err)); + this.ERR('AppAPI DisplaySettings getSettopHDRSupport failed ', JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", 'Error in Thunder DisplaySettings getSettopHDRSupport ' + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.error('AppAPI activate DisplaySettings Error', JSON.stringify(err)) + this.ERR('AppAPI activate DisplaySettings Error', JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", 'Error while Thunder Controller DisplaySettings activate ' + JSON.stringify(err), false, null) }) }) @@ -313,17 +317,17 @@ export default class AppApi { thunder .call('DisplayInfo', 'hdrsetting') .then(result => { - console.log("AppAPI DisplayInfo hdrsetting : " + JSON.stringify(result)); + this.LOG("AppAPI DisplayInfo hdrsetting : " + JSON.stringify(result)); resolve(result) }) .catch(err => { - console.error("AppAPI DisplayInfo hdrsetting failed : " + JSON.stringify(err)); + this.ERR("AppAPI DisplayInfo hdrsetting failed : " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", 'Error in fetching Thunder DisplayInfo hdrsetting ' + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.log('AppAPI activate DisplayInfo Error', JSON.stringify(err)) + this.LOG('AppAPI activate DisplayInfo Error', JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", 'Error while Thunder Controller DisplayInfo activate ' + JSON.stringify(err), false, null) }) }) @@ -339,17 +343,17 @@ export default class AppApi { thunder .call('OCDM', 'drms') .then(result => { - console.log("AppAPI OCDM supported drms: " + JSON.stringify(result)); + this.LOG("AppAPI OCDM supported drms: " + JSON.stringify(result)); resolve(result) }) .catch(err => { - console.error("AppAPI OCDM drms failed." + JSON.stringify(err)); + this.ERR("AppAPI OCDM drms failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "OCDMError", 'Error in fetching Thunder OCDM drms ' + JSON.stringify(err), false, null) resolve(false) }) }) .catch(err => { - console.error('AppAPI activate OCDM error:', JSON.stringify(err)) + this.ERR('AppAPI activate OCDM error:', JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "OCDMError", 'Error while Thunder Controller OCDM activate ' + JSON.stringify(err), false, null) }) }) @@ -366,7 +370,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI ResidentApp delete cache failed."); + this.ERR("AppAPI ResidentApp delete cache failed."); Metrics.error(Metrics.ErrorType.OTHER, "Cache failure", JSON.stringify(err), false, null) resolve(err) }) @@ -377,7 +381,7 @@ export default class AppApi { return RDKShellApis.getAvailableTypes().then(types => { // Include NativeApp as well as its not being included from backend. if (!types.includes("NativeApp")) types.push("NativeApp"); - console.log("RDKShell.getAvailableTypes:", JSON.stringify(types)) + this.LOG("RDKShell.getAvailableTypes:", JSON.stringify(types)) resolve(types) }).catch(err => { Metrics.error(Metrics.ErrorType.OTHER, "Cache failure", 'Error in fetching Thunder RDKShell getAvailableTypes ' + JSON.stringify(err), false, null) @@ -407,7 +411,7 @@ export default class AppApi { GLOBALS.LastvisitedRoute="menu" } Router.navigate("applauncher"); - console.log("AppAPI launchApp called with: ", callsign, args); + this.LOG("AppAPI launchApp called with: " + JSON.stringify(callsign) + JSON.stringify(args)); if (callsign.startsWith("YouTube")) { Storage.set(callsign + "LaunchLocation", args.launchLocation) } @@ -440,7 +444,7 @@ export default class AppApi { } } - console.log("AppAPI launchApp with callsign: " + callsign + " | url: " + url + " | preventInternetCheck: " + preventInternetCheck + " | preventCurrentExit: " + preventCurrentExit + " | launchLocation: " + launchLocation); + this.LOG("AppAPI launchApp with callsign: " + JSON.stringify(callsign) + " | url: " + JSON.stringify(url) + " | preventInternetCheck: " + JSON.stringify(preventInternetCheck) + " | preventCurrentExit: " + JSON.stringify(preventCurrentExit) + " | launchLocation: " + JSON.stringify(launchLocation)); let IIDqueryString = ""; if (callsign === "Netflix") { @@ -451,7 +455,7 @@ export default class AppApi { IIDqueryString = "&" + IIDqueryString; //so that IIDqueryString can be appended with url later. } } else { - console.warn("AppAPI launchLocation(IID) not specified while launching netflix"); + this.WARN("AppAPI launchLocation(IID) not specified while launching netflix"); } } @@ -481,59 +485,59 @@ export default class AppApi { pluginState = pluginStatus[0].state; } } catch (err) { - console.error(err); + this.ERR("Getplugin status error"+err); Storage.set("appSwitchingInProgress", false); Router.navigate(GLOBALS.LastvisitedRoute); return Promise.reject("AppAPI PluginError: " + callsign + ": App not supported on this device | Error: " + JSON.stringify(err)); } - console.log("AppAPI " + callsign + " : pluginStatus: " + JSON.stringify(pluginStatus) + " pluginState: ", JSON.stringify(pluginState)); + this.LOG("AppAPI " + callsign + " : pluginStatus: " + JSON.stringify(pluginStatus) + " pluginState: ", JSON.stringify(pluginState)); if(callsign.startsWith("Amazon") || callsign.startsWith("Netflix")||callsign.startsWith("YouTube")){ if(pluginState ==='hibernated') { thunder.call('org.rdk.RDKShell.1','restore',{"callsign": callsign}).then(res =>{ - console.log(JSON.stringify(res)); + this.LOG(JSON.stringify(res)); }) } } if (callsign === "Netflix") { if (pluginState === "deactivated" || pluginState === "deactivation") { //netflix cold launch scenario - console.log(`AppAPI Netflix : ColdLaunch`) + this.LOG(`AppAPI Netflix : ColdLaunch`) if (Router.getActivePage().showSplashImage) { Router.getActivePage().showSplashImage(callsign) //to make the splash image for netflix visible } if (url) { try { - console.log("AppAPI Netflix ColdLaunch passing netflix url & IIDqueryString using configureApplication method: ", url, IIDqueryString); + this.LOG("AppAPI Netflix ColdLaunch passing netflix url & IIDqueryString using configureApplication method: ", url, IIDqueryString); await this.configureApplication("Netflix", url + IIDqueryString); } catch (err) { - console.error("AppAPI Netflix configureApplication error: ", err); + this.ERR("AppAPI Netflix configureApplication error: ", err); } } else { try { - console.log("AppAPI Netflix ColdLaunch passing netflix IIDqueryString using configureApplication method: ", IIDqueryString); + this.LOG("AppAPI Netflix ColdLaunch passing netflix IIDqueryString using configureApplication method: ", IIDqueryString); await this.configureApplication("Netflix", IIDqueryString); } catch (err) { - console.error("AppAPI Netflix configureApplication error: ", err); + this.ERR("AppAPI Netflix configureApplication error: ", err); } } } else { //netflix hot launch scenario - console.log("AppAPI Netflix : HotLaunch") + this.LOG("AppAPI Netflix : HotLaunch") if (url) { try { - console.log("AppAPI Netflix HotLaunch passing netflix url & IIDqueryString using systemcommand method: ", url, IIDqueryString); + this.LOG("AppAPI Netflix HotLaunch passing netflix url & IIDqueryString using systemcommand method: ", url, IIDqueryString); await thunder.call("Netflix", "systemcommand", { command: url + IIDqueryString }); } catch (err) { - console.error("AppAPI Netflix systemcommand error: ", err); + this.ERR("AppAPI Netflix systemcommand error: ", err); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder Netflix systemcommand " + JSON.stringify(err), false, null) } } else { try { - console.log("AppAPI Netflix HotLaunch passing netflix IIDqueryString using systemcommand method: ", IIDqueryString); + this.LOG("AppAPI Netflix HotLaunch passing netflix IIDqueryString using systemcommand method: ", IIDqueryString); await thunder.call("Netflix", "systemcommand", { command: IIDqueryString }); } catch (err) { - console.error("AppAPI Netflix systemcommand error: ", err); + this.ERR("AppAPI Netflix systemcommand error: ", err); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder Netflix systemcommand " + JSON.stringify(err), false, null) } } @@ -578,7 +582,7 @@ export default class AppApi { } url += "vs=2" // YT Dev Doc specific to Alexa } - console.log("AppAPI " + callsign + " is being launched using the url: " + url) + this.LOG("AppAPI " + callsign + " is being launched using the url: " + JSON.stringify(url)) } params.configuration = { //for gracenote cold launch url needs to be re formatted to youtube.com/tv/ @@ -603,11 +607,11 @@ export default class AppApi { if (!preventCurrentExit && (currentApp !== GLOBALS.selfClientName) && (currentApp !== callsign)) { //currentApp==="" means currently on residentApp | make currentApp = "residentApp" in the cache and stack try { - console.log("AppAPI calling exitApp with params: " + callsign + " and exitInBackground " + currentApp + " true.") + this.LOG("AppAPI calling exitApp with params: " + callsign + " and exitInBackground " + currentApp + " true.") await this.exitApp(currentApp, true) } catch (err) { - console.error("AppAPI currentApp " + currentApp + " exit failed!: launching new app...") + this.ERR("AppAPI currentApp " + currentApp + " exit failed!: launching new app...") Metrics.error(Metrics.ErrorType.OTHER, "AppError", `exit failed! for ${currentApp} with ${JSON.stringify(err)}.So launching new app...`, false, null) } } @@ -622,14 +626,14 @@ export default class AppApi { if (JSON.stringify(params.configuration) === '{}') { delete params.configuration; } - console.log("AppAPI RDKShell launch with params: ", params); + this.LOG("AppAPI RDKShell launch with params: " + JSON.stringify(params)); return new Promise((resolve, reject) => { if (callsign === "NativeApp") { // Could be coming from PartnerApp. params.client = callsign; params.mimeType = "application/native"; RDKShellApis.launchApplication(params).then(res => { - console.log(`AppAPI ${callsign} : Launch results in ${JSON.stringify(res)}`) + this.LOG(`AppAPI ${callsign} : Launch results in ${JSON.stringify(res)}`) if (res.success) { AlexaApi.get().reportApplicationState(callsign); if (args.appIdentifier) { @@ -650,14 +654,14 @@ export default class AppApi { Storage.set("appSwitchingInProgress", false); resolve(res); } else { - console.error("AppAPI failed to launchApp(success false) : ", callsign, " ERROR: ", JSON.stringify(res)) + this.ERR("AppAPI failed to launchApp(success false) : ", callsign, " ERROR: ", JSON.stringify(res)) Storage.set("appSwitchingInProgress", false); Router.navigate(GLOBALS.LastvisitedRoute); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell launchApplication " + JSON.stringify(res), false, null) reject(res) } }).catch(err => { - console.error("AppAPI failed to launchApp: ", callsign, " ERROR: ", JSON.stringify(err), " | Launching residentApp back") + this.ERR("AppAPI failed to launchApp: ", callsign, " ERROR: ", JSON.stringify(err), " | Launching residentApp back") RDKShellApis.kill(callsign); this.launchResidentApp(GLOBALS.selfClientName); Storage.set("appSwitchingInProgress", false); @@ -667,7 +671,7 @@ export default class AppApi { }) } else { RDKShellApis.launch(params).then(res => { - console.log(`AppAPI ${callsign} : Launch results in ${JSON.stringify(res)}`) + this.LOG("AppAPI " + callsign + " : Launch results in " + JSON.stringify(res)) if (res.success) { if ((callsign === "HtmlApp") || (callsign === "LightningApp")) { AlexaApi.get().reportApplicationState(url); @@ -691,32 +695,32 @@ export default class AppApi { if (callsign !== "Netflix") { //if app is not netflix, move it to front(netflix will be moved to front from applauncherScreen.) RDKShellApis.getZOrder().then(res => { - console.warn("AppAPI zOrder:" + JSON.stringify(res)); + this.WARN("AppAPI zOrder:" + JSON.stringify(res)); }).catch(err => { - console.error("AppAPI failed to zOrder : ", callsign, " ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to zOrder : " + JSON.stringify(callsign) + " ERROR: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell zOrder " + JSON.stringify(err), false, null) }) RDKShellApis.moveToFront(callsign, callsign).catch(err => { - console.error("AppAPI failed to moveToFront : ", callsign, " ERROR: ", JSON.stringify(err), " | fail reason can be since app is already in front") + this.ERR("AppAPI failed to moveToFront : " + JSON.stringify(callsign) + " ERROR: " + JSON.stringify(err) + " | fail reason can be since app is already in front") Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell moveToFront " + JSON.stringify(err), false, null) }) } RDKShellApis.setFocus(callsign, callsign).catch(err => { - console.error("AppAPI failed to setFocus : ", callsign, " ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to setFocus : ", callsign, " ERROR: ", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell setFocus " + JSON.stringify(err), false, null) }) RDKShellApis.setVisibility(callsign, true).catch(err => { - console.error("AppAPI failed to setVisibility : ", callsign, " ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to setVisibility : ", callsign, " ERROR: ", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell setVisibility " + JSON.stringify(err), false, null) }) if (callsign === "Netflix") { - console.log("AppAPI Netflix launched: hiding residentApp"); + this.LOG("AppAPI Netflix launched: hiding residentApp"); //if netflix splash screen was launched resident app was kept visible Netflix until app launched. RDKShellApis.setVisibility(GLOBALS.selfClientName, false).catch(err => { - console.error("AppAPI failed to setVisibility : ", GLOBALS.selfClientName, " ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to setVisibility : ", GLOBALS.selfClientName, " ERROR: ", JSON.stringify(err)) }) } @@ -727,26 +731,26 @@ export default class AppApi { } else if (!url) { url = params.configuration.url; } - console.log("AppAPI Calling " + callsign + ".deeplink with url: " + url); + this.LOG("AppAPI Calling " + callsign + ".deeplink with url: " + url); thunder.call(callsign, 'deeplink', url) } Storage.set("appSwitchingInProgress", false); GLOBALS.topmostApp = callsign; resolve(res); } else { - console.error("AppAPI failed to launchApp(success false) : ", callsign, " ERROR: ", JSON.stringify(res)) + this.ERR("AppAPI failed to launchApp(success false) : "+ JSON.stringify(callsign), " ERROR: ", JSON.stringify(res)) Storage.set("appSwitchingInProgress", false); Router.navigate(GLOBALS.LastvisitedRoute); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell launch " + JSON.stringify(err), false, null) reject(res) } }).catch(err => { - console.error("AppAPI failed to launchApp: ", callsign, " ERROR: ", JSON.stringify(err), " | Launching residentApp back") + this.ERR("AppAPI failed to launchApp: " + JSON.stringify(callsign) + " ERROR: " + JSON.stringify(err) + " | Launching residentApp back") Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell launch " + JSON.stringify(err), false, null) //destroying the app incase it's stuck in launching | if taking care of ResidentApp as callsign, make sure to prevent destroying it RDKShellApis.destroy(callsign).catch(err => { - console.error("AppAPI failed to destroy : ", callsign, " ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to destroy : " + JSON.stringify(callsign) + " ERROR: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell destroy " + JSON.stringify(err), false, null) }) this.launchResidentApp(GLOBALS.selfClientName); @@ -773,7 +777,7 @@ export default class AppApi { } if (callsign === "HDMI") { - console.log("AppAPI exit method called for hdmi") + this.LOG("AppAPI exit method called for hdmi") new HDMIApi().stopHDMIInput() Storage.set("_currentInputMode", {}); if (!exitInBackground) { //means resident App needs to be launched @@ -795,7 +799,7 @@ export default class AppApi { pluginStatus = await this.getPluginStatus(callsign); if (pluginStatus !== undefined) { pluginState = pluginStatus[0].state; - console.log("AppAPI pluginStatus: " + JSON.stringify(pluginStatus) + " pluginState: ", JSON.stringify(pluginState)); + this.LOG("AppAPI pluginStatus: " + JSON.stringify(pluginStatus) + " pluginState: ", JSON.stringify(pluginState)); } else { return Promise.reject("AppAPI PluginError: " + callsign + ": App not supported on this device"); @@ -805,44 +809,44 @@ export default class AppApi { } } - if (!exitInBackground) { //means resident App needs to be launched + if (!exitInBackground && GLOBALS.Miracastclientdevicedetails.state != "PLAYING") { //means resident App needs to be launched this.launchResidentApp(GLOBALS.selfClientName, GLOBALS.selfClientName).then(() => { AlexaApi.get().reportApplicationState("menu", true); }); } //to hide the current app - console.log("AppAPI setting visibility of " + callsign + " to false") + this.LOG("AppAPI setting visibility of " + callsign + " to false") await RDKShellApis.setVisibility(callsign, false).catch(err => { - console.error("AppAPI failed to setVisibility : " + callsign + " ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to setVisibility : " + callsign + " ERROR: ", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell setVisibility " + JSON.stringify(err), false, null) }) if (forceDestroy) { if (pluginState != undefined) { // App is a Plugin - console.log("AppAPI Force Destroying the app: ", callsign) + this.LOG("AppAPI Force Destroying the app: ", callsign) await RDKShellApis.destroy(callsign).catch(err => { - console.error("AppAPI Error in destroying app: " + callsign + " " + JSON.stringify(err)); + this.ERR("AppAPI Error in destroying app: " + callsign + " " + JSON.stringify(err)); RDKShellApis.kill(callsign).catch(err => { - console.error("AppAPI Error in killing app: " + callsign + " " + JSON.stringify(err)); + this.ERR("AppAPI Error in killing app: " + callsign + " " + JSON.stringify(err)); }) }) return Promise.resolve(true); } else if (callsign === "NativeApp" || callsign.includes('application/dac.native')) { await RDKShellApis.kill((callsign.includes('application/dac.native') ? callsign.substring(0, callsign.indexOf(';')) : callsign)).catch(err => { - console.error("AppAPI RDKShell kill: " + callsign + " ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI RDKShell kill: " + callsign + " ERROR: ", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell kill " + JSON.stringify(err), false, null) return Promise.resolve(false); }); } } else { - console.log("AppAPI Exiting from App: ", callsign, " depending on platform settings enableAppSuspended: ", Settings.get("platform", "enableAppSuspended")); + this.LOG("AppAPI Exiting from App: ", callsign, " depending on platform settings enableAppSuspended: ", Settings.get("platform", "enableAppSuspended")); //enableAppSuspended = true means apps will be suspended by default if (Settings.get("platform", "enableAppSuspended")) { if (pluginState != undefined) { // App is a Plugin await RDKShellApis.suspend(callsign).catch(err => { - console.error("AppAPI Error in suspending app: ", callsign, " | trying to destroy the app" + JSON.stringify(err)); + this.ERR("AppAPI Error in suspending app: ", callsign, " | trying to destroy the app" + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell suspend " + JSON.stringify(err), false, null) RDKShellApis.destroy(callsign); }) @@ -850,7 +854,7 @@ export default class AppApi { } else if (callsign === "NativeApp" || callsign.includes('application/dac.native')) { // DAC Demo WorkAround; TODO: use suspendApplication instead of kill await RDKShellApis.kill((callsign.includes('application/dac.native') ? callsign.substring(0, callsign.indexOf(';')) : callsign)).catch(err => { - console.error("AppAPI Error in kill app: ", callsign, " | trying to destroy the app" + JSON.stringify(err)); + this.ERR("AppAPI Error in kill app: ", callsign, " | trying to destroy the app" + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell kill " + JSON.stringify(err), false, null) RDKShellApis.destroy(callsign); }) @@ -869,19 +873,19 @@ export default class AppApi { * Prefer using launchApp and exitApp for ALL app launch and exit scenarios. */ async launchResidentApp(client = GLOBALS.selfClientName, callsign = GLOBALS.selfClientName) { - console.log("AppAPI launchResidentApp got Called: setting visibility, focus and moving to front the client: " + client) + this.LOG("AppAPI launchResidentApp got Called: setting visibility, focus and moving to front the client: " + client) await RDKShellApis.moveToFront(client, callsign).catch(err => { - console.error("AppAPI failed to moveToFront : ResidentApp ERROR: ", JSON.stringify(err), " | fail reason can be since app is already in front") + this.ERR("AppAPI failed to moveToFront : ResidentApp ERROR: ", JSON.stringify(err), " | fail reason can be since app is already in front") Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell moveToFront " + JSON.stringify(err), false, null) }) await RDKShellApis.setFocus(client, callsign).catch(err => { - console.error("AppAPI failed to setFocus : ResidentApp ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to setFocus : ResidentApp ERROR: ", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell setFocus " + JSON.stringify(err), false, null) }) await RDKShellApis.setVisibility(client, true).catch(err => { - console.error("AppAPI failed to setVisibility : ResidentApp ERROR: ", JSON.stringify(err)) + this.ERR("AppAPI failed to setVisibility : ResidentApp ERROR: ", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell setVisibility " + JSON.stringify(err), false, null) }) @@ -895,21 +899,21 @@ export default class AppApi { if (!data) { return defaultIIDs; } - console.log("AppAPI homedata: ", data); + this.LOG("AppAPI homedata: " + JSON.stringify(data)); try { data = await JSON.parse(data); if (data != null && Object.prototype.hasOwnProperty.call(data, "netflix-iid-file-path")) { let url = data["netflix-iid-file-path"] - console.log(`AppAPI Netflix : requested to fetch iids from `, url) + this.LOG("AppAPI Netflix : requested to fetch iids from " + JSON.stringify(url)) const fetchResponse = await fetch(url); const fetchData = await fetchResponse.json(); return fetchData; } else { - console.log("AppAPI Netflix IID file path not found in conf file, using deffault IIDs"); + this.LOG("AppAPI Netflix IID file path not found in conf file, using deffault IIDs" + JSON.stringify(undefined)); return defaultIIDs; } } catch (err) { - console.error("AppAPI Error in fetching iid data from specified path, returning defaultIIDs | Error:", err); + this.ERR("AppAPI Error in fetching iid data from specified path, returning defaultIIDs | Error:", err); Metrics.error(Metrics.ErrorType.OTHER, "Apperror", "AppAPI Error in fetching iid data from specified path" + JSON.stringify(err), false, null) return defaultIIDs; } @@ -928,18 +932,18 @@ export default class AppApi { focused: false, }).then((res) => { if (childCallsign == "Netflix") { - console.log(`AppAPI launchPremiumAppInSuspendMode : launch netflix results in :`, res); + this.LOG(`AppAPI launchPremiumAppInSuspendMode : launch netflix results in :`, res); } else { - console.log(`AppAPI launchPremiumAppInSuspendMode : launch amazon results in :`, res); + this.LOG(`AppAPI launchPremiumAppInSuspendMode : launch amazon results in :`, res); } resolve(true) }).catch(err => { if (childCallsign == "Netflix") { - console.error(`AppAPI Netflix : error while launching netflix :`, err); + this.ERR(`AppAPI Netflix : error while launching netflix :`, err); } else { - console.log(`AppAPI Amazon : error while launching amazon :`, err); + this.LOG(`AppAPI Amazon : error while launching amazon :`, err); } Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell launch " + JSON.stringify(err), false, null) reject(false) @@ -959,23 +963,23 @@ export default class AppApi { focused: true }).then((res) => { if (childCallsign == "Netflix") { - console.log(`AppAPI launchPremiumApp : launch netflix results in :`, res); + this.LOG(`AppAPI launchPremiumApp : launch netflix results in :`, res); } else { - console.log(`AppAPI launchPremiumApp : launch amazon results in :`, res); + this.LOG(`AppAPI launchPremiumApp : launch amazon results in :`, res); } RDKShellApis.setVisibility(childCallsign, true) RDKShellApis.setFocus(childCallsign) RDKShellApis.moveToFront(childCallsign) GLOBALS.topmostApp = childCallsign; - console.log(`AppAPI launchPremiumApp the current application Type : `, GLOBALS.topmostApp); + this.LOG(`AppAPI launchPremiumApp the current application Type : `, GLOBALS.topmostApp); resolve(true) }).catch(err => { if (childCallsign == "Netflix") { - console.error(`AppAPI launchPremiumApp : error while launching netflix :`, err); + this.ERR(`AppAPI launchPremiumApp : error while launching netflix :`, err); } else { - console.error(`AppAPI launchPremiumApp : error while launching amazon :`, err); + this.ERR(`AppAPI launchPremiumApp : error while launching amazon :`, err); } Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell launch " + JSON.stringify(err), false, null) reject(false) @@ -995,10 +999,10 @@ export default class AppApi { type: GLOBALS.selfClientName, uri: url, }).then((res) => { - console.log(`AppAPI launchResident returned: `, JSON.stringify(res)); + this.LOG(`AppAPI launchResident returned: `, JSON.stringify(res)); resolve(true) }).catch(err => { - console.error('AppAPI launchResident error: ' + JSON.stringify(err)) + this.ERR('AppAPI launchResident error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell launch " + JSON.stringify(err), false, null) reject(false) }) @@ -1014,10 +1018,10 @@ export default class AppApi { uri: url, }).then(res => { RDKShellApis.moveToFront(childCallsign, childCallsign) - console.log(`AppAPI launchOverlay : launched overlay : `, JSON.stringify(res)); + this.LOG(`AppAPI launchOverlay : launched overlay : `, JSON.stringify(res)); resolve(res) }).catch(err => { - console.error("AppAPI launchOverlay : error ", JSON.stringify(err)) + this.ERR("AppAPI launchOverlay : error ", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell launch " + JSON.stringify(err), false, null) reject(err) }) @@ -1032,7 +1036,7 @@ export default class AppApi { RDKShellApis.suspend(appName).then(() => { resolve(true); }).catch(err => { - console.error("AppAPI suspendPremiumApp error: ", JSON.stringify(err)); + this.ERR("AppAPI suspendPremiumApp error: ", JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder RDKShell suspend " + JSON.stringify(err), false, null) resolve(false) }) @@ -1061,7 +1065,7 @@ export default class AppApi { } }) } catch (e) { - console.error('AppAPI Failed to register statechange event' + e) + this.ERR('AppAPI Failed to register statechange event' + e) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error while Thunder Controller stateChange " + JSON.stringify(e), false, null) } } @@ -1100,7 +1104,7 @@ export default class AppApi { thunder.call(plugin, method).then((res) => { res.querystring = config_data; thunder.call(plugin, method, res).then((resp) => { - console.log(`AppAPI ${appName} : updating configuration with object ${res} results in ${resp}`) + this.LOG(`AppAPI ${appName} : updating configuration with object ${res} results in ${resp}`) resolve(true); }).catch((err) => { Metrics.error(Metrics.ErrorType.OTHER, "PluginError", `Error in Thunder ${plugin} ${method} ${JSON.stringify(err)}`, false, null) @@ -1121,7 +1125,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI System setPowerState failed: ", JSON.stringify(err)); + this.ERR("AppAPI System setPowerState failed: ", JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PowerStateFailure", "Error in Thunder System setPowerState " + JSON.stringify(err), false, null) resolve(false) }) @@ -1133,7 +1137,7 @@ export default class AppApi { thunder.call('org.rdk.System', 'getPowerStateBeforeReboot').then(result => { resolve(result); }).catch(err => { - console.error("AppAPI System getPowerStateBeforeReboot failed: ", JSON.stringify(err)); + this.ERR("AppAPI System getPowerStateBeforeReboot failed: ", JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PowerStateFailure", "Error in Thunder System getPowerStateBeforeReboot " + JSON.stringify(err), false, null); reject(err); }); @@ -1145,7 +1149,7 @@ export default class AppApi { thunder.call('org.rdk.System', 'getPowerStateIsManagedByDevice').then(result => { resolve(result); }).catch(err => { - console.error("AppAPI System getPowerStateIsManagedByDevice failed: ", JSON.stringify(err)); + this.ERR("AppAPI System getPowerStateIsManagedByDevice failed: ", JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PowerStateFailure", "Error in Thunder System getPowerStateIsManagedByDevice " + JSON.stringify(err), false, null); reject(err); }); @@ -1160,7 +1164,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI System getPowerState failed: ", JSON.stringify(err)); + this.ERR("AppAPI System getPowerState failed: ", JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PowerStateFailure", "Error in Thunder System getPowerState " + JSON.stringify(err), false, null) reject(err) }) @@ -1175,7 +1179,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.log("org.rdk.System: getWakeupReason: Error in getting wake up reason: ", err) + this.ERR("org.rdk.System: getWakeupReason: Error in getting wake up reason: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PowerStateFailure", "Error in Thunder System getWakeupReason " + JSON.stringify(err), false, null) reject(err) }) @@ -1186,11 +1190,11 @@ export default class AppApi { return new Promise((resolve, reject) => { thunder.call('Controller', 'activate', { callsign: 'org.rdk.DisplaySettings' }) .then(result => { - console.log('AppAPI activate DisplaySettings success.') + this.LOG('AppAPI activate DisplaySettings success.') resolve(result) }) .catch(err => { - console.error('AppAPI activate DisplaySettings error: ', JSON.stringify(err)) + this.ERR('AppAPI activate DisplaySettings error: ', JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "AppError", "Error while Thunder Controller displaySettings activate " + JSON.stringify(err), false, null) reject(err) }) @@ -1207,7 +1211,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings getSoundMode error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI DisplaySettings getSoundMode error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings getSoundMode " + JSON.stringify(err), false, null) resolve(false) }) @@ -1216,7 +1220,7 @@ export default class AppApi { setSoundMode(mode) { mode = mode.startsWith("AUTO") ? "AUTO" : mode - console.log("mode", mode) + this.LOG("mode", mode) return new Promise((resolve) => { thunder .call('org.rdk.DisplaySettings', 'setSoundMode', { @@ -1228,7 +1232,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings setSoundMode error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI DisplaySettings setSoundMode error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings setSoundMode " + JSON.stringify(err), false, null) resolve(false) }) @@ -1245,7 +1249,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings getSupportedAudioModes error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI DisplaySettings getSupportedAudioModes error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings getSupportedAudioModes " + JSON.stringify(err), false, null) reject(false) }) @@ -1263,7 +1267,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings setEnableAudioPort error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI DisplaySettings setEnableAudioPort error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings setEnableAudioPort " + JSON.stringify(err), false, null) resolve(false) }) @@ -1278,7 +1282,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings getDRCMode error:", JSON.stringify(err)) + this.ERR("AppAPI DisplaySettings getDRCMode error:", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings getDRCMode " + JSON.stringify(err), false, null) resolve(false) }) @@ -1295,7 +1299,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings setDRCMode error:", JSON.stringify(err)) + this.ERR("AppAPI DisplaySettings setDRCMode error:", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings setDRCMode " + JSON.stringify(err), false, null) resolve(false) }) @@ -1310,7 +1314,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings getZoomSetting error:", JSON.stringify(err)) + this.ERR("AppAPI DisplaySettings getZoomSetting error:", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings getZoomSetting " + JSON.stringify(err), false, null) resolve(false) }) @@ -1325,7 +1329,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings setZoomSetting error:", JSON.stringify(err)) + this.ERR("AppAPI DisplaySettings setZoomSetting error:", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings setZoomSetting " + JSON.stringify(err), false, null) resolve(false) }) @@ -1340,7 +1344,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings getEnableAudioPort error:", JSON.stringify(err)) + this.ERR("AppAPI DisplaySettings getEnableAudioPort error:", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings getEnableAudioPort " + JSON.stringify(err), false, null) resolve(false) }) @@ -1355,7 +1359,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI DisplaySettings getSupportedAudioPorts error:", JSON.stringify(err)) + this.ERR("AppAPI DisplaySettings getSupportedAudioPorts error:", JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DisplaySettings getSupportedAudioPorts " + JSON.stringify(err), false, null) resolve(false) }) @@ -1379,7 +1383,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI System getFirmwareUpdateInfo error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI System getFirmwareUpdateInfo error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getFirmwareUpdateInfo " + JSON.stringify(err), false, null) resolve(false) }) @@ -1395,7 +1399,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error(" AppAPI System getFirmwareUpdateState error:", JSON.stringify(err, 3, null)) + this.ERR(" AppAPI System getFirmwareUpdateState error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getFirmwareUpdateState " + JSON.stringify(err), false, null) resolve(false) }) @@ -1411,7 +1415,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI System getDownloadedFirmwareInfo error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI System getDownloadedFirmwareInfo error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getDownloadedFirmwareInfo " + JSON.stringify(err), false, null) resolve(false) }) @@ -1423,7 +1427,7 @@ export default class AppApi { thunder.call('DeviceInfo', 'modelname').then(result => { resolve(result.model) }).catch(err => { - console.error("AppAPI DeviceInfo modelname failed:", err); + this.ERR("AppAPI DeviceInfo modelname failed:" + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DeviceInfo modelname " + JSON.stringify(err), false, null) resolve("RDK-VA") }) @@ -1435,7 +1439,7 @@ export default class AppApi { thunder.call('DeviceInfo', 'serialnumber').then(result => { resolve(result.serialnumber) }).catch(err => { - console.error("AppAPI DeviceInfo serialnumber error:", JSON.stringify(err, 3, null)); + this.ERR("AppAPI DeviceInfo serialnumber error:", JSON.stringify(err, 3, null)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DeviceInfo serialnumber " + JSON.stringify(err), false, null) resolve('0123456789') }) @@ -1448,11 +1452,11 @@ export default class AppApi { thunder .call('org.rdk.System', 'getSystemVersions') .then(result => { - console.log(JSON.stringify(result, 3, null)) + this.LOG(JSON.stringify(result, 3, null)) resolve(result) }) .catch(err => { - console.error("AppAPI System getSystemVersions error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI System getSystemVersions error:" + JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getSystemVersions " + JSON.stringify(err), false, null) resolve(false) }) @@ -1468,7 +1472,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI System updateFirmware error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI System updateFirmware error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system updateFirmware " + JSON.stringify(err), false, null) resolve(false) }) @@ -1484,7 +1488,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI getFirmwareDownloadPercent error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI getFirmwareDownloadPercent error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getFirmwareDownloadPercent " + JSON.stringify(err), false, null) resolve(false) }) @@ -1501,7 +1505,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI systeminfo error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI systeminfo error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DeviceInfo systeminfo " + JSON.stringify(err), false, null) resolve(false) }) @@ -1516,7 +1520,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI devicetype error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI devicetype error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder DeviceInfo devicetype " + JSON.stringify(err), false, null) resolve(false) }) @@ -1534,7 +1538,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI reboot error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI reboot error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system reboot " + JSON.stringify(err), false, null) resolve(false) }) @@ -1558,7 +1562,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI getPreferredStandbyMode error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI getPreferredStandbyMode error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.NETWORK, "PluginError", "Error in Thunder system getPreferredStandbyMode " + JSON.stringify(err), false, null) resolve(false) }) @@ -1566,7 +1570,7 @@ export default class AppApi { } setPreferredStandbyMode(standbyMode) { - console.log("setPreferredStandbyMode called : " + standbyMode) + this.LOG("setPreferredStandbyMode called : " + standbyMode) return new Promise((resolve) => { thunder .call('org.rdk.System', 'setPreferredStandbyMode', { @@ -1575,7 +1579,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI setPreferredStandbyMode error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI setPreferredStandbyMode error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.NETWORK, "PluginError", "Error in Thunder system setPreferredStandbyMode " + JSON.stringify(err), false, null) resolve(false) }) @@ -1587,7 +1591,7 @@ export default class AppApi { thunder.call('org.rdk.System', 'getNetworkStandbyMode').then(result => { resolve(result) }).catch(err => { - console.error("AppAPI getNetworkStandbyMode error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI getNetworkStandbyMode error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.NETWORK, "PluginError", "Error in Thunder system getNetworkStandbyMode " + JSON.stringify(err), false, null) reject(err) }) @@ -1600,7 +1604,7 @@ export default class AppApi { if (result.success) resolve(result) reject(false) }).catch(err => { - console.error("AppAPI getRFCConfig error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI getRFCConfig error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system getRFCConfig " + JSON.stringify(err), false, null) reject(err) }) @@ -1612,7 +1616,7 @@ export default class AppApi { thunder.call('org.rdk.System', 'setNetworkStandbyMode', { nwStandby: nwStandby }).then(result => { resolve(result.success) }).catch(err => { - console.error("AppAPI setNetworkStandbyMode error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI setNetworkStandbyMode error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.NETWORK, "NetworkError", "Error in Thunder system setNetworkStandbyMode " + JSON.stringify(err), false, null) reject(err) }) @@ -1620,12 +1624,12 @@ export default class AppApi { } setWakeupSrcConfiguration(params) { - console.log("AppAPI: setWakeupSrcConfiguration params:", JSON.stringify(params)); + this.LOG("AppAPI: setWakeupSrcConfiguration params:", JSON.stringify(params)); return new Promise((resolve, reject) => { thunder.call('org.rdk.System', 'setWakeupSrcConfiguration', params).then(result => { resolve(result.success) }).catch(err => { - console.error("AppAPI setWakeupSrcConfiguration error:", JSON.stringify(err, 3, null)) + this.ERR("AppAPI setWakeupSrcConfiguration error:", JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder system setWakeupSrcConfiguration " + JSON.stringify(err), false, null) reject(err) }) @@ -1654,86 +1658,6 @@ export default class AppApi { .call('org.rdk.Xcast', 'onApplicationStateChanged', params) .then(result => result.success); } - //NETWORK INFO APIS - - //1. Get IP Setting - getIPSetting(defaultInterface, ipversion = "IPv4") { - return new Promise((resolve) => { - thunder.call('org.rdk.Network', 'getIPSettings', { "interface": defaultInterface, "ipversion": ipversion }).then(result => { - resolve(result) - }).catch(err => { - console.error("AppAPI getIPSetting error:", JSON.stringify(err, 3, null)) - Metrics.error(Metrics.ErrorType.NETWORK, "NetworkError", "Error in Thunder getIPSettings of Network " + JSON.stringify(err), false, null) - resolve(false) - }) - }) - } - - //2. Get default interface - getDefaultInterface() { - return new Promise((resolve) => { - thunder - .call('org.rdk.Network', 'getDefaultInterface') - .then(result => { - resolve(result) - }) - .catch(err => { - console.error("AppAPI getDefaultInterface error:", JSON.stringify(err, 3, null)) - Metrics.error(Metrics.ErrorType.NETWORK, "NetworkError", "Error in Thunder getDefaultInterface of Network " + JSON.stringify(err), false, null) - resolve(false) - }) - }) - } - - //3. Is interface enabled - isInterfaceEnabled() { - return new Promise((resolve) => { - thunder - .call('org.rdk.Network', 'isInterfaceEnabled', { - "interface": "WIFI" - }) - .then(result => { - resolve(result) - }) - .catch(err => { - console.error("AppAPI isInterfaceEnabled error:", JSON.stringify(err, 3, null)) - Metrics.error(Metrics.ErrorType.NETWORK, "NetworkError", "Error in Thunder isInterfaceEnabled of Network " + JSON.stringify(err), false, null) - resolve(false) - }) - }) - } - - //4. Get interfaces - getInterfaces() { - return new Promise((resolve) => { - thunder - .call('org.rdk.Network', 'getInterfaces') - .then(result => { - resolve(result) - }) - .catch(err => { - console.error("AppAPI getInterfaces error:", JSON.stringify(err, 3, null)) - Metrics.error(Metrics.ErrorType.NETWORK, "NetworkError", "Error in Thunder getInterfaces of Network " + JSON.stringify(err), false, null) - resolve(false) - }) - }) - } - - //5. getConnectedSSID - getConnectedSSID() { - return new Promise((resolve) => { - thunder - .call('org.rdk.Wifi', 'getConnectedSSID') - .then(result => { - resolve(result) - }) - .catch(err => { - console.error("AppAPI getConnectedSSID error:", JSON.stringify(err, 3, null)) - Metrics.error(Metrics.ErrorType.NETWORK, "NetworkError", "Error in Thunder getConnectedSSID of WIFI " + JSON.stringify(err), false, null) - resolve(false) - }) - }) - } // Volume Apis getConnectedAudioPorts() { @@ -1744,7 +1668,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error('AppAPI getConnectedAudioPorts error:', JSON.stringify(err, 3, null)) + this.ERR('AppAPI getConnectedAudioPorts error:', JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder getConnectedAudioPorts of DisplaySettings " + JSON.stringify(err), false, null) reject(false) }) @@ -1756,7 +1680,7 @@ export default class AppApi { thunder.call('org.rdk.DisplaySettings', 'getVolumeLevel', { audioPort: port }).then(result => { resolve(result) }).catch(err => { - console.error('AppAPI getVolumeLevel error:', JSON.stringify(err, 3, null)) + this.ERR('AppAPI getVolumeLevel error:', JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder getVolumeLevel of DisplaySettings " + JSON.stringify(err), false, null) reject(false) }) @@ -1773,7 +1697,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error('AppAPI getMuted error:', JSON.stringify(err, 3, null)) + this.ERR('AppAPI getMuted error:', JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder getMuted of DisplaySettings " + JSON.stringify(err), false, null) reject(false) }) @@ -1788,11 +1712,11 @@ export default class AppApi { volumeLevel: volume, }) .then(result => { - console.log("AppAPI setVolumeLevel :", JSON.stringify(result)) + this.LOG("AppAPI setVolumeLevel :", JSON.stringify(result)) resolve(result) }) .catch(err => { - console.error('AppAPI setVolumeLevel error:', JSON.stringify(err)) + this.ERR('AppAPI setVolumeLevel error:', JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder setVolumeLevel of DisplaySettings " + JSON.stringify(err), false, null) resolve(false) }) @@ -1810,7 +1734,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error('AppAPI audio_mute setMuted error:', JSON.stringify(err, 3, null)) + this.ERR('AppAPI audio_mute setMuted error:', JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder setMuted of DisplaySettings " + JSON.stringify(err), false, null) resolve(false) }) @@ -1821,12 +1745,12 @@ export default class AppApi { return new Promise((resolve, reject) => { thunder.call('Controller', `status@${plugin}`) .then(result => { - console.log("pluginstatus", result) + this.LOG("pluginstatus", result) let pluginParams = [result[0].callsign, result[0].state] resolve(pluginParams) }) .catch(err => { - console.error("AppAPI getPluginStatusParams error: ", err) + this.ERR("AppAPI getPluginStatusParams error: ", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", `Error in fetching Thunder status@${plugin} of Thunder Controller ${JSON.stringify(err)}`, false, null) reject(err) }) @@ -1841,18 +1765,18 @@ export default class AppApi { "timeout": '30' }) .then(result => { - console.log("AppAPI activateAutoPairing: ", result) + this.LOG("AppAPI activateAutoPairing: ", result) resolve(result) }) .catch(err => { - console.error('AppAPI activateAutoPairing error:', JSON.stringify(err, 3, null)) + this.ERR('AppAPI activateAutoPairing error:', JSON.stringify(err, 3, null)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder startPairing of RemoteControl " + JSON.stringify(err), false, null) resolve(false) }) }) } resetBassEnhancer(port) { - console.log("portname", port) + this.LOG("portname", port) return new Promise((resolve) => { thunder .call('org.rdk.DisplaySettings', 'resetBassEnhancer', { @@ -1862,7 +1786,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI resetBassEnhancer error: ", err) + this.ERR("AppAPI resetBassEnhancer error: ", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder resetBassEnhancer of DisplaySettings " + JSON.stringify(err), false, null) resolve(false) }); @@ -1879,7 +1803,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI resetDialogEnhancement error:", err) + this.ERR("AppAPI resetDialogEnhancement error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder resetDialogEnhancement of DisplaySettings " + JSON.stringify(err), false, null) resolve(false) }); @@ -1896,7 +1820,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI resetSoundVitualizer error:", err) + this.ERR("AppAPI resetSoundVitualizer error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder resetSurroundVirtualizer of DisplaySettings " + JSON.stringify(err), false, null) resolve(false) }); @@ -1913,7 +1837,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI resetvolumeLevel error:", err) + this.ERR("AppAPI resetvolumeLevel error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder resetVolumeLeveller of DisplaySettings " + JSON.stringify(err), false, null) resolve(false) }); @@ -1928,7 +1852,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI resetInactivityTime error:", err) + this.ERR("AppAPI resetInactivityTime error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in fetching Thunder resetInactivityTime of RDKShell " + JSON.stringify(err), false, null) resolve(false) }) @@ -1944,7 +1868,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI clearLastDeepSleepReason error:", err) + this.ERR("AppAPI clearLastDeepSleepReason error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder clearLastDeepSleepReason of system " + JSON.stringify(err), false, null) resolve(false) }) @@ -1961,7 +1885,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI monitorStatus error:", err) + this.ERR("AppAPI monitorStatus error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder fetching resetstats of Monitor " + JSON.stringify(err), false, null) resolve(false) }); @@ -1976,7 +1900,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI deletecache error:", err) + this.ERR("AppAPI deletecache error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", `Error in Thunder delete of ${systemcCallsign} ${JSON.stringify(err)}`, false, null) resolve(false) }); @@ -1992,7 +1916,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI activateController error:", err) + this.ERR("AppAPI activateController error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", `Error while Thunder Controller activate ${callsign} ${JSON.stringify(err)}`, false, null) resolve(false) }); @@ -2002,10 +1926,10 @@ export default class AppApi { checkStatus(plugin) { return new Promise((resolve) => { thunder.call('Controller', 'status@' + plugin).then(res => { - //console.log("AppAPI checkStatus ", JSON.stringify(res)) + //this.LOG("AppAPI checkStatus ", JSON.stringify(res)) resolve(res) }).catch(err => { - console.error("AppAPI checkStatus error:", err) + this.ERR("AppAPI checkStatus error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", `Error while Thunder Controller fetching status@${plugin} ${JSON.stringify(err)}`, false, null) resolve(false) }); @@ -2016,10 +1940,10 @@ export default class AppApi { //controller.1.configuration return new Promise((resolve) => { thunder.call('Controller', 'status').then(res => { - //console.log("AppAPI configStatus ",JSON.stringify(res)) + //this.LOG("AppAPI configStatus ",JSON.stringify(res)) resolve(res) }).catch(err => { - console.error("AppAPI configStatus error:", err) + this.ERR("AppAPI configStatus error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", `Error while Thunder Controller fetching status ${JSON.stringify(err)}`, false, null) resolve(false) }); @@ -2034,7 +1958,7 @@ export default class AppApi { resolve(result) }) .catch(err => { - console.error("AppAPI getAvCodeStatus error:", err) + this.ERR("AppAPI getAvCodeStatus error:", err) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", 'Error in Thunder fetching getAVDecoderStatus of DeviceDiagnostics' + JSON.stringify(err), false, null) resolve(false) }); @@ -2046,7 +1970,7 @@ export default class AppApi { thunder.call('org.rdk.UserPreferences', 'setUILanguage', { "ui_language": updatedLanguage }).then(result => { resolve(result) }).catch(err => { - console.error('AppAPI setUILanguage failed:' + JSON.stringify(err)) + this.ERR('AppAPI setUILanguage failed:' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", 'Error in Thunder setUILanguage of UserPreferences' + JSON.stringify(err), false, null) resolve(false) }) @@ -2057,7 +1981,7 @@ export default class AppApi { thunder.call('org.rdk.UserPreferences', 'getUILanguage').then(result => { resolve(result.ui_language) }).catch(err => { - console.error('AppAPI getUILanguage failed:' + JSON.stringify(err)) + this.ERR('AppAPI getUILanguage failed:' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", 'Error in Thunder getUILanguage of UserPreferences' +JSON.stringify(err), false, null) resolve(false) }) @@ -2067,7 +1991,7 @@ export default class AppApi { deeplinkToApp(app = undefined, payload = undefined, launchLocation = "voice", namespace = undefined) { return new Promise((resolve, reject) => { if (app === undefined || app === "" || payload == undefined) { - console.error("AppApi: deeplinkToApp '" + app + "' not possible with payload '" + payload + "'."); + this.ERR("AppApi: deeplinkToApp '" + app + "' not possible with payload '" + payload + "'."); Metrics.error(Metrics.ErrorType.OTHER, "AppError", `AppApi: deeplinkToApp ${app} not possible with payload ${payload}`, false, null) resolve(false); } else if (app.startsWith("YouTube")) { @@ -2104,20 +2028,20 @@ export default class AppApi { url += "&va=media" + payload + "Video"; } } - console.info("AppApi: deeplinkToApp " + app + " url - " + url); + this.INFO("AppApi: deeplinkToApp " + app + " url - " + url); thunder.call(app, 'deeplink', url); } else if (app === "Amazon") { // TODO: no deeplink format support. - console.error("AppApi: deeplinkToApp '" + app + "' not supported."); + this.ERR("AppApi: deeplinkToApp '" + app + "' not supported."); Metrics.error(Metrics.ErrorType.OTHER, "AppDeeplinkError", JSON.stringify(err), false, null) reject(false); } else if (app === "Netflix") { // TODO: no deeplink format support. - console.error("AppApi: deeplinkToApp '" + app + "' not supported."); + this.ERR("AppApi: deeplinkToApp '" + app + "' not supported."); Metrics.error(Metrics.ErrorType.OTHER, "AppDeeplinkError", JSON.stringify(err), false, null) reject(false); } else { - console.error("AppApi: deeplinkToApp '" + app + "' not supported."); + this.ERR("AppApi: deeplinkToApp '" + app + "' not supported."); Metrics.error(Metrics.ErrorType.OTHER, "AppDeeplinkError", JSON.stringify(err), false, null) reject(false); } diff --git a/accelerator-home-ui/src/api/BluetoothApi.js b/accelerator-home-ui/src/api/BluetoothApi.js index 4b9a699..254d73c 100644 --- a/accelerator-home-ui/src/api/BluetoothApi.js +++ b/accelerator-home-ui/src/api/BluetoothApi.js @@ -32,6 +32,10 @@ export default class BluetoothApi { this._connectedDevices = [] this.btStatus = false this._thunder = ThunderJS(CONFIG.thunderConfig) + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; } /** @@ -107,7 +111,7 @@ export default class BluetoothApi { resolve('Blutooth activated') }) .catch(err => { - console.error('Activation failure', err) + this.ERR('Activation failure', err) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Controller Bluetooth activate "+JSON.stringify(err), false, null) reject('Bluetooth activation failed', err) }) @@ -143,7 +147,7 @@ export default class BluetoothApi { resolve(result) }) .catch(err => { - console.error(`Can't disable : ${JSON.stringify(err)}`) + this.ERR("Can't disable : " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth disable "+JSON.stringify(err), false, null) }) }) @@ -161,7 +165,7 @@ export default class BluetoothApi { this.btStatus = true }) .catch(err => { - console.error(`Can't enable : ${JSON.stringify(err)}`) + this.ERR("Can't enable : " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth enable "+JSON.stringify(err), false, null) reject() }) @@ -186,7 +190,7 @@ export default class BluetoothApi { else reject() }) .catch(err => { - console.error('Error', err) + this.ERR("Error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth startScan "+JSON.stringify(err), false, null) reject() }) @@ -208,7 +212,7 @@ export default class BluetoothApi { else reject(result) }) .catch(err => { - console.error('Error', err) + this.ERR("Error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth startScan "+JSON.stringify(err), false, null) reject(err) }) @@ -227,7 +231,7 @@ export default class BluetoothApi { else reject() }) .catch(err => { - console.error('Error', err) + this.ERR("Error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth stopScan "+JSON.stringify(err), false, null) reject() }) @@ -246,7 +250,7 @@ export default class BluetoothApi { resolve(result.discoveredDevices) }) .catch(err => { - console.error(`Can't get discovered devices : ${JSON.stringify(err)}`) + this.ERR("Can't get discovered devices : " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth getDiscoveredDevices "+JSON.stringify(err), false, null) }) }) @@ -267,7 +271,7 @@ export default class BluetoothApi { resolve(result.pairedDevices) }) .catch(err => { - console.error(`Can't get paired devices : ${err}`) + this.ERR("Can't get paired devices : " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth getPairedDevices "+JSON.stringify(err), false, null) reject(false) }) @@ -289,7 +293,7 @@ export default class BluetoothApi { resolve(result.connectedDevices) }) .catch(err => { - console.error(`Can't get connected devices : ${err}`) + this.ERR("Can't get connected devices : " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth getConnectedDevices "+JSON.stringify(err), false, null) reject() }) @@ -318,7 +322,7 @@ export default class BluetoothApi { resolve(result.success) }) .catch(err => { - console.error('Connection failed', err) + this.ERR("Connection failed: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth connect "+JSON.stringify(err), false, null) reject() }) @@ -342,7 +346,7 @@ export default class BluetoothApi { else reject() }) .catch(err => { - console.error('disconnect failed', err) + this.ERR("disconnect failed: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth disconnect "+JSON.stringify(err), false, null) reject() }) @@ -362,7 +366,7 @@ export default class BluetoothApi { else resolve(false) }) .catch(err => { - console.error('unpair failed', err) + this.ERR("unpair failed: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth unpair "+JSON.stringify(err), false, null) resolve(false) }) @@ -382,7 +386,7 @@ export default class BluetoothApi { else reject(result) }) .catch(err => { - console.error('Error on pairing', err) + this.ERR("Error on pairing: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth pair "+JSON.stringify(err), false, null) reject() }) @@ -408,7 +412,7 @@ export default class BluetoothApi { else reject() }) .catch(err => { - console.error('Error on respondToEvent', err) + this.ERR("Error on respondToEvent: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth respondToEvent "+JSON.stringify(err), false, null) reject() }) @@ -431,13 +435,12 @@ export default class BluetoothApi { this._thunder .call('org.rdk.Bluetooth', 'setAudioStream', { "deviceID": deviceID, "audioStreamName": "AUXILIARY" }) .then(result => { - - // console.log(JSON.stringify(result)) + // this.LOG(JSON.stringify(result)) this._connectedDevices = result.connectedDevices resolve(result.connectedDevices) }) .catch(err => { - console.error(`Can't get connected devices : ${err}`) + this.ERR("Can't get connected devices : " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "BluetoothError", "Error while Thunder Bluetooth setAudioStream "+JSON.stringify(err), false, null) reject() }) diff --git a/accelerator-home-ui/src/api/CECApi.js b/accelerator-home-ui/src/api/CECApi.js index c9a63c4..7e730f2 100644 --- a/accelerator-home-ui/src/api/CECApi.js +++ b/accelerator-home-ui/src/api/CECApi.js @@ -23,6 +23,12 @@ import { Metrics } from '@firebolt-js/sdk'; const thunder = ThunderJS(CONFIG.thunderConfig) export default class CECApi { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } activate() { return new Promise((resolve, reject) => { thunder.Controller.activate({ callsign: 'org.rdk.HdmiCecSource' }) @@ -30,7 +36,7 @@ export default class CECApi { resolve(true) }) .catch(err => { - console.log('CEC Error Activation', err) + this.ERR("CEC Error Activation: " + err) Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error while Thunder Controller HdmiCecSource activate "+JSON.stringify(err), false, null) reject(err) }) @@ -43,7 +49,7 @@ export default class CECApi { resolve(true) }) .catch(err => { - console.log('CEC Error Deactivation', err) + this.ERR("CEC Error Deactivation: " + err) Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error while Thunder Controller HdmiCecSource deactivate "+JSON.stringify(err), false, null) reject(err) }) @@ -56,7 +62,7 @@ export default class CECApi { resolve(result) }) .catch(err => { - console.error('CEC Get Enabled', +JSON.stringify(err)) + this.ERR("CEC Get Enabled: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error in Thunder HdmiCecSource getEnabled "+JSON.stringify(err), false, null) resolve({ enabled: false }) }) @@ -70,7 +76,7 @@ export default class CECApi { resolve(result) }) .catch(err => { - console.error('CEC Set Enabled', err) + this.ERR("CEC Set Enabled: " + err) Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error in Thunder HdmiCecSource setEnabled "+JSON.stringify(err), false, null) resolve({ success: false }) }) @@ -83,7 +89,7 @@ export default class CECApi { resolve(result) }) .catch(err => { - console.error('getOSDName' + JSON.stringify(err)) + this.ERR("getOSDName: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error in Thunder HdmiCecSource getOSDName "+JSON.stringify(err), false, null) resolve({ enabled: false }) }) @@ -96,7 +102,7 @@ export default class CECApi { resolve(result) }) .catch(err => { - console.error('setOSDName', err); + this.ERR("setOSDName: " + err); Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error in Thunder HdmiCecSource setOSDName "+JSON.stringify(err), false, null) resolve({ success: false }) }) @@ -110,7 +116,7 @@ export default class CECApi { resolve(result) }) .catch(err => { - console.error('CEC Otp Error', err) + this.ERR("CEC Otp Error: " + err) Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error in Thunder HdmiCecSource performOTPAction "+JSON.stringify(err), false, null) resolve({ success: false }) }) @@ -124,7 +130,7 @@ export default class CECApi { resolve(result.status) }) .catch(err => { - console.error("CECApi HdmiCecSource getActiveSourceStatus failed." + err); + this.ERR("CECApi HdmiCecSource getActiveSourceStatus failed: " + err); Metrics.error(Metrics.ErrorType.OTHER, "HdmiCecSourceError", "Error in Thunder HdmiCecSource getActiveSourceStatus "+JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/DACApi.js b/accelerator-home-ui/src/api/DACApi.js index 8ca150a..0d9f40c 100644 --- a/accelerator-home-ui/src/api/DACApi.js +++ b/accelerator-home-ui/src/api/DACApi.js @@ -37,7 +37,7 @@ function thunderJS() { async function registerListener(plugin, eventname, cb) { return await LISAApi.get().thunder.on(plugin, eventname, (notification) => { - console.log("DACApi Received event " + plugin + ":" + eventname, notification) + console.log("DACApi Received event " + plugin + ":" + eventname + " " + JSON.stringify(notification)) if (cb != null) { cb(notification, eventname, plugin) } @@ -113,7 +113,7 @@ export const installDACApp = async (app, progress) => { } try { - console.info("installDACApp LISA.install with param:", JSON.stringify(param)) + console.info("installDACApp LISA.install with param:"+ JSON.stringify(param)) app.handle = await LISAApi.get().install(param) } catch (error) { console.error('DACApi Error on installDACApp: ' + error.code + ' ' + error.message) @@ -143,7 +143,7 @@ export const uninstallDACApp = async (app, progress) => { } try { - console.info("uninstallDACApp LISA.uninstall with params:", JSON.stringify(param)) + console.info("uninstallDACApp LISA.uninstall with params:"+ JSON.stringify(param)) if (Object.prototype.hasOwnProperty.call(app, "errorCode")) delete app.errorCode; await LISAApi.get().uninstall(param) } catch (error) { @@ -164,7 +164,7 @@ export const isInstalledDACApp = async (app) => { versionAsParameter: app.version, }) } catch (error) { - console.error('DACApi Error on LISA getStorageDetails: ', error) + console.error('DACApi Error on LISA getStorageDetails: ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER, "DACApiError", 'DACApi Error on LISA getStorageDetails: '+JSON.stringify(error), false, null) return false } @@ -177,7 +177,7 @@ export const getInstalledDACApps = async () => { try { result = await LISAApi.get().getList() } catch (error) { - console.error('DACApi Error on LISA getList: ', error) + console.error('DACApi Error on LISA getList: ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER, "DACApiError", 'DACApi Error on LISA getList: '+JSON.stringify(error), false, null) } @@ -190,7 +190,7 @@ export const getPlatformNameForDAC = async () => { if (platform == null || platform === "") { platform = await getDeviceName() platform = platform.split('-')[0] - console.info("getPlatformNameForDAC platform after split: ", JSON.stringify(platform)) + console.info("getPlatformNameForDAC platform after split: " + JSON.stringify(platform)) } else { return platform @@ -227,7 +227,7 @@ export const getDeviceName = async () => { try { result = await thunderJS().DeviceInfo.systeminfo() } catch (error) { - console.error('DAC Api Error on systeminfo: ', error) + console.error('DAC Api Error on systeminfo: '+ error) Metrics.error(Metrics.ErrorType.OTHER, "DACApiError", 'DAC Api Error on systeminfo: '+JSON.stringify(error), false, null) } return result == null ? "unknown" : result.devicename @@ -254,13 +254,13 @@ export const startDACApp = async (app) => { return false } } catch (error) { - console.error('DACApi Error on launchApplication: ', error) + console.error('DACApi Error on launchApplication: ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER, "DACApiError", 'DACApi Error on launchApplication: '+JSON.stringify(error), false, null) return false } if (result == null) { - console.error('DACApi launch error returned result: ', result) + console.error('DACApi launch error returned result: ' + JSON.stringify(result)) return false } else if (!result.success) { // Could be same app is in suspended mode. @@ -289,7 +289,7 @@ export const startDACApp = async (app) => { try { result = await thunderJS()['org.rdk.RDKShell'].moveToFront({ client: app.id }) } catch (error) { - console.log('DACApi Error on moveToFront: ', error) + console.log('DACApi Error on moveToFront: ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER, "DACApiError", "Error in Thunder RDKShell moveToFront DACApiError"+JSON.stringify(error), false, null) } @@ -297,7 +297,7 @@ export const startDACApp = async (app) => { result = await thunderJS()['org.rdk.RDKShell'].setFocus({ client: app.id }) GLOBALS.topmostApp = (app.id + ';' + app.version + ';' + app.type); } catch (error) { - console.log('DACApi Error on setFocus: ', error) + console.log('DACApi Error on setFocus: ' + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER, "DACApiError", "Error in Thunder DACApi setFocus"+JSON.stringify(error), false, null) return false } @@ -320,7 +320,7 @@ export const getAppCatalogInfo = async () => { .then(response => response.text()) .then(result => { result = JSON.parse(result) - console.log("DACApi fetch result: ", result) + console.log("DACApi fetch result: " + JSON.stringify(result)) if (Object.prototype.hasOwnProperty.call(result, "applications")) { appListArray = result["applications"]; } else { @@ -344,7 +344,7 @@ export const getAppCatalogInfo = async () => { .then(response => response.text()) .then(result => { result = JSON.parse(result) - console.log("DACApi fetch result: ", result) + console.log("DACApi fetch result: " + JSON.stringify(result)) if (Object.prototype.hasOwnProperty.call(result, "applications")) { appListArray = result["applications"]; } else { @@ -353,7 +353,7 @@ export const getAppCatalogInfo = async () => { } }) .catch(error => { - console.log("DACApi fetch error from cloud", error) + console.log("DACApi fetch error from cloud: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER, "DACApiError", JSON.stringify(error), false, null) }); } else { @@ -396,7 +396,7 @@ export const getAppCatalogInfo = async () => { } }) .catch(error => { - console.log("DACApi fetch error from cloud", error) + console.log("DACApi fetch error from cloud: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) hasmore = false; }); @@ -438,7 +438,7 @@ export const getAppCatalogInfo = async () => { } }) .catch(error => { - console.log("DACApi fetch error from cloud", error) + console.log("DACApi fetch error from cloud: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) hasmore = false; }); @@ -480,7 +480,7 @@ export const getFirmwareVersion = async () => { firmwareVer = await getFirmareVer() } } catch (error) { - console.log("DACApi getFirmwareVersion Error: ", error) + console.log("DACApi getFirmwareVersion Error: " + JSON.stringify(error)) //code temporarily added based on new api implementation Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) firmwareVer = await getFirmareVer() @@ -501,7 +501,7 @@ export const fetchAppIcon = async (id, version) => { .then(response => response.text()) .then(result => { result = JSON.parse(result) - console.log("fetchAppIcon fetch result: ", result) + console.log("fetchAppIcon fetch result: " + JSON.stringify(result)) if (Object.prototype.hasOwnProperty.call(result, "header")) { appIcon = result.header.icon; } else { @@ -510,7 +510,7 @@ export const fetchAppIcon = async (id, version) => { } }) .catch(error => { - console.log("App Icon fetch error", error) + console.log("App Icon fetch error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) }); } @@ -541,12 +541,12 @@ export const fetchAppIcon = async (id, version) => { } }) .catch(error => { - console.log("fetchAppIcon App Icon fetch error", error) + console.log("fetchAppIcon App Icon fetch error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) }); } } catch (error) { - console.log("DACApi fetchAppIcon try block Error: ", error) + console.log("DACApi fetchAppIcon try block Error: " + JSON.stringify(error)) //code temporarily added based on new api implementation let asms = await getAsmsUrlObj() let myHeaders = new Headers(); @@ -571,7 +571,7 @@ export const fetchAppIcon = async (id, version) => { } }) .catch(error => { - console.log("fetchAppIcon App Icon fetch error", error) + console.log("fetchAppIcon App Icon fetch error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) }); } @@ -605,7 +605,7 @@ export const fetchLocalAppIcon = async (id) => { } }) .catch(error => { - console.log("fetchLocalAppIcon App Icon fetch error", error) + console.log("fetchLocalAppIcon App Icon fetch error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) }); } @@ -614,7 +614,7 @@ export const fetchLocalAppIcon = async (id) => { Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", "etchLocalAppIcon Appstore info not available; DAC features won't work", false, null) } } catch (error) { - console.log("fetchLocalAppIcon Appstore info Error: ", error) + console.log("fetchLocalAppIcon Appstore info Error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) } return appIcon == null ? undefined : appIcon; @@ -633,7 +633,7 @@ export const fetchAppUrl = async (id, version) => { .then(response => response.text()) .then(result => { result = JSON.parse(result) - console.log("fetchAppUrl App fetch result: ", result) + console.log("fetchAppUrl App fetch result: " + JSON.stringify(result)) if (Object.prototype.hasOwnProperty.call(result, "header")) { appUrl = result.header.url; } else { @@ -642,7 +642,7 @@ export const fetchAppUrl = async (id, version) => { } }) .catch(error => { - console.log("fetchAppUrl App URL fetch error", error) + console.log("fetchAppUrl App URL fetch error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) }); } @@ -672,12 +672,12 @@ export const fetchAppUrl = async (id, version) => { } }) .catch(error => { - console.log("fetchAppUrl App URL fetch error", error) + console.log("fetchAppUrl App URL fetch error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) }); } } catch (error) { - console.log("fetchAppUrl DACApi Appstore info Error: ", error) + console.log("fetchAppUrl DACApi Appstore info Error: " + JSON.stringify(error)) Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", error, false, null) } return appUrl == null ? undefined : appUrl; @@ -709,7 +709,7 @@ export const getAsmsUrlObj = async () => { throw new Error('getAsmsUrlObj: Failed to parse data'); } } catch (err) { - console.error("getAsmsUrlObj FETCH error: ", err); + console.error("getAsmsUrlObj FETCH error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DACApiError", err, false, null) throw new Error('getAsmsUrlObj: Failed to parse data: ' + err); } diff --git a/accelerator-home-ui/src/api/DTVApi.js b/accelerator-home-ui/src/api/DTVApi.js index 6426256..e5673ec 100644 --- a/accelerator-home-ui/src/api/DTVApi.js +++ b/accelerator-home-ui/src/api/DTVApi.js @@ -45,6 +45,12 @@ getCustomServiceList(); //call this method in activate //plugin is activated by default, no need to call explicitly export default class DTVApi { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } activate() { return new Promise((resolve, reject) => { thunder.Controller.activate({ callsign: "DTV" }) @@ -52,7 +58,7 @@ export default class DTVApi { resolve(true); }) .catch((err) => { - console.log("DTV Error Activation", err); + this.ERR("DTV Error Activation: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error while Thunder Controller DTV activate "+JSON.stringify(err), false, null) reject(err); }); @@ -65,7 +71,7 @@ export default class DTVApi { resolve(true); }) .catch((err) => { - console.log("DTV Error Deactivation", err); + this.ERR("DTV Error Deactivation: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error while Thunder Controller DTV deactivate "+JSON.stringify(err), false, null) reject(err); }); @@ -80,7 +86,7 @@ export default class DTVApi { resolve(result); }) .catch((err) => { - console.log("Error: noOfCountries: ", JSON.stringify(err)); + this.ERR("Error: noOfCountries: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV numberOfCountries "+JSON.stringify(err), false, null) reject(err); }); @@ -95,7 +101,7 @@ export default class DTVApi { resolve(result); }) .catch((err) => { - console.log("Error: countryList: ", JSON.stringify(err)); + this.ERR("Error: countryList: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV countryList "+JSON.stringify(err), false, null) reject(err); }); @@ -113,17 +119,17 @@ export default class DTVApi { if (customServiceList) { arr = arr.concat(JSON.parse(JSON.stringify(customServiceList))); } - console.log("arr from serviceList: ", arr) + this.LOG("arr from serviceList: " + JSON.stringify(arr)) return new Promise((resolve) => { thunder .call("DTV", "serviceList@dvbs") .then((result) => { arr = arr.concat(result) - console.log("serviceListResult: ", JSON.stringify(arr)); + this.LOG("serviceListResult: " + JSON.stringify(arr)); resolve(arr); }) .catch((err) => { - console.log("Error: serviceList: ", JSON.stringify(err)); + this.ERR("Error: serviceList: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV serviceList@dvbs "+JSON.stringify(err), false, null) resolve(arr); }); @@ -149,7 +155,7 @@ export default class DTVApi { } resolve(data); } else { - console.log("Error: getting schedule from custom channels"); + this.ERR("Error: getting schedule from custom channels"); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error: getting schedule from custom channels", false, null) resolve([]); } @@ -157,7 +163,7 @@ export default class DTVApi { thunder .call("DTV", method) .then((result) => { - console.log("scheduleEventsResult: ", JSON.stringify(result)); + this.LOG("scheduleEventsResult: " + JSON.stringify(result)); for (let show of result) { show.starttime *= 1000; show.duration *= 1000; @@ -165,7 +171,7 @@ export default class DTVApi { resolve(result); }) .catch((err) => { - console.log("Error: scheduleEvents: ", JSON.stringify(err)); + this.ERR("Error: scheduleEvents: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV scheduleEvents@dvbs "+JSON.stringify(err), false, null) reject(err); }); @@ -186,7 +192,7 @@ export default class DTVApi { resolve(result); }) .catch((err) => { - console.log("Error: satelliteList: ", JSON.stringify(err)); + this.ERR("Error: satelliteList: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV satelliteList "+JSON.stringify(err), false, null) reject(err); }); @@ -247,7 +253,7 @@ export default class DTVApi { resolve(result); }) .catch((err) => { - console.log("serviceSearchError: ", JSON.stringify(err)); + this.ERR("serviceSearchError: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV startServiceSearch "+JSON.stringify(err), false, null) reject(err); }); @@ -263,7 +269,7 @@ export default class DTVApi { resolve(result); }) .catch((err) => { - console.log("Error: numberOfServices: ", JSON.stringify(err)); + this.ERR("Error: numberOfServices: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV numberOfServices "+JSON.stringify(err), false, null) reject(err); }); @@ -281,7 +287,7 @@ export default class DTVApi { resolve(result); }) .catch((err) => { - console.log("Error: nowNextEvents: ", JSON.stringify(err)); + this.ERR("Error: nowNextEvents: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV nowNextEvents@dvbs "+JSON.stringify(err), false, null) reject(err); }); @@ -291,7 +297,7 @@ export default class DTVApi { startPlaying(params) { //params contains dvburi and lcn - console.log("PARAMS: startPlaying: ", JSON.stringify(params)); + this.LOG("PARAMS: startPlaying: " + JSON.stringify(params)); if (playerID !== -1) { this.stopPlaying(); return Promise.reject("something is still playing Please retry"); @@ -300,7 +306,7 @@ export default class DTVApi { thunder .call("DTV", "startPlaying", params) .then((result) => { - console.log("RESULT: startPlaying: ", JSON.stringify(result)); + this.LOG("RESULT: startPlaying: " + JSON.stringify(result)); if (result === -1) { reject("Can't be played"); } else { @@ -309,7 +315,7 @@ export default class DTVApi { } }) .catch((err) => { - console.log("ERROR: startPlaying: ", JSON.stringify(err)); + this.ERR("ERROR: startPlaying: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV startPlaying "+JSON.stringify(err), false, null) reject(err); }); @@ -322,12 +328,12 @@ export default class DTVApi { .call("DTV", "stopPlaying", playerID) .then((result) => { //playerID is retuned from startPlaying method - console.log("RESULT: stopPlaying: ", JSON.stringify(result)); //result is always null + this.LOG("RESULT: stopPlaying: " + JSON.stringify(result)); //result is always null playerID = -1; //to set that nothing is being played currently resolve(true); }) .catch((err) => { - console.log("ERROR: stopPlaying: ", JSON.stringify(err)); + this.ERR("ERROR: stopPlaying: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", "Error in Thunder DTV stopPlaying "+JSON.stringify(err), false, null) reject(err); }); @@ -335,10 +341,10 @@ export default class DTVApi { } launchChannel(dvburi) { - console.log("PARAMS: launchChannel: ", JSON.stringify(dvburi)); + this.LOG("PARAMS: launchChannel: " + JSON.stringify(dvburi)); if (playerID !== -1) { this.exitChannel() - console.log("launchChannel: FAIL: something is still playing, trying to call exitChannel") + this.LOG("launchChannel: FAIL: something is still playing, trying to call exitChannel") return Promise.reject("Fail: something is still playing") } return new Promise((resolve, reject) => { @@ -361,14 +367,14 @@ export default class DTVApi { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }; - console.log("launchChannel: url & params: ", JSON.stringify(url), JSON.stringify(params)) + this.LOG("launchChannel: url & params: " + JSON.stringify(url) + JSON.stringify(params)) fetch(url, params).then(response => response.json()).then(result => { - console.log("launchChannel: SUCCESS: ", JSON.stringify(result)) + this.LOG("launchChannel: SUCCESS: " + JSON.stringify(result)) playerID = result.openStatus.sessionId - console.log("launchChannel: SESSIONID: ", playerID) + this.LOG("launchChannel: SESSIONID: " + JSON.stringify(playerID)) resolve(result) }).catch(err => { - console.log("launchChannel: FAILED: ", JSON.stringify(err)) + this.ERR("launchChannel: FAILED: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", JSON.stringify(err), false, null) reject(err) }) @@ -386,13 +392,13 @@ export default class DTVApi { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }; - console.log("exitChannel: url & params: ", JSON.stringify(url), JSON.stringify(params)) + this.LOG("exitChannel: url & params: " + JSON.stringify(url) + JSON.stringify(params)) fetch(url, params).then(response => response.json()).then(result => { - console.log("exitChannel: SUCCESS: ", JSON.stringify(result)) + this.LOG("exitChannel: SUCCESS: " + JSON.stringify(result)) playerID = -1 resolve(result) }).catch(err => { - console.log("exitChannel: FAILED: ", JSON.stringify(err)) + this.ERR("exitChannel: FAILED: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"DTVApiError", JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/HDMIApi.js b/accelerator-home-ui/src/api/HDMIApi.js index e03660f..290d412 100644 --- a/accelerator-home-ui/src/api/HDMIApi.js +++ b/accelerator-home-ui/src/api/HDMIApi.js @@ -39,6 +39,10 @@ export default class HDMIApi { Resolution1080: [1920, 1080], Resolution2160: [3840, 2160] } + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; } activate() { @@ -46,7 +50,7 @@ export default class HDMIApi { this._thunder .call('Controller', 'activate', { callsign: this.callsign }) .then(result => { - console.log('Activated HdmiInput plugin') + this.LOG("Activated HdmiInput plugin") this._thunder.on(this.callsign, 'onInputStatusChanged', notification => { if (this._events.has('onInputStatusChanged')) { this._events.get('onInputStatusChanged')(notification) @@ -73,7 +77,7 @@ export default class HDMIApi { resolve(false) }) .catch(err => { - console.log('Failed to activate HdmiInput plugin', JSON.stringify(err)) + this.ERR("Failed to activate HdmiInput plugin" + " " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"HdmiApiError", "Error while Thunder Controller HdmiApi activate "+JSON.stringify(err), false, null) reject(false) }) @@ -90,7 +94,7 @@ export default class HDMIApi { }) .catch(err => { // reject(err) // #forTesting //make the api reject, instead of resolving empty array - console.log("getHDMIDevices Error: ", JSON.stringify(err), " resolving empty array") + this.ERR("getHDMIDevices Error: " + JSON.stringify(err) + " resolving empty array") Metrics.error(Metrics.ErrorType.OTHER,"HdmiApiError", "Error in Thunder HdmiApi getHDMIInputDevices "+JSON.stringify(err), false, null) resolve([]) }) @@ -101,11 +105,11 @@ export default class HDMIApi { return new Promise((resolve, reject) => { this._thunder.call('Controller.1', 'status@' + plugin) .then(res => { - console.log(JSON.stringify(res)) + this.LOG(JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error(JSON.stringify(err)) + this.ERR(JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"HdmiApiError", "Error while Thunder Controller.1 HdmiApi status "+JSON.stringify(err), false, null) reject(err) }) @@ -123,7 +127,7 @@ export default class HDMIApi { resolve(this.resolution[result1]) }) .catch(err => { - console.log('Failed to fetch dimensions', err) + this.ERR('Failed to fetch dimensions' + " " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"HdmiApiError", "Error in Thunder playerInfo resolution "+JSON.stringify(err), false, null) resolve([1920, 1080]) }) diff --git a/accelerator-home-ui/src/api/HomeApi.js b/accelerator-home-ui/src/api/HomeApi.js index 504b253..934f645 100644 --- a/accelerator-home-ui/src/api/HomeApi.js +++ b/accelerator-home-ui/src/api/HomeApi.js @@ -16,8 +16,6 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -import { Storage } from "@lightningjs/sdk"; -import Network from "../api/NetworkApi"; import AppApi from "./AppApi"; import { GLOBALS } from "../Config/Config.js"; import { appListInfo } from "./../../static/data/AppListInfo.js"; @@ -35,29 +33,18 @@ import xml2json from "@hendt/xml2json"; import PersistentStoreApi from "./PersistentStore.js"; let partnerApps = []; - -/** - * Get the ip address. - */ -let IpAddress1 = ""; -let IpAddress2 = ""; - -Network.get().getStbIp().then((ip) => { - IpAddress1 = ip; - Storage.set("ipAddress", IpAddress1); -}).catch(() => { - Storage.set("ipAddress", null); -}); - let appApi = new AppApi(); -appApi.getIP().then((ip) => { - IpAddress2 = ip; -}); /** * Class that returns the data required for home screen. */ export default class HomeApi { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } /** * Function to get details for app listing. */ @@ -118,7 +105,7 @@ export default class HomeApi { getMetroInfo() { let metroAppsMetaData; - if (IpAddress1 || IpAddress2) { + if (GLOBALS.IsConnectedToInternet) { metroAppsMetaData = metroAppsInfo; } else { metroAppsMetaData = metroAppsInfoOffline; @@ -170,12 +157,12 @@ export default class HomeApi { resolve(xml2json(res)); }); } catch (err) { - console.log("API key not defined." + JSON.stringify(err)); + this.ERR("API key not defined." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"ApiError", JSON.stringify(err), false, null) } } }).catch((err) => { - console.log("Gracenote Info not found." + JSON.stringify(err)); + this.ERR("Gracenote Info not found." + JSON.stringify(err)); }); }); } @@ -207,7 +194,7 @@ export default class HomeApi { }); }) .catch((err) => { - console.log("Gracenote: Incorrect API key or no data available" + JSON.stringify(err)); + this.ERR("Gracenote: Incorrect API key or no data available" + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"ApiError", JSON.stringify(err), false, null) resolve({ key: res.value, @@ -215,7 +202,7 @@ export default class HomeApi { }); }); } catch (err) { - console.error("Gracenote fetch failed." + JSON.stringify(err)); + this.ERR("Gracenote fetch failed." + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"ApiError", JSON.stringify(err), false, null) resolve({ key: res.value, @@ -223,7 +210,7 @@ export default class HomeApi { }); } } else { - console.error("Gracenote apiKey is invalid in PersistentStore."); + this.ERR("Gracenote apiKey is invalid in PersistentStore."); Metrics.error(Metrics.ErrorType.OTHER,"ApiError", JSON.stringify(err), false, null) resolve({ key: "", @@ -231,7 +218,7 @@ export default class HomeApi { }); } }).catch((err) => { - console.error("Gracenote apiKey not found in PersistentStore." + JSON.stringify(err)); + this.ERR("Gracenote apiKey not found in PersistentStore." + JSON.stringify(err)); resolve({ key: "", data: [], @@ -248,7 +235,7 @@ export default class HomeApi { callsign = "Cobalt" } await appApi.getPluginStatus(callsign).catch(err => { - console.log("Error:", err) + this.ERR("Error: " + JSON.stringify(err)) items.splice(i, 1) i-- }) @@ -268,7 +255,7 @@ export default class HomeApi { callsign = "Cobalt" } await appApi.getPluginStatus(callsign).catch(err => { - console.log("Error:", err) + this.ERR("Error: " + JSON.stringify(err)) items.splice(i, 1) i-- }) diff --git a/accelerator-home-ui/src/api/LISAApi.js b/accelerator-home-ui/src/api/LISAApi.js index 0037ee7..a246629 100644 --- a/accelerator-home-ui/src/api/LISAApi.js +++ b/accelerator-home-ui/src/api/LISAApi.js @@ -26,7 +26,7 @@ export default class LISA { constructor() { this.thunder = ThunderJS(CONFIG.thunderConfig); this.callsign = 'LISA'; - this.INFO = function () { }; + this.INFO = console.info; this.LOG = console.log; this.ERR = console.error; this.metadata = null; diff --git a/accelerator-home-ui/src/api/Miracast.js b/accelerator-home-ui/src/api/Miracast.js index d8a264a..b9d4632 100644 --- a/accelerator-home-ui/src/api/Miracast.js +++ b/accelerator-home-ui/src/api/Miracast.js @@ -22,16 +22,20 @@ import { Metrics } from "@firebolt-js/sdk"; export default class Miracast { constructor() { this._thunder = ThunderJS(CONFIG.thunderConfig); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; } activateService() { return new Promise((resolve,reject) => { this._thunder.Controller.activate({ callsign: 'org.rdk.MiracastService' }).then((res) => { - console.log(res) + this.LOG("MiracastService: Activated " + JSON.stringify(res)) resolve(res) }).catch(err => { reject(err) - console.error('MiracastService: Error Activation ', err); + this.ERR('MiracastService: Error Activation ' + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"MiracastServiceError", "Error while Thunder Controller MiracastService activate "+JSON.stringify(err), false, null) }) }) @@ -40,11 +44,11 @@ export default class Miracast { activatePlayer() { return new Promise((resolve,reject) => { this._thunder.Controller.activate({ callsign: 'org.rdk.MiracastPlayer' }).then((res) => { - console.log(res) + this.LOG("MiracastPlayer: Activated " + JSON.stringify(res)) resolve(res) }).catch(err => { reject(err) - console.error('MiracastPlayer: Error Activation ', err); + this.ERR('MiracastPlayer: Error Activation ' + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"MiracastPlayerError", "Error while Thunder Controller MiracastPlayer activate "+JSON.stringify(err), false, null) }) }) @@ -54,11 +58,11 @@ export default class Miracast { { return new Promise((resolve,reject) => { this._thunder.Controller.deactivate({ callsign: 'org.rdk.MiracastService' }).then((res) => { - console.log("MiracastService: deactivated org.rdk.MiracastService" +res) + this.LOG("MiracastService: deactivated org.rdk.MiracastService" + JSON.stringify(res)) resolve(res) }).catch(err => { reject(err) - console.error('MiracastService: Error deactivation ', err) + this.ERR('MiracastService: Error deactivation ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"MiracastServiceError", "Error while Thunder Controller MiracastService deactivate "+JSON.stringify(err), false, null) }) }) @@ -68,11 +72,11 @@ export default class Miracast { { return new Promise((resolve,reject) => { this._thunder.Controller.deactivate({ callsign: 'org.rdk.MiracastPlayer' }).then((res) => { - console.log("MiracastPlayer: deactivated org.rdk.MiracastPlayer") + this.LOG("MiracastPlayer: deactivated org.rdk.MiracastPlayer" + JSON.stringify(res)) resolve(res) }).catch(err => { reject(err) - console.error('MiracastPlayer: Error deactivation ', err) + this.ERR('MiracastPlayer: Error deactivation ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"MiracastPlayerError", "Error while Thunder Controller MiracastPlayer deactivate "+JSON.stringify(err), false, null) }) }) @@ -82,11 +86,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastService', 'setEnable',{enabled:state}) .then(res => { - console.log("Sucess response from setEnable "+JSON.stringify(res)) + this.LOG("Sucess response from setEnable " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setEnable "+JSON.stringify(err)) + this.ERR("Error response from setEnable " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setEnable", "Error while Thunder setEnable status "+JSON.stringify(err), false, null) reject(err) }) @@ -98,11 +102,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastService', 'getEnable') .then(res => { - console.log("Sucess response from getEnable "+JSON.stringify(res)) + this.LOG("Sucess response from getEnable " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from getEnable "+JSON.stringify(err)) + this.ERR("Error response from getEnable " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"getEnable", "Error while Thunder getEnable status "+JSON.stringify(err), false, null) reject(err) }) @@ -114,11 +118,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastService', 'acceptClientConnection',{requestStatus:status}) .then(res => { - console.log("Sucess response from acceptClientConnection "+JSON.stringify(res)) + this.LOG("Sucess response from acceptClientConnection " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from acceptClientConnection "+JSON.stringify(err)) + this.ERR("Error response from acceptClientConnection " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"acceptClientConnection", "Error while Thunder acceptClientConnection status "+JSON.stringify(err), false, null) reject(err) }) @@ -130,11 +134,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastService', 'updatePlayerState',{mac:mac,state:state,reason_code:reason_code,reason:reason}) .then(res => { - console.log("Sucess response from updatePlayerState "+JSON.stringify(res)) + this.LOG("Sucess response from updatePlayerState " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from updatePlayerState "+JSON.stringify(err)) + this.ERR("Error response from updatePlayerState " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"updatePlayerState", "Error while Thunder updatePlayerState status "+JSON.stringify(err), false, null) reject(err) }) @@ -146,11 +150,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastService', 'stopClientConnection',{mac:mac,name:name}) .then(res => { - console.log("Sucess response from stopClientConnection "+JSON.stringify(res)) + this.LOG("Sucess response from stopClientConnection " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from stopClientConnection "+JSON.stringify(err)) + this.ERR("Error response from stopClientConnection " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"stopClientConnection", "Error while Thunder stopClientConnection status "+JSON.stringify(err), false, null) reject(err) }) @@ -162,11 +166,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastService', 'setLogging',{level:level,separate_logger:{logfilename:logfilename,status:status}}) .then(res => { - console.log("Sucess response from setLogging "+JSON.stringify(res)) + this.LOG("Sucess response from setLogging " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setLogging "+JSON.stringify(err)) + this.ERR("Error response from setLogging " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setLogging", "Error while Thunder setLogging status "+JSON.stringify(err), false, null) reject(err) }) @@ -180,11 +184,11 @@ export default class Miracast { {source_dev_ip:source_dev_ip,source_dev_mac:source_dev_mac,source_dev_name:source_dev_name,sink_dev_ip:sink_dev_ip}, video_rectangle:{X:X,Y:Y,W:W,H:H}}) .then(res => { - console.log("Sucess response from playRequest "+JSON.stringify(res)) + this.LOG("Sucess response from playRequest " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from playRequest "+JSON.stringify(err)) + this.ERR("Error response from playRequest " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"playRequest", "Error while Thunder playRequest status "+JSON.stringify(err), false, null) reject(err) }) @@ -196,11 +200,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastPlayer', 'stopRequest',{mac:mac,name:name,reason_code:reason_code}) .then(res => { - console.log("Sucess response from stopRequest "+JSON.stringify(res)) + this.LOG("Sucess response from stopRequest " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from stopRequest "+JSON.stringify(err)) + this.ERR("Error response from stopRequest " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"stopRequest", "Error while Thunder stopRequest status "+JSON.stringify(err), false, null) reject(err) }) @@ -212,11 +216,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastPlayer', 'setPlayerState',{state:state}) .then(res => { - console.log("Sucess response from setPlayerState "+JSON.stringify(res)) + this.LOG("Sucess response from setPlayerState " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setPlayerState "+JSON.stringify(err)) + this.ERR("Error response from setPlayerState " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setPlayerState", "Error while Thunder setPlayerState status "+JSON.stringify(err), false, null) reject(err) }) @@ -228,11 +232,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastPlayer', 'setVideoRectangle',{X:X,Y:Y,W:W,H:H}) .then(res => { - console.log("Sucess response from setVideoRectangle "+JSON.stringify(res)) + this.LOG("Sucess response from setVideoRectangle " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setVideoRectangle "+JSON.stringify(err)) + this.ERR("Error response from setVideoRectangle " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setVideoRectangle", "Error while Thunder setVideoRectangle status "+JSON.stringify(err), false, null) reject(err) }) @@ -244,11 +248,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastPlayer', 'setRTSPWaitTimeout',{Request:Request,Response:Response}) .then(res => { - console.log("Sucess response from setRTSPWaitTimeout "+JSON.stringify(res)) + this.LOG("Sucess response from setRTSPWaitTimeout " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setRTSPWaitTimeout "+JSON.stringify(err)) + this.ERR("Error response from setRTSPWaitTimeout " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setRTSPWaitTimeout", "Error while Thunder setRTSPWaitTimeout status "+JSON.stringify(err), false, null) reject(err) }) @@ -260,11 +264,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastPlayer', 'setLogging',{level:level,separate_logger:{logfilename:logfilename,status:status}}) .then(res => { - console.log("Sucess response from setLogging "+JSON.stringify(res)) + this.LOG("Sucess response from setLogging " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setLogging "+JSON.stringify(err)) + this.ERR("Error response from setLogging " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setLogging", "Error while Thunder setLogging status "+JSON.stringify(err), false, null) reject(err) }) @@ -281,11 +285,11 @@ export default class Miracast { video_frame_skip_support:video_frame_skip_support,max_skip_intervals:max_skip_intervals, video_frame_rate_change_support:video_frame_rate_change_support}}) .then(res => { - console.log("Sucess response from setVideoFormats "+JSON.stringify(res)) + this.LOG("Sucess response from setVideoFormats " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setVideoFormats "+JSON.stringify(err)) + this.ERR("Error response from setVideoFormats " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setVideoFormats", "Error while Thunder playResetVideoFormatsquest status "+JSON.stringify(err), false, null) reject(err) }) @@ -297,11 +301,11 @@ export default class Miracast { return new Promise((resolve, reject) => { this._thunder.call('org.rdk.MiracastPlayer', 'setAudioFormats',{audio_format:audio_format,modes:modes,latency:latency}) .then(res => { - console.log("Sucess response from setAudioFormats "+JSON.stringify(res)) + this.LOG("Sucess response from setAudioFormats " + JSON.stringify(res)) resolve(res) }) .catch(err => { - console.error("Error response from setAudioFormats "+JSON.stringify(err)) + this.ERR("Error response from setAudioFormats " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"setAudioFormats", "Error while Thunder setAudioFormats status "+JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/NetworkApi.js b/accelerator-home-ui/src/api/NetworkApi.js index 4532071..6015fa7 100644 --- a/accelerator-home-ui/src/api/NetworkApi.js +++ b/accelerator-home-ui/src/api/NetworkApi.js @@ -29,6 +29,7 @@ export default class Network { this.INFO = console.info; this.LOG = console.log; this.ERR = console.error; + this.WARN = console.warn; } static get() { @@ -43,10 +44,10 @@ export default class Network { activate() { return new Promise((resolve, reject) => { this._thunder.call('Controller', 'activate', { callsign: this.callsign }).then(result => { - this.INFO(this.callsign + " activate result:" + result) + this.INFO(this.callsign + " activate result:" + JSON.stringify(result)) resolve(true) }).catch(err => { - this.ERR(this.callsign + " activate error: " + err) + this.ERR(this.callsign + " activate error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error while Thunder Controller Network activate "+JSON.stringify(err), false, null) reject(err) }); @@ -56,10 +57,10 @@ export default class Network { deactivate() { return new Promise((resolve, reject) => { this._thunder.call('Controller', 'deactivate', { callsign: this.callsign }).then(result => { - this.INFO(this.callsign + " deactivate result:" + result) + this.INFO(this.callsign + " deactivate result:" + JSON.stringify(result)) resolve(true) }).catch(err => { - this.ERR(this.callsign + " deactivate error: " + err) + this.ERR(this.callsign + " deactivate error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error while Thunder Controller Network deactivate "+JSON.stringify(err), false, null) reject(err) }); @@ -69,11 +70,11 @@ export default class Network { getDefaultInterface() { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getDefaultInterface').then(result => { - this.INFO(this.callsign + " getDefaultInterface result: " + result) + this.INFO(this.callsign + " getDefaultInterface result: " + JSON.stringify(result)) if (result.success) resolve(result.interface) reject(false) }).catch(err => { - this.ERR(this.callsign + " getDefaultInterface error: " + err) + this.ERR(this.callsign + " getDefaultInterface error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getDefaultInterface "+JSON.stringify(err), false, null) reject(err) }) @@ -83,13 +84,13 @@ export default class Network { getInterfaces() { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getInterfaces').then(result => { - this.INFO(this.callsign + " getInterfaces result: " + result) + this.INFO(this.callsign + " getInterfaces result: " + JSON.stringify(result)) if (result.success) { resolve(result.interfaces) } reject(false) }).catch(err => { - this.ERR(this.callsign + " getInterfaces error: " + err) + this.ERR(this.callsign + " getInterfaces error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getInterfaces "+JSON.stringify(err), false, null) reject(err) }) @@ -99,13 +100,13 @@ export default class Network { getIPSettings(interfaceName, ipversion = "IPv4") { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getIPSettings', { "interface": interfaceName, "ipversion": ipversion }).then(result => { - this.INFO(this.callsign + "[getIPSettings] result: " + result) + this.INFO(this.callsign + "[getIPSettings] result: " + JSON.stringify(result)) if (result.success) { resolve(result); } reject(false); }).catch(err => { - this.ERR(this.callsign + "[getIPSettings] error: " + err) + this.ERR(this.callsign + "[getIPSettings] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getIPSettings "+JSON.stringify(err), false, null) reject(err) }) @@ -115,11 +116,11 @@ export default class Network { getNamedEndpoints() { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getNamedEndpoints').then(result => { - this.INFO(this.callsign + "[getNamedEndpoints] result: " + result) + this.INFO(this.callsign + "[getNamedEndpoints] result: " + JSON.stringify(result)) if (result.success) resolve(result.endpoints); reject(false) }).catch(err => { - this.ERR(this.callsign + "[getNamedEndpoints] error: " + err) + this.ERR(this.callsign + "[getNamedEndpoints] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getNamedEndpoints "+JSON.stringify(err), false, null) reject(err) }) @@ -142,7 +143,7 @@ export default class Network { } reject(false) }).catch(err => { - this.ERR(this.callsign + "[getStbIp] error: " + err) + this.ERR(this.callsign + "[getStbIp] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getStbIp result "+JSON.stringify(err), false, null) reject(err) }) @@ -152,11 +153,11 @@ export default class Network { getSTBIPFamily(family = "AF_INET") { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getSTBIPFamily', { "family": family }).then(result => { - this.INFO(this.callsign + "[getSTBIPFamily] result: " + result) + this.INFO(this.callsign + "[getSTBIPFamily] result: " + JSON.stringify(result)) if (result.success) { resolve(result) } reject(false); }).catch(err => { - this.ERR(this.callsign + "[getSTBIPFamily] error: " + err) + this.ERR(this.callsign + "[getSTBIPFamily] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getSTBIPFamily "+JSON.stringify(err), false, null) reject(err) }) @@ -167,10 +168,10 @@ export default class Network { return new Promise((resolve, reject) => { if (!endpoints.length) reject(false) this._thunder.call(this.callsign, 'setConnectivityTestEndpoints', { endpoints: endpoints }).then(result => { - this.INFO(this.callsign + "[setConnectivityTestEndpoints] result: " + result) + this.INFO(this.callsign + "[setConnectivityTestEndpoints] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[setConnectivityTestEndpoints] error: " + err) + this.ERR(this.callsign + "[setConnectivityTestEndpoints] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network setConnectivityTestEndpoints "+JSON.stringify(err), false, null) reject(err) }) @@ -184,7 +185,7 @@ export default class Network { if (result.success) resolve(result.connectedToInternet) resolve(false) }).catch(err => { - this.ERR(this.callsign + "[isConnectedToInternet] error: " + err) + this.ERR(this.callsign + "[isConnectedToInternet] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network isConnectedToInternet "+JSON.stringify(err), false, null) reject(err) }) @@ -194,11 +195,11 @@ export default class Network { getinternetconnectionstate() { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getInternetConnectionState').then(result => { - this.INFO(this.callsign + "[getinternetconnectionstate] result: " + result) + this.INFO(this.callsign + "[getinternetconnectionstate] result: " + JSON.stringify(result)) if (result.success) resolve(result) reject(false) }).catch(err => { - this.ERR(this.callsign + "[getinternetconnectionstate] error: " + err) + this.ERR(this.callsign + "[getinternetconnectionstate] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getInternetConnectionState "+JSON.stringify(err), false, null) reject(err) }) @@ -208,11 +209,11 @@ export default class Network { getCaptivePortalURI() { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getCaptivePortalURI').then(result => { - this.INFO(this.callsign + "[getCaptivePortalURI] result: " + result) + this.INFO(this.callsign + "[getCaptivePortalURI] result: " + JSON.stringify(result)) if (result.success) resolve(result) reject(false) }).catch(err => { - this.ERR(this.callsign + "[getCaptivePortalURI] error: " + err) + this.ERR(this.callsign + "[getCaptivePortalURI] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getCaptivePortalURI "+JSON.stringify(err), false, null) reject(err) }) @@ -222,10 +223,10 @@ export default class Network { startConnectivityMonitoring(intervalInSec = 30) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'startConnectivityMonitoring', { "interval": intervalInSec }).then(result => { - this.INFO(this.callsign + "[startConnectivityMonitoring] result: " + result) + this.INFO(this.callsign + "[startConnectivityMonitoring] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[startConnectivityMonitoring] error: " + err) + this.ERR(this.callsign + "[startConnectivityMonitoring] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network startConnectivityMonitoring "+JSON.stringify(err), false, null) reject(err) }) @@ -235,10 +236,10 @@ export default class Network { stopConnectivityMonitoring() { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'stopConnectivityMonitoring').then(result => { - this.INFO(this.callsign + "[stopConnectivityMonitoring] result: " + result) + this.INFO(this.callsign + "[stopConnectivityMonitoring] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[stopConnectivityMonitoring] error: " + err) + this.ERR(this.callsign + "[stopConnectivityMonitoring] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network stopConnectivityMonitoring "+JSON.stringify(err), false, null) reject(err) }) @@ -252,7 +253,7 @@ export default class Network { if (result.success) resolve(result.enabled) resolve(false) }).catch(err => { - this.ERR(this.callsign + "[isInterfaceEnabled] error: " + err) + this.ERR(this.callsign + "[isInterfaceEnabled] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network isInterfaceEnabled "+JSON.stringify(err), false, null) reject(err) }) @@ -262,11 +263,11 @@ export default class Network { ping(endpoint = "8.8.8.8", packets = 10, guid = "2c6ff543-d929-4be4-a0d8-9abae2ca7471") { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'ping', { "endpoint": endpoint, "packets": packets, "guid": guid }).then(result => { - this.INFO(this.callsign + "[ping] result: " + result) + this.INFO(this.callsign + "[ping] result: " + JSON.stringify(result)) if (result.success) resolve(result) resolve(false) }).catch(err => { - this.ERR(this.callsign + "[ping] error: " + err) + this.ERR(this.callsign + "[ping] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network ping "+JSON.stringify(err), false, null) reject(err) }) @@ -276,11 +277,11 @@ export default class Network { pingNamedEndpoint(endpointName = "CMTS", packets = 15, guid = "2c6ff543-d929-4be4-a0d8-9abae2ca7471") { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'pingNamedEndpoint', { "endpointName": endpointName, "packets": packets, "guid": guid }).then(result => { - this.INFO(this.callsign + "[pingNamedEndpoint] result: " + result) + this.INFO(this.callsign + "[pingNamedEndpoint] result: " + JSON.stringify(result)) if (result.success) resolve(result) resolve(false) }).catch(err => { - this.ERR(this.callsign + "[pingNamedEndpoint] error: " + err) + this.ERR(this.callsign + "[pingNamedEndpoint] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network pingNamedEndpoint "+JSON.stringify(err), false, null) reject(err) }) @@ -290,10 +291,10 @@ export default class Network { setDefaultInterface(interfaceName = "ETHERNET", persist = true) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'setDefaultInterface', { "interface": interfaceName, "persist": persist }).then(result => { - this.INFO(this.callsign + "[setDefaultInterface] result: " + result) + this.INFO(this.callsign + "[setDefaultInterface] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[setDefaultInterface] error: " + err) + this.ERR(this.callsign + "[setDefaultInterface] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network setDefaultInterface "+JSON.stringify(err), false, null) reject(err) }) @@ -303,10 +304,10 @@ export default class Network { setInterfaceEnabled(interfaceName, enabled = true, persist = true) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'setInterfaceEnabled', { "interface": interfaceName, "enabled": enabled, "persist": persist }).then(result => { - this.INFO(this.callsign + "[setInterfaceEnabled] result: " + result) + this.INFO(this.callsign + "[setInterfaceEnabled] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[setInterfaceEnabled] error: " + err) + this.ERR(this.callsign + "[setInterfaceEnabled] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network setInterfaceEnabled "+JSON.stringify(err), false, null) reject(err) }) @@ -316,10 +317,10 @@ export default class Network { setIPSettings(IPSettings) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'setIPSettings', IPSettings).then(result => { - this.INFO(this.callsign + "[setIPSettings] result: " + result) + this.INFO(this.callsign + "[setIPSettings] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[setIPSettings] error: " + err) + this.ERR(this.callsign + "[setIPSettings] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network setIPSettings "+JSON.stringify(err), false, null) reject(err) }) @@ -329,11 +330,11 @@ export default class Network { getPublicIP(iface = "ETHERNET", ipv6 = false) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'getPublicIP', { "iface": iface, "ipv6": ipv6 }).then(result => { - this.INFO(this.callsign + "[getPublicIP] result: " + result) + this.INFO(this.callsign + "[getPublicIP] result: " + JSON.stringify(result)) if (result.success) resolve(result.public_ip) resolve(false) }).catch(err => { - this.ERR(this.callsign + "[getPublicIP] error: " + err) + this.ERR(this.callsign + "[getPublicIP] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network getPublicIP "+JSON.stringify(err), false, null) reject(err) }) @@ -349,10 +350,10 @@ export default class Network { "timeout": timeout, "cache_timeout": cache_timeout }).then(result => { - this.INFO(this.callsign + "[setStunEndPoint] result: " + result) + this.INFO(this.callsign + "[setStunEndPoint] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[setStunEndPoint] error: " + err) + this.ERR(this.callsign + "[setStunEndPoint] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network setStunEndPoint "+JSON.stringify(err), false, null) reject(err) }) @@ -362,10 +363,10 @@ export default class Network { configurePNI(disableConnectivityTest = true) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'configurePNI', { "disableConnectivityTest": disableConnectivityTest }).then(result => { - this.INFO(this.callsign + "[configurePNI] result: " + result) + this.INFO(this.callsign + "[configurePNI] result: " + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + "[configurePNI] error: " + err) + this.ERR(this.callsign + "[configurePNI] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network configurePNI "+JSON.stringify(err), false, null) reject(err) }) @@ -375,11 +376,11 @@ export default class Network { trace(endpoint = "8.8.8.8", packets = 15) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'trace', { endpoint: endpoint, packets: packets }).then(result => { - this.INFO(this.callsign + "[trace] result: " + result) + this.INFO(this.callsign + "[trace] result: " + JSON.stringify(result)) if (result.success) resolve(result) reject(false) }).catch(err => { - this.ERR(this.callsign + "[trace] error: " + err) + this.ERR(this.callsign + "[trace] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network trace "+JSON.stringify(err), false, null) reject(err) }) @@ -389,11 +390,11 @@ export default class Network { traceNamedEndpoint(endpointName = "CMTS", packets = 15) { return new Promise((resolve, reject) => { this._thunder.call(this.callsign, 'trace', { "endpointName": endpointName, "packets": packets }).then(result => { - this.INFO(this.callsign + "[traceNamedEndpoint] result: " + result) + this.INFO(this.callsign + "[traceNamedEndpoint] result: " + JSON.stringify(result)) if (result.success) resolve(result) reject(false) }).catch(err => { - this.ERR(this.callsign + "[traceNamedEndpoint] error: " + err) + this.ERR(this.callsign + "[traceNamedEndpoint] error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"NetworkApiError", "Error in Thunder Network traceNamedEndpoint "+JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/NetworkManagerAPI.js b/accelerator-home-ui/src/api/NetworkManagerAPI.js new file mode 100644 index 0000000..5f0dc1d --- /dev/null +++ b/accelerator-home-ui/src/api/NetworkManagerAPI.js @@ -0,0 +1,154 @@ +/** + * If not stated otherwise in this file or this component's LICENSE + * file the following copyright and licenses apply: + * + * Copyright 2025 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ +import ThunderJS from 'ThunderJS'; +import { CONFIG } from '../Config/Config' +import { Metrics } from "@firebolt-js/sdk" + +export const WiFiState = { + WIFI_STATE_UNINSTALLED:0, + WIFI_STATE_DISABLED:1, + WIFI_STATE_DISCONNECTED:2, + WIFI_STATE_PAIRING:3, + WIFI_STATE_CONNECTING:4, + WIFI_STATE_CONNECTED:5, + WIFI_STATE_SSID_NOT_FOUND:6, + WIFI_STATE_SSID_CHANGED:7, + WIFI_STATE_CONNECTION_LOST:8, + WIFI_STATE_CONNECTION_FAILED:9, + WIFI_STATE_CONNECTION_INTERRUPTED:10, + WIFI_STATE_INVALID_CREDENTIALS:11, + WIFI_STATE_AUTHENTICATION_FAILED:12, + WIFI_STATE_ERROR:13 +} + +class NetworkManager { + constructor() { + this.thunder = ThunderJS(CONFIG.thunderConfig); + this.callsign = 'org.rdk.NetworkManager'; + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + + thunderCall = (infoMessage, method, params = {}, property) => { + return new Promise((resolve, reject) => { + this.INFO("NetworkManager: " + infoMessage + "."); + this.thunder.call(this.callsign, method, params) + .then(result => { + this.LOG("NetworkManager: " + infoMessage + ": " + JSON.stringify(params) + " result: " + JSON.stringify(result)); + if (result.success) { + if (property === 'result') { + resolve(result); + } else { + resolve(property ? result[property] : result.success); + } + } else { + this.ERR("NetworkManager: Error " + infoMessage + " " + JSON.stringify(params) + " result: " + JSON.stringify(result)); + Metrics.error(Metrics.ErrorType.OTHER, "NetworkManagerError", `Error ${infoMessage} ${JSON.stringify(params)} result: ${JSON.stringify(result)}`, false, null) + reject(result.success); + } + }) + .catch(err => { + this.ERR("NetworkManager: Error " + infoMessage + " " + JSON.stringify(err)); + reject(err); + }); + }); + } + activate() { + return new Promise((resolve, reject) => { + this.thunder.call('Controller', 'activate', { callsign: this.callsign }).then(result => { + this.INFO(this.callsign + " NetworkManager activate result: " + JSON.stringify(result)) + resolve(true) + }).catch(err => { + this.ERR(this.callsign + " NetworkManager activate error: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.NETWORK,"NetworkManagerError", "Error while Thunder Controller NetworkManager activate "+JSON.stringify(err), false, null) + reject(err) + }); + }); + } + + deactivate() { + return new Promise((resolve, reject) => { + this.thunder.call('Controller', 'deactivate', { callsign: this.callsign }).then(result => { + this.INFO(this.callsign + " NetworkManager deactivate result: " + JSON.stringify(result)) + resolve(true) + }).catch(err => { + this.ERR(this.callsign + " NetworkManager deactivate error: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.NETWORK,"NetworkManagerError", "Error while Thunder Controller NetworkManager deactivate "+JSON.stringify(err), false, null) + reject(err) + }); + }); + } + + GetAvailableInterfaces =() => this.thunderCall('GetAvailableInterfaces', 'GetAvailableInterfaces', {}, 'interfaces'); + GetPrimaryInterface =() => this.thunderCall('GetPrimaryInterface', 'GetPrimaryInterface', {}, 'interface'); + SetPrimaryInterface =(Interface) => this.thunderCall('SetPrimaryInterface', 'SetPrimaryInterface', {"interface":Interface} ); + SetInterfaceState =(Interface,enabled=true) => this.thunderCall('SetInterfaceState', 'SetInterfaceState', {"interface":Interface,"enabled":enabled} ); + GetInterfaceState =(Interface) => this.thunderCall('GetInterfaceState', 'GetInterfaceState', {"interface":Interface},"enabled" ); + GetIPSettings =(Interface,ipversion="IPv4") => this.thunderCall('GetIPSettings', 'GetIPSettings', {"interface":Interface,"ipversion":ipversion}, 'result'); + SetIPSettings =(Interface,ipversion,autoconfig,ipaddress,prefix,gateway,primarydns,secondarydns) => this.thunderCall('SetIPSettings', 'SetIPSettings', {Interface,ipversion,autoconfig,ipaddress,prefix,gateway,primarydns,secondarydns}, ); + GetStunEndpoint =() => this.thunderCall('GetStunEndpoint', 'GetStunEndpoint', {}, 'result'); + SetStunEndpoint =(endPoint,port,bindTimeout,cacheTimeout) => this.thunderCall('SetStunEndpoint', 'SetStunEndpoint', {endPoint,port,bindTimeout,cacheTimeout} ); + GetConnectivityTestEndpoints =() => this.thunderCall('GetConnectivityTestEndpoints', 'GetConnectivityTestEndpoints', {}, 'result'); + SetConnectivityTestEndpoints =(endpoints) => this.thunderCall('SetConnectivityTestEndpoints', 'SetConnectivityTestEndpoints', {endpoints} ); + IsConnectedToInternet =(ipversion="IPv4") => this.thunderCall('IsConnectedToInternet', 'IsConnectedToInternet', {"ipversion":ipversion}, 'result'); + GetCaptivePortalURI =() => this.thunderCall('GetCaptivePortalURI', 'GetCaptivePortalURI', {}, 'result'); + StartConnectivityMonitoring =(interval) => this.thunderCall('StartConnectivityMonitoring', 'StartConnectivityMonitoring', {interval}); + StopConnectivityMonitoring =() => this.thunderCall('StopConnectivityMonitoring', 'StopConnectivityMonitoring', {}); + GetPublicIP =(ipversion) => this.thunderCall('GetPublicIP', 'GetPublicIP', {ipversion}, 'result'); + Ping =(endpoint,ipversion,noOfRequest,timeout,guid) => this.thunderCall('Ping', 'Ping', {endpoint,ipversion,noOfRequest,timeout,guid}, 'result'); + Trace =(endpoint,ipversion,noOfRequest,guid) => this.thunderCall('Trace', 'Trace', {endpoint,ipversion,noOfRequest,guid}, 'result'); + StartWiFiScan =(frequency) => this.thunderCall('StartWiFiScan', 'StartWiFiScan', {frequency}); + StopWiFiScan =() => this.thunderCall('StopWiFiScan', 'StopWiFiScan', {}); + GetKnownSSIDs =() => this.thunderCall('GetKnownSSIDs', 'GetKnownSSIDs', {}, 'ssids'); + AddToKnownSSIDs =(ssid,passphrase,securityMode) => this.thunderCall('AddToKnownSSIDs', 'AddToKnownSSIDs', {"ssid":ssid,"passphrase":passphrase,"securityMode":securityMode}); + RemoveKnownSSID =(ssid) => this.thunderCall('RemoveKnownSSID', 'RemoveKnownSSID', {"ssid":ssid}); + // WiFiConnect =(ssid,passphrase,securityMode) => this.thunderCall('WiFiConnect', 'WiFiConnect', {ssid,passphrase,securityMode}); + WiFiDisconnect =() => this.thunderCall('WiFiDisconnect', 'WiFiDisconnect', {},"result"); + WiFiConnect(useSaved = false, networkInfo, passphrase = "") { + let params = {} + if (!useSaved) { // saveSSID was never called earlier. Need proper params. + params.ssid = networkInfo.ssid + if (Object.prototype.hasOwnProperty.call(networkInfo, "security")) params.securityMode = networkInfo.security + if (passphrase.length) params.passphrase = passphrase + } + return new Promise((resolve, reject) => { + this.LOG(this.callsign + " connect with params: " + JSON.stringify(params)) + this.thunderCall('WiFiConnect', 'WiFiConnect', params,"result").then(result => { + result.success ? resolve(result) : reject(result.success) + + }).catch(err => { + this.ERR(this.callsign + ": connect error: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.NETWORK,"NetworkManagerError", "Error in Thunder NetworkManager connect params "+JSON.stringify(err), false, null) + reject(err) + }) + }) + } + GetConnectedSSID =() => this.thunderCall('GetConnectedSSID', 'GetConnectedSSID', {}, 'result'); + StartWPS =(method,wps_pin) => this.thunderCall('StartWPS', 'StartWPS', {method,wps_pin},'result'); + StopWPS =() => this.thunderCall('StopWPS', 'StopWPS', {}); + GetWiFiSignalStrength =() => this.thunderCall('GetWiFiSignalStrength', 'GetWiFiSignalStrength', {}, 'result'); + GetSupportedSecurityModes =() => this.thunderCall('GetSupportedSecurityModes', 'GetSupportedSecurityModes', {}, 'result'); + SetLogLevel =(logLevel) => this.thunderCall('SetLogLevel', 'SetLogLevel', {logLevel} ); + GetWifiState =() => this.thunderCall('GetWifiState', 'GetWifiState', {},"state"); +} + +const NetworkManagerInstance = new NetworkManager(); +export default NetworkManagerInstance; diff --git a/accelerator-home-ui/src/api/PersistentStore.js b/accelerator-home-ui/src/api/PersistentStore.js index 104feb0..c9e9969 100644 --- a/accelerator-home-ui/src/api/PersistentStore.js +++ b/accelerator-home-ui/src/api/PersistentStore.js @@ -29,9 +29,10 @@ export default class PersistentStoreApi { this._events = new Map(); this.callsign = "org.rdk.PersistentStore"; this.thunder = ThunderJS(CONFIG.thunderConfig); - this.INFO = function () { }; - this.LOG = function () { }; + this.INFO = console.info; + this.LOG = console.log; this.ERR = console.error; + this.WARN = console.warn; PersistentStoreApi.instance = this; } @@ -65,7 +66,7 @@ export default class PersistentStoreApi { }); resolve(true); }).catch(err => { - this.ERR('PersistentStoreApi: Error Activation ', err); + this.ERR('PersistentStoreApi: Error Activation ' + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"PersistentStoreApiError", "Error while Thunder Controller PersistentStore activate "+JSON.stringify(err), false, null) reject(err); }) @@ -85,7 +86,7 @@ export default class PersistentStoreApi { } deleteKey(namespace, key) { return new Promise((resolve, reject) => { - this.INFO("PersistentStoreApi: deleteKey:" + namespace + " & " + key); + this.INFO("PersistentStoreApi: deleteKey:" + JSON.stringify(namespace) + " & " + JSON.stringify(key)); this.thunder.call(this.callsign, 'deleteKey', { namespace: namespace, key: key @@ -101,7 +102,7 @@ export default class PersistentStoreApi { } deleteNamespace(namespace) { return new Promise((resolve, reject) => { - this.INFO("PersistentStoreApi: deleteNamespace params:", namespace); + this.INFO("PersistentStoreApi: deleteNamespace params:" + JSON.stringify(namespace)); this.thunder.call(this.callsign, 'deleteNamespace', { namespace: namespace }).then(result => { this.LOG("PersistentStoreApi: deleteNamespace result:" + JSON.stringify(result)) resolve(result); @@ -126,7 +127,7 @@ export default class PersistentStoreApi { } getKeys(namespace) { return new Promise((resolve, reject) => { - this.INFO("PersistentStoreApi: getKeys params:", namespace); + this.INFO("PersistentStoreApi: getKeys params:" + JSON.stringify(namespace)); this.thunder.call(this.callsign, 'getKeys', { namespace: namespace }).then(result => { this.LOG("PersistentStoreApi: getKeys result: " + JSON.stringify(result)) resolve(result); @@ -163,7 +164,7 @@ export default class PersistentStoreApi { } getValue(namespace, key) { return new Promise((resolve, reject) => { - this.INFO("PersistentStoreApi: getValue " + namespace + " & " + key); + this.INFO("PersistentStoreApi: getValue " + JSON.stringify(namespace) + " & " + JSON.stringify(key)); this.thunder.call(this.callsign, 'getValue', { namespace: namespace, key: key }).then(result => { this.LOG("PersistentStoreApi: getValue result: " + JSON.stringify(result)) resolve(result); @@ -176,7 +177,7 @@ export default class PersistentStoreApi { } setValue(namespace, key, value) { return new Promise((resolve, reject) => { - this.INFO("PersistentStoreApi: setValue:" + namespace + " & " + key + " & " + value); + this.INFO("PersistentStoreApi: setValue:" + JSON.stringify(namespace) + " & " + JSON.stringify(key) + " & " + JSON.stringify(value)); this.thunder.call(this.callsign, 'setValue', { namespace: namespace, key: key, value: value }).then(result => { this.LOG("PersistentStoreApi: setValue result: " + JSON.stringify(result)) resolve(result); diff --git a/accelerator-home-ui/src/api/PictureSettingsApi.js b/accelerator-home-ui/src/api/PictureSettingsApi.js index d35b3c0..f8b1606 100644 --- a/accelerator-home-ui/src/api/PictureSettingsApi.js +++ b/accelerator-home-ui/src/api/PictureSettingsApi.js @@ -64,6 +64,10 @@ export default class PictureSettingsApi { _sharpness: {get: this.getSharpness.bind(this), set: this.setSharpness.bind(this)}, _saturation: {get: this.getSaturation.bind(this), set: this.setSaturation.bind(this)} }; + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; } activate() { @@ -71,17 +75,11 @@ export default class PictureSettingsApi { this._thunder .call("Controller", "activate", { callsign: this.callsign }) .then(result => { - console.log( - "Activated tv.ControlSettings plugin: ", - JSON.stringify(result) - ); + this.LOG("Activated tv.ControlSettings plugin: " + JSON.stringify(result)); resolve(result); }) .catch(err => { - console.log( - "Failed to activate tv.ControlSettings plugin: ", - JSON.stringify(err) - ); + this.ERR("Failed to activate tv.ControlSettings plugin: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"PictureSettingsApiError", "Error while Thunder Controller TvControlSettings activate "+JSON.stringify(err), false, null) reject(err); }); @@ -89,13 +87,13 @@ export default class PictureSettingsApi { } getSettingsValue(settingsName) { - console.log("getSettingsValue called for : ",settingsName) + this.LOG("getSettingsValue called for : " + JSON.stringify(settingsName)) return new Promise((resolve, reject) => { this.methodNames[settingsName].get().then(result => { - console.log(`Result from getSettingsValue API for ${settingsName} : ${JSON.stringify(result)}`) + this.LOG("Result from getSettingsValue API for " + JSON.stringify(settingsName) + " : " + JSON.stringify(result)) resolve(result) }).catch(err => { - console.log(`Error from getSettingsValue API for ${settingsName} : ${JSON.stringify(err)}`) + this.ERR("Error from getSettingsValue API for " + JSON.stringify(settingsName) + " : " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"PictureSettingsApiError", "Error in Thunder TvControlSettings getSettings "+JSON.stringify(err), false, null) reject(err) }) @@ -103,13 +101,13 @@ export default class PictureSettingsApi { } setSettingsValue(settingsName, value){ - console.log("setSettingsValue called for : ",settingsName, " and for value: ",value) + this.LOG("setSettingsValue called for : " + JSON.stringify(settingsName) + " and for value: " + JSON.stringify(value)) return new Promise((resolve, reject) => { this.methodNames[settingsName].set(value).then(result => { - console.log(`Result from setSettingsValue API for ${settingsName} : ${JSON.stringify(result)}`) + this.LOG("Result from setSettingsValue API for " + JSON.stringify(settingsName) + " : " + JSON.stringify(result)) resolve(result) }).catch(err => { - console.log(`Error from setSettingsValue API for ${settingsName} and value : ${value} | Error: ${JSON.stringify(err)}`) + this.ERR("Error from setSettingsValue API for " + JSON.stringify(settingsName) + " and value : " + JSON.stringify(value) + " | Error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"PictureSettingsApiError", "Error in Thunder TvControlSettings setSettings "+JSON.stringify(err), false, null) reject(err) }) @@ -117,22 +115,21 @@ export default class PictureSettingsApi { } getOptions() { - console.log("getOptions called: ",JSON.stringify(this.settingsOptions)) + this.LOG("getOptions called: " + JSON.stringify(this.settingsOptions)) return this.settingsOptions; } getSupportedPictureModes() { - console.log("getSupportedPictureModes got called") - + this.LOG("getSupportedPictureModes got called") return new Promise((resolve,reject) => { this._thunder.call(this.callsign, "getSupportedPictureModes").then(result => { - console.log("getSupportedPictureModes Result: ",JSON.stringify(result)) + this.LOG("getSupportedPictureModes Result: " + JSON.stringify(result)) if (result.success) { this.settingsOptions[0].value=result.SupportedPicmodes resolve(true) } }).catch(err => { - console.log("getSupportedPictureModes Error: ",JSON.stringify(err)) + this.ERR("getSupportedPictureModes Error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"PictureSettingsApiError", "Error in Thunder TvControlSettings getSupportedPictureModes "+JSON.stringify(err), false, null) reject(err) }) @@ -140,17 +137,16 @@ export default class PictureSettingsApi { } getSupportedColorTemps() { - console.log("getSupportedColorTemps got called") - + this.LOG("getSupportedColorTemps got called") return new Promise((resolve,reject) => { this._thunder.call(this.callsign, "getColorTemperature").then(result => { - console.log("Log from getSupportedColorTemps API: ", JSON.stringify(result)) + this.LOG("Log from getSupportedColorTemps API: " + JSON.stringify(result)) if (result.success) { this.settingsOptions[1].value=result.ColorTemperature.Options resolve(true) } }).catch(err => { - console.log("Error from getSupportedColorTemps API: ", JSON.stringify(err)) + this.ERR("Error from getSupportedColorTemps API: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"PictureSettingsApiError", "Error in Thunder TvControlSettings getColorTemperature "+JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/RemoteControl.js b/accelerator-home-ui/src/api/RemoteControl.js index 164b524..1caf9f1 100644 --- a/accelerator-home-ui/src/api/RemoteControl.js +++ b/accelerator-home-ui/src/api/RemoteControl.js @@ -25,11 +25,10 @@ let instance = null export default class RCApi { constructor() { this.thunder = ThunderJS(CONFIG.thunderConfig); - // this.INFO = console.info; - // this.LOG = console.log; - this.INFO = function () { }; - this.LOG = function () { }; + this.INFO = console.info; + this.LOG = console.log; this.ERR = console.error; + this.WARN = console.warn; } static get() { @@ -45,7 +44,7 @@ export default class RCApi { this.thunder.Controller.activate({ callsign: 'org.rdk.RemoteControl' }).then(() => { resolve(true); }).catch(err => { - this.ERR('RCApi: Error Activation ', err); + this.ERR("RCApi: Error Activation " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error while Thunder Controller RemoteControl activate "+JSON.stringify(err), false, null) reject(err) }) @@ -58,7 +57,7 @@ export default class RCApi { this.INFO("RCApi: deactivated org.rdk.RemoteControl") resolve(true) }).catch(err => { - this.ERR('RCApi: Error deactivation ', err) + this.ERR("RCApi: Error deactivation " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error while Thunder Controller RemoteControl deactivate "+JSON.stringify(err), false, null) reject(err) }) @@ -69,10 +68,10 @@ export default class RCApi { return new Promise((resolve, reject) => { this.INFO("RCApi: getApiVersionNumber"); this.thunder.call('org.rdk.RemoteControl', 'getApiVersionNumber').then(result => { - this.INFO("RCApi: getApiVersionNumber result: ", JSON.stringify(result)) + this.INFO("RCApi: getApiVersionNumber result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("RCApi: getApiVersionNumber error:", err); + this.ERR("RCApi: getApiVersionNumber error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error in Thunder RemoteControl getApiVersionNumber "+JSON.stringify(err), false, null) reject(err); }); @@ -82,11 +81,11 @@ export default class RCApi { getNetStatus() { return new Promise((resolve, reject) => { this.thunder.call('org.rdk.RemoteControl', 'getNetStatus').then(result => { - this.INFO("RCApi: getNetStatus result: ", JSON.stringify(result)) + this.INFO("RCApi: getNetStatus result: " + JSON.stringify(result)) if (result.success) resolve(result); reject(false); }).catch(err => { - this.ERR("RCApi: getNetStatus error:", err); + this.ERR("RCApi: getNetStatus error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error in Thunder RemoteControl getNetStatus "+JSON.stringify(err), false, null) reject(err); }); @@ -100,7 +99,7 @@ export default class RCApi { //this.INFO("RCApi: startPairing result: ", JSON.stringify(result)) resolve(result.success); }).catch(err => { - this.ERR("RCApi: startPairing error:", err); + this.ERR("RCApi: startPairing error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error in Thunder RemoteControl startPairing "+JSON.stringify(err), false, null) reject(err); }); @@ -174,13 +173,13 @@ export default class RCApi { configureWakeupKeys(netType = 1, wakeupConfig = "custom", customKeys = "3,1") { return new Promise((resolve, reject) => { - this.INFO("RCApi: configureWakeupKeys netType:" + netType + " wakeupConfig:" + wakeupConfig + " customKeys:" + customKeys); + this.INFO("RCApi: configureWakeupKeys netType:" + JSON.stringify(netType) + " wakeupConfig:" + JSON.stringify(wakeupConfig) + " customKeys:" + JSON.stringify(customKeys)); this.thunder.call('org.rdk.RemoteControl', 'configureWakeupKeys', { netType: netType, wakeupConfig: wakeupConfig, customKeys: customKeys }).then(result => { - this.INFO("RCApi: configureWakeupKeys result: ", JSON.stringify(result)) + this.INFO("RCApi: configureWakeupKeys result: " + JSON.stringify(result)) resolve(result.success); }).catch(err => { - this.ERR("RCApi: configureWakeupKeys error:", err); + this.ERR("RCApi: configureWakeupKeys error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error in Thunder RemoteControl configureWakeupKeys "+JSON.stringify(err), false, null) reject(err); }); @@ -189,12 +188,12 @@ export default class RCApi { findMyRemote(netType = 1, level = "mid") { return new Promise((resolve, reject) => { - this.INFO("RCApi: findMyRemote netType:" + netType + " level:" + level); + this.INFO("RCApi: findMyRemote netType:" + JSON.stringify(netType) + " level:" + JSON.stringify(level)); this.thunder.call('org.rdk.RemoteControl', 'findMyRemote', { netType: netType, level: level }).then(result => { - this.INFO("RCApi: findMyRemote result: ", JSON.stringify(result)) + this.INFO("RCApi: findMyRemote result: " + JSON.stringify(result)) resolve(result.success); }).catch(err => { - this.ERR("RCApi: findMyRemote error:", err); + this.ERR("RCApi: findMyRemote error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error in Thunder RemoteControl findMyRemote "+JSON.stringify(err), false, null) reject(err); }); @@ -205,10 +204,10 @@ export default class RCApi { return new Promise((resolve, reject) => { this.INFO("RCApi: factoryReset"); this.thunder.call('org.rdk.RemoteControl', 'factoryReset').then(result => { - this.INFO("RCApi: factoryReset result: ", JSON.stringify(result)) + this.INFO("RCApi: factoryReset result: " + JSON.stringify(result)) resolve(result.success); }).catch(err => { - this.ERR("RCApi: factoryReset error:", err); + this.ERR("RCApi: factoryReset error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"RemoteControlApiError", "Error in Thunder RemoteControl factoryReset "+JSON.stringify(err), false, null) reject(err); }); diff --git a/accelerator-home-ui/src/api/TTSApi.js b/accelerator-home-ui/src/api/TTSApi.js index 07e5245..c4d2310 100644 --- a/accelerator-home-ui/src/api/TTSApi.js +++ b/accelerator-home-ui/src/api/TTSApi.js @@ -25,6 +25,13 @@ const callsign = 'org.rdk.TextToSpeech' const errorName = 'TextToSpeechError' export default class TTSApi { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + activate() { return new Promise((resolve, reject) => { thunder.Controller.activate({ callsign: callsign }) @@ -32,7 +39,7 @@ export default class TTSApi { resolve(true) }) .catch(err => { - console.error('Error Activation', err) + this.ERR("Error Activation " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, errorName, `Error while Thunder Controller ${callsign} activate ${JSON.stringify(err)}`, false, null) reject(err) }) @@ -45,7 +52,7 @@ export default class TTSApi { resolve(true) }) .catch(err => { - console.error('Error Deactivation', err) + this.ERR("Error Deactivation " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, errorName, `Error while Thunder Controller ${callsign} deactivate ${JSON.stringify(err)}`, false, null) reject(err) }) @@ -62,7 +69,7 @@ export default class TTSApi { resolve(true) }) .catch(err => { - console.error("TTSApi TextToSpeech enable error:", JSON.stringify(err, 3, null)) + this.ERR("TTSApi TextToSpeech enable error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech enable " + JSON.stringify(err), false, null) resolve(false) }) @@ -77,7 +84,7 @@ export default class TTSApi { resolve(result.isenabled) }) .catch(err => { - console.error("TTSApi TextToSpeech isEnabled error:", JSON.stringify(err, 3, null)) + this.ERR("TTSApi TextToSpeech isEnabled error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech isEnabled " + JSON.stringify(err), false, null) resolve(false) }) @@ -92,7 +99,7 @@ export default class TTSApi { resolve(true) }) .catch(err => { - console.error("TTSApi TextToSpeech setTTSConfiguration error:", JSON.stringify(err, 3, null)) + this.ERR("TTSApi TextToSpeech setTTSConfiguration error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech setTTSConfiguration " + JSON.stringify(err), false, null) resolve(false) }) @@ -107,7 +114,7 @@ export default class TTSApi { resolve(result) }) .catch(err => { - console.error("TTSApi TextToSpeech getTTSConfiguration error:", JSON.stringify(err, 3, null)) + this.ERR("TTSApi TextToSpeech getTTSConfiguration error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech getTTSConfiguration " + JSON.stringify(err), false, null) resolve(false) }) @@ -124,7 +131,7 @@ export default class TTSApi { resolve(result) }) .catch(err => { - console.error("TTSAPI TextToSpeech speak error:", JSON.stringify(err, 3, null)) + this.ERR("TTSAPI TextToSpeech speak error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech Speak " + JSON.stringify(err), false, null) resolve(false) }) @@ -141,7 +148,7 @@ export default class TTSApi { resolve(result) }) .catch(err => { - console.error("TTSAPI TextToSpeech resume error:", JSON.stringify(err, 3, null)) + this.ERR("TTSAPI TextToSpeech resume error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech resume " + JSON.stringify(err), false, null) resolve(false) }) @@ -158,7 +165,7 @@ export default class TTSApi { resolve(result) }) .catch(err => { - console.error("TTSApi TextToSpeech pause error:", JSON.stringify(err, 3, null)) + this.ERR("TTSApi TextToSpeech pause error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech pause " + JSON.stringify(err), false, null) resolve(false) }) @@ -175,7 +182,7 @@ export default class TTSApi { resolve(result) }) .catch(err => { - console.error("TTSAPI TextToSpeech listvoices error:", JSON.stringify(err, 3, null)) + this.ERR("TTSAPI TextToSpeech listvoices error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder TextToSpeech listVoices " + JSON.stringify(err), false, null) resolve(false) }) diff --git a/accelerator-home-ui/src/api/UsbApi.js b/accelerator-home-ui/src/api/UsbApi.js index b85b611..9307de0 100644 --- a/accelerator-home-ui/src/api/UsbApi.js +++ b/accelerator-home-ui/src/api/UsbApi.js @@ -31,6 +31,13 @@ let thunder = ThunderJS(CONFIG.thunderConfig) */ export default class UsbApi { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + /** * Function to activate USB Access Plugin */ @@ -41,7 +48,7 @@ export default class UsbApi { .then(res => { resolve(res) }).catch(err => { - console.log('UsbAccess Plugin Activation Failed: ' + err) + this.ERR('UsbAccess Plugin Activation Failed: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"UsbApiError", "Error while Thunder Controller usbAccess activate "+JSON.stringify(err), false, null) reject(err) }) @@ -58,7 +65,7 @@ export default class UsbApi { .then(res => { resolve(res) }).catch(err => { - console.log('UsbAccess Plugin Deactivation Failed: ' + err) + this.ERR('UsbAccess Plugin Deactivation Failed: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"UsbApiError", "Error while Thunder Controller usbAccess deactivate "+JSON.stringify(err), false, null) reject(err) }) @@ -76,7 +83,7 @@ export default class UsbApi { .then(result => { resolve(result) }).catch(err => { - console.error('UsbAccess Plugin ClearLink Failed: ' + JSON.stringify(err)) + this.ERR('UsbAccess Plugin ClearLink Failed: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"UsbApiError", "Error in Thunder usbAccess clearLink "+JSON.stringify(err), false, null) resolve(false) }) @@ -94,7 +101,7 @@ export default class UsbApi { .then(result => { resolve(result) }).catch(err => { - console.error('UsbAccess Plugin CreateLink Failed: ' + JSON.stringify(err)) + this.ERR('UsbAccess Plugin CreateLink Failed: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"UsbApiError", "Error in Thunder usbAccess createLink "+JSON.stringify(err), false, null) resolve(false) }) @@ -113,7 +120,7 @@ export default class UsbApi { .then(result => { resolve(result.contents) }).catch(err => { - console.error('UsbAccess Plugin getFileList Failed: ' + JSON.stringify(err)) + this.ERR('UsbAccess Plugin getFileList Failed: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"UsbApiError", "Error in Thunder usbAccess getFileList "+JSON.stringify(err), false, null) resolve(false) }) @@ -127,7 +134,7 @@ export default class UsbApi { .then(result => { resolve(result.contents) }).catch(err => { - console.error('UsbAccess Plugin getFileList Failed: ' + JSON.stringify(err)) + this.ERR('UsbAccess Plugin getFileList Failed: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"UsbApiError", "Error in Thunder usbAccess getFileList "+JSON.stringify(err), false, null) resolve(false) }) @@ -192,7 +199,7 @@ export default class UsbApi { }) .catch(err => { reject(err) - console.error(`Error while getting the mounted device ${JSON.stringify(err)}`); + this.ERR("Error while getting the mounted device " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"UsbApiError", "Error in Thunder usbAccess getMounted "+JSON.stringify(err), false, null) }); }); @@ -210,7 +217,7 @@ export default class UsbApi { let extensionForAudio = ['.mp3', '.mpeg', '.MP3', '.MPEG']; this._discoveredC = result; - // console.log("Discovered result :: " + JSON.stringify(result)); + // this.LOG("Discovered result :: " + JSON.stringify(result)); this._discoveredC.filter(device => { for (let i in extensionForImage) { diff --git a/accelerator-home-ui/src/api/UserSettingsApi.js b/accelerator-home-ui/src/api/UserSettingsApi.js index 629edf5..4e8038e 100644 --- a/accelerator-home-ui/src/api/UserSettingsApi.js +++ b/accelerator-home-ui/src/api/UserSettingsApi.js @@ -25,6 +25,13 @@ const callsign = 'org.rdk.UserSettings' const errorName = 'UserSettingsError' export default class UserSettingsApi { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + activate() { return new Promise((resolve, reject) => { thunder.Controller.activate({ callsign: callsign }) @@ -32,7 +39,7 @@ export default class UserSettingsApi { resolve(true) }) .catch(err => { - console.log('Error Activation', err) + this.ERR("Error Activation " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, errorName, `Error while Thunder Controller ${callsign} activate ${JSON.stringify(err)}`, false, null) reject(err) }) @@ -45,7 +52,7 @@ export default class UserSettingsApi { resolve(true) }) .catch(err => { - console.log('Error Deactivation', err) + this.ERR("Error Deactivation " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, errorName, `Error while Thunder Controller ${callsign} deactivate ${JSON.stringify(err)}`, false, null) reject(err) }) @@ -62,7 +69,7 @@ export default class UserSettingsApi { resolve(true) }) .catch(err => { - console.log('Error enable', err) + this.ERR("Error enable " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder UserSettings setVoiceGuidance " + JSON.stringify(err), false, null) resolve(false) }) @@ -77,11 +84,10 @@ export default class UserSettingsApi { resolve(result) }) .catch(err => { - console.log('Error enable', err) + this.ERR("Error enable " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Error in Thunder UserSettings getVoiceGuidance " + JSON.stringify(err), false, null) resolve(false) }) }) } - } diff --git a/accelerator-home-ui/src/api/VoiceApi.js b/accelerator-home-ui/src/api/VoiceApi.js index be13b5d..aef78d4 100644 --- a/accelerator-home-ui/src/api/VoiceApi.js +++ b/accelerator-home-ui/src/api/VoiceApi.js @@ -24,9 +24,10 @@ export default class VoiceApi { constructor() { this._events = new Map(); this.thunder = ThunderJS(CONFIG.thunderConfig); - this.INFO = function () { }; - this.LOG = function () { }; + this.INFO = console.info; + this.LOG = console.log; this.ERR = console.error; + this.WARN = console.warn; } registerEvent(eventId, callback) { this._events.set(eventId, callback) @@ -73,7 +74,7 @@ export default class VoiceApi { }); resolve(true); }).catch(err => { - this.ERR('VoiceApi: Error Activation ', err); + this.ERR('VoiceApi: Error Activation ' + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error while Thunder Controller VoiceApi activate "+JSON.stringify(err), false, null) }) }) @@ -84,19 +85,19 @@ export default class VoiceApi { this.INFO("VoiceApi: deactivated org.rdk.VoiceControl") resolve(true) }).catch(err => { - this.ERR('VoiceApi: Error deactivation ', err) + this.ERR('VoiceApi: Error deactivation ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error while Thunder Controller VoiceApi deactivate "+JSON.stringify(err), false, null) }) }) } configureVoice(params) { return new Promise((resolve) => { - this.INFO("VoiceApi: configure params:", params); + this.INFO("VoiceApi: configure params: " + JSON.stringify(params)); this.thunder.call('org.rdk.VoiceControl', 'configureVoice', params).then(result => { - this.INFO("VoiceApi: configureVoice: " + JSON.stringify(params) + " result: ", JSON.stringify(result)) + this.INFO("VoiceApi: configureVoice: " + JSON.stringify(params) + " result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: configureVoice error:", err); + this.ERR("VoiceApi: configureVoice error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error while Thunder VoiceApi configureVoice "+JSON.stringify(err), false, null) resolve(false); }); @@ -104,12 +105,12 @@ export default class VoiceApi { } sendVoiceMessage(params) { return new Promise((resolve) => { - this.INFO("VoiceApi: sendVoiceMessage params:", params); + this.INFO("VoiceApi: sendVoiceMessage params: " + JSON.stringify(params)); this.thunder.call('org.rdk.VoiceControl', 'sendVoiceMessage', params).then(result => { - this.INFO("VoiceApi: sendVoiceMessage result:", JSON.stringify(result)) + this.INFO("VoiceApi: sendVoiceMessage result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: sendVoiceMessage error:", err); + this.ERR("VoiceApi: sendVoiceMessage error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi sendVoiceMessage "+JSON.stringify(err), false, null) resolve(false); }); @@ -117,12 +118,12 @@ export default class VoiceApi { } setVoiceInit(params) { return new Promise((resolve) => { - this.INFO("VoiceApi: setVoiceInit params:", params); + this.INFO("VoiceApi: setVoiceInit params: " + JSON.stringify(params)); this.thunder.call('org.rdk.VoiceControl', 'setVoiceInit', params).then(result => { - this.INFO("VoiceApi: setVoiceInit result: ", JSON.stringify(result)) + this.INFO("VoiceApi: setVoiceInit result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: setVoiceInit error:", err); + this.ERR("VoiceApi: setVoiceInit error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi setVoiceInit "+JSON.stringify(err), false, null) resolve(false); }); @@ -130,12 +131,12 @@ export default class VoiceApi { } voiceSessionByText(params) { return new Promise((resolve) => { - this.INFO("VoiceApi: voiceSessionByText params:", params); + this.INFO("VoiceApi: voiceSessionByText params: " + JSON.stringify(params)); this.thunder.call('org.rdk.VoiceControl', 'voiceSessionByText', params).then(result => { - this.INFO("VoiceApi: voiceSessionByText result: ", JSON.stringify(result)) + this.INFO("VoiceApi: voiceSessionByText result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: voiceSessionByText error:", err); + this.ERR("VoiceApi: voiceSessionByText error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi voiceSessionByText "+JSON.stringify(err), false, null) resolve(false); }); @@ -144,10 +145,10 @@ export default class VoiceApi { voiceSessionTypes() { return new Promise((resolve) => { this.thunder.call('org.rdk.VoiceControl', 'voiceSessionTypes').then(result => { - this.INFO("VoiceApi: voiceSessionTypes result: ", JSON.stringify(result)) + this.INFO("VoiceApi: voiceSessionTypes result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: voiceSessionTypes error:", err); + this.ERR("VoiceApi: voiceSessionTypes error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi voiceSessionTypes "+JSON.stringify(err), false, null) resolve(false); }); @@ -155,12 +156,12 @@ export default class VoiceApi { } voiceSessionRequest(params) { return new Promise((resolve) => { - this.INFO("VoiceApi: voiceSessionRequest params", params); + this.INFO("VoiceApi: voiceSessionRequest params: " + JSON.stringify(params)); this.thunder.call('org.rdk.VoiceControl', 'voiceSessionRequest', params).then(result => { - this.INFO("VoiceApi: voiceSessionRequest result: ", JSON.stringify(result)) + this.INFO("VoiceApi: voiceSessionRequest result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: voiceSessionRequest error:", err); + this.ERR("VoiceApi: voiceSessionRequest error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi voiceSessionRequest "+JSON.stringify(err), false, null) resolve(false); }); @@ -168,12 +169,12 @@ export default class VoiceApi { } voiceSessionTerminate(params) { return new Promise((resolve) => { - this.INFO("VoiceApi: voiceSessionTerminate params:", params); + this.INFO("VoiceApi: voiceSessionTerminate params: " + JSON.stringify(params)); this.thunder.call('org.rdk.VoiceControl', 'voiceSessionTerminate', params).then(result => { - this.INFO("VoiceApi: voiceSessionTerminate result: ", JSON.stringify(result)) + this.INFO("VoiceApi: voiceSessionTerminate result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: voiceSessionTerminate error:", err); + this.ERR("VoiceApi: voiceSessionTerminate error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi voiceSessionTerminate "+JSON.stringify(err), false, null) resolve(false); }); @@ -181,12 +182,12 @@ export default class VoiceApi { } voiceSessionAudioStreamStart(params) { return new Promise((resolve) => { - this.INFO("VoiceApi: voiceSessionAudioStreamStart params:", params); + this.INFO("VoiceApi: voiceSessionAudioStreamStart params: " + JSON.stringify(params)); this.thunder.call('org.rdk.VoiceControl', 'voiceSessionAudioStreamStart', params).then(result => { - this.INFO("VoiceApi: voiceSessionAudioStreamStart : " + JSON.stringify(params) + " result: ", JSON.stringify(result)) + this.INFO("VoiceApi: voiceSessionAudioStreamStart : " + JSON.stringify(params) + " result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: voiceSessionAudioStreamStart error:", err); + this.ERR("VoiceApi: voiceSessionAudioStreamStart error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi voiceSessionAudioStreamStart "+JSON.stringify(err), false, null) resolve(false); }); @@ -196,10 +197,10 @@ export default class VoiceApi { return new Promise((resolve) => { this.INFO("VoiceApi: voiceStatus"); this.thunder.call('org.rdk.VoiceControl', 'voiceStatus').then(result => { - this.INFO("VoiceApi: voiceStatus result: ", JSON.stringify(result)) + this.INFO("VoiceApi: voiceStatus result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - this.ERR("VoiceApi: voiceStatus error:", err); + this.ERR("VoiceApi: voiceStatus error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"VoiceApiError", "Error in Thunder VoiceApi voiceStatus "+JSON.stringify(err), false, null) resolve(false); }); diff --git a/accelerator-home-ui/src/api/WarehouseApis.js b/accelerator-home-ui/src/api/WarehouseApis.js index c900055..2c3ef90 100644 --- a/accelerator-home-ui/src/api/WarehouseApis.js +++ b/accelerator-home-ui/src/api/WarehouseApis.js @@ -26,9 +26,10 @@ export default class Warehouse { constructor() { this.thunder = ThunderJS(CONFIG.thunderConfig); this.callsign = 'org.rdk.Warehouse'; - this.INFO = function(){}; - this.LOG = function(){}; + this.INFO = console.info; + this.LOG = console.log; this.ERR = console.error; + this.WARN = console.warn; } static get() { @@ -41,10 +42,10 @@ export default class Warehouse { activate() { return new Promise((resolve, reject) => { this.thunder.call('Controller', 'activate', { callsign: this.callsign }).then(result => { - this.INFO(this.callsign + " activate result:" + result) + this.INFO(this.callsign + " activate result:" + JSON.stringify(result)) resolve(true) }).catch(err => { - this.ERR(this.callsign + " activate error: " + err) + this.ERR(this.callsign + " activate error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error in Thunder controller warehouseApi activate "+JSON.stringify(err), false, null) reject(err) }); @@ -54,10 +55,10 @@ export default class Warehouse { deactivate() { return new Promise((resolve, reject) => { this.thunder.call('Controller', 'deactivate', { callsign: this.callsign }).then(result => { - this.INFO(this.callsign + " deactivate result:" + result) + this.INFO(this.callsign + " deactivate result:" + JSON.stringify(result)) resolve(true) }).catch(err => { - this.ERR(this.callsign + " deactivate error: " + err) + this.ERR(this.callsign + " deactivate error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error in Thunder controller warehouseApi deactivate "+JSON.stringify(err), false, null) reject(err) }); @@ -67,11 +68,11 @@ export default class Warehouse { executeHardwareTest() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'executeHardwareTest').then(result => { - this.INFO(this.callsign + " executeHardwareTest result: " + result) + this.INFO(this.callsign + " executeHardwareTest result: " + JSON.stringify(result)) if (result.success) resolve(result.success) reject(false) }).catch(err => { - this.ERR(this.callsign + " executeHardwareTest error: " + err) + this.ERR(this.callsign + " executeHardwareTest error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error while Thunder warehouseApi executeHardwareTest "+JSON.stringify(err), false, null) reject(err) }) @@ -81,11 +82,11 @@ export default class Warehouse { internalReset(passPhrase = "FOR TEST PURPOSES ONLY") { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'internalReset', {passPhrase: passPhrase}).then(result => { - this.INFO(this.callsign + " internalReset result: " + result) + this.INFO(this.callsign + " internalReset result: " + JSON.stringify(result)) if (result.success) resolve(result.success) reject(false) }).catch(err => { - this.ERR(this.callsign + " internalReset error: " + err) + this.ERR(this.callsign + " internalReset error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error while Thunder warehouseApi internalReset "+JSON.stringify(err), false, null) reject(err) }) @@ -95,11 +96,11 @@ export default class Warehouse { isClean() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'isClean').then(result => { - this.INFO(this.callsign + " isClean result: " + result) + this.INFO(this.callsign + " isClean result: " + JSON.stringify(result)) if (result.success) resolve(result) reject(false) }).catch(err => { - this.ERR(this.callsign + " isClean error: " + err) + this.ERR(this.callsign + " isClean error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error while Thunder warehouseApi isClean "+JSON.stringify(err), false, null) reject(err) }) @@ -109,11 +110,11 @@ export default class Warehouse { lightReset() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'lightReset').then(result => { - this.INFO(this.callsign + " lightReset result: " + result) - if (result.success)resolve(result.success) - reject(false) + this.INFO(this.callsign + " lightReset result: " + JSON.stringify(result)) + if (result.success){resolve(result.success)} + else{reject(false)} }).catch(err => { - this.ERR(this.callsign + " lightReset error: " + err) + this.ERR(this.callsign + " lightReset error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error while Thunder warehouseApi lightReset "+JSON.stringify(err), false, null) reject(err) }) @@ -125,11 +126,11 @@ export default class Warehouse { let params = { resetType: resetType, suppressReboot: suppressReboot} this.INFO(this.callsign + " resetDevice params: " + JSON.stringify(params)); this.thunder.call(this.callsign, 'resetDevice', params).then(result => { - this.INFO(this.callsign + " resetDevice result: " + result) + this.INFO(this.callsign + " resetDevice result: " + JSON.stringify(result)) if (result.success)resolve(result.success) reject(false) }).catch(err => { - this.ERR(this.callsign + " resetDevice error: " + err) + this.ERR(this.callsign + " resetDevice error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error while Thunder warehouseApi resetDevice "+JSON.stringify(err), false, null) reject(err) }) @@ -139,11 +140,11 @@ export default class Warehouse { setFrontPanelState(state = -1) { // -1 (NONE), 1 (DOWNLOAD IN PROGRESS), 3 (DOWNLOAD FAILED) return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'setFrontPanelState', {state: state}).then(result => { - this.INFO(this.callsign + " setFrontPanelState result: " + result) + this.INFO(this.callsign + " setFrontPanelState result: " + JSON.stringify(result)) if (result.success)resolve(result.success) reject(false) }).catch(err => { - this.ERR(this.callsign + " setFrontPanelState error: " + err) + this.ERR(this.callsign + " setFrontPanelState error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"WarehouseApiError", "Error while Thunder warehouseApi setFrontPanelState "+JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/WifiApi.js b/accelerator-home-ui/src/api/WifiApi.js index bf9d1cf..0d4d344 100644 --- a/accelerator-home-ui/src/api/WifiApi.js +++ b/accelerator-home-ui/src/api/WifiApi.js @@ -89,6 +89,7 @@ export default class Wifi { this.INFO = console.info; this.LOG = console.log; this.ERR = console.error; + this.WARN = console.warn; } static get() { @@ -102,11 +103,11 @@ export default class Wifi { activate() { return new Promise((resolve, reject) => { - this.LOG(this.callsign + " activate") + this.LOG(this.callsign + " activate"); this.thunder.call('Controller', 'activate', { callsign: this.callsign }).then(result => { resolve(result) }).catch(err => { - this.ERR(this.callsign + " activate error: " + err) + this.ERR(this.callsign + " activate error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder Controller wifi activate" + JSON.stringify(err), false, null) reject(err) }) @@ -115,11 +116,11 @@ export default class Wifi { deactivate() { return new Promise((resolve, reject) => { - this.LOG(this.callsign + " deactivate") + this.LOG(this.callsign + " deactivate"); this.thunder.call('Controller', 'deactivate', { callsign: this.callsign }).then(result => { resolve(result) }).catch(err => { - this.ERR(this.callsign + " deactivate error: " + err) + this.ERR(this.callsign + " deactivate error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder Controller wifi deactivate" +JSON.stringify(err), false, null) reject(err) }) @@ -128,7 +129,7 @@ export default class Wifi { cancelWPSPairing() { return new Promise((resolve, reject) => { - this.LOG(this.callsign + " cancelWPSPairing") + this.LOG(this.callsign + " cancelWPSPairing"); this.thunder.call(this.callsign, 'cancelWPSPairing').then(result => { resolve(result) }).catch(err => { @@ -141,7 +142,7 @@ export default class Wifi { clearSSID() { return new Promise((resolve, reject) => { - this.LOG(this.callsign + " clearSSID") + this.LOG(this.callsign + " clearSSID"); this.thunder.call(this.callsign, 'clearSSID').then(result => { resolve(result) }).catch(err => { @@ -160,7 +161,7 @@ export default class Wifi { if (passphrase.length) params.passphrase = passphrase } return new Promise((resolve, reject) => { - this.LOG(this.callsign + " connect with params: " + JSON.stringify(params)) + this.LOG(this.callsign + " connect with params: " + JSON.stringify(params)); this.thunder.call(this.callsign, 'connect', params).then(result => { result.success ? resolve(result.success) : reject(result.success) @@ -174,7 +175,7 @@ export default class Wifi { disconnect() { return new Promise((resolve, reject) => { - this.LOG(this.callsign + " disconnect") + this.LOG(this.callsign + " disconnect"); this.thunder.call(this.callsign, 'disconnect').then(result => { resolve(result) }).catch(err => { @@ -191,7 +192,7 @@ export default class Wifi { this.LOG(this.callsign + " getConnectedSSID result:" + "Error in Thunder wifi connect params"+JSON.stringify(result)) resolve(result) }).catch(err => { - this.ERR(this.callsign + " getConnectedSSID error: " + err) + this.ERR(this.callsign + " getConnectedSSID error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi getConnectedSSID "+JSON.stringify(err), false, null) reject(err) }) @@ -201,10 +202,10 @@ export default class Wifi { getCurrentState() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'getCurrentState').then(result => { - this.LOG(this.callsign + " getCurrentState result:" + result) + this.LOG(this.callsign + " getCurrentState result:" + JSON.stringify(result)) resolve(result.success ? result.state : 0) // 0 is UNINSTALLED }).catch(err => { - this.ERR(this.callsign + " getCurrentState error: " + err) + this.ERR(this.callsign + " getCurrentState error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi getCurrentState "+JSON.stringify(err), false, null) reject(err) }) @@ -214,11 +215,11 @@ export default class Wifi { getPairedSSID() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'getPairedSSID').then(result => { - this.LOG(this.callsign + " getPairedSSID result:" + result) + this.LOG(this.callsign + " getPairedSSID result:" + JSON.stringify(result)) if (result.success) resolve(result.ssid) reject(result) }).catch(err => { - this.ERR(this.callsign + " getPairedSSID error: " + err) + this.ERR(this.callsign + " getPairedSSID error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi getPairedSSID "+JSON.stringify(err), false, null) reject(err) }) @@ -228,11 +229,11 @@ export default class Wifi { getPairedSSIDInfo() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'getPairedSSIDInfo').then(result => { - this.LOG(this.callsign + " getPairedSSIDInfo result:" + result) + this.LOG(this.callsign + " getPairedSSIDInfo result:" + JSON.stringify(result)) if (result.success) resolve(result) reject(result) }).catch(err => { - this.ERR(this.callsign + " getPairedSSIDInfo error: " + err) + this.ERR(this.callsign + " getPairedSSIDInfo error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi getPairedSSIDInfo "+JSON.stringify(err), false, null) reject(err) }) @@ -242,10 +243,10 @@ export default class Wifi { getSupportedSecurityModes() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'getSupportedSecurityModes').then(result => { - this.LOG(this.callsign + " getSupportedSecurityModes result:" + result) + this.LOG(this.callsign + " getSupportedSecurityModes result:" + JSON.stringify(result)) resolve(result) }).catch(err => { - this.ERR(this.callsign + " getSupportedSecurityModes error: " + err) + this.ERR(this.callsign + " getSupportedSecurityModes error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi getSupportedSecurityModes "+JSON.stringify(err), false, null) reject(err) }) @@ -259,10 +260,10 @@ export default class Wifi { params.wps_pin = wps_pin } this.thunder.call(this.callsign, 'initiateWPSPairing', params).then(result => { - this.LOG(this.callsign + " initiateWPSPairing result:" + result) + this.LOG(this.callsign + " initiateWPSPairing result:" + JSON.stringify(result)) resolve(result) }).catch(err => { - this.ERR(this.callsign + " initiateWPSPairing error: " + err) + this.ERR(this.callsign + " initiateWPSPairing error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi initiateWPSPairing "+JSON.stringify(err), false, null) reject(err) }) @@ -272,11 +273,11 @@ export default class Wifi { isPaired() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'isPaired').then(result => { - this.LOG(this.callsign + " isPaired result:" + result) + this.LOG(this.callsign + " isPaired result:" + JSON.stringify(result)) if (result.success) resolve(result.result) reject(result) }).catch(err => { - this.ERR(this.callsign + " isPaired error: " + err) + this.ERR(this.callsign + " isPaired error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi isPaired "+JSON.stringify(err), false, null) reject(err) }) @@ -286,10 +287,10 @@ export default class Wifi { isSignalThresholdChangeEnabled() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'isSignalThresholdChangeEnabled').then(result => { - this.LOG(this.callsign + " isSignalThresholdChangeEnabled result:" + result) + this.LOG(this.callsign + " isSignalThresholdChangeEnabled result:" + JSON.stringify(result)) resolve(result) }).catch(err => { - this.ERR(this.callsign + " isSignalThresholdChangeEnabled error: " + err) + this.ERR(this.callsign + " isSignalThresholdChangeEnabled error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi isSignalThresholdChangeEnabled "+JSON.stringify(err), false, null) reject(err) }) @@ -303,10 +304,10 @@ export default class Wifi { passphrase: passphrase, securityMode: securityMode }).then(result => { - this.LOG(this.callsign + " saveSSID result:" + result) + this.LOG(this.callsign + " saveSSID result:" + JSON.stringify(result)) resolve(result) }).catch(err => { - this.ERR(this.callsign + " saveSSID error: " + err) + this.ERR(this.callsign + " saveSSID error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi saveSSID "+JSON.stringify(err), false, null) reject(err) }) @@ -316,10 +317,10 @@ export default class Wifi { setEnabled(enable = true) { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'setEnabled', { enable: enable }).then(result => { - this.LOG(this.callsign + " setEnabled result:" + result) + this.LOG(this.callsign + " setEnabled result:" + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + " setEnabled error: " + err) + this.ERR(this.callsign + " setEnabled error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi setEnabled "+JSON.stringify(err), false, null) reject(err) }) @@ -329,10 +330,10 @@ export default class Wifi { setSignalThresholdChangeEnabled(enabled = true, interval = 2000) { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'setSignalThresholdChangeEnabled', { enabled: enabled, interval: interval }).then(result => { - this.LOG(this.callsign + " setSignalThresholdChangeEnabled result:" + result) + this.LOG(this.callsign + " setSignalThresholdChangeEnabled result:" + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + " setSignalThresholdChangeEnabled error: " + err) + this.ERR(this.callsign + " setSignalThresholdChangeEnabled error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi setSignalThresholdChangeEnabled "+JSON.stringify(err), false, null) reject(err) }) @@ -344,12 +345,12 @@ export default class Wifi { let params = { incremental: incremental } if (ssid.length) params.ssid = ssid if (frequency.length) params.frequency = frequency - this.LOG(this.callsign + " startScan params:" + params) + this.LOG(this.callsign + " startScan params:" + JSON.stringify(params)) this.thunder.call(this.callsign, 'startScan', params).then(result => { - this.LOG(this.callsign + " startScan result:" + result) + this.LOG(this.callsign + " startScan result:" + JSON.stringify(result)) resolve(result) }).catch(err => { - this.ERR(this.callsign + " startScan error: " + err) + this.ERR(this.callsign + " startScan error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi startScan "+JSON.stringify(err), false, null) reject(err) }) @@ -359,10 +360,10 @@ export default class Wifi { stopScan() { return new Promise((resolve, reject) => { this.thunder.call(this.callsign, 'stopScan').then(result => { - this.LOG(this.callsign + " stopScan result:" + result) + this.LOG(this.callsign + " stopScan result:" + JSON.stringify(result)) resolve(result.success) }).catch(err => { - this.ERR(this.callsign + " stopScan error: " + err) + this.ERR(this.callsign + " stopScan error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.NETWORK,"WifiApiError", "Error in Thunder wifi stopScan "+JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/XcastApi.js b/accelerator-home-ui/src/api/XcastApi.js index 20dddce..5ce16a6 100644 --- a/accelerator-home-ui/src/api/XcastApi.js +++ b/accelerator-home-ui/src/api/XcastApi.js @@ -27,7 +27,11 @@ import { Metrics } from '@firebolt-js/sdk'; export default class XcastApi { constructor() { this._thunder = ThunderJS(CONFIG.thunderConfig); - console.log('Xcast constructor'); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + this.LOG("Xcast constructor"); this._events = new Map(); } @@ -40,55 +44,55 @@ export default class XcastApi { this._thunder .call('Controller', 'activate', { callsign: this.callsign }) .then(result => { - console.log('Xcast activation success ' + result); + this.LOG("Xcast activation success " + JSON.stringify(result)); this._thunder .call('org.rdk.Xcast', 'setEnabled', { enabled: true }) .then(result => { if (result.success) { - console.log('Xcast enabled'); + this.LOG("Xcast enabled"); this._thunder.on(this.callsign, 'onApplicationLaunchRequest', notification => { - console.log('onApplicationLaunchRequest ' + JSON.stringify(notification)); + this.LOG("onApplicationLaunchRequest " + JSON.stringify(notification)); if (this._events.has('onApplicationLaunchRequest')) { this._events.get('onApplicationLaunchRequest')(notification); } }); this._thunder.on(this.callsign, 'onApplicationHideRequest', notification => { - console.log('onApplicationHideRequest ' + JSON.stringify(notification)); + this.LOG("onApplicationHideRequest " + JSON.stringify(notification)); if (this._events.has('onApplicationHideRequest')) { this._events.get('onApplicationHideRequest')(notification); } }); this._thunder.on(this.callsign, 'onApplicationResumeRequest', notification => { - console.log('onApplicationResumeRequest ' + JSON.stringify(notification)); + this.LOG("onApplicationResumeRequest " + JSON.stringify(notification)); if (this._events.has('onApplicationResumeRequest')) { this._events.get('onApplicationResumeRequest')(notification); } }); this._thunder.on(this.callsign, 'onApplicationStopRequest', notification => { - console.log('onApplicationStopRequest ' + JSON.stringify(notification)); + this.LOG("onApplicationStopRequest " + JSON.stringify(notification)); if (this._events.has('onApplicationStopRequest')) { this._events.get('onApplicationStopRequest')(notification); } }); this._thunder.on(this.callsign, 'onApplicationStateRequest', notification => { - // console.log('onApplicationStateRequest ' + JSON.stringify(notification)); + // this.LOG("onApplicationStateRequest " + JSON.stringify(notification)); if (this._events.has('onApplicationStateRequest')) { this._events.get('onApplicationStateRequest')(notification); } }); resolve(true); } else { - console.log('Xcast enabled failed'); + this.LOG("Xcast enabled failed"); } }) .catch(err => { - console.error('Enabling failure', err); + this.ERR("Enabling failure: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error in Thunder Xcast enable " + JSON.stringify(err), false, null) reject('Xcast enabling failed', err); }); }) .catch(err => { - console.error('Activation failure', err); + this.ERR("Activation failure: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error in Thunder Controller Xcast activate "+JSON.stringify(err), false, null) reject('Xcast activation failed', err); }); @@ -102,7 +106,7 @@ export default class XcastApi { resolve(res) }) .catch(err => { - console.log('Xdial error', err) + this.ERR("Xdial error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error while fetching Thunder Xcast enable status"+JSON.stringify(err), false, null) reject(err) }) @@ -115,7 +119,7 @@ export default class XcastApi { resolve(res) }) .catch(err => { - console.log('Xdial getFriendlyName error', err); + this.ERR("Xdial getFriendlyName error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error while getting Thunder Xcast FriendlyName "+JSON.stringify(err), false, null) reject(err) }) @@ -128,7 +132,7 @@ export default class XcastApi { resolve(res) }) .catch(err => { - console.log('Xdial setStandbyBehavior error', err) + this.ERR("Xdial setStandbyBehavior error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error while fetching Thunder setStandbyBehavior status"+JSON.stringify(err), false, null) reject(err) }) @@ -137,18 +141,18 @@ export default class XcastApi { setFriendlyName(name) { return new Promise((resolve) => { this._thunder.call('org.rdk.Xcast', 'setFriendlyName', { friendlyname: name }).then(result => { - console.log("Xcast setFriendlyName: " + name + " result: ", JSON.stringify(result)) + this.LOG("Xcast setFriendlyName: " + name + " result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - console.error(err); resolve(false); + this.ERR(JSON.stringify(err)); resolve(false); Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error while setting Thunder Xcast FriendlyName "+JSON.stringify(err), false, null) }); }).then(val => { - console.log("The resolved value is:", val); + this.LOG("The resolved value is: " + JSON.stringify(val)); }) .catch(error => { - Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "An error occurred: "+JSON.stringify(err), false, null) - console.error("An error occurred:", error); + Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "An error occurred: "+JSON.stringify(error), false, null) + this.ERR("An error occurred: " + JSON.stringify(error)); }); } /** @@ -172,7 +176,7 @@ export default class XcastApi { }) .catch(err => { Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error while setting Thunder Xcast enable "+JSON.stringify(err), false, null) - console.log('Failed to close Xcast', err) + this.ERR("Failed to close Xcast: " + JSON.stringify(err)) }) }) } @@ -183,23 +187,23 @@ export default class XcastApi { onApplicationStateChanged(params) { return new Promise((resolve) => { this._thunder.call('org.rdk.Xcast.1', 'onApplicationStateChanged', params).then(result => { - //console.log("XCastAPI onApplicationStateChanged Updating: "+ JSON.stringify(params) +" result: ",JSON.stringify(result)) + //this.LOG("XCastAPI onApplicationStateChanged Updating: " + JSON.stringify(params) + " result: " + JSON.stringify(result)) resolve(result); }).catch(err => { - console.error(err); resolve(false); + this.ERR(JSON.stringify(err)); resolve(false); Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error in Thunder Xcast.1 onApplicationStateChange "+JSON.stringify(err), false, null) }); }); } registerApplications(params){ - console.log("Register Apllication Params"+ JSON.stringify(params)) + this.LOG("Register Apllication Params" + JSON.stringify(params)) return new Promise((resolve,reject) => { this._thunder.call('org.rdk.Xcast', 'registerApplications',params ) .then(res => { resolve(res) }) .catch(err => { - console.error('Xdial registerApplications error', err); + this.ERR("Xdial registerApplications error: " + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER,"XcastApiError", "Error while getting Thunder Xcast registerApplications "+JSON.stringify(err), false, null) reject(err) }) diff --git a/accelerator-home-ui/src/api/firebolt/FBTDeviceInfo.js b/accelerator-home-ui/src/api/firebolt/FBTDeviceInfo.js index c523907..e24bc8a 100644 --- a/accelerator-home-ui/src/api/firebolt/FBTDeviceInfo.js +++ b/accelerator-home-ui/src/api/firebolt/FBTDeviceInfo.js @@ -20,241 +20,262 @@ import { Device, Metrics } from '@firebolt-js/sdk' export default class FBTDeviceInfo { - + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + getaudio(){ - return new Promise((resolve,reject)=>{ + return new Promise((resolve,reject)=>{ Device.audio() .then(supportedAudioProfiles => { - console.log(supportedAudioProfiles) + this.LOG("supportedAudioProfiles: " + JSON.stringify(supportedAudioProfiles)) resolve(supportedAudioProfiles) }) .catch(err => { - console.error('firebolt getaudio error', err) + this.ERR("firebolt getaudio error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get audio error "+err, false, null) reject(err) - }) - })} + }) + }) + } getdistributor(){ - return new Promise((resolve,reject)=>{ + return new Promise((resolve,reject)=>{ Device.distributor() .then(distributorId => { - console.log(distributorId) + this.LOG("distributorId: " + JSON.stringify(distributorId)) resolve(distributorId) }) .catch(err => { - console.error('firebolt getdistributor error', err) + this.ERR("firebolt getdistributor error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get distributor error "+err, false, null) reject(err) - }) - })} + }) + }) + } gethdcp(){ - return new Promise((resolve,reject)=>{ + return new Promise((resolve,reject)=>{ Device.hdcp() .then(supportedHdcpProfiles => { - console.log(supportedHdcpProfiles) + this.LOG("supportedHdcpProfiles: " + JSON.stringify(supportedHdcpProfiles)) resolve(supportedHdcpProfiles) }) .catch(err => { - console.error('firebolt gethdcp error', err) + this.ERR("firebolt gethdcp error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get hdcp error " + err, false, null) reject(err) - }) - })} + }) + }) + } gethdr(){ - return new Promise((resolve,reject)=>{ + return new Promise((resolve,reject)=>{ Device.hdr() .then(supportedHdrProfiles => { - console.log(supportedHdrProfiles) + this.LOG("supportedHdrProfiles: " + JSON.stringify(supportedHdrProfiles)) resolve(supportedHdrProfiles) }) .catch(err => { - console.error('firebolt gethdr error', err) + this.ERR("firebolt gethdr error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get hdr error "+err, false, null) reject(err) - }) - })} + }) + }) + } getid(){ return new Promise((resolve,reject)=>{ Device.id() .then(id => { - console.log(id) + this.LOG("id: " + JSON.stringify(id)) resolve(id) }) .catch(err => { - console.error('firebolt getid error', err) + this.ERR("firebolt getid error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get Id error "+err, false, null) reject(err) - }) - })} + }) + }) + } getmake(){ return new Promise((resolve,reject)=>{ Device.make() .then(make => { - console.log(make) + this.LOG("make: " + JSON.stringify(make)) resolve(make) }) .catch(err => { - console.error('firebolt getmake error', err) + this.ERR("firebolt getmake error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get make error "+err, false, null) reject(err) - }) - })} + }) + }) + } getmodel(){ return new Promise((resolve,reject)=>{ Device.model() .then(model => { - console.log(model) + this.LOG("model: " + JSON.stringify(model)) resolve(model) }) .catch(err => { - console.error('firebolt getmodel error', err) + this.ERR("firebolt getmodel error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get model error " +err, false, null) reject(err) - }) - })} - + }) + }) + } getname(){ return new Promise((resolve,reject)=>{ Device.name() .then(value => { - console.log(value) + this.LOG("name: " + JSON.stringify(value)) resolve(value) }) .catch(err => { - console.error('firebolt getname error', err) + this.ERR("firebolt getname error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get name error "+err, false, null) reject(err) - }) - })} + }) + }) + } getnetwork(){ return new Promise((resolve,reject)=>{ Device.network() .then(networkInfo => { - console.log(networkInfo) + this.LOG("networkInfo: " + JSON.stringify(networkInfo)) resolve(networkInfo) }) .catch(err => { - console.error('firebolt getnetwork error', err) + this.ERR("firebolt getnetwork error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get network error "+err, false, null) reject(err) - }) - })} + }) + }) + } getplatform(){ return new Promise((resolve,reject)=>{ Device.platform() .then(platformId => { - console.log(platformId) + this.LOG("platformId: " + JSON.stringify(platformId)) resolve(platformId) }) .catch(err => { - console.error('firebolt getplatform error', err) + this.ERR("firebolt getplatform error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get platform error " +err, false, null) reject(err) - }) - })} + }) + }) + } getscreenresolution(){ return new Promise((resolve,reject)=>{ Device.screenResolution() .then(screenResolution => { - console.log(screenResolution) + this.LOG("screenResolution: " + JSON.stringify(screenResolution)) resolve(screenResolution) }) .catch(err => { - console.error('firebolt getscreenresolution error', err) + this.ERR("firebolt getscreenresolution error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get screen resolution error " +err, false, null) reject(err) - }) - })} + }) + }) + } getsku(){ return new Promise((resolve,reject)=>{ Device.sku() .then(sku => { - console.log(sku) + this.LOG("sku: " + JSON.stringify(sku)) resolve(sku) }) .catch(err => { - console.error('firebolt getsku error', err) + this.ERR("firebolt getsku error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get sku error "+err, false, null) reject(err) - }) - })} + }) + }) + } gettype(){ return new Promise((resolve,reject)=>{ Device.type() .then(deviceType => { - console.log(deviceType) + this.LOG("deviceType: " + JSON.stringify(deviceType)) resolve(deviceType) }) .catch(err => { - console.error('firebolt gettype error', err) + this.ERR("firebolt gettype error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get type error "+err, false, null) reject(err) - }) - })} + }) + }) + } getuid(){ return new Promise((resolve,reject)=>{ Device.uid() .then(uniqueId => { - console.log(uniqueId) + this.LOG("uniqueId: " + JSON.stringify(uniqueId)) resolve(uniqueId) }) .catch(err => { - console.error('firebolt getuid error', err) + this.ERR("firebolt getuid error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get uid error"+err, false, null) reject(err) - }) - })} + }) + }) + } getversion(){ return new Promise((resolve,reject)=>{ Device.version() .then(versions => { - console.log(versions) + this.LOG("versions: " + JSON.stringify(versions)) resolve(versions) }) .catch(err => { - console.error('firebolt getversion error', err) + this.ERR("firebolt getversion error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginErrorr", "firebolt get version error "+err, false, null) reject(err) - }) - })} + }) + }) + } getvideoresolution(){ return new Promise((resolve,reject)=>{ Device.videoResolution() .then(videoResolution => { - console.log(videoResolution) + this.LOG("videoResolution: " + JSON.stringify(videoResolution)) resolve(videoResolution) }) .catch(err => { - console.error('firebolt getvideoresolution error', err) + this.ERR("firebolt getvideoresolution error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt get video resolution error "+err, false, null) reject(err) - }) - })} - + }) + }) + } listen(event){ - return new Promise((resolve,reject)=>{ - Device.listen(event, value => { - console.log(value) - resolve(value) + return new Promise((resolve,reject)=>{ + Device.listen(event, value => { + this.LOG("listen value: " + JSON.stringify(value)) + resolve(value) }) - .catch(err => { - console.error('firebolt listen error', err) - Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt listen error "+err, false, null) - reject(err) + .catch(err => { + this.ERR("firebolt listen error: " + JSON.stringify(err)) + Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt listen error "+err, false, null) + reject(err) + }) }) - })} + } once(event){ return new Promise((resolve,reject)=>{ Device.once(event, value => { - console.log(value) + this.LOG("once value: " + JSON.stringify(value)) resolve(value) - }) + }) .catch(err => { - console.error('firebolt listen error', err) + this.ERR("firebolt once error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "FireboltDevicePluginError", "firebolt once error "+err, false, null) reject(err) - }) - })} - + }) + }) + } } \ No newline at end of file diff --git a/accelerator-home-ui/src/api/firebolt/FBTDiscovery.js b/accelerator-home-ui/src/api/firebolt/FBTDiscovery.js index 95f4551..ab11b1a 100644 --- a/accelerator-home-ui/src/api/firebolt/FBTDiscovery.js +++ b/accelerator-home-ui/src/api/firebolt/FBTDiscovery.js @@ -18,17 +18,24 @@ **/ import { Discovery, Metrics } from '@firebolt-js/sdk' export default class FBTDiscovery { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } launch(appId,intent){ return new Promise((resolve,reject)=>{ Discovery.launch(appId, intent).then(success => { - console.log( "Discovery.launch result:"+success) + this.LOG("Discovery.launch result:" + JSON.stringify(success)) resolve(success); }) .catch(err => { - console.error('firebolt Discovery.launch error', err) + this.ERR("firebolt Discovery.launch error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "fireboltDiscoveryError", "Discovery.launch error"+ err, false, null) reject(err) }) - })} + }) + } } \ No newline at end of file diff --git a/accelerator-home-ui/src/api/firebolt/FBTLifecycle.js b/accelerator-home-ui/src/api/firebolt/FBTLifecycle.js index 2f7ec99..ccd20ee 100644 --- a/accelerator-home-ui/src/api/firebolt/FBTLifecycle.js +++ b/accelerator-home-ui/src/api/firebolt/FBTLifecycle.js @@ -22,32 +22,36 @@ import { Lifecycle, Metrics } from '@firebolt-js/sdk' export default class FBTLifecycle { constructor() { this._events = new Map(); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; Lifecycle.listen('background', value => { - console.log('Fireboltapi background ' + JSON.stringify(value)); + this.LOG("Fireboltapi background " + JSON.stringify(value)); if (this._events.has('background')) { this._events.get('background')(value) } }) Lifecycle.listen('foreground', value => { - console.log('Fireboltapi foreground ' + JSON.stringify(value)); + this.LOG("Fireboltapi foreground " + JSON.stringify(value)); if (this._events.has('foreground')) { this._events.get('foreground')(value) } }) Lifecycle.listen('inactive', value => { - console.log('Fireboltapi inactive ' + JSON.stringify(value)); + this.LOG("Fireboltapi inactive " + JSON.stringify(value)); if (this._events.has('inactive')) { this._events.get('inactive')(value) } }) Lifecycle.listen('suspended', value => { - console.log('Fireboltapi suspended ' + JSON.stringify(value)); + this.LOG("Fireboltapi suspended " + JSON.stringify(value)); if (this._events.has('suspended')) { this._events.get('suspended')(value) } }) Lifecycle.listen('unloading', value => { - console.log('Fireboltapi unloading ' + JSON.stringify(value)); + this.LOG("Fireboltapi unloading " + JSON.stringify(value)); if (this._events.has('unloading')) { this._events.get('unloading')(value) } @@ -62,11 +66,11 @@ export default class FBTLifecycle { return new Promise((resolve, reject) => { Lifecycle.close("remoteButton") .then(success => { - console.log(success) + this.LOG("Fireboltapi close success: " + JSON.stringify(success)) resolve(success) }) .catch(err => { - console.error('firebolt Lifecycle.close error', err) + this.ERR("firebolt Lifecycle.close error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LifecycleError", err, false, null) reject(err) }) @@ -76,11 +80,11 @@ export default class FBTLifecycle { return new Promise((resolve, reject) => { Lifecycle.finished() .then(results => { - console.log(results) + this.LOG("Fireboltapi finished results: " + JSON.stringify(results)) resolve(results) }) .catch(err => { - console.error('firebolt Lifecycle.finished error', err) + this.ERR("firebolt Lifecycle.finished error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LifecycleError", err, false, null) reject(err) }) @@ -90,13 +94,11 @@ export default class FBTLifecycle { return new Promise((resolve, reject) => { Lifecycle.ready() .then(result => { - console.log("getting result") - console.log(result) + this.LOG("Fireboltapi ready result: " + JSON.stringify(result)) resolve(result) - }) .catch(err => { - console.error('firebolt Lifecycle.ready error', err) + this.ERR("firebolt Lifecycle.ready error: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LifecycleError", err, false, null) reject(err) }) @@ -105,7 +107,7 @@ export default class FBTLifecycle { state() { return new Promise((resolve) => { const state = Lifecycle.state() - console.log(state) + this.LOG("Fireboltapi state: " + JSON.stringify(state)) resolve(state) }) } diff --git a/accelerator-home-ui/src/api/firebolt/FBTLocalization.js b/accelerator-home-ui/src/api/firebolt/FBTLocalization.js index 3288faa..8bf1a83 100644 --- a/accelerator-home-ui/src/api/firebolt/FBTLocalization.js +++ b/accelerator-home-ui/src/api/firebolt/FBTLocalization.js @@ -21,14 +21,21 @@ import { Localization, Metrics } from '@firebolt-js/manage-sdk' export default class FBTLocalization { + constructor() { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + listen(event){ return new Promise((resolve,reject)=>{ Localization.listen(event, value => { - console.log("Firebolt listening to ",JSON.stringify(value)) + this.LOG("Firebolt listening to " + JSON.stringify(value)) resolve(value) }) .catch(err => { - console.error('firebolt listen error', err) + this.ERR('firebolt listen error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject(err) }) @@ -39,11 +46,11 @@ export default class FBTLocalization { return new Promise((resolve, reject) => { Localization.additionalInfo() .then(info => { - console.log(info) + this.LOG("AdditionalInfo: " + JSON.stringify(info)) resolve(info) }) .catch(err => { - console.error('firebolt Localization.additionalInfo error', err) + this.ERR('firebolt Localization.additionalInfo error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject(err) }) @@ -53,11 +60,11 @@ export default class FBTLocalization { return new Promise((resolve, reject) => { Localization.countryCode() .then(code => { - console.log(code) + this.LOG("CountryCode: " + JSON.stringify(code)) resolve(code) }) .catch(err => { - console.error('firebolt Localization.countryCode error', err) + this.ERR('firebolt Localization.countryCode error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject(err) }) @@ -67,10 +74,10 @@ export default class FBTLocalization { return new Promise((resolve, reject) => { Localization.locality() .then(locality => { - console.log(locality) + this.LOG("Locality: " + JSON.stringify(locality)) }) .catch(err => { - console.error('firebolt Localization.locality error', err) + this.ERR('firebolt Localization.locality error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject(err) }) @@ -80,11 +87,11 @@ export default class FBTLocalization { return new Promise((resolve, reject) => { Localization.latlon() .then(latlong => { - console.log(latlong) + this.LOG("LatLon: " + JSON.stringify(latlong)) resolve(latlong) }) .catch(err => { - console.error('firebolt Localization.latlon error', err) + this.ERR('firebolt Localization.latlon error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject(err) }) @@ -95,11 +102,11 @@ export default class FBTLocalization { return new Promise((resolve,reject)=>{ Localization.language() .then(lang => { - console.log('Localization.language :'+ lang) + this.LOG("Localization.language : " + JSON.stringify(lang)) resolve(lang) }) .catch(err => { - console.error('firebolt Localization.language error :', err) + this.ERR('firebolt Localization.language error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject (err) }) @@ -110,11 +117,11 @@ export default class FBTLocalization { return new Promise((resolve,reject)=>{ Localization.language(lang) .then(lang => { - console.log('Localization.language :'+ lang) + this.LOG("Localization.language : " + JSON.stringify(lang)) resolve(lang) }) .catch(err => { - console.error('firebolt Localization.language error :', err) + this.ERR('firebolt Localization.language error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject (err) }) @@ -126,11 +133,11 @@ export default class FBTLocalization { return new Promise((resolve,reject)=>{ Localization.timeZone(zone) .then(zone => { - console.log('set Localization.timeZone :'+ zone) + this.LOG("set Localization.timeZone : " + JSON.stringify(zone)) resolve(zone) }) .catch(err => { - console.error('firebolt set Localization.timeZone error :', err) + this.ERR('firebolt set Localization.timeZone error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject (err) }) @@ -141,11 +148,11 @@ export default class FBTLocalization { return new Promise((resolve,reject)=>{ Localization.timeZone() .then(zone => { - console.log('get Localization.timeZone :'+ zone) + this.LOG("get Localization.timeZone : " + JSON.stringify(zone)) resolve(zone) }) .catch(err => { - console.error('firebolt get Localization.timeZone error :', err) + this.ERR('firebolt get Localization.timeZone error: ' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "LocalizationError", err, false, null) reject (err) }) diff --git a/accelerator-home-ui/src/api/firebolt/provider/AcknowledgeScreen.js b/accelerator-home-ui/src/api/firebolt/provider/AcknowledgeScreen.js index bc63a84..d7b504d 100644 --- a/accelerator-home-ui/src/api/firebolt/provider/AcknowledgeScreen.js +++ b/accelerator-home-ui/src/api/firebolt/provider/AcknowledgeScreen.js @@ -21,13 +21,21 @@ import { CONFIG } from '../../../Config/Config' export default class AcknowledgeScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } set params(args) { - console.log("args:",args) + this.LOG("args: " + JSON.stringify(args)) if(args.message!=="") { this.tag('Info').text.text=Language.translate(args.message) diff --git a/accelerator-home-ui/src/api/firebolt/provider/KeyboardScreen.js b/accelerator-home-ui/src/api/firebolt/provider/KeyboardScreen.js index 7769173..cf55f1e 100644 --- a/accelerator-home-ui/src/api/firebolt/provider/KeyboardScreen.js +++ b/accelerator-home-ui/src/api/firebolt/provider/KeyboardScreen.js @@ -22,6 +22,14 @@ import { Keyboard } from '../../../ui-components/index' import { KEYBOARD_FORMATS } from '../../../ui-components/components/Keyboard' import PasswordSwitch from '../../../screens/PasswordSwitch'; export default class KeyboardScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + set params(args) { if (args.message !== "") { this.tag('Description').text.text = Language.translate(args.message) @@ -32,7 +40,7 @@ export default class KeyboardScreen extends Lightning.Component { if (args.type === 'password') { this.password = true this.hidePasswd = true; - console.log("Making the password switch visible") + this.LOG("Making the password switch visible") this.tag('PasswrdSwitch').patch({ visible: true }); @@ -244,7 +252,7 @@ export default class KeyboardScreen extends Lightning.Component { this.tag("InputText").text.text = this.hidePasswd ? this.textCollection['encrypted'] : this.textCollection['TextBox']; } else if (key === '#@!' || key === 'abc' || key === 'áöû' || key === 'shift') { - console.log('no saving') + this.LOG('no saving') } else { this.textCollection['TextBox'] += key diff --git a/accelerator-home-ui/src/api/firebolt/provider/PinChallengeProvider.js b/accelerator-home-ui/src/api/firebolt/provider/PinChallengeProvider.js index 0ff211d..632de61 100644 --- a/accelerator-home-ui/src/api/firebolt/provider/PinChallengeProvider.js +++ b/accelerator-home-ui/src/api/firebolt/provider/PinChallengeProvider.js @@ -25,9 +25,16 @@ let thunder = ThunderJS(CONFIG.thunderConfig) export default class PinChallengeProvider { + constructor(...args) { + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + challenge(challenge, session) { if (!challenge) return - console.log('Got challenge ' + JSON.stringify(challenge), "challenge") + this.LOG('Got challenge ' + JSON.stringify(challenge) + " challenge") return new Promise((resolve) => { this.showChallengeUi(challenge, resolve) @@ -36,7 +43,7 @@ export default class PinChallengeProvider { } showChallengeUi(challenge, responder) { - console.log("Displaying showChallengeUi with: " + GLOBALS.selfClientName) + this.LOG("Displaying showChallengeUi with: " + JSON.stringify(GLOBALS.selfClientName)) new Promise(async (resolve) => { let message = challenge.requestor.name + ' is requesting that you enter your ' + challenge.pinSpace + ' pin.' let params = { message: message, challenge: challenge, responder } diff --git a/accelerator-home-ui/src/api/firebolt/provider/SecurityPinScreen.js b/accelerator-home-ui/src/api/firebolt/provider/SecurityPinScreen.js index ce57c3d..277c977 100644 --- a/accelerator-home-ui/src/api/firebolt/provider/SecurityPinScreen.js +++ b/accelerator-home-ui/src/api/firebolt/provider/SecurityPinScreen.js @@ -23,8 +23,16 @@ import { KEYBOARD_FORMATS } from '../../../ui-components/components/Keyboard' import { CONSTANTS } from './constant'; import { PinChallenge } from '@firebolt-js/manage-sdk' export default class SecurityPinScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + set params(args) { - console.log("args:", args) + this.LOG("args: " + JSON.stringify(args)) if (args.message !== "") { this.tag('Description').text.text = Language.translate(args.message) } @@ -38,7 +46,7 @@ export default class SecurityPinScreen extends Lightning.Component { } handleDone() { - console.log("Inside handle done") + this.LOG("Inside handle done") this.onPinEntered(this.textCollection['TextBox']) } @@ -114,14 +122,14 @@ export default class SecurityPinScreen extends Lightning.Component { } onPinEntered(pin) { if (pin === CONSTANTS.PINS[this.challenge.pinSpace]) { - console.log("Correct pin") + this.LOG("Correct pin") this.responder({ granted: true, reason: PinChallenge.ResultReason.CORRECT_PIN }) Router.back() } else { - console.log("Wrong pin") + this.LOG("Wrong pin") this.numFailures++ if (this.numFailures >= CONSTANTS.MAX_FAILURES) { this.lockedTime = Date.now() diff --git a/accelerator-home-ui/src/items/AppCatalogItem.js b/accelerator-home-ui/src/items/AppCatalogItem.js index 730059d..70abe6b 100644 --- a/accelerator-home-ui/src/items/AppCatalogItem.js +++ b/accelerator-home-ui/src/items/AppCatalogItem.js @@ -24,6 +24,13 @@ import { installDACApp, getInstalledDACApps, fetchAppUrl } from '../api/DACApi' import LISAApi from '../api/LISAApi'; export default class AppCatalogItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { Shadow: { @@ -118,10 +125,10 @@ export default class AppCatalogItem extends Lightning.Component { updateStatus() { if (this._app.isRunning) { - this.tag('StatusProgress').setProgress(1.0, Language.translate('Running') + "!") + this.tag('StatusProgress').setProgress(1.0, Language.translate('Running') + "!"); } else { if (this._app.isInstalled) { - console.log("App is installed") + this.LOG("App is installed") this.tag('StatusProgress').setProgress(1.0, Language.translate('Installed') + '!') } else { this.tag('StatusProgress').reset() @@ -155,7 +162,7 @@ export default class AppCatalogItem extends Lightning.Component { return } if (this._app.isInstalled) { - console.log("App is already installed") + this.LOG("App is already installed") this.tag("Overlay").alpha = 0.7 this.tag("OverlayText").alpha = 1 this.tag("OverlayText").text.text = Language.translate('Already installed') + "!"; @@ -197,7 +204,7 @@ export default class AppCatalogItem extends Lightning.Component { this._app.size = this.data.size this._app.category = this.data.category this._app.url = await fetchAppUrl(this._app.id, this._app.version) - console.log("fetchAppUrl:", this._app.url) + this.LOG("fetchAppUrl: " + JSON.stringify(this._app.url)) } else { this._app.url = this.data.uri @@ -212,6 +219,6 @@ export default class AppCatalogItem extends Lightning.Component { this.myfireINSTALL() } else - console.error("App url undefined") + this.ERR("App url undefined") } } diff --git a/accelerator-home-ui/src/items/EnergySavingsItem.js b/accelerator-home-ui/src/items/EnergySavingsItem.js index ab13daf..23c7ef8 100644 --- a/accelerator-home-ui/src/items/EnergySavingsItem.js +++ b/accelerator-home-ui/src/items/EnergySavingsItem.js @@ -23,6 +23,14 @@ import AppApi from '../api/AppApi' export default class EnergySavingsItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.Tick = Utils.asset('/images/settings/Tick.png') } @@ -70,7 +78,7 @@ export default class EnergySavingsItem extends Lightning.Component { standbyMode = "LIGHT_SLEEP" } this.appApi.setPreferredStandbyMode(standbyMode).then(result => { - console.log("setPreferredStandbyMode " + JSON.stringify(result)) + this.LOG("setPreferredStandbyMode " + JSON.stringify(result)) self.fireAncestors("$resetPrevTickObject", self) this.fireAncestors("$updateStandbyMode", this._item) self.tag("Item.Tick").visible = true; diff --git a/accelerator-home-ui/src/items/ListItem.js b/accelerator-home-ui/src/items/ListItem.js index f7b4825..dc1d9e9 100644 --- a/accelerator-home-ui/src/items/ListItem.js +++ b/accelerator-home-ui/src/items/ListItem.js @@ -26,6 +26,14 @@ export default class ListItem extends Lightning.Component { /** * Function to render various elements in the main view item. */ + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Item: { @@ -66,7 +74,7 @@ export default class ListItem extends Lightning.Component { y: this.y - this.bar }) if(!this.data.url) { - console.log("data from app carousal: ", this.data); + this.LOG("data from app carousal: " + JSON.stringify(this.data)); } if (this.data.url.startsWith('/images')) { this.tag('Image').patch({ diff --git a/accelerator-home-ui/src/items/SubscriptionItem.js b/accelerator-home-ui/src/items/SubscriptionItem.js index b98ec2f..316ba5a 100644 --- a/accelerator-home-ui/src/items/SubscriptionItem.js +++ b/accelerator-home-ui/src/items/SubscriptionItem.js @@ -24,6 +24,14 @@ import { CONFIG } from '../Config/Config' */ let index = 0; export default class SubscriptionItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { SubscriptionItem: { @@ -157,14 +165,14 @@ export default class SubscriptionItem extends Lightning.Component { // this.handleDone() if (this._item.host["_@attribute"].toLowerCase() === "youtube") { let appApi = new AppApi() - console.log(this._item.url); + this.LOG("this._item.url: " + JSON.stringify(this._item.url)); let params = { url: this._item.url, launchLocation: "gracenote", appIdentifier: 'n:3' } appApi.launchApp("YouTube", params).catch((err) => { - console.log("Error in launching YouTube", JSON.stringify(err)) + this.ERR("Error in launching YouTube: " + JSON.stringify(err)) }); } } diff --git a/accelerator-home-ui/src/items/TimeItems.js b/accelerator-home-ui/src/items/TimeItems.js index cd136f7..2011821 100644 --- a/accelerator-home-ui/src/items/TimeItems.js +++ b/accelerator-home-ui/src/items/TimeItems.js @@ -26,6 +26,14 @@ import FireBoltApi from '../api/firebolt/FireBoltApi.js' */ export default class TimeItems extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -55,7 +63,7 @@ export default class TimeItems extends Lightning.Component { * Function to set contents for an item in settings screen. */ set params(item) { - console.log(item) + this.LOG("params: " + JSON.stringify(item)) this._item = item this.tag('List').h = Object.keys(item.time_region).length * 90 this.tag('List').items = Object.keys(item.time_region).map((ele, idx) => { @@ -76,7 +84,7 @@ export default class TimeItems extends Lightning.Component { _active() { if ("ResidentApp" !== GLOBALS.selfClientName){ FireBoltApi.get().localization.listen("timeZoneChanged",value =>{ - console.log('timezone changed successfully to ', JSON.stringify(value)) + this.LOG('timezone changed successfully to ' + JSON.stringify(value)) }) } } @@ -90,7 +98,7 @@ export default class TimeItems extends Lightning.Component { } _handleEnter() { - console.log(`${this._item.zone}/${this.tag('List').element._item[0]}`) + this.LOG(`${this._item.zone}/${this.tag('List').element._item[0]}`) this.widgets.menu.updateTimeZone(`${this._item.zone}/${this.tag('List').element._item[0]}`) if ("ResidentApp" === GLOBALS.selfClientName) { this.appApi.setZone(`${this._item.zone}/${this.tag('List').element._item[0]}`) diff --git a/accelerator-home-ui/src/items/TimeOverlayItems.js b/accelerator-home-ui/src/items/TimeOverlayItems.js index c79b400..d397fbe 100644 --- a/accelerator-home-ui/src/items/TimeOverlayItems.js +++ b/accelerator-home-ui/src/items/TimeOverlayItems.js @@ -26,6 +26,14 @@ import FireBoltApi from '../api/firebolt/FireBoltApi.js'; */ export default class TimeOverlayItems extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { TimeItemsContents: { @@ -46,22 +54,22 @@ import FireBoltApi from '../api/firebolt/FireBoltApi.js'; } } - /** - * Function refresh the list. - */ - refreshList(item) { - console.log("item from refreshList",item) - this._item = item - this.tag('List').items = Object.keys(item.time_region).map((ele, idx) => { - return { - ref: 'Time' + idx, - w: 1620, - h: 90, - type: TimeItem, - item: [ele, ele === item.isActive], - } - }) - } + /** + * Function refresh the list. + */ + refreshList(item) { + this.LOG("item from refreshList: " + JSON.stringify(item)) + this._item = item + this.tag('List').items = Object.keys(item.time_region).map((ele, idx) => { + return { + ref: 'Time' + idx, + w: 1620, + h: 90, + type: TimeItem, + item: [ele, ele === item.isActive], + } + }) + } _firstEnable() { this.appApi = new AppApi() @@ -70,7 +78,7 @@ import FireBoltApi from '../api/firebolt/FireBoltApi.js'; _init(){ if ("ResidentApp" !== GLOBALS.selfClientName){ FireBoltApi.get().localization.listen("timeZoneChanged",value =>{ - console.log('timezone changed successfully to ', JSON.stringify(value)) + this.LOG('timezone changed successfully to ' + JSON.stringify(value)) }) } } @@ -84,9 +92,9 @@ import FireBoltApi from '../api/firebolt/FireBoltApi.js'; this.tag('List').setPrevious() } - _handleEnter() { - console.log(`${this._item.zone}/${this.tag('List').element._item[0]}`) - this.fireAncestors("$updateTimeZone",`${this._item.zone}/${this.tag('List').element._item[0]}`) + _handleEnter() { + this.LOG(`${this._item.zone}/${this.tag('List').element._item[0]}`) + this.fireAncestors("$updateTimeZone",`${this._item.zone}/${this.tag('List').element._item[0]}`) // this.widgets.menu.updateTimeZone(`${this._item.zone}/${this.tag('List').element._item[0]}`) if ("ResidentApp" === GLOBALS.selfClientName) { this.appApi.setZone(`${this._item.zone}/${this.tag('List').element._item[0]}`) diff --git a/accelerator-home-ui/src/items/TimeZoneItem.js b/accelerator-home-ui/src/items/TimeZoneItem.js index d6cca83..bb86b8f 100644 --- a/accelerator-home-ui/src/items/TimeZoneItem.js +++ b/accelerator-home-ui/src/items/TimeZoneItem.js @@ -24,6 +24,14 @@ import { CONFIG } from '../Config/Config.js' */ export default class TimeZoneItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.Arrow = Utils.asset('/images/settings/Arrow.png') this.Tick = Utils.asset('/images/settings/Tick.png') @@ -85,7 +93,7 @@ export default class TimeZoneItem extends Lightning.Component { } _handleEnter() { - console.log('enter', this._item[1]) + this.LOG("enter: " + JSON.stringify(this._item[1])) Router.navigate('settings/advanced/device/timezone/item', { time_region: this._item[1], zone: this._item[0], isActive: this.zone }) } diff --git a/accelerator-home-ui/src/items/TimeZoneOverlayItem.js b/accelerator-home-ui/src/items/TimeZoneOverlayItem.js index 069de33..99f19fc 100644 --- a/accelerator-home-ui/src/items/TimeZoneOverlayItem.js +++ b/accelerator-home-ui/src/items/TimeZoneOverlayItem.js @@ -24,6 +24,14 @@ */ export default class TimeZoneOverlayItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.Arrow = Utils.asset('/images/settings/Arrow.png') this.Tick = Utils.asset('/images/settings/Tick.png') @@ -84,8 +92,8 @@ }) } - _handleEnter() { - console.log('enter', this._item[1]) + _handleEnter() { + this.LOG("enter: " + JSON.stringify(this._item[1])) this.fireAncestors("$navigateAndRefreshItems",{ time_region: this._item[1], zone: this._item[0], isActive: this.zone }); // Router.navigate('settings/advanced/device/timezone/item', { time_region: this._item[1], zone: this._item[0], isActive: this.zone }) } diff --git a/accelerator-home-ui/src/items/TvOverlayInputItem.js b/accelerator-home-ui/src/items/TvOverlayInputItem.js index 325a3c6..1dba4cd 100644 --- a/accelerator-home-ui/src/items/TvOverlayInputItem.js +++ b/accelerator-home-ui/src/items/TvOverlayInputItem.js @@ -22,6 +22,14 @@ import { CONFIG } from "../Config/Config"; import HDMIApi from "../api/HDMIApi"; export default class TvOverlayInputItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.Tick = Utils.asset("/images/settings/Tick.png"); } @@ -92,7 +100,7 @@ export default class TvOverlayInputItem extends Lightning.Component { } _init() { - console.log("_init from inputItem: list is getting rendered"); + this.LOG("_init from inputItem: list is getting rendered"); this.hdmiApi = new HDMIApi(); this.loadingAnimation = this.tag("Item.Loader").animation({ duration: 3, @@ -138,7 +146,7 @@ export default class TvOverlayInputItem extends Lightning.Component { this.hdmiApi .getHDMIDevices() //api does not throw error, just consider error condition when result is empty .then((res) => { - console.log("getHDMIDevices from input Item: ", JSON.stringify(res)); + this.LOG("getHDMIDevices from input Item: " + JSON.stringify(res)); if (res.length > 0) { res.map((item) => { if (item.id === this.uniqID.id) { @@ -147,7 +155,7 @@ export default class TvOverlayInputItem extends Lightning.Component { this.hdmiApi .setHDMIInput(item) .then(() => { - console.log("input set to: ", JSON.stringify(item)); + this.LOG("input set to: " + JSON.stringify(item)); //to stop the loader and show tickmark setTimeout(() => { this.loadingAnimation.stop(); @@ -157,10 +165,7 @@ export default class TvOverlayInputItem extends Lightning.Component { }, minLoaderDuration); }) .catch((err) => { - console.log( - "Failed to setHDMIInput", - JSON.stringify(err) - ); + this.ERR("Failed to setHDMIInput: " + JSON.stringify(err)); //to stop the loader setTimeout(() => { this.loadingAnimation.stop(); @@ -170,10 +175,7 @@ export default class TvOverlayInputItem extends Lightning.Component { //display the error in the notification }); } else { - console.log( - "device not connected! item: ", - JSON.stringify(item) - ); + this.LOG("device not connected! item: " + JSON.stringify(item)); setTimeout(() => { this.loadingAnimation.stop(); this.tag("Item.Loader").visible = false; @@ -181,16 +183,11 @@ export default class TvOverlayInputItem extends Lightning.Component { }, minLoaderDuration); } } else { - console.log( - "ID not match! uniqID: ", - JSON.stringify(this.uniqID), - " item: ", - JSON.stringify(item) - ); + this.LOG("ID not match! uniqID: " + JSON.stringify(this.uniqID) + " item: " + JSON.stringify(item)); } }); } else { - console.log("getHDMIDevices returned empty array"); //in case of error, getHDMIDevices api return empty array + this.LOG("getHDMIDevices returned empty array"); //in case of error, getHDMIDevices api return empty array setTimeout(() => { this.loadingAnimation.stop(); this.tag("Item.Loader").visible = false; @@ -198,7 +195,7 @@ export default class TvOverlayInputItem extends Lightning.Component { } }) .catch((err) => { - console.log("Failed to getHDMIDevices", JSON.stringify(err)); + this.ERR("Failed to getHDMIDevices: " + JSON.stringify(err)); //to stop the loader setTimeout(() => { this.loadingAnimation.stop(); @@ -206,7 +203,7 @@ export default class TvOverlayInputItem extends Lightning.Component { }, minLoaderDuration); }); } else { - console.log(Storage.get("_currentInputMode")); + this.LOG("Current input mode: " + JSON.stringify(Storage.get("_currentInputMode"))); } } diff --git a/accelerator-home-ui/src/items/TvOverlaySettingsItem.js b/accelerator-home-ui/src/items/TvOverlaySettingsItem.js index 3bdb5e7..f4d22e0 100644 --- a/accelerator-home-ui/src/items/TvOverlaySettingsItem.js +++ b/accelerator-home-ui/src/items/TvOverlaySettingsItem.js @@ -22,6 +22,14 @@ import PictureSettingsApi from "../api/PictureSettingsApi"; import { CONFIG } from "../Config/Config"; export default class TvOverlaySettingsItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.pictureApi = new PictureSettingsApi(); } @@ -93,7 +101,7 @@ export default class TvOverlaySettingsItem extends Lightning.Component { } fetchAndUpdateValues() { - console.log("fetchAndUpdateValues got called!!!") + this.LOG("fetchAndUpdateValues got called!!!") if (Array.isArray(this._item.value)) { this.valueIdx = 0; this.valueLength = this._item.value.length; @@ -101,7 +109,7 @@ export default class TvOverlaySettingsItem extends Lightning.Component { this.pictureApi .getSettingsValue(this._item.id) .then((res) => { - console.log("getSettingsValue Result from fetchAndUpdateValues(array): ",JSON.stringify(res)); + this.LOG("getSettingsValue Result from fetchAndUpdateValues(array): " + JSON.stringify(res)); let tIdx = this._item.value.indexOf(res); if (tIdx >= 0) { this.valueIdx = tIdx; @@ -111,25 +119,19 @@ export default class TvOverlaySettingsItem extends Lightning.Component { ); }) .catch((err) => { - console.log( - "error from getSettingsValue(value is array) in set(item) in settings Item: ", - JSON.stringify(err) - ); + this.ERR("error from getSettingsValue(value is array) in set(item) in settings Item: " + JSON.stringify(err)); }); } else { this.pictureApi .getSettingsValue(this._item.id) .then((res) => { - console.log("getSettingsValue Result from fetchAndUpdateValues(number): ", JSON.stringify(res)); + this.LOG("getSettingsValue Result from fetchAndUpdateValues(number): " + JSON.stringify(res)); this._item.value = +res; this.currentVal = +res; //to change to int this.updateValue(this._item.value); }) .catch((err) => { - console.log( - "error from getSettingsValue(value is number) in set(item) in settings Item: ", - JSON.stringify(err) - ); + this.ERR("error from getSettingsValue(value is number) in set(item) in settings Item: " + JSON.stringify(err)); }); } } @@ -146,7 +148,7 @@ export default class TvOverlaySettingsItem extends Lightning.Component { try { clearTimeout(this.changeValueTimer); } catch { - console.log("CLEANUP ERROR"); + this.ERR("CLEANUP ERROR"); } if (this.currentVal + val <= 100 && this.currentVal + val >= 0) { this.currentVal += val; @@ -154,18 +156,18 @@ export default class TvOverlaySettingsItem extends Lightning.Component { } this.changeValueTimer = setTimeout(() => { - console.log(`SENDING VALUE:${this.currentVal} TO API: ${this._item.id}`); + this.LOG(`SENDING VALUE:${this.currentVal} TO API: ${this._item.id}`); ///////////////// call set method and update the value in _item this.pictureApi .setSettingsValue(this._item.id, this.currentVal) .then((res) => { - console.log(JSON.stringify(res)); + this.LOG(JSON.stringify(res)); this._item.value = this.currentVal; this.updateValue(this.currentVal); }) .catch((err) => { - console.log(JSON.stringify(err)); - console.log("this._item: ", JSON.stringify(this._item)); + this.ERR(JSON.stringify(err)); + this.ERR("this._item: " + JSON.stringify(this._item)); }); }, 600); } @@ -175,7 +177,7 @@ export default class TvOverlaySettingsItem extends Lightning.Component { try { clearTimeout(this.changePresetTimer); } catch { - console.log("CLEANUP ERROR"); + this.ERR("CLEANUP ERROR"); } if (direction === "left") { @@ -192,7 +194,7 @@ export default class TvOverlaySettingsItem extends Lightning.Component { this.updateValue(this.formatItemName(this._item.value[this.valueIdx])); this.changePresetTimer = setTimeout(() => { - console.log( + this.LOG( `SENDING VALUE:${this._item.value[this.valueIdx]} TO API: ${ this._item.id }` @@ -201,15 +203,15 @@ export default class TvOverlaySettingsItem extends Lightning.Component { this.pictureApi .setSettingsValue(this._item.id, this._item.value[this.valueIdx]) .then((res) => { - console.log(JSON.stringify(res)); - console.log(this._item.value[this.valueIdx]); + this.LOG("setsettingsvalue response"+JSON.stringify(res)); + this.LOG("setsettingsseleceted value"+JSON.stringify(this._item.value[this.valueIdx])); this.updateValue( this.formatItemName(this._item.value[this.valueIdx]) ); this.fireAncestors("$moveDownLock",false); //api call success user can move down }) .catch((err) => { - console.log(JSON.stringify(err)); + this.ERR("setsettingsselected value error "+JSON.stringify(err)); }); }, 600); } diff --git a/accelerator-home-ui/src/items/VideoAndAudioItem.js b/accelerator-home-ui/src/items/VideoAndAudioItem.js index d13cfc7..44f0039 100644 --- a/accelerator-home-ui/src/items/VideoAndAudioItem.js +++ b/accelerator-home-ui/src/items/VideoAndAudioItem.js @@ -23,6 +23,14 @@ import AppApi from '../api/AppApi' export default class VideoAndAudioItem extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.Tick = Utils.asset('/images/settings/Tick.png') } @@ -64,7 +72,7 @@ export default class VideoAndAudioItem extends Lightning.Component { _handleEnter() { if (this.videoElement === true) { this.appApi.setResolution(this._item).catch(err => { - console.log(`there was an error while setting the resolution.` + JSON.stringify(err)); + this.ERR("there was an error while setting the resolution." + JSON.stringify(err)); }); } else { @@ -79,7 +87,7 @@ export default class VideoAndAudioItem extends Lightning.Component { this.fireAncestors("$updateSoundMode", this._item) }) .catch(err => { - console.log('Some error while setting the sound mode ', err) + this.ERR('Some error while setting the sound mode ' + JSON.stringify(err)) }) } } diff --git a/accelerator-home-ui/src/overlays/AppCarousel.js b/accelerator-home-ui/src/overlays/AppCarousel.js index 4b06a1d..01a423a 100644 --- a/accelerator-home-ui/src/overlays/AppCarousel.js +++ b/accelerator-home-ui/src/overlays/AppCarousel.js @@ -7,6 +7,13 @@ import RDKShellApis from "../api/RDKShellApis.js"; import { GLOBALS } from "../Config/Config.js"; export default class AppCarousel extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { @@ -63,12 +70,12 @@ export default class AppCarousel extends Lightning.Component { } async _focus() { let self = this - console.log("self.homeApi.getAppListInfo()", self.homeApi.getAppListInfo()); + this.LOG("self.homeApi.getAppListInfo() " + JSON.stringify(self.homeApi.getAppListInfo())); self.metroApps = self.homeApi.getOnlineMetroApps() self.premiumApps = self.homeApi.getAppListInfo() self.showcaseApps = self.homeApi.getShowCaseApps() let order = Storage.get("appCarouselOrder") - console.log("order", order) + this.LOG("order " + JSON.stringify(order)) let apps = [] if (order) { let storedApps = order.split(",") @@ -90,7 +97,7 @@ export default class AppCarousel extends Lightning.Component { self.metroApps[index] = -1 } }) - console.log("APPS ARRAY: ", apps) + this.LOG("APPS ARRAY: " + JSON.stringify(apps)) self.premiumApps.map(papp => { if (papp !== -1 && papp.uri != "USB") { apps.push(papp) @@ -144,7 +151,7 @@ export default class AppCarousel extends Lightning.Component { }) } _unfocus() { - console.log("unfocus") + this.LOG("unfocus") this.close(); } @@ -171,7 +178,7 @@ export default class AppCarousel extends Lightning.Component { } _handleLeft() { - console.log("H left") + this.LOG("H left") } async _handleEnter() { let applicationType = this.tag('AppList').items[this.tag('AppList').index].data.applicationType; @@ -185,7 +192,7 @@ export default class AppCarousel extends Lightning.Component { this.appApi.launchApp(applicationType, params).then(() => { Router.focusPage(); }).catch(err => { - console.log("ApplaunchError: ", err) + this.ERR("ApplaunchError: " + JSON.stringify(err)) }); } }, diff --git a/accelerator-home-ui/src/overlays/AudioScreens/AudioScreenOverlay.js b/accelerator-home-ui/src/overlays/AudioScreens/AudioScreenOverlay.js index 74c7b03..6ad7559 100644 --- a/accelerator-home-ui/src/overlays/AudioScreens/AudioScreenOverlay.js +++ b/accelerator-home-ui/src/overlays/AudioScreens/AudioScreenOverlay.js @@ -20,7 +20,7 @@ import { Lightning, Utils, Language, Storage } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from "../../colors/Colors"; -import { CONFIG } from "../../Config/Config"; +import { CONFIG, GLOBALS } from "../../Config/Config"; import AppApi from "../../api/AppApi"; import HdmiOutputScreen from './HdmiOutputScreen'; @@ -279,7 +279,7 @@ export default class AudioScreen extends Lightning.Component { console.log(err) }) - this.appApi.setVolumeLevel(((Storage.get("deviceType") == "tv") ? "SPEAKER0" : "HDMI0"), 100).then(() => { + this.appApi.setVolumeLevel(((GLOBALS.deviceType == "IpTv") ? "SPEAKER0" : "HDMI0"), 100).then(() => { this.appApi.getVolumeLevel().catch(err => { console.log(err) }) @@ -292,7 +292,7 @@ export default class AudioScreen extends Lightning.Component { console.log(err) }) // gets the enabled Audio Port - this.appApi.getEnableAudioPort(((Storage.get("deviceType") == "tv") ? "SPEAKER0" : "HDMI0")).then(() => { + this.appApi.getEnableAudioPort(((GLOBALS.deviceType == "IpTv") ? "SPEAKER0" : "HDMI0")).then(() => { }).catch(err => { console.log(err) }) @@ -302,9 +302,9 @@ export default class AudioScreen extends Lightning.Component { }); // set enable Audio POrt - this.appApi.setEnableAudioPort(((Storage.get("deviceType") == "tv") ? "SPEAKER0" : "HDMI0")).then(() => { + this.appApi.setEnableAudioPort(((GLOBALS.deviceType == "IpTv") ? "SPEAKER0" : "HDMI0")).then(() => { - this.appApi.getEnableAudioPort(((Storage.get("deviceType") == "tv") ? "SPEAKER0" : "HDMI0")).then(() => { + this.appApi.getEnableAudioPort(((GLOBALS.deviceType == "IpTv") ? "SPEAKER0" : "HDMI0")).then(() => { }).catch(err => { console.log(err) diff --git a/accelerator-home-ui/src/overlays/AudioScreens/HdmiOutputScreen.js b/accelerator-home-ui/src/overlays/AudioScreens/HdmiOutputScreen.js index 6ca927c..924263c 100644 --- a/accelerator-home-ui/src/overlays/AudioScreens/HdmiOutputScreen.js +++ b/accelerator-home-ui/src/overlays/AudioScreens/HdmiOutputScreen.js @@ -25,6 +25,13 @@ import AppApi from '../../api/AppApi.js'; */ var appApi = new AppApi(); export default class HdmiOutputScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { HdmiOutputScreenContents: { @@ -105,11 +112,11 @@ export default class HdmiOutputScreen extends Lightning.Component { this._setState("Options") }) .catch(err => { - console.log('error', err) + this.ERR('error from getsupportedAudiomodes: ' + JSON.stringify(err)) }) }) .catch(err => { - console.log('error', JSON.stringify(err)) + this.ERR('error from getsoundmode: ' + JSON.stringify(err)) }) } diff --git a/accelerator-home-ui/src/overlays/AudioScreens/ResolutionOverlay.js b/accelerator-home-ui/src/overlays/AudioScreens/ResolutionOverlay.js index 7756f0b..e8ecc6f 100644 --- a/accelerator-home-ui/src/overlays/AudioScreens/ResolutionOverlay.js +++ b/accelerator-home-ui/src/overlays/AudioScreens/ResolutionOverlay.js @@ -30,6 +30,13 @@ const thunder = thunderJS(CONFIG.thunderConfig) */ export default class ResolutionScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { ResolutionScreenContents: { @@ -70,12 +77,12 @@ export default class ResolutionScreen extends Lightning.Component { }); thunder.on('org.rdk.DisplaySettings', 'resolutionPreChange', () => { - console.log(new Date().toISOString() + " ResolutionOverlay got resolutionPreChange"); + this.LOG(new Date().toISOString() + " ResolutionOverlay got resolutionPreChange"); Storage.set("ResolutionChangeInProgress", true); }) thunder.on('org.rdk.DisplaySettings', 'resolutionChanged', notification => { - console.log(new Date().toISOString() + " ResolutionOverlay got resolutionChanged"); + this.LOG(new Date().toISOString() + " ResolutionOverlay got resolutionChanged"); const items = this.tag('List').items items.forEach(element => { element.tag('Item.Tick').visible = false @@ -123,7 +130,7 @@ export default class ResolutionScreen extends Lightning.Component { this.tag('List').setIndex(sIndex) this._setState("Options") }).catch(err => { - console.log(`error while fetching the supported resolution ${err}`); + this.ERR("error while fetching the supported resolution " + JSON.stringify(err)); }) }) } diff --git a/accelerator-home-ui/src/overlays/AudioScreens/VideoScreenOverlay.js b/accelerator-home-ui/src/overlays/AudioScreens/VideoScreenOverlay.js index 9e764ee..45dc4f6 100644 --- a/accelerator-home-ui/src/overlays/AudioScreens/VideoScreenOverlay.js +++ b/accelerator-home-ui/src/overlays/AudioScreens/VideoScreenOverlay.js @@ -29,6 +29,14 @@ import FireBoltApi from '../../api/firebolt/FireBoltApi'; */ export default class VideoScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { VideoScreenContents: { @@ -206,7 +214,7 @@ export default class VideoScreen extends Lightning.Component { this._appApi.getResolution().then(resolution => { this.tag("Resolution.Title").text.text = Language.translate('Resolution: ') + resolution; }).catch(err => { - console.log("Error fetching the Resolution" + JSON.stringify(err)) + this.ERR("Error fetching the Resolution" + JSON.stringify(err)) }) this._appApi.getHDCPStatus().then(result => { if (result.isHDCPCompliant && result.isHDCPEnabled) { diff --git a/accelerator-home-ui/src/overlays/LiveTvSettings/DvbSScan.js b/accelerator-home-ui/src/overlays/LiveTvSettings/DvbSScan.js index 9862ece..b62c3ba 100644 --- a/accelerator-home-ui/src/overlays/LiveTvSettings/DvbSScan.js +++ b/accelerator-home-ui/src/overlays/LiveTvSettings/DvbSScan.js @@ -37,6 +37,13 @@ const thunder = ThunderJS(CONFIG.thunderConfig); * Class for DVB Scan screen. */ export default class DvbSScan extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { DvbSScanScreenContents: { @@ -415,44 +422,36 @@ export default class DvbSScan extends Lightning.Component { } consoleLog() { //log it everywhere - console.log( - "selectedSatellite: ", - JSON.stringify(this.selectedSatellite), - " selectedFrequency: ", - this.selectedFrequency, - " selectedPolarity: ", - this.selectedPolarity, - " selectedSymbolRate: ", - this.selectedSymbolRate, - " selectedFEC: ", - this.selectedFEC, - " selectedDVBS2: ", - this.selectedDVBS2, - " selectedModulation: ", - this.selectedModulation, - " selectedSearchType: ", - this.selectedSearchType, - " selectedRetune: ", - this.selectedRetune + this.LOG( + "selectedSatellite: " + JSON.stringify(this.selectedSatellite) + + " selectedFrequency: " + JSON.stringify(this.selectedFrequency) + + " selectedPolarity: " + JSON.stringify(this.selectedPolarity) + + " selectedSymbolRate: " + JSON.stringify(this.selectedSymbolRate) + + " selectedFEC: " + JSON.stringify(this.selectedFEC) + + " selectedDVBS2: " + JSON.stringify(this.selectedDVBS2) + + " selectedModulation: " + JSON.stringify(this.selectedModulation) + + " selectedSearchType: " + JSON.stringify(this.selectedSearchType) + + " selectedRetune: " + JSON.stringify(this.selectedRetune) ); } + _focus() { - // console.log("dvbscan screen in focus"); + // this.LOG("dvbscan screen in focus"); this.resetForm(); this._setState("Satellite"); this.consoleLog(); - // console.log(this.satelliteList); - // console.log(this.polarityList); - // console.log(this.fecList); - // console.log(this.modulationList); - // console.log(this.searchtypeList); + // this.LOG(JSON.stringify(this.satelliteList)); + // this.LOG(JSON.stringify(this.polarityList)); + // this.LOG(JSON.stringify(this.fecList)); + // this.LOG(JSON.stringify(this.modulationList)); + // this.LOG(JSON.stringify(this.searchtypeList)); } _firstActive() { thunder.on("DTV", "searchstatus", (notification) => { - console.log("SearchStatus Notification: ", JSON.stringify(notification)); + this.LOG("SearchStatus Notification: " + JSON.stringify(notification)); if (notification.finished) { - console.log("notification.finished: ", notification.finished) + this.LOG("notification.finished: " + JSON.stringify(notification.finished)) this.setScanFinished(); } }) @@ -1042,10 +1041,10 @@ export default class DvbSScan extends Lightning.Component { dvbs2: this.selectedDVBS2, }, }; - console.log(JSON.stringify(serviceSearchParams)); + this.LOG("serviceSearchParams: " + JSON.stringify(serviceSearchParams)); dtvApi.startServiceSearch(serviceSearchParams).then((res) => { this.setScanInProgress(); - console.log(res); + this.LOG("startServiceSearch result: " + JSON.stringify(res)); setTimeout(() => { this.setScanFinished() //to give back controls after 30 sec in case searchstatus event fails }, 30000) diff --git a/accelerator-home-ui/src/overlays/LiveTvSettings/LiveTvSettingsOverlay.js b/accelerator-home-ui/src/overlays/LiveTvSettings/LiveTvSettingsOverlay.js index 20c332f..a2f5e24 100644 --- a/accelerator-home-ui/src/overlays/LiveTvSettings/LiveTvSettingsOverlay.js +++ b/accelerator-home-ui/src/overlays/LiveTvSettings/LiveTvSettingsOverlay.js @@ -19,7 +19,7 @@ import { Lightning, Utils, Language } from "@lightningjs/sdk"; import { COLORS } from "../../colors/Colors"; import SettingsMainItem from "../../items/SettingsMainItem"; - import { CONFIG } from "../../Config/Config"; + import { CONFIG, GLOBALS } from "../../Config/Config"; import DTVApi from "../../api/DTVApi"; import LiveTvScanOverlay from './LiveTvScanOverlay' @@ -29,6 +29,14 @@ * Class for Live TV settings screen. */ export default class LiveTVSettings extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { LiveTVSettingsScreenContents: { @@ -116,72 +124,72 @@ this.tag("LiveTVSettingsScreenContents").visible = true; } - static _states() { - return [ - class Activate extends this { - $enter() { - this.tag("Activate")._focus(); - } - $exit() { - this.tag("Activate")._unfocus(); - } - _handleDown() { - this._setState("Scan"); - } - _handleEnter() { - if (Storage.get("deviceType") != "IpStb") { - if (active) { - this.dtvApi.deactivate().then((res) => { - console.log(res); - active = false; - this.tag("Activate.Button").src = Utils.asset( - "images/settings/ToggleOffWhite.png" - ); - }); - } else { - this.dtvApi.activate().then((res) => { - console.log(res); - active = true; - this.tag("Activate.Button").src = Utils.asset( - "images/settings/ToggleOnOrange.png" - ); - }); - } + static _states() { + return [ + class Activate extends this { + $enter() { + this.tag("Activate")._focus(); + } + $exit() { + this.tag("Activate")._unfocus(); + } + _handleDown() { + this._setState("Scan"); + } + _handleEnter() { + if (GLOBALS.deviceType != "IpStb") { + if (active) { + this.dtvApi.deactivate().then((res) => { + this.LOG("Deactivate result: " + JSON.stringify(res)); + active = false; + this.tag("Activate.Button").src = Utils.asset( + "images/settings/ToggleOffWhite.png" + ); + }); + } else { + this.dtvApi.activate().then((res) => { + this.LOG("Activate result: " + JSON.stringify(res)); + active = true; + this.tag("Activate.Button").src = Utils.asset( + "images/settings/ToggleOnOrange.png" + ); + }); } } - }, - class Scan extends this { - $enter() { - this.tag("Scan")._focus(); - } - $exit() { - this.tag("Scan")._unfocus(); - } - _handleUp() { - this._setState("Activate"); - } - _handleEnter() { - this._setState("LiveTvScanOverlay") - } - }, - class LiveTvScanOverlay extends this { - $enter() { - this.hide() - this.tag('LiveTvScanOverlay').visible = true - this.fireAncestors('$updatePageTitle', Language.translate('Settings / Live TV / Scan')) - } - $exit() { - this.show() - this.tag('LiveTvScanOverlay').visible = false - this.fireAncestors('$updatePageTitle', Language.translate('Settings / Live TV')) - } - _getFocused() { - return this.tag('LiveTvScanOverlay') - } - _handleBack() { - this._setState('Scan') - } - }, - ]; - } + } + }, + class Scan extends this { + $enter() { + this.tag("Scan")._focus(); + } + $exit() { + this.tag("Scan")._unfocus(); + } + _handleUp() { + this._setState("Activate"); + } + _handleEnter() { + this._setState("LiveTvScanOverlay") + } + }, + class LiveTvScanOverlay extends this { + $enter() { + this.hide() + this.tag('LiveTvScanOverlay').visible = true + this.fireAncestors('$updatePageTitle', Language.translate('Settings / Live TV / Scan')) + } + $exit() { + this.show() + this.tag('LiveTvScanOverlay').visible = false + this.fireAncestors('$updatePageTitle', Language.translate('Settings / Live TV')) + } + _getFocused() { + return this.tag('LiveTvScanOverlay') + } + _handleBack() { + this._setState('Scan') + } + }, + ]; + } } diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothPairing.js b/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothPairing.js index 987bb89..8e706df 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothPairing.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothPairing.js @@ -23,6 +23,13 @@ * Class for pairing screen for the Bluetooth. */ export default class BluetoothPairingScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { BluetoothPair: { @@ -103,7 +110,7 @@ } getData(item) { - console.log("setting pairing screen item: ",item) + this.LOG("setting pairing screen item: " + JSON.stringify(item)) _item = item this._setState('ConnectDisconnect') this.tag('Title').text = item.name diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothScreenOverlay.js b/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothScreenOverlay.js index 94c20fe..b1a4399 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothScreenOverlay.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/BluetoothScreenOverlay.js @@ -29,6 +29,13 @@ import FailComponent from './FailComponent' * Class for Bluetooth screen. */ export default class BluetoothScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { Bluetooth: { @@ -531,7 +538,7 @@ export default class BluetoothScreen extends Lightning.Component { } }) .catch(() => { - console.log('Cannot turn off Bluetooth') + this.ERR('Cannot turn off Bluetooth') }) } else { this._bt.enable().then(result => { @@ -545,7 +552,7 @@ export default class BluetoothScreen extends Lightning.Component { } }) .catch(() => { - console.log('Cannot turn on Bluetooth') + this.ERR('Cannot turn on Bluetooth') }) } } @@ -555,7 +562,7 @@ export default class BluetoothScreen extends Lightning.Component { */ _activateBluetooth() { this._bt.activate().then((res) => { - console.log(res) + this.LOG("Bluetooth activate result: " + JSON.stringify(res)) this._bluetooth = true this._bt.registerEvent('onDiscoveredDevice', () => { this.renderDeviceList() @@ -593,7 +600,7 @@ export default class BluetoothScreen extends Lightning.Component { }) }) .catch(err => { - console.log(err) + this.ERR("Bluetooth activate error: " + JSON.stringify(err)) }) } diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/FailComponent.js b/accelerator-home-ui/src/overlays/NetworkScreens/FailComponent.js index 4c3795d..b770260 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/FailComponent.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/FailComponent.js @@ -22,9 +22,16 @@ import { CONFIG } from "../../Config/Config"; const errorTitle = 'Error Title' const errorMsg = 'Error Message' export default class FailComponent extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } notify(args) { - console.log(args) + this.LOG("FailComponent notify args: " + JSON.stringify(args)) if (args.title && args.msg) { this.tag('FailComponent.Title').text.text = args.title this.tag('FailComponent.Message').text.text = Language.translate(args.msg) @@ -44,7 +51,10 @@ export default class FailComponent extends Lightning.Component { _active() { this.tag('Timer').text.text ="" - this.initTimer() + if(this.timeout>0) + { + this.initTimer() + } } initTimer() { this.timeInterval = Registry.setInterval(() => { @@ -53,7 +63,7 @@ export default class FailComponent extends Lightning.Component { --this.timeout } else { - Router.focusPage(); + this.fireAncestors("$navigateBack") } }, 1000) } diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/JoinAnotherNetworkOverlay.js b/accelerator-home-ui/src/overlays/NetworkScreens/JoinAnotherNetworkOverlay.js index b6e7628..bd21c35 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/JoinAnotherNetworkOverlay.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/JoinAnotherNetworkOverlay.js @@ -21,10 +21,18 @@ import { CONFIG } from '../../Config/Config'; import { Keyboard } from '../../ui-components/index' import { KEYBOARD_FORMATS } from '../../ui-components/components/Keyboard' import PasswordSwitch from '../../screens/PasswordSwitch'; -import WiFi from '../../api/WifiApi'; +import NetworkManager from '../../api/NetworkManagerAPI'; import PersistentStoreApi from '../../api/PersistentStore'; export default class JoinAnotherNetworkComponent extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + handleDone() { this.tag("Keyboard").visible = false let securityCode = this.securityCodes[this.securityCodeIndex].value; @@ -49,13 +57,13 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component { } } - startConnectForAnotherNetwork(device, passphrase) { - WiFi.get().connect(false, device, passphrase).then(() => { - WiFi.get().saveSSID(device.ssid, passphrase, device.security).then((response) => { - if (response.result === 0 && response.success === true) { - PersistentStoreApi.get().setValue('wifi', 'SSID', this._item.ssid) - } else if (response.result !== 0) { - WiFi.get().clearSSID() + async startConnectForAnotherNetwork(device, passphrase) { + await NetworkManager.WiFiConnect(false, { ssid: device.ssid, security: device.security }, passphrase).then(() => { + NetworkManager.AddToKnownSSIDs(device.ssid, passphrase, device.security).then((response) => { + if (response === true ) { + PersistentStoreApi.get().setValue('wifi', 'SSID', device.ssid) + } else { + NetworkManager.RemoveKnownSSID(device.ssid) PersistentStoreApi.get().deleteNamespace('wifi') } }) @@ -392,7 +400,7 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component { if (this.prevState === 'PasswordSwitchState') { this.prevState = "EnterPassword" } - console.log("Prev state:", this.prevState) + this.LOG("Prev state:", this.prevState) if (key === 'Done') { this.handleDone(); } else if (key === 'Clear') { @@ -400,7 +408,7 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component { this.star = (this.prevState === "EnterPassword") ? this.star.substring(0, this.star.length - 1) : this.star this.tag(this.element).text.text = this.encrypt() ? this.star : this.textCollection[this.prevState]; } else if (key === '#@!' || key === 'abc' || key === 'áöû' || key === 'shift') { - console.log('no saving') + this.LOG('no saving') } else if (key === 'Space') { this.textCollection[this.prevState] += ' ' this.star += (this.prevState === "EnterPassword") ? '\u25CF' : this.star diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkConfigurationOverlay.js b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkConfigurationOverlay.js index 6b4a660..9bae7f1 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkConfigurationOverlay.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkConfigurationOverlay.js @@ -20,9 +20,9 @@ import { Lightning, Utils, Language } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' import { CONFIG } from '../../Config/Config' -import Network from '../../api/NetworkApi' import NetworkInfoScreen from './NetworkInfoScreen' import NetworkInterfaceOverlay from './NetworkInterfaceOverlay' +import NetworkManager from '../../api/NetworkManagerAPI' export default class NetworkConfigurationScreen extends Lightning.Component { static _template() { @@ -150,17 +150,20 @@ export default class NetworkConfigurationScreen extends Lightning.Component { let _currentIPSettings = {} let _newIPSettings = {} - Network.get().getDefaultInterface().then(interfaceName => { - this.$NetworkInterfaceText(interfaceName) + NetworkManager.GetPrimaryInterface().then(interfaceName => { + if(interfaceName === "eth0"){this.$NetworkInterfaceText("ETHERNET")} + if(interfaceName === "wlan0"){this.$NetworkInterfaceText("WIFI")} }) - this.onDefaultIfaceChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onDefaultInterfaceChanged', data => { - this.$NetworkInterfaceText(data.newInterfaceName) + this.onDefaultIfaceChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onActiveInterfaceChange', data => { + if(data.currentActiveInterface === "eth0"){this.$NetworkInterfaceText("ETHERNET")} + else{this.$NetworkInterfaceText("WIFI")} this.tag('TestInternetAccess.Title').text.text = Language.translate('Test Internet Access: ') + Metrics.action("user", "User changed the network interface", null) }); _newIPSettings = _currentIPSettings - _newIPSettings.ipversion = "IPV6" + _newIPSettings.ipversion = "IPV6" // this fails, need to verify how to set proper ip settings // loader animation for testing internet this.loadingAnimation = this.tag('TestInternetAccess.Loader').animation({ @@ -244,18 +247,17 @@ export default class NetworkConfigurationScreen extends Lightning.Component { _handleEnter() { this.loadingAnimation.start() this.tag('TestInternetAccess.Loader').visible = true - Network.get().isConnectedToInternet().then(result => { - let connectionStatus = Language.translate("Internet Access: ") - if (result) { + NetworkManager.IsConnectedToInternet().then(result => { + var connectionStatus = Language.translate("Internet Access: ") + if (result.connected) { connectionStatus += Language.translate("Connected") } else { - connectionStatus += Language.translate("Not Connected") + connectionStatus += Language.translate("Disconnected") } - setTimeout(() => { - this.tag('TestInternetAccess.Loader').visible = false - this.tag('TestInternetAccess.Title').text.text = connectionStatus - this.loadingAnimation.stop() + this.tag('TestInternetAccess.Loader').visible = false + this.tag('TestInternetAccess.Title').text.text = connectionStatus + this.loadingAnimation.stop() }, 2000) }) } diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInfoScreen.js b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInfoScreen.js index 0a5c7ca..2d31284 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInfoScreen.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInfoScreen.js @@ -20,13 +20,19 @@ import { Lightning, Language } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' -import { CONFIG } from '../../Config/Config' -import Network from '../../api/NetworkApi'; -import WiFi from '../../api/WifiApi'; +import { CONFIG ,GLOBALS } from '../../Config/Config' +import NetworkManager from '../../api/NetworkManagerAPI'; var currentInterface = []; export default class NetworkInfo extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { NetworkInfoScreenContents: { @@ -251,30 +257,31 @@ export default class NetworkInfo extends Lightning.Component { } _active() { - this.onInterfaceStatusChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onInterfaceStatusChanged', () => { + this.onInterfaceStatusChangedCB = NetworkManager.thunder.on(NetworkManager.callsign,'onInterfaceStatusChanged', data => { this.refreshDetails(); }) - this.onConnectionStatusChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onConnectionStatusChanged', () => { + this.onIPAddressStatusChangedCB = NetworkManager.thunder.on(NetworkManager.callsign,'onAddressChange', data => { this.refreshDetails(); }) - this.onIPAddressStatusChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onIPAddressStatusChanged', () => { + this.onDefaultInterfaceChangedCB = NetworkManager.thunder.on(NetworkManager.callsign,'onActiveInterfaceChange', data => { this.refreshDetails(); }) - this.onDefaultInterfaceChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onDefaultInterfaceChanged', () => { + if ("ResidentApp" !== GLOBALS.selfClientName) + { + this.OnNetworkChangedfirebolt = FireBoltApi.get().deviceinfo.listen("networkChanged",value =>{ this.refreshDetails(); }) + } } _inactive() { this.onInterfaceStatusChangedCB.dispose() - this.onConnectionStatusChangedCB.dispose() this.onIPAddressStatusChangedCB.dispose() this.onDefaultInterfaceChangedCB.dispose() } _disable() { - if (this.NWPluginSelfActivated) Network.get().deactivate() - if (this.WiFiPluginSelfActivated) WiFi.get().deactivate() + if (this.NetworkManagerActivated) {NetworkManager.deactivate()} } async refreshDetails() { @@ -283,13 +290,59 @@ export default class NetworkInfo extends Lightning.Component { this.tag("IPAddress.Value").text.text = `NA` this.tag("Gateway.Value").text.text = `NA` this.tag("MACAddress.Value").text.text = `NA` - await Network.get().getDefaultInterface().then((defaultInterface) => { - Network.get().getIPSettings(defaultInterface).then((result) => { - if (result.interface === "WIFI") { + if ("ResidentApp" === GLOBALS.selfClientName) + { + await NetworkManager.GetPrimaryInterface().then((defaultInterface) => { + console.log("defaultinterface"+defaultInterface) + NetworkManager.GetIPSettings(defaultInterface).then((result) => { + if (result.interface === "wlan0") { + this.tag("ConnectionType.Value").text.text = Language.translate("Wireless") + this.tag("SSID").alpha = 1 + this.tag("SignalStrength").alpha = 1 + NetworkManager.GetConnectedSSID().then((result) => { + if (parseInt(result.signalStrength) >= -50) { + this.tag("SignalStrength.Value").text.text = `Excellent` + } + else if (parseInt(result.signalStrength) >= -60) { + this.tag("SignalStrength.Value").text.text = `Good` + } + else if (parseInt(result.signalStrength) >= -67) { + this.tag("SignalStrength.Value").text.text = `Fair` + } + else { + this.tag("SignalStrength.Value").text.text = `Poor` + } + this.tag("SSID.Value").text.text = `${result.ssid}` + }).catch((error) => console.log(error)); + } else if (result.interface === "eth0") { + this.tag("ConnectionType.Value").text.text = 'Ethernet' + this.tag("SSID").alpha = 0 + this.tag("SignalStrength").alpha = 0 + } + this.tag('InternetProtocol.Value').text.text = result.ipversion + this.tag('IPAddress.Value').text.text = result.ipaddress + this.tag("Gateway.Value").text.text = result.gateway + }).catch((err) => console.error(err)) + + NetworkManager.GetAvailableInterfaces().then((interfaces) => { + currentInterface = interfaces.filter((data) => data.name === defaultInterface) + if (currentInterface[0].connected) { + this.tag("Status.Value").text.text = Language.translate('Connected') + } + else { + this.tag('Status.Value').text.text = Language.translate('Disconnected') + } + this.tag('MACAddress.Value').text.text = currentInterface[0].mac + }).catch((error) => console.log(error)); + }).catch((error) => console.log(error)); + } + else{ + await FireBoltApi.get().deviceinfo.getnetwork().then(res=>{ + if (res.type === "wifi") { this.tag("ConnectionType.Value").text.text = Language.translate("Wireless") this.tag("SSID").alpha = 1 this.tag("SignalStrength").alpha = 1 - WiFi.get().getConnectedSSID().then((result) => { + NetworkManager.GetConnectedSSID().then((result) => { if (parseInt(result.signalStrength) >= -50) { this.tag("SignalStrength.Value").text.text = `Excellent` } @@ -303,28 +356,34 @@ export default class NetworkInfo extends Lightning.Component { this.tag("SignalStrength.Value").text.text = `Poor` } this.tag("SSID.Value").text.text = `${result.ssid}` - }).catch((error) => console.log(error)); - } else if (result.interface === "ETHERNET") { + }).catch((error) => { + this.ERR("WiFi.get().getConnectedSSID error: " + JSON.stringify(error)) + }); + } else if (res.type === "ethernet") { this.tag("ConnectionType.Value").text.text = 'Ethernet' this.tag("SSID").alpha = 0 this.tag("SignalStrength").alpha = 0 } - this.tag('InternetProtocol.Value').text.text = result.ipversion - this.tag('IPAddress.Value').text.text = result.ipaddr - this.tag("Gateway.Value").text.text = result.gateway - }).catch((err) => console.error(err)) - - Network.get().getInterfaces().then((interfaces) => { - currentInterface = interfaces.filter((data) => data.interface === defaultInterface) - if (currentInterface[0].connected) { + if (res.state== "connected") { this.tag("Status.Value").text.text = Language.translate('Connected') } else { this.tag('Status.Value').text.text = Language.translate('Disconnected') } - this.tag('MACAddress.Value').text.text = currentInterface[0].macAddress + NetworkManager.GetPrimaryInterface().then((defaultInterface) => { + NetworkManager.GetIPSettings(defaultInterface).then((result) => { + this.tag('InternetProtocol.Value').text.text = result.ipversion + this.tag('IPAddress.Value').text.text = result.ipaddress + this.tag("Gateway.Value").text.text = result.gateway + }) + NetworkManager.GetAvailableInterfaces().then((res) => { + currentInterface = res.interfaces.filter((data) => data.type === defaultInterface) + this.tag('MACAddress.Value').text.text = currentInterface[0].mac + }).catch((error) => console.log(error)); + }) + }).catch((error) => console.log(error)); - }).catch((error) => console.log(error)); + } } _focus() { diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInterfaceOverlay.js b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInterfaceOverlay.js index 63091e5..bc09ad3 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInterfaceOverlay.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkInterfaceOverlay.js @@ -20,12 +20,21 @@ import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' import { CONFIG } from '../../Config/Config' - import Network from '../../api/NetworkApi' import { Language } from '@lightningjs/sdk'; import WifiScreen from './NetworkWifiOverlay' + import NetworkManager from '../../api/NetworkManagerAPI'; + import { Metrics } from '@firebolt-js/sdk' export default class NetworkInterfaceScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.LoadingIcon = Utils.asset('images/settings/Loading.png') } @@ -74,7 +83,7 @@ Loader: { h: 45, w: 45, - x: 175, + x: 500, mountX: 1, y: 45, mountY: 0.5, @@ -95,33 +104,36 @@ } _active() { - this.onDefaultInterfaceChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onDefaultInterfaceChanged', (notification) => { - console.log('onDefaultInterfaceChanged notification from networkInterfaceScreen: ', notification) - if (notification.newInterfaceName === "ETHERNET") { + this.onDefaultInterfaceChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onActiveInterfaceChange', (notification) => { + this.LOG('onActiveInterfaceChange notification from networkInterfaceScreen: ' + JSON.stringify(notification)) + if (notification.currentActiveInterface === "eth0") { this.loadingAnimation.stop() this.tag('Ethernet.Loader').visible = false this.tag('Ethernet.Title').text.text = 'Ethernet: ' + Language.translate("Connected") - } else if (notification.newInterfaceName === "" && notification.oldInterfaceName === "WIFI") { + } else if (notification.currentActiveInterface === "" && notification.prevActiveInterface === "wlan0") { this.loadingAnimation.stop() this.tag('Ethernet.Loader').visible = false this.tag('Ethernet.Title').text.text = 'Ethernet: '+Language.translate('Error')+', '+Language.translate('Retry')+'!' - } else if (notification.newInterfaceName === "WIFI") { + } else if (notification.currentActiveInterface === "wlan0") { this.loadingAnimation.stop() this.tag('Ethernet.Loader').visible = false this.tag('Ethernet.Title').text.text = 'Ethernet' } + Metrics.action("user", "The user changed the network interface", null) }); - this.onConnectionStatusChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onConnectionStatusChanged', (notification) => { - console.log('onConnectionStatusChanged notification from networkInterfaceScreen: ', notification) - if (notification.interface === "ETHERNET") { - this.tag('Ethernet.Title').text.text = 'Ethernet: ' + Language.translate(notification.status.toLowerCase()) + this.onConnectionStatusChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onInterfaceStateChange', (notification) => { + this.LOG('onInterfaceStateChange notification from networkInterfaceScreen: ' + JSON.stringify(notification)) + if (notification.interface === "eth0") { + this.tag('Ethernet.Title').text.text = 'Ethernet: ' + Language.translate(notification.state.toLowerCase()) } + Metrics.action("App", "network connection of app changed", null) }); this.loadingAnimation = this.tag('Ethernet.Loader').animation({ duration: 3, repeat: -1, stopMethod: 'immediate', stopDelay: 0.2, actions: [{ p: 'rotation', v: { sm: 0, 0: 0, 1: 2 * Math.PI } }] }); + this.tag('Ethernet.Loader').src = this.LoadingIcon } @@ -175,25 +187,21 @@ this.tag('Ethernet.Title').text.text = 'Ethernet :' + Language.translate('Configuring as default') this.tag('Ethernet.Loader').visible = true this.loadingAnimation.start() - await Network.get().isInterfaceEnabled("ETHERNET").then(enabled => { + await NetworkManager.GetInterfaceState("eth0").then(enabled => { if (!enabled) { - Network.get().setInterfaceEnabled("ETHERNET").then(() => { - Network.get().setDefaultInterface("ETHERNET").then(result => { - if (result) { - this.loadingAnimation.stop() - this.tag('Ethernet.Title').text.text = 'Ethernet' - this.tag('Ethernet.Loader').visible = false - } - }); - }); - } else { - Network.get().setDefaultInterface("ETHERNET").then(result => { + NetworkManager.SetInterfaceState("eth0").then(() => { if (result) { this.loadingAnimation.stop() this.tag('Ethernet.Title').text.text = 'Ethernet' this.tag('Ethernet.Loader').visible = false } }); + } else { + setTimeout(() => { + this.loadingAnimation.stop() + this.tag('Ethernet.Title').text.text = 'Ethernet' + this.tag('Ethernet.Loader').visible = false + }, 1000) } }); } @@ -206,7 +214,7 @@ }, class WifiScreen extends this { $enter() { - console.log("wifiscreen") + this.LOG("wifiscreen") this.hide() this.tag('WifiScreen').visible = true this.fireAncestors('$updatePageTitle', 'Settings Network Configuration Network Interface WiFi') diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkWifiOverlay.js b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkWifiOverlay.js index 3bc6964..8810044 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/NetworkWifiOverlay.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/NetworkWifiOverlay.js @@ -17,21 +17,27 @@ * limitations under the License. **/ import { Language, Lightning, Utils } from '@lightningjs/sdk' -import Network from '../../api/NetworkApi' import WiFiItem from '../../items/WiFiItem' import SettingsMainItem from '../../items/SettingsMainItem' -import WiFi, { WiFiState, WiFiError, WiFiErrorMessages } from '../../api/WifiApi' import { COLORS } from '../../colors/Colors' import { CONFIG } from '../../Config/Config' import JoinAnotherNetworkOverlay from './JoinAnotherNetworkOverlay' import WifiPairingScreen from './WifiPairingOverlayScreen' import FailComponent from './FailComponent' import PersistentStoreApi from '../../api/PersistentStore' +import NetworkManager,{WiFiState} from '../../api/NetworkManagerAPI' /** * Class for WiFi screen. */ export default class WiFiScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { WifiContents: { @@ -136,14 +142,16 @@ export default class WiFiScreen extends Lightning.Component { } _init() { - Network.get().activate() - WiFi.get().activate() + NetworkManager.activate() } async _active() { this.ssids = this.renderSSIDS = [] - this.onAvailableSSIDsCB = WiFi.get().thunder.on(WiFi.get().callsign, 'onAvailableSSIDs', params => { - console.log("WiFiOverlay onAvailableSSIDs length: ", params.ssids.length); + await NetworkManager.GetInterfaceState("wlan0").then(enabled => { + this.wifiStatus = enabled + }); + this.onAvailableSSIDsCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onAvailableSSIDs', params => { + this.LOG("WiFiOverlay onAvailableSSIDs length: " + JSON.stringify(params.ssids.length)); this.ssids = [...this.ssids, ...params.ssids] if (!params.moreData) { this.renderSSIDS = this.ssids @@ -153,57 +161,58 @@ export default class WiFiScreen extends Lightning.Component { this.renderDeviceList(this.renderSSIDS); } if (!params.ssids.length) { - console.log("onAvailableSSIDs length is ZERO; scanning again.") + this.LOG("onAvailableSSIDs length is ZERO; scanning again.") if (this.wifiStatus) { - WiFi.get().startScan() + NetworkManager.StartWiFiScan() this.wifiLoading.play() this.tag('Switch.Loader').visible = true } } }); - this.onWIFIStateChangedHandler = WiFi.get().thunder.on(WiFi.get().callsign, 'onWIFIStateChanged', notification => { - if ((notification.state > WiFiState.DISABLED) && (notification.state !== WiFiState.FAILED)) { + this.onWIFIStateChangedHandler = NetworkManager.thunder.on(NetworkManager.callsign, 'onWiFiStateChange', notification => { + if ((notification.state > WiFiState.WIFI_STATE_DISABLED) && (notification.state !== WiFiState.WIFI_STATE_CONNECTION_FAILED)) { if (this.wifiStatus) { - console.log("onWIFIStateChanged: startScan()") - WiFi.get().startScan() + this.LOG("onWIFIStateChanged: startScan()") + NetworkManager.StartWiFiScan() } } - if (notification.state === WiFiState.CONNECTED) { - Network.get().setDefaultInterface("WIFI").then(() => { - console.log("Successfully set WIFI as default interface.") - }).catch(err => { - console.error("Could not set WIFI as default interface." + JSON.stringify(err)) - }); - WiFi.get().getConnectedSSID().then(result => { - PersistentStoreApi.get().setValue('wifi', 'SSID', result.ssid).then((response) => { console.log(response) }) + if (notification.state === WiFiState.WIFI_STATE_CONNECTED) { + NetworkManager.GetConnectedSSID().then(result => { + PersistentStoreApi.get().setValue('wifi', 'SSID', result.ssid).then((response) => { this.LOG("setValue response: " + JSON.stringify(response)) }) }) if (this.renderSSIDS.length) this.renderDeviceList(this.renderSSIDS); } - }) + if(notification.state === WiFiState.WIFI_STATE_SSID_CHANGED|| notification.state === WiFiState.WIFI_STATE_CONNECTION_LOST || + notification.state === WiFiState.WIFI_STATE_CONNECTION_FAILED || + notification.state === WiFiState.WIFI_STATE_CONNECTION_INTERRUPTED || + notification.state === WiFiState.WIFI_STATE_INVALID_CREDENTIALS || + notification.state === WiFiState.WIFI_STATE_AUTHENTICATION_FAILED || + notification.state === WiFiState.WIFI_STATE_ERROR ) + { + if ((notification.code === WiFiState.WIFI_STATE_INVALID_CREDENTIALS) || (notification.code === WiFiState.WIFI_STATE_SSID_CHANGED)) { + NetworkManager.RemoveKnownSSID().then(() => { + this.LOG("INVALID_CREDENTIALS; deleting WiFi Persistence data.") + PersistentStoreApi.get().deleteNamespace('wifi') + }); + } + this.tag("FailScreen").notify({ title: Language.translate('WiFi Status'), msg: `${Language.translate("Error Code :")} ${notification.state} \t ${Language.translate("Error Msg :")} ${Language.translate(Object.keys(WiFiState).find(key=>WiFiState[key]===notification.state))}` }) + this._setState('FailScreen'); - this.onErrorHandler = WiFi.get().thunder.on(WiFi.get().callsign, 'onError', notification => { - if ((notification.code === WiFiError.INVALID_CREDENTIALS) || (notification.code === WiFiError.SSID_CHANGED)) { - WiFi.get().clearSSID().then(() => { - console.log("INVALID_CREDENTIALS; deleting WiFi Persistence data.") - PersistentStoreApi.get().deleteNamespace('wifi') - }); - } - this.tag("FailScreen").notify({ title: 'WiFi Status', msg: Language.translate(`Error Code : ${notification.code} \t Error Msg : ${WiFiErrorMessages[notification.code]}`) }) - this._setState('FailScreen'); + } }) } async _focus() { - await Network.get().isInterfaceEnabled("WIFI").then(enabled => { + await NetworkManager.GetInterfaceState("wlan0").then(enabled => { this.wifiStatus = enabled this._setState('Switch') if (this.wifiStatus) { - this.wifiLoading.play() + this.wifiLoading.start() this.tag('Switch.Loader').visible = true this.tag('Networks').visible = true this.tag('JoinAnotherNetwork').visible = true - WiFi.get().startScan() + NetworkManager.StartWiFiScan() } else { this.wifiLoading.stop() this.tag('Switch.Loader').visible = false @@ -231,9 +240,9 @@ export default class WiFiScreen extends Lightning.Component { _inactive() { if (this.wifiStatus) { - WiFi.get().stopScan() + NetworkManager.StopWiFiScan() } else { - console.log("check - not calling stopScan since this.wifiStatus is FALSE.") + this.LOG("check - not calling stopScan since this.wifiStatus is FALSE.") } if (this.onWIFIStateChangedHandler) this.onWIFIStateChangedHandler.dispose(); if (this.onErrorHandler) this.onErrorHandler.dispose(); @@ -241,16 +250,16 @@ export default class WiFiScreen extends Lightning.Component { } async renderDeviceList(ssids) { - console.log("WIFI Overlay renderDeviceList ssids.length:", ssids.length) + this.LOG("WIFI Overlay renderDeviceList ssids.length: " + JSON.stringify(ssids.length)) this._pairedList = []; this.tag('Networks.PairedNetworks').h = 0; this.tag('Networks.AvailableNetworks').tag('List').rollMax = ssids.length * 90 this.tag('Networks.PairedNetworks').tag('List').items = [] this.tag('Networks.PairedNetworks').tag('List').h = 0 - await WiFi.get().getCurrentState().then(async (state) => { - if (state === WiFiState.CONNECTED) { - await WiFi.get().getConnectedSSID().then(result => { + await NetworkManager.GetWifiState().then(async (state) => { + if (state === WiFiState.WIFI_STATE_CONNECTED) { + await NetworkManager.GetConnectedSSID().then(result => { if (result.ssid != '') { console.log("Connected network detected " + JSON.stringify(result.ssid)) this._pairedList = [result] @@ -363,50 +372,37 @@ export default class WiFiScreen extends Lightning.Component { this._navigate('AvailableDevices', 'up') } async _handleEnter() { - console.log("SSID check" + JSON.stringify(this.tag('Networks.AvailableNetworks').tag('List').element._item)) + this.LOG("SSID check" + JSON.stringify(this.tag('Networks.AvailableNetworks').tag('List').element._item)) this.ListItem = this.tag('Networks.AvailableNetworks').tag('List').element._item - await WiFi.get().isPaired().then(ispaired => { - if (!ispaired) { // ispaired.result == 0 means saved SSID. - WiFi.get().getPairedSSID().then(pairedssid => { - if (pairedssid === this.ListItem.ssid) { - console.log("WiFiScreen getPairedSSID matched with current selection; try auto connect."); - WiFi.get().connect(true).then(() => { - WiFi.get().thunder.on('onError', notification => { - if (notification.code === WiFiError.SSID_CHANGED || notification.code === WiFiError.INVALID_CREDENTIALS) { - WiFi.get().clearSSID().then(() => { + await NetworkManager.GetKnownSSIDs().then(ssids => { + if (ssids.length) { // ispaired.result == 0 means saved SSID. + if (ssids.includes(this.ListItem.ssid)) { + this.LOG("WiFiScreen getPairedSSID matched with current selection; try auto connect."); + NetworkManager.WiFiConnect(true).then(() => { + NetworkManager.thunder.on('onWiFiStateChange', notification => { + if (notification.code === WiFiState.WIFI_STATE_SSID_CHANGED || notification.code === WiFiState.WIFI_STATE_INVALID_CREDENTIALS) { + + NetworkManager.RemoveKnownSSID(this.ListItem).then(() => { this._setState("WifiPairingScreen") }) } }) - WiFi.get().thunder.on('onWIFIStateChanged', notification => { - if (notification.state === WiFiState.CONNECTED) { - Network.get().setDefaultInterface("WIFI").then(() => { - console.log("Successfully set WIFI as default interface.") - }).catch(err => { - console.error("Could not set WIFI as default interface." + JSON.stringify(err)) - }); - } - }) }).catch(err => { - console.error("WiFiScreen auto-connect error:", JSON.stringify(err)); + this.ERR("WiFiScreen auto-connect error:" + JSON.stringify(err)); PersistentStoreApi.get().deleteKey('wifi', 'SSID').then(() => { this._setState("WifiPairingScreen") }) }) } else { - console.log("WiFiScreen getPairedSSID differs with current selection."); + this.LOG("WiFiScreen getPairedSSID differs with current selection."); this._setState("WifiPairingScreen") } - }).catch(err => { - console.error("WiFi.getPairedSSID() error: ", JSON.stringify(err)); - this._setState("WifiPairingScreen") - }); } else { - console.log("WiFi.isPaired() is false; attempting regular connect."); + this.LOG("WiFi.GetKnownSSIDs() is false; attempting regular connect."); this._setState("WifiPairingScreen") } }).catch(err => { - console.error("WiFi.isPaired() error: ", JSON.stringify(err)); + this.ERR("WiFi.GetKnownSSIDs() error: " + JSON.stringify(err)); PersistentStoreApi.get().deleteKey('wifi', 'SSID').then(() => { this._setState("WifiPairingScreen") }) @@ -438,7 +434,7 @@ export default class WiFiScreen extends Lightning.Component { }, class JoinAnotherNetworkOverlay extends this { $enter() { - console.log("wifiscreen JoinAnotherNetworkOverlay") + this.LOG("wifiscreen JoinAnotherNetworkOverlay") this.hide() this.fireAncestors('$hideBreadCrum') this.tag('JoinAnotherNetworkOverlay').visible = true @@ -458,7 +454,7 @@ export default class WiFiScreen extends Lightning.Component { class WifiPairingScreen extends this { $enter() { - console.log("wifiscreen WifiPairingScreen") + this.LOG("wifiscreen WifiPairingScreen") this.hide() this.fireAncestors('$hideBreadCrum') this.tag('WifiPairingScreen').visible = true @@ -478,7 +474,7 @@ export default class WiFiScreen extends Lightning.Component { class FailScreen extends this { $enter() { - console.log("wifiscreen FailScreen") + this.LOG("wifiscreen FailScreen") this.hide() this.fireAncestors('$hideBreadCrum') this.tag('FailScreen').visible = true @@ -513,7 +509,6 @@ export default class WiFiScreen extends Lightning.Component { } if (list.index < list.length - 1) list.setNext() else if (list.index == list.length - 1) { - //WiFi.get().startScan() if (listname === 'MyDevices' && this.tag('Networks.AvailableNetworks').tag('List').length > 0) { this._setState('AvailableDevices') } @@ -536,10 +531,10 @@ export default class WiFiScreen extends Lightning.Component { async switch() { if (this.wifiStatus) { - console.log("Disabling WIFI interface and plugin.") - this.wifiLoading.start(); + this.LOG("Disabling WIFI interface and plugin.") + this.wifiLoading.play(); this.tag('Switch.Loader').visible = true - await Network.get().setInterfaceEnabled("WIFI", false).then(() => { + await NetworkManager.SetInterfaceState("wlan0", false).then(() => { this.wifiStatus = false this.tag('Networks').visible = false this.tag('JoinAnotherNetwork').visible = false @@ -548,29 +543,27 @@ export default class WiFiScreen extends Lightning.Component { this.tag('Switch.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') }); } else { - console.log("Enabling WIFI interface and plugin.") + this.LOG("Enabling WIFI interface and plugin.") this.tag('JoinAnotherNetwork').visible = true this.tag('Networks.PairedNetworks').tag('List').items = [] this.tag('Networks.AvailableNetworks').tag('List').items = [] this.tag('Switch.Loader').visible = true - this.wifiLoading.start() - await Network.get().setInterfaceEnabled("WIFI", true).then(resp => { - console.log("setInterfaceEnabled WIFI return: ", resp) - WiFi.get().setEnabled().then(() => { + this.wifiLoading.play() + await NetworkManager.SetInterfaceState("wlan0", true).then(resp => { + this.LOG("setInterfaceEnabled WIFI return: " + JSON.stringify(resp)) this.wifiStatus = true this.tag('Networks').visible = true this.tag('JoinAnotherNetwork').visible = true this.tag('Switch.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') - WiFi.get().isPaired().then(ispaired => { - if (!ispaired.result) { - WiFi.get().connect(true) + NetworkManager.GetKnownSSIDs().then(ssids => { + if (ssids.length) { + NetworkManager.WiFiConnect(true) } else { - WiFi.get().startScan() + NetworkManager.startScan() this.tag('Networks.PairedNetworks').tag('List').items = [] this.tag('Networks.AvailableNetworks').tag('List').items = [] } }) - }) }) } } diff --git a/accelerator-home-ui/src/overlays/NetworkScreens/WifiPairingOverlayScreen.js b/accelerator-home-ui/src/overlays/NetworkScreens/WifiPairingOverlayScreen.js index a5a454d..93084ed 100644 --- a/accelerator-home-ui/src/overlays/NetworkScreens/WifiPairingOverlayScreen.js +++ b/accelerator-home-ui/src/overlays/NetworkScreens/WifiPairingOverlayScreen.js @@ -23,9 +23,18 @@ import ConfirmAndCancel from '../../items/ConfirmAndCancel' import PasswordSwitch from '../../screens/PasswordSwitch' import { Keyboard } from '../../ui-components/index' import { KEYBOARD_FORMATS } from '../../ui-components/components/Keyboard' -import WiFi from '../../api/WifiApi' +import NetworkManager from '../../api/NetworkManagerAPI' +import FailComponent from './FailComponent' export default class WifiPairingScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { PairingScreen: { @@ -109,6 +118,10 @@ export default class WifiPairingScreen extends Lightning.Component { formats: KEYBOARD_FORMATS.qwerty } }, + FailScreen: { + type: FailComponent, + visible: false + } } } @@ -163,27 +176,35 @@ export default class WifiPairingScreen extends Lightning.Component { this.fireAncestors("$navigateBack") } else if (option === 'Connect') { if (this._item) { - console.log('trying to connect wifi') + this.LOG("trying to connect wifi") this.startConnect(this.passwd) } } else if (option === 'Disconnect') { - WiFi.get().disconnect().then(() => { + NetworkManager.WiFiDisconnect().then(() => { this.fireAncestors("$navigateBack") }) } } startConnect(password = "") { - WiFi.get().connect(false, this._item, password).then(() => { - WiFi.get().saveSSID(this._item.ssid, password, this._item.security).then(() => { - console.log('Started connect and saved SSID; going back now.') + NetworkManager.WiFiConnect(false, this._item, password).then(() => { + NetworkManager.AddToKnownSSIDs(this._item.ssid, password, this._item.security).then(() => { + this.LOG("Started connect and saved SSID; going back now.") this.fireAncestors("$navigateBack") }); }).catch(err => { - console.log('Not able to connect to wifi', JSON.stringify(err)) - this.fireAncestors("$navigateBack") + this.ERR("Not able to connect to wifi: " + JSON.stringify(err)) + this.tag("FailScreen").notify({ title: 'WiFi Status', msg: Language.translate(`Wificonnect API response: ${err}`) }) + this._setState('FailScreen'); }); } + hide() { + this.tag('PairingScreen').visible = false + } + + show() { + this.tag('PairingScreen').visible = true + } static _states() { return [ @@ -205,7 +226,7 @@ export default class WifiPairingScreen extends Lightning.Component { this.star = this.star.substring(0, this.star.length - 1); this._updateText(this.hidePasswd ? this.star : this.passwd) } else if (key === '#@!' || key === 'abc' || key === 'áöû' || key === 'shift') { - console.log('no saving') + this.LOG("no saving") } else if (key === 'Space') { this.star += '\u25CF' this.passwd += ' ' @@ -277,6 +298,25 @@ export default class WifiPairingScreen extends Lightning.Component { $exit() { this.tag("PasswordBox").texture = Lightning.Tools.getRoundRect(1279, 88, 0, 3, 0xffffffff, false) } + }, + class FailScreen extends this { + $enter() { + this.hide() + this.tag('FailScreen').visible = true + } + $exit() { + this.show() + this.tag('FailScreen').visible = false + } + _getFocused() { + return this.tag('FailScreen') + } + _handleBack() { + this.fireAncestors("$navigateBack") + } + _handleEnter() { + this.fireAncestors("$navigateBack") + } } ] } diff --git a/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js index 273e782..26d46bc 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js @@ -28,321 +28,328 @@ */ export default class AdvanceSettingsScreen extends Lightning.Component { - static _template() { - return { - AdvanceScreenContents: { - x: 200, - y: 275, - TTSOptions: { - alpha: 0.3, // disabled - type: SettingsMainItem, - Title: { - x: 10, - y: 45, - mountY: 0.5, - text: { - text: Language.translate('TTS Options'), - textColor: COLORS.titleColor, - fontFace: CONFIG.language.font, - fontSize: 25, - } - }, - Button: { - h: 45, - w: 45, - x: 1600, - mountX: 1, - y: 45, - mountY: 0.5, - src: Utils.asset('images/settings/Arrow.png'), - }, - }, - CECControl: { - y: 90, - // alpha: 0.3, // disabled - type: SettingsMainItem, - Title: { - x: 10, - y: 45, - mountY: 0.5, - text: { - text: Language.translate('CEC Control'), - textColor: COLORS.titleColor, - fontFace: CONFIG.language.font, - fontSize: 25, - } - }, - Button: { - h: 45, - w: 67, - x: 1600, - mountX: 1, - y: 45, - mountY: 0.5, - src: Utils.asset('images/settings/ToggleOffWhite.png'), - }, - }, - Bug: { - y: 180, - alpha: 0.3, // disabled - type: SettingsMainItem, - Title: { - x: 10, - y: 45, - mountY: 0.5, - text: { - text: Language.translate('Bug Report'), - textColor: COLORS.titleColor, - fontFace: CONFIG.language.font, - fontSize: 25, - } - }, - Button: { - h: 45, - w: 45, - x: 1600, - mountX: 1, - y: 45, - mountY: 0.5, - src: Utils.asset('images/settings/Arrow.png'), - }, - }, - Contact: { - alpha: 0.3, // disabled - y: 270, - type: SettingsMainItem, - Title: { - x: 10, - y: 45, - mountY: 0.5, - text: { - text: Language.translate('Contact Support'), - textColor: COLORS.titleColor, - fontFace: CONFIG.language.font, - fontSize: 25, - } - }, - Button: { - h: 45, - w: 45, - x: 1600, - mountX: 1, - y: 45, - mountY: 0.5, - src: Utils.asset('images/settings/Arrow.png'), - }, - }, - Device: { - y: 360, - type: SettingsMainItem, - Title: { - x: 10, - y: 45, - mountY: 0.5, - text: { - text: Language.translate('Device'), - textColor: COLORS.titleColor, - fontFace: CONFIG.language.font, - fontSize: 25, - } - }, - Button: { - h: 45, - w: 45, - x: 1600, - mountX: 1, - y: 45, - mountY: 0.5, - src: Utils.asset('images/settings/Arrow.png'), - }, - }, - }, - DeviceScreen:{ + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { + return { + AdvanceScreenContents: { + x: 200, + y: 275, + TTSOptions: { + alpha: 0.3, // disabled + type: SettingsMainItem, + Title: { + x: 10, + y: 45, + mountY: 0.5, + text: { + text: Language.translate('TTS Options'), + textColor: COLORS.titleColor, + fontFace: CONFIG.language.font, + fontSize: 25, + } + }, + Button: { + h: 45, + w: 45, + x: 1600, + mountX: 1, + y: 45, + mountY: 0.5, + src: Utils.asset('images/settings/Arrow.png'), + }, + }, + CECControl: { + y: 90, + // alpha: 0.3, // disabled + type: SettingsMainItem, + Title: { + x: 10, + y: 45, + mountY: 0.5, + text: { + text: Language.translate('CEC Control'), + textColor: COLORS.titleColor, + fontFace: CONFIG.language.font, + fontSize: 25, + } + }, + Button: { + h: 45, + w: 67, + x: 1600, + mountX: 1, + y: 45, + mountY: 0.5, + src: Utils.asset('images/settings/ToggleOffWhite.png'), + }, + }, + Bug: { + y: 180, + alpha: 0.3, // disabled + type: SettingsMainItem, + Title: { + x: 10, + y: 45, + mountY: 0.5, + text: { + text: Language.translate('Bug Report'), + textColor: COLORS.titleColor, + fontFace: CONFIG.language.font, + fontSize: 25, + } + }, + Button: { + h: 45, + w: 45, + x: 1600, + mountX: 1, + y: 45, + mountY: 0.5, + src: Utils.asset('images/settings/Arrow.png'), + }, + }, + Contact: { + alpha: 0.3, // disabled + y: 270, + type: SettingsMainItem, + Title: { + x: 10, + y: 45, + mountY: 0.5, + text: { + text: Language.translate('Contact Support'), + textColor: COLORS.titleColor, + fontFace: CONFIG.language.font, + fontSize: 25, + } + }, + Button: { + h: 45, + w: 45, + x: 1600, + mountX: 1, + y: 45, + mountY: 0.5, + src: Utils.asset('images/settings/Arrow.png'), + }, + }, + Device: { + y: 360, + type: SettingsMainItem, + Title: { + x: 10, + y: 45, + mountY: 0.5, + text: { + text: Language.translate('Device'), + textColor: COLORS.titleColor, + fontFace: CONFIG.language.font, + fontSize: 25, + } + }, + Button: { + h: 45, + w: 45, + x: 1600, + mountX: 1, + y: 45, + mountY: 0.5, + src: Utils.asset('images/settings/Arrow.png'), + }, + }, + }, + DeviceScreen:{ type: DeviceScreen, visible: false - } - } - - } - - _init() { - this.cecApi = new CECApi() - this.cecApi.activate() - .then(() => { - this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') - this.performOTPAction() - }) - this._setState('CECControl') - } - _focus() { + } + } + + } + + _init() { + this.cecApi = new CECApi() + this.cecApi.activate() + .then(() => { + this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') + this.performOTPAction() + }) this._setState('CECControl') - } - performOTPAction() { - this.cecApi.setEnabled().then(res => { - if (res.success) { - this.cecApi.performOTP().then(otpRes => { - if (otpRes.success) { - console.log('Otp Action success full') - } - }) - } - }) - } - - toggleCEC() { - this.cecApi.getEnabled() - .then(res => { - console.log(res) - if (res.enabled) { - this.cecApi.deactivate() - .then(() => { - this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') - }) - } - else { - this.cecApi.activate() - .then(() => { - this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') - }) - } - }) - } + } + _focus() { + this._setState('CECControl') + } + performOTPAction() { + this.cecApi.setEnabled().then(res => { + if (res.success) { + this.cecApi.performOTP().then(otpRes => { + if (otpRes.success) { + this.LOG('Otp Action success full') + } + }) + } + }) + } - - hide() { - this.tag('AdvanceScreenContents').visible = false - - } + toggleCEC() { + this.cecApi.getEnabled() + .then(res => { + this.LOG("toggleCEC getEnabled result: " + JSON.stringify(res)) + if (res.enabled) { + this.cecApi.deactivate() + .then(() => { + this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + }) + } + else { + this.cecApi.activate() + .then(() => { + this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') + }) + } + }) + } - show() { - this.tag('AdvanceScreenContents').visible = true - } - static _states() { - return [ - class UIVoice extends this{ - $enter() { - this.tag('UIVoice')._focus() - } - $exit() { - this.tag('UIVoice')._unfocus() - } - _handleUp() { - //this._setState('Reset'); - } - _handleDown() { - //this._setState('TTSOptions') - } - _handleEnter() { - - } - }, - class TTSOptions extends this{ - $enter() { - this.tag('TTSOptions')._focus() - } - $exit() { - this.tag('TTSOptions')._unfocus() - } - _handleUp() { - //this._setState('UIVoice'); - } - _handleDown() { - //this._setState('CECControl') - } - _handleEnter() { - - } - }, - class CECControl extends this{ - $enter() { - this.tag('CECControl')._focus() - } - $exit() { - this.tag('CECControl')._unfocus() - } - _handleUp() { - //this._setState('TTSOptions'); - } - _handleDown() { - this._setState('Device') - } - _handleEnter() { - this.toggleCEC() - } - }, - class Bug extends this{ - $enter() { - this.tag('Bug')._focus() - } - $exit() { - this.tag('Bug')._unfocus() - } - _handleUp() { - //this._setState('CECControl'); - } - _handleDown() { - //this._setState('Contact') - } - _handleEnter() { - - } - }, - class Contact extends this{ - $enter() { - this.tag('Contact')._focus() - } - $exit() { - this.tag('Contact')._unfocus() - } - _handleUp() { - //this._setState('Bug'); - } - _handleDown() { - //this._setState('Device') - } - _handleEnter() { - - } - }, - class Device extends this{ - $enter() { - this.tag('Device')._focus() - } - $exit() { - this.tag('Device')._unfocus() - } - _handleUp() { - this._setState('CECControl'); - } - _handleDown() { - //this._setState('UI Voice') - } - _handleEnter() { + + hide() { + this.tag('AdvanceScreenContents').visible = false + + } + + show() { + this.tag('AdvanceScreenContents').visible = true + } + static _states() { + return [ + class UIVoice extends this{ + $enter() { + this.tag('UIVoice')._focus() + } + $exit() { + this.tag('UIVoice')._unfocus() + } + _handleUp() { + //this._setState('Reset'); + } + _handleDown() { + //this._setState('TTSOptions') + } + _handleEnter() { + + } + }, + class TTSOptions extends this{ + $enter() { + this.tag('TTSOptions')._focus() + } + $exit() { + this.tag('TTSOptions')._unfocus() + } + _handleUp() { + //this._setState('UIVoice'); + } + _handleDown() { + //this._setState('CECControl') + } + _handleEnter() { + + } + }, + class CECControl extends this{ + $enter() { + this.tag('CECControl')._focus() + } + $exit() { + this.tag('CECControl')._unfocus() + } + _handleUp() { + //this._setState('TTSOptions'); + } + _handleDown() { + this._setState('Device') + } + _handleEnter() { + this.toggleCEC() + } + }, + class Bug extends this{ + $enter() { + this.tag('Bug')._focus() + } + $exit() { + this.tag('Bug')._unfocus() + } + _handleUp() { + //this._setState('CECControl'); + } + _handleDown() { + //this._setState('Contact') + } + _handleEnter() { + + } + }, + class Contact extends this{ + $enter() { + this.tag('Contact')._focus() + } + $exit() { + this.tag('Contact')._unfocus() + } + _handleUp() { + //this._setState('Bug'); + } + _handleDown() { + //this._setState('Device') + } + _handleEnter() { + + } + }, + class Device extends this{ + $enter() { + this.tag('Device')._focus() + } + $exit() { + this.tag('Device')._unfocus() + } + _handleUp() { + this._setState('CECControl'); + } + _handleDown() { + //this._setState('UI Voice') + } + _handleEnter() { this._setState("DeviceScreen") - } - }, - class DeviceScreen extends this { + } + }, + class DeviceScreen extends this { $enter() { - ////console.log("bpscreen") - this.hide() - this.tag('DeviceScreen').visible = true - this.fireAncestors("$updatePageTitle",'Settings Other Settings Advanced Settings Device') + //this.LOG("bpscreen") + this.hide() + this.tag('DeviceScreen').visible = true + this.fireAncestors("$updatePageTitle",'Settings Other Settings Advanced Settings Device') } _getFocused() { - //console.log("getfocusedbp") - return this.tag('DeviceScreen') + //this.LOG("getfocusedbp") + return this.tag('DeviceScreen') } $exit() { - this.show() - this.tag('DeviceScreen').visible = false - this.fireAncestors("$updatePageTitle",'Settings Other Settings ') + this.show() + this.tag('DeviceScreen').visible = false + this.fireAncestors("$updatePageTitle",'Settings Other Settings ') } _handleBack() { - this._setState('Device') + this._setState('Device') } - }, - ] - } - - + }, + ] + } + + } \ No newline at end of file diff --git a/accelerator-home-ui/src/overlays/OtherSettings/DeviceInformationOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/DeviceInformationOverlay.js index dc38144..a283fef 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/DeviceInformationOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/DeviceInformationOverlay.js @@ -20,13 +20,19 @@ import { Lightning, Language, Settings, Storage } from '@lightningjs/sdk' import { COLORS } from '../../colors/Colors' import { CONFIG, GLOBALS } from '../../Config/Config' import AppApi from '../../api/AppApi.js'; -import NetworkApi from '../../api/NetworkApi' import FireBoltApi from '../../api/firebolt/FireBoltApi'; /** * Class for Video and Audio screen. */ export default class DeviceInformationScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { DeviceInfoWrapper: { @@ -183,7 +189,6 @@ export default class DeviceInformationScreen extends Lightning.Component { } _init() { - this._network = new NetworkApi(); this.appApi = new AppApi(); } @@ -198,19 +203,19 @@ export default class DeviceInformationScreen extends Lightning.Component { this.appApi.getSystemVersions().then(res => { this.tag('FirmwareVersions.Value').text.text = `UI Version - ${Settings.get('platform', 'version')} \nBuild Version - ${res.stbVersion} \nTime Stamp - ${res.stbTimestamp} ` }).catch(err => { - console.error(`error while getting the system versions` + JSON.stringify(err)) + this.ERR("error while getting the system versions" + JSON.stringify(err)) }) } else { FireBoltApi.get().deviceinfo.getversion().then(res => { - console.log(`build verion${res.firmware.readable} Firebolt API Version - ${res.api.readable}`) + this.LOG("build verion" + JSON.stringify(res.firmware.readable) + " Firebolt API Version - " + JSON.stringify(res.api.readable)) this.tag('FirmwareVersions.Value').text.text = `UI Version - ${Settings.get('platform', 'version')} \nBuild Version - ${res.firmware.readable} \nFirebolt API Version - ${res.api.readable} ` }).catch(err => { - console.error(`error while getting the system versions from Firebolt.getversion API` + JSON.stringify(err)) + this.ERR("error while getting the system versions from Firebolt.getversion API" + JSON.stringify(err)) }) } this.appApi.getDRMS().then(result => { - console.log('from device info supported drms ' + JSON.stringify(result)) + this.LOG("from device info supported drms " + JSON.stringify(result)) let drms = "" result.forEach(element => { drms += `${element.name} :` @@ -235,37 +240,37 @@ export default class DeviceInformationScreen extends Lightning.Component { self.appApi.getPluginStatus('Netflix') .then(result => { let sel = self; - console.log(`Netflix : plugin status : `, JSON.stringify(result)); + this.LOG("Netflix : plugin status : " + JSON.stringify(result)); if (result[0].state === 'deactivated' || result[0].state === 'deactivation') { sel.appApi.launchPremiumAppInSuspendMode("Netflix").then(res => { - console.log("Netflix : netflix launch for esn value in suspend mode returns : ", JSON.stringify(res)); + this.LOG("Netflix : netflix launch for esn value in suspend mode returns : " + JSON.stringify(res)); let se = sel; se.appApi.getNetflixESN() .then(res => { Storage.set('Netflix_ESN', res) - console.log(`Netflix : netflix esn call returns : `, JSON.stringify(res)); + this.LOG("Netflix : netflix esn call returns : " + JSON.stringify(res)); se.netflixESN = `YouTube: NA \nAmazon Prime: NA \nNetflix ESN: ${res}` }) .catch(err => { - console.error(`Netflix : error while getting netflix esn : `, JSON.stringify(err)) + this.ERR("Netflix : error while getting netflix esn : " + JSON.stringify(err)) }) }).catch(err => { - console.error(`Netflix : error while launching netflix in suspendMode : `, JSON.stringify(err)) + this.ERR("Netflix : error while launching netflix in suspendMode : " + JSON.stringify(err)) }) } else { self.appApi.getNetflixESN() .then(res => { Storage.set('Netflix_ESN', res) - console.log(`Netflix : netflix esn call returns : `, JSON.stringify(res)); + this.LOG("Netflix : netflix esn call returns : " + JSON.stringify(res)); self.netflixESN = `YouTube: NA \nAmazon Prime: NA \nNetflix ESN: ${res}`; }) .catch(err => { - console.error(`Netflix : error while getting netflix esn : `, JSON.stringify(err)) + this.ERR("Netflix : error while getting netflix esn : " + JSON.stringify(err)) }) } }).catch(err => { - console.error(`Netflix : error while getting netflix plugin status ie. `, JSON.stringify(err)) + this.ERR("Netflix : error while getting netflix plugin status ie. " + JSON.stringify(err)) }) } @@ -273,7 +278,7 @@ export default class DeviceInformationScreen extends Lightning.Component { } set netflixESN(v) { - console.log(`setting netflix ESN value to ${v}`); + this.LOG("setting netflix ESN value to " + JSON.stringify(v)); this.tag('AppVersions.Value').text.text = v; } diff --git a/accelerator-home-ui/src/overlays/OtherSettings/FirmWareOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/FirmWareOverlay.js index cbebadc..284355f 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/FirmWareOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/FirmWareOverlay.js @@ -29,6 +29,13 @@ import { Metrics } from '@firebolt-js/sdk'; const thunder = ThunderJS(CONFIG.thunderConfig) export default class FirmwareScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { FirmwareContents: { @@ -111,11 +118,11 @@ export default class FirmwareScreen extends Lightning.Component { thunder.Controller.activate({ callsign: "org.rdk.System" }) .then(() => { thunder.on("org.rdk.System", "onFirmwareUpdateStateChange", notification => { - console.log(`FirmwareOverlay: on Firmware update state changed notifcation = ${JSON.stringify(notification)}`); + this.LOG("FirmwareOverlay: on Firmware update state changed notifcation = " + JSON.stringify(notification)); if (state[notification.firmwareUpdateStateChange] == "Downloading") { this.downloadInterval = setInterval(() => { - console.log(`Downloading...`); + this.LOG("Downloading..."); this.getDownloadPercent(); }, 1000) } else if (state[notification.firmwareUpdateStateChange] != "Downloading" && this.downloadInterval) { @@ -123,12 +130,12 @@ export default class FirmwareScreen extends Lightning.Component { this.downloadInterval = null } }, err => { - console.error(`FirmwareOverlay: error while fetching notification ie. ${err}`) + this.ERR("FirmwareOverlay: error while fetching notification ie. " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"PluginError", "Thunder system error while fetching onFirmwareUpdateStateChange notification "+JSON.stringify(err), false, null) }) }) .catch(err => { - console.error(`FirmwareOverlay: error while activating the system plugin` + JSON.stringify(err)) + this.ERR("FirmwareOverlay: error while activating the system plugin" + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER,"PluginError", "Thunder Controller.activate system error "+JSON.stringify(err), false, null) }) @@ -145,16 +152,16 @@ export default class FirmwareScreen extends Lightning.Component { let state = ['Uninitialized', 'Requesting', 'Downloading', 'Failed', 'DownLoad Complete', 'Validation Complete', 'Preparing to Reboot'] this.onFirmwareUpdateStateChangeCB = thunder.on('org.rdk.System', 'onFirmwareUpdateStateChange', notification => { this.tag('State.Title').text.text = Language.translate("Firmware State: ") + state[notification.firmwareUpdateStateChange] - console.log('onFirmwareUpdateStateChange:' + JSON.stringify(notification)); + this.LOG("onFirmwareUpdateStateChange:" + JSON.stringify(notification)); if (state[notification.firmwareUpdateStateChange] === "Downloading") { this.downloadInterval = setInterval(() => { - console.log(`Downloading...`); + this.LOG("Downloading..."); this.getDownloadPercent(); }, 1000) } else if (state[notification.firmwareUpdateStateChange] != "Downloading") { this.tag('DownloadedPercent.Title').visible = false; if (this.downloadInterval) { - console.log(""); + this.LOG(""); clearInterval(this.downloadInterval); this.downloadInterval = null } @@ -165,7 +172,7 @@ export default class FirmwareScreen extends Lightning.Component { showDownloadPercentage() { this.downloadInterval = setInterval(() => { - console.log(`showDownloadPercentage Downloading...`); + this.LOG("showDownloadPercentage Downloading..."); this.getDownloadPercent(); }, 1000) } @@ -179,7 +186,7 @@ export default class FirmwareScreen extends Lightning.Component { this._appApi = new AppApi(); const downloadState = ['Uninitialized', 'Requesting', 'Downloading', 'Failed', 'DownLoad Complete', 'Validation Complete', 'Preparing to Reboot'] await this._appApi.getFirmwareUpdateState().then(res => { - console.log("FirmwareOverlay: getFirmwareUpdateState " + JSON.stringify(res)) + this.LOG("FirmwareOverlay: getFirmwareUpdateState " + JSON.stringify(res)) this.tag('State.Title').text.text = Language.translate("Firmware State: ") + downloadState[res.firmwareUpdateState] if (res.firmwareUpdateState === "Downloading") { this.showDownloadPercentage(); @@ -187,7 +194,7 @@ export default class FirmwareScreen extends Lightning.Component { }) this._appApi.getDownloadFirmwareInfo().then(res => { - console.log("FirmwareOverlay: getDownloadFirmwareInfo " + JSON.stringify(res)) + this.LOG("FirmwareOverlay: getDownloadFirmwareInfo " + JSON.stringify(res)) this.tag('Version.Title').text.text = Language.translate("Firmware Versions: ") + res.currentFWVersion }) this._setState('FirmwareUpdate') @@ -196,7 +203,7 @@ export default class FirmwareScreen extends Lightning.Component { getDownloadPercent() { this._appApi = new AppApi(); this._appApi.getFirmwareDownloadPercent().then(res => { - console.log(`FirmwareOverlay: getFirmwareDownloadPercent ${JSON.stringify(res)}`); + this.LOG("FirmwareOverlay: getFirmwareDownloadPercent " + JSON.stringify(res)); if (res.downloadPercent < 0) { this.tag('DownloadedPercent.Title').visible = false; this.tag('DownloadedPercent.Title').text.text = ""; @@ -211,7 +218,7 @@ export default class FirmwareScreen extends Lightning.Component { } } }).catch(err => { - console.error(err); + this.ERR("getDownloadperecent error:"+ JSON.stringify(err)); }) } @@ -219,13 +226,13 @@ export default class FirmwareScreen extends Lightning.Component { this._appApi = new AppApi(); this._appApi.updateFirmware().then(() => { this._appApi.getDownloadFirmwareInfo().then(result => { - console.log(`FirmwareOverlay: getDownloadFirmwareInfo : ${JSON.stringify(result.downloadFWVersion)}`); + this.LOG("FirmwareOverlay: getDownloadFirmwareInfo : " + JSON.stringify(result.downloadFWVersion)); this.tag('DownloadedVersion.Title').text.text = Language.translate('Downloaded Firmware Version: ') + `${result.downloadFWVersion ? result.downloadFWVersion : 'NA'}` }).catch(err => { - console.error(err); + this.ERR("getDownloadFirmwareInfo error" + JSON.stringify(err)); }) }).catch(err => { - console.error(err); + this.ERR("updateFirmware error" + JSON.stringify(err)); }) } diff --git a/accelerator-home-ui/src/overlays/OtherSettings/LanguageScreenOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/LanguageScreenOverlay.js index d9e1e2d..19bcf30 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/LanguageScreenOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/LanguageScreenOverlay.js @@ -31,6 +31,14 @@ const thunder = thunderJS(CONFIG.thunderConfig) const loader = 'Loader' export default class LanguageScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { LanguageScreenContents: { @@ -67,14 +75,14 @@ export default class LanguageScreen extends Lightning.Component { } }) RDKShellApis.destroy(loader).catch(err => { - console.log("LanguageScreenOverlay: Error destroy loader: " + JSON.stringify(err)) + this.ERR("LanguageScreenOverlay: Error destroy loader: " + JSON.stringify(err)) }); RDKShellApis.setVisibility(GLOBALS.selfClientName, true); RDKShellApis.moveToFront(GLOBALS.selfClientName); RDKShellApis.setFocus(GLOBALS.selfClientName).then(() => { - console.log('LanguageScreenOverlay: ResidentApp moveToFront Success'); + this.LOG('LanguageScreenOverlay: ResidentApp moveToFront Success'); }).catch(err => { - console.log('LanguageScreenOverlay: Error', err); + this.ERR('LanguageScreenOverlay: Error: ' + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "PluginError", "Thunder RDKShell Failed to moveToFront " + JSON.stringify(err), false, null) }); } @@ -102,7 +110,7 @@ export default class LanguageScreen extends Lightning.Component { if (Language.get() !== availableLanguages[this._Languages.tag('List').index]) { let updatedLanguage = availableLanguageCodes[availableLanguages[this._Languages.tag('List').index]] if ("ResidentApp" !== GLOBALS.selfClientName) { - FireBoltApi.get().localization.setlanguage(availableLanguages[this._Languages.tag('List').index]).then(res => console.log(`language set successfully`)) + FireBoltApi.get().localization.setlanguage(availableLanguages[this._Languages.tag('List').index]).then(res => this.LOG("language set successfully")) } else { appApi.setUILanguage(updatedLanguage) } @@ -110,9 +118,9 @@ export default class LanguageScreen extends Lightning.Component { let path = location.pathname.split('index.html')[0] let url = path.slice(-1) === '/' ? "static/loaderApp/index.html" : "/static/loaderApp/index.html" let notification_url = location.origin + path + url - console.log(notification_url) + this.LOG(notification_url) appApi.launchResident(notification_url, loader).catch(err => { - console.log("Error launchResident: " + JSON.stringify(err)) + this.ERR("Error launchResident: " + JSON.stringify(err)) }) RDKShellApis.setVisibility(GLOBALS.selfClientName, false) location.reload(); diff --git a/accelerator-home-ui/src/overlays/OtherSettings/PrivacyScreenOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/PrivacyScreenOverlay.js index 64abff9..61912ac 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/PrivacyScreenOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/PrivacyScreenOverlay.js @@ -20,17 +20,27 @@ import AppApi from '../../api/AppApi' import { Lightning, Utils, Storage, Language } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' -import { CONFIG } from '../../Config/Config' +import { CONFIG, GLOBALS } from '../../Config/Config' import XcastApi from '../../api/XcastApi' import UsbApi from '../../api/UsbApi' import PrivacyPolicyScreen from './PrivacyPolicyOverlay' +import Warehouse from '../../api/WarehouseApis' +import AlexaApi from '../../api/AlexaApi' /** * Class for Privacy Screen. */ const xcastApi = new XcastApi() +let cookieToggle = false export default class PrivacyScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { PrivacyScreenContents: { @@ -122,6 +132,15 @@ export default class PrivacyScreen extends Lightning.Component { fontSize: 25, } }, + Button: { + h: 45, + w: 67, + x: 1600, + mountX: 1, + y: 45, + mountY: 0.5, + src: Utils.asset('images/settings/ToggleOffWhite.png'), + }, }, PrivacyPolicy: { y: 360, @@ -162,9 +181,9 @@ export default class PrivacyScreen extends Lightning.Component { this.checkLocalDeviceStatus() this.USBApi = new UsbApi() this.AppApi = new AppApi() + this.Warehouse= new Warehouse() } - _focus() { this._setState(this.state) this.checkLocalDeviceStatus() @@ -190,7 +209,7 @@ export default class PrivacyScreen extends Lightning.Component { this.tag('LocalDeviceDiscovery.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') } }).catch(err => { - console.log('xcastApi getEnabled error:' + JSON.stringify(err)); + this.ERR('xcastApi getEnabled error:' + JSON.stringify(err)); this.tag('LocalDeviceDiscovery.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') }) } @@ -213,7 +232,7 @@ export default class PrivacyScreen extends Lightning.Component { } }) .catch(err => { - console.log('Service not active' + JSON.stringify(err)); + this.ERR('Service not active' + JSON.stringify(err)); this.tag('LocalDeviceDiscovery.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') }) } @@ -267,7 +286,7 @@ export default class PrivacyScreen extends Lightning.Component { this.tag('UsbMediaDevices.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') this.widgets.menu.refreshMainView() }).catch(err => { - console.error(`error while disabling the usb plugin = ${err}`) + this.ERR("error while disabling the usb plugin = " + JSON.stringify(err)) this.fireAncestors('$registerUsbMount') }) } else if (_UsbMedia === 'OFF') { @@ -311,10 +330,67 @@ export default class PrivacyScreen extends Lightning.Component { this._setState('PrivacyPolicy') } _handleEnter() { - this.AppApi.clearCache() - .then(() => { - //location.reload(true) - }) + cookieToggle = !cookieToggle + + //TOGGLE BUTTON + if(cookieToggle){ + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate('In Progress') + } + else{ + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + } + + setTimeout(async () => { + if(GLOBALS.AlexaAvsstatus){ + AlexaApi.get().resetAVSCredentials().then((result) => { + this.LOG("Triggering AVS credential reset." + JSON.stringify(result)) + if (result.success) { + AlexaApi.get().setAlexaAuthStatus("AlexaAuthPending"); + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate('Finished') + setTimeout(() => { + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + cookieToggle = !cookieToggle + }, 2000) + } else { + //UNSUCCESSFULL API CALL + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data')+ " - " + Language.translate("Error!") + setTimeout(() => { + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + cookieToggle = !cookieToggle + }, 2000) + } + }) } + else{ + try { + await this.Warehouse.activate() + await this.Warehouse.lightReset() + } + catch (err) { + this.ERR("FactoryReset: warehouse plugin activation failed; feature may not work." + JSON.stringify(err)); + } + this.AppApi.clearCache() + .then(() =>{ + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate('Finished') + setTimeout(() => { + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + cookieToggle = !cookieToggle + }, 2000) + }) + .catch((err) => { + this.ERR("Error clearing cache: " + JSON.stringify(err)); + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate("Error!") + setTimeout(() => { + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + cookieToggle = !cookieToggle + }, 2000) + }) + }}, 2000) } }, class PrivacyPolicy extends this { diff --git a/accelerator-home-ui/src/overlays/OtherSettings/RebootConfirmation.js b/accelerator-home-ui/src/overlays/OtherSettings/RebootConfirmation.js index bfb3934..b064894 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/RebootConfirmation.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/RebootConfirmation.js @@ -25,6 +25,13 @@ const appApi = new AppApi(); * Class for Reboot Confirmation Component. */ export default class RebootConfirmation extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { RebootScreen: { @@ -146,7 +153,7 @@ export default class RebootConfirmation extends Lightning.Component { } _handleEnter() { appApi.reboot("User Trigger").then((result) => { - console.log("device rebooting" + JSON.stringify(result)); + this.LOG("device rebooting" + JSON.stringify(result)); this._setState("Rebooting"); }); } diff --git a/accelerator-home-ui/src/overlays/OtherSettings/SleepTimerOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/SleepTimerOverlay.js index 1a12e07..6d2b62f 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/SleepTimerOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/SleepTimerOverlay.js @@ -20,6 +20,13 @@ import { Lightning, Storage } from '@lightningjs/sdk' import SettingsItem from '../../items/SettingsItem' export default class SleepTimerScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { SleepTimer: { @@ -69,7 +76,7 @@ export default class SleepTimerScreen extends Lightning.Component { this.fireAncestors('$registerInactivityMonitoringEvents').then(() => { this.fireAncestors('$resetSleepTimer', timeoutInterval); }).catch(err => { - console.error(`error while registering the inactivity monitoring event` + JSON.stringify(err)); + this.ERR("error while registering the inactivity monitoring event" + JSON.stringify(err)); }) this._setState('Options') diff --git a/accelerator-home-ui/src/overlays/OtherSettings/TimeZoneOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/TimeZoneOverlay.js index 3eee3c0..4d7606b 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/TimeZoneOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/TimeZoneOverlay.js @@ -6,6 +6,13 @@ import TimeZoneOverlayItem from "../../items/TimeZoneOverlayItem"; import FireBoltApi from "../../api/firebolt/FireBoltApi"; export default class TimeZone extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } /** * @param {object} args */ @@ -86,7 +93,7 @@ export default class TimeZone extends Lightning.Component { } try { - console.log(this.resp, this.zone) + this.LOG("TimeZoneOverlay: resp: " + JSON.stringify(this.resp) + " zone: " + JSON.stringify(this.zone)) delete this.resp.Etc for (const i in this.resp) { if (typeof this.resp[i] === 'object') { @@ -94,10 +101,10 @@ export default class TimeZone extends Lightning.Component { } } } catch (error) { - console.log('no api present', error) + this.ERR("no api present: " + JSON.stringify(error)) } - console.log(data) + this.LOG("TimeZoneOverlay: data: " + JSON.stringify(data)) if (data.length > 1) { this.tag('List').h = data.length * 90 this.tag('List').items = data.map((item, idx) => { diff --git a/accelerator-home-ui/src/overlays/SettingsOverlay.js b/accelerator-home-ui/src/overlays/SettingsOverlay.js index 0f8ed32..1a60174 100644 --- a/accelerator-home-ui/src/overlays/SettingsOverlay.js +++ b/accelerator-home-ui/src/overlays/SettingsOverlay.js @@ -37,6 +37,13 @@ var thunder = ThunderJS(CONFIG.thunderConfig); * Class for settings screen. */ export default class SettingsOverlay extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { Wrapper: { @@ -269,17 +276,17 @@ export default class SettingsOverlay extends Lightning.Component { } _firstActive() { if (Storage.get("NFRStatus")) { - console.log(`Netflix : NFRStatus is found to be enabled`) + this.LOG("Netflix : NFRStatus is found to be enabled") this.tag("NFRStatus.Button").src = "static/images/settings/ToggleOnOrange.png" } else { - console.log(`Netflix : NFRStatus is found to be disabled`) + this.LOG("Netflix : NFRStatus is found to be disabled") this.tag("NFRStatus.Button").src = "static/images/settings/ToggleOffWhite.png" } this.appApi = new AppApi(); this.dtvApi = new DTVApi(); this.dtvPlugin = false; //plugin availability - if (Storage.get("deviceType") != "IpStb") { + if (GLOBALS.deviceType != "IpStb") { this.dtvApi.activate().then(() => { this.dtvPlugin = true; this.tag("DTVSettings").alpha = 1; @@ -288,7 +295,7 @@ export default class SettingsOverlay extends Lightning.Component { } _handleBack() { - console.log("application Type = ", GLOBALS.topmostApp); + this.LOG("application Type = " + JSON.stringify(GLOBALS.topmostApp)); if (GLOBALS.topmostApp === GLOBALS.selfClientName) { if (Router.getActiveHash() === "player" || Router.getActiveHash() === "dtvplayer" || Router.getActiveHash() === "usb/player") { Router.focusPage(); @@ -317,7 +324,7 @@ export default class SettingsOverlay extends Lightning.Component { } $updatePageTitle(title, alreadyTranslated) { - console.log("title", title) + this.LOG("title" + JSON.stringify(title)) if (alreadyTranslated) { this.tag("BreadCrumbs").text.text = title; } else { @@ -451,11 +458,11 @@ export default class SettingsOverlay extends Lightning.Component { thunder.call("Netflix.1", "nfrstatus", { "params": "disable" }).then(nr => { self.tag("NFRStatus.Button").src = "static/images/settings/ToggleOffWhite.png" Storage.set("NFRStatus", false) - console.log(`Netflix : nfr disable updation results in ${nr}`) + self.LOG("Netflix : nfr disable updation results in " + JSON.stringify(nr)) }).catch(nerr => { - console.error(`Netflix : error while updating nfrstatus`) + self.ERR("Netflix : error while updating nfrstatus") Metrics.error(Metrics.ErrorType.OTHER,"PluginError", "Thunder Netflix.1 error disabling nfrstatus "+JSON.stringify(nerr), false, null) - console.error(nerr) + self.ERR(JSON.stringify(nerr)) }) } @@ -464,11 +471,11 @@ export default class SettingsOverlay extends Lightning.Component { thunder.call("Netflix.1", "nfrstatus", { "params": "enable" }).then(nr => { self.tag("NFRStatus.Button").src = "static/images/settings/ToggleOnOrange.png" Storage.set("NFRStatus", true) - console.log(`Netflix : nfr enable results in ${nr}`) + self.LOG("Netflix : nfr enable results in " + JSON.stringify(nr)) }).catch(nerr => { - console.error(`Netflix : error while updating nfrstatus `) + self.ERR("Netflix : error while updating nfrstatus ") Metrics.error(Metrics.ErrorType.OTHER,"PluginError", "Thunder Netflix.1 error enabling nfrstatus "+JSON.stringify(nerr), false, null) - console.error(nerr) + self.ERR("Netflix : nfr enable results in error:" + JSON.stringify(nerr)) }) } diff --git a/accelerator-home-ui/src/overlays/VideoInfoChange/VideoInfoChange.js b/accelerator-home-ui/src/overlays/VideoInfoChange/VideoInfoChange.js index e761406..45604e2 100644 --- a/accelerator-home-ui/src/overlays/VideoInfoChange/VideoInfoChange.js +++ b/accelerator-home-ui/src/overlays/VideoInfoChange/VideoInfoChange.js @@ -3,6 +3,13 @@ import { CONFIG } from "../../Config/Config" import { COLORS } from "../../colors/Colors.js" export default class VideoInfoChange extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { @@ -53,7 +60,7 @@ export default class VideoInfoChange extends Lightning.Component { let txt = this.tag("Title").text.text txt += "\n" + data this.tag("Title").text.text = txt - console.log("write request recieved with data " , data) + this.LOG("write request recieved with data " + JSON.stringify(data)) clearTimeout(this.timer) this.timer = setTimeout(() => { Router.focusPage(); @@ -61,7 +68,7 @@ export default class VideoInfoChange extends Lightning.Component { }, 3000) } else{ - console.log("update request recieved with the data " , data) + this.LOG("update request recieved with the data " + JSON.stringify(data)) this.tag("Title").text.text = data } } @@ -87,7 +94,7 @@ export default class VideoInfoChange extends Lightning.Component { clearTimeout(this.timer) this.timer = null; this.clear() - console.log("Widget handle kEy Trigger") + this.LOG("Widget handle kEy Trigger") } } \ No newline at end of file diff --git a/accelerator-home-ui/src/routes/networkRoutes.js b/accelerator-home-ui/src/routes/networkRoutes.js index 8bf23bb..1f8e091 100644 --- a/accelerator-home-ui/src/routes/networkRoutes.js +++ b/accelerator-home-ui/src/routes/networkRoutes.js @@ -51,7 +51,7 @@ const networkRoutes = [ { path: 'settings/network/interface/wifi/connect', component: WifiPairingScreen, - widgets: ['Volume', "AppCarousel"] + widgets: ['Volume','Fail', "AppCarousel"] }, { path: 'settings/network/interface/wifi/another', diff --git a/accelerator-home-ui/src/screens/AlexaLoginScreen.js b/accelerator-home-ui/src/screens/AlexaLoginScreen.js index f476d90..8bdd9e2 100644 --- a/accelerator-home-ui/src/screens/AlexaLoginScreen.js +++ b/accelerator-home-ui/src/screens/AlexaLoginScreen.js @@ -21,6 +21,13 @@ import { CONFIG } from '../Config/Config' import AlexaApi from '../api/AlexaApi' export default class AlexaLoginScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { Wrapper:{ @@ -133,7 +140,7 @@ export default class AlexaLoginScreen extends Lightning.Component { } async _handleEnter() { if(AlexaApi.get().checkAlexaAuthStatus() != "AlexaUserDenied"){ - console.log("Code coming from AlexaLoginScreen") + this.LOG("Code coming from AlexaLoginScreen") Router.navigate("CodeScreen") } } diff --git a/accelerator-home-ui/src/screens/AppLauncherScreen.js b/accelerator-home-ui/src/screens/AppLauncherScreen.js index d0df5b9..13b76c2 100644 --- a/accelerator-home-ui/src/screens/AppLauncherScreen.js +++ b/accelerator-home-ui/src/screens/AppLauncherScreen.js @@ -26,6 +26,14 @@ import { Metrics } from "@firebolt-js/sdk"; //applauncher screen "will" be responsible for handling all overlays as widget and splash screens for apps(if required) | currently only handles settings overlay widget export default class AppLauncherScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Overlay: { @@ -49,9 +57,9 @@ export default class AppLauncherScreen extends Lightning.Component { //first frame event this.firstFrameListener = this._thunder.on("org.rdk.RDKShell", "onApplicationFirstFrame", (notification) => { - console.log("onApplicationFirstFrame notification from applauncherscreen: ", notification) + this.LOG("onApplicationFirstFrame notification from applauncherscreen: " + JSON.stringify(notification)) if (notification.client === callsign.toLowerCase()) { - console.log("firstframe event triggered hiding splash image"); + this.LOG("firstframe event triggered hiding splash image"); this.tag("SplashImage").src = "" this.tag("SplashImage").visible = false; this.moveApptoFront(callsign); @@ -66,30 +74,29 @@ export default class AppLauncherScreen extends Lightning.Component { //to hide the splash image after 30 sec in case firstframe event failed this.splashTimeout = Registry.setTimeout(() => { - console.log("timeout triggered hiding splash image"); + this.LOG("timeout triggered hiding splash image"); this.tag("SplashImage").src = "" this.tag("SplashImage").visible = false; RDKShellApis.moveToFront(callsign); this.firstFrameListener.dispose(); //dispose the event listener incase event did not trigger till 30s }, 30000) - } } _firstEnable() { - console.log("AppLauncherScreen is enabled for firstTime"); + this.LOG("AppLauncherScreen is enabled for firstTime"); this.splashImages = { "Netflix": 'images/apps/App_Netflix_Splash.png' - }; //mapping between callsigns and splash images + }; this._thunder = ThunderJS(CONFIG.thunderConfig); } _focus() { - console.log("AppLauncherScreen is focused"); + this.LOG("AppLauncherScreen is focused"); } _handleKey() { - console.log("AppLauncherScreen is in focus, returning focus to corresponding app") + this.LOG("AppLauncherScreen is in focus, returning focus to corresponding app") if (GLOBALS.topmostApp === GLOBALS.selfClientName) { //if appLauncher screen is in focus while on residentApp RDKShellApis.moveToFront(GLOBALS.selfClientName); RDKShellApis.setFocus(GLOBALS.selfClientName); diff --git a/accelerator-home-ui/src/screens/BluetoothScreen.js b/accelerator-home-ui/src/screens/BluetoothScreen.js index 0446cce..5d08a70 100644 --- a/accelerator-home-ui/src/screens/BluetoothScreen.js +++ b/accelerator-home-ui/src/screens/BluetoothScreen.js @@ -30,6 +30,14 @@ import { CONFIG } from '../Config/Config' */ export default class BluetoothScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Bluetooth On/Off')); } @@ -571,7 +579,7 @@ export default class BluetoothScreen extends Lightning.Component { } }) .catch(() => { - console.log('Cannot turn off Bluetooth') + this.ERR('Cannot turn off Bluetooth') }) } else { this._bt.enable().then(result => { @@ -585,7 +593,7 @@ export default class BluetoothScreen extends Lightning.Component { } }) .catch(() => { - console.log('Cannot turn on Bluetooth') + this.ERR('Cannot turn on Bluetooth') }) } } @@ -595,7 +603,7 @@ export default class BluetoothScreen extends Lightning.Component { */ _activateBluetooth() { this._bt.activate().then((res) => { - console.log(res) + this.LOG('Bluetooth activate result: ' + JSON.stringify(res)) this._bluetooth = true this._bt.registerEvent('onDiscoveredDevice', () => { this.renderDeviceList() @@ -635,11 +643,10 @@ export default class BluetoothScreen extends Lightning.Component { this.widgets.fail.notify({ title: notification.name, msg: notification.newStatus }) Router.focusWidget('Fail') } - }) }) .catch(err => { - console.log(err) + this.ERR('Bluetooth activate error: ' + JSON.stringify(err)) }) } diff --git a/accelerator-home-ui/src/screens/CameraStreamingScreen.js b/accelerator-home-ui/src/screens/CameraStreamingScreen.js index 465f9c3..9431c68 100644 --- a/accelerator-home-ui/src/screens/CameraStreamingScreen.js +++ b/accelerator-home-ui/src/screens/CameraStreamingScreen.js @@ -20,6 +20,14 @@ import { Lightning, Router, Utils, VideoPlayer, Language } from '@lightningjs/sd import { CONFIG } from '../Config/Config'; export default class CameraStreamingScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Background: { @@ -210,11 +218,11 @@ export default class CameraStreamingScreen extends Lightning.Component { } _handleEnter() { if(this.tag("Switch1.Button").src == "static/images/settings/ToggleOnOrange.png") { - this.tag("Switch1.Button").src = "static/images/settings/ToggleOffWhite.png" - console.log("Switch1 Turned Off"); + this.tag("Switch1.Button").src = "static/images/settings/ToggleOffWhite.png" + this.LOG("Switch1 Turned Off"); } else { this.tag("Switch1.Button").src = "static/images/settings/ToggleOnOrange.png" - console.log("Switch1 Turned On"); + this.LOG("Switch1 Turned On"); } } }, @@ -236,11 +244,11 @@ export default class CameraStreamingScreen extends Lightning.Component { _handleEnter() { if(this.tag("Switch2.Button").src == "static/images/settings/ToggleOnOrange.png") { this.tag("Switch2.Button").src = "static/images/settings/ToggleOffWhite.png" - console.log("Switch2 Turned Off"); - } else { - this.tag("Switch2.Button").src = "static/images/settings/ToggleOnOrange.png" - console.log("Switch2 Turned On"); - } + this.LOG("Switch2 Turned Off"); + } else { + this.tag("Switch2.Button").src = "static/images/settings/ToggleOnOrange.png" + this.LOG("Switch2 Turned On"); + } } }, class Switch3 extends this{ @@ -261,11 +269,11 @@ export default class CameraStreamingScreen extends Lightning.Component { _handleEnter() { if(this.tag("Switch3.Button").src == "static/images/settings/ToggleOnOrange.png") { this.tag("Switch3.Button").src = "static/images/settings/ToggleOffWhite.png" - console.log("Switch3 Turned Off"); - } else { - this.tag("Switch3.Button").src = "static/images/settings/ToggleOnOrange.png" - console.log("Switch3 Turned On"); - } + this.LOG("Switch3 Turned Off"); + } else { + this.tag("Switch3.Button").src = "static/images/settings/ToggleOnOrange.png" + this.LOG("Switch3 Turned On"); + } } }, class Switch4 extends this{ @@ -283,11 +291,11 @@ export default class CameraStreamingScreen extends Lightning.Component { _handleEnter() { if(this.tag("Switch4.Button").src == "static/images/settings/ToggleOnOrange.png") { this.tag("Switch4.Button").src = "static/images/settings/ToggleOffWhite.png" - console.log("Switch4 Turned Off"); - } else { - this.tag("Switch4.Button").src = "static/images/settings/ToggleOnOrange.png" - console.log("Switch4 Turned On"); - } + this.LOG("Switch4 Turned Off"); + } else { + this.tag("Switch4.Button").src = "static/images/settings/ToggleOnOrange.png" + this.LOG("Switch4 Turned On"); + } } } ] diff --git a/accelerator-home-ui/src/screens/CodeScreen.js b/accelerator-home-ui/src/screens/CodeScreen.js index 02d278c..702efaf 100644 --- a/accelerator-home-ui/src/screens/CodeScreen.js +++ b/accelerator-home-ui/src/screens/CodeScreen.js @@ -25,6 +25,14 @@ import { Metrics } from '@firebolt-js/sdk' var thunder = ThunderJS(CONFIG.thunderConfig); export default class CodeScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Wrapper: { @@ -105,7 +113,7 @@ export default class CodeScreen extends Lightning.Component { Storage.remove("alexaOTPReset"); } thunder.on("org.rdk.VoiceControl", 'onServerMessage', notification => { - console.log("VoiceControl.onServerMessage Notification: ", notification) + this.LOG("VoiceControl.onServerMessage Notification: " + JSON.stringify(notification)) this.VoiceControlData = notification if (notification.xr_speech_avs.url != undefined) { this.tag('Description').text.text = Language.translate('Enter the code at') + ` ${notification.xr_speech_avs.url}` @@ -125,16 +133,15 @@ export default class CodeScreen extends Lightning.Component { Router.navigate("SuccessScreen"); } else if ((notification.xr_speech_avs.state === "uninitialized") || (notification.xr_speech_avs.state === "authorizing")) { - console.log("notification state is uninitialised") + this.LOG("notification state is uninitialised") AlexaApi.get().setAlexaAuthStatus("AlexaAuthPending") } else if (notification.xr_speech_avs.state === "unrecoverable error") { - console.log("notification state is unrecoverable error") - // Could be AUTH token Timeout; refresh it. + this.LOG("notification state is unrecoverable error") Router.navigate("FailureScreen") } }) }).catch(err => { - console.log("VoiceControl Plugin Activation ERROR!: ", err) + this.ERR("VoiceControl Plugin Activation ERROR!: " + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, 'PluginError', "Thunder Controller.activate Voice Error"+JSON.stringify(err), false, null) }) this._setState('Description') diff --git a/accelerator-home-ui/src/screens/DTVScreens/DvbSScan.js b/accelerator-home-ui/src/screens/DTVScreens/DvbSScan.js index 4b1dcc4..71235fc 100644 --- a/accelerator-home-ui/src/screens/DTVScreens/DvbSScan.js +++ b/accelerator-home-ui/src/screens/DTVScreens/DvbSScan.js @@ -37,6 +37,14 @@ const systemcCallsign = "DTV"; * Class for DVB Scan screen. */ export default class DvbSScan extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.tag("Scroller").y = 2; //to reset the position when this route is hit this.widgets.menu.updateTopPanelText( @@ -430,25 +438,16 @@ export default class DvbSScan extends Lightning.Component { } consoleLog() { //log it everywhere - console.log( - "selectedSatellite: ", - JSON.stringify(this.selectedSatellite), - " selectedFrequency: ", - this.selectedFrequency, - " selectedPolarity: ", - this.selectedPolarity, - " selectedSymbolRate: ", - this.selectedSymbolRate, - " selectedFEC: ", - this.selectedFEC, - " selectedDVBS2: ", - this.selectedDVBS2, - " selectedModulation: ", - this.selectedModulation, - " selectedSearchType: ", - this.selectedSearchType, - " selectedRetune: ", - this.selectedRetune + this.LOG( + "selectedSatellite: " + JSON.stringify(this.selectedSatellite) + + " selectedFrequency: " + JSON.stringify(this.selectedFrequency) + + " selectedPolarity: " + JSON.stringify(this.selectedPolarity) + + " selectedSymbolRate: " + JSON.stringify(this.selectedSymbolRate) + + " selectedFEC: " + JSON.stringify(this.selectedFEC) + + " selectedDVBS2: " + JSON.stringify(this.selectedDVBS2) + + " selectedModulation: " + JSON.stringify(this.selectedModulation) + + " selectedSearchType: " + JSON.stringify(this.selectedSearchType) + + " selectedRetune: " + JSON.stringify(this.selectedRetune) ); } _focus() { @@ -465,9 +464,9 @@ export default class DvbSScan extends Lightning.Component { _firstActive() { let searchEventListener = thunder.on(systemcCallsign, "searchstatus", (notification) => { - console.log("SearchStatus Notification: ", JSON.stringify(notification)); + this.LOG("SearchStatus Notification: " + JSON.stringify(notification)); if(notification.finished){ - console.log("notification.finished: ", notification.finished) + this.LOG("notification.finished: " + JSON.stringify(notification.finished)) this.setScanFinished(); dtvApi.noOfServices().then(res => { this.tag("ErrorNotification.Content").text.text = Language.translate("Found ") + res + Language.translate(" services."); @@ -1075,10 +1074,10 @@ export default class DvbSScan extends Lightning.Component { dvbs2: this.selectedDVBS2, }, }; - console.log(JSON.stringify(serviceSearchParams)); + this.LOG(JSON.stringify(serviceSearchParams)); dtvApi.startServiceSearch(serviceSearchParams).then((res) => { this.setScanInProgress(); - console.log(res); + this.LOG("Scan Result: " + JSON.stringify(res)); setTimeout(() => { this.setScanFinished() //to give back controls after 30 sec in case searchstatus event fails dtvApi.noOfServices().then(res => { diff --git a/accelerator-home-ui/src/screens/DTVScreens/InputScreens/IntegerInput.js b/accelerator-home-ui/src/screens/DTVScreens/InputScreens/IntegerInput.js index b148757..f094427 100644 --- a/accelerator-home-ui/src/screens/DTVScreens/InputScreens/IntegerInput.js +++ b/accelerator-home-ui/src/screens/DTVScreens/InputScreens/IntegerInput.js @@ -25,6 +25,14 @@ import { Keyboard } from "../../../ui-components"; import { KEYBOARD_FORMATS } from "../../../ui-components/components/Keyboard"; export default class IntegerInput extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { x: 200, @@ -99,12 +107,12 @@ export default class IntegerInput extends Lightning.Component { this.tag("Content").text.text = this.prevVal === "" ? Language.translate("Enter the value and click Done") : this.prevVal; this.inputValue = this.prevVal; - console.log("presetValues: ",this.presetValues) + this.LOG("presetValues: " + JSON.stringify(this.presetValues)) this.presetValuesLength = 0; this.presetIdx = -1; //to accomodate previous value of the input field if(Array.isArray(this.presetValues)){ this.presetValuesLength = this.presetValues.length; - console.log(this.presetValues, this.presetValuesLength) + this.LOG(JSON.stringify(this.presetValues) + " " + JSON.stringify(this.presetValuesLength)) this.tag("Arrows").visible = true; } else { this.tag("Arrows").visible = false; diff --git a/accelerator-home-ui/src/screens/DTVScreens/LiveTVSettings.js b/accelerator-home-ui/src/screens/DTVScreens/LiveTVSettings.js index 9076579..0388339 100644 --- a/accelerator-home-ui/src/screens/DTVScreens/LiveTVSettings.js +++ b/accelerator-home-ui/src/screens/DTVScreens/LiveTVSettings.js @@ -28,6 +28,14 @@ let active = true; //expecting dtv plugin is active by default * Class for Live TV settings screen. */ export default class LiveTVSettings extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText( Language.translate("Settings / Live TV") @@ -136,7 +144,7 @@ export default class LiveTVSettings extends Lightning.Component { _handleEnter() { if (active) { this.dtvApi.deactivate().then((res) => { - console.log(res); + this.LOG("Deactivate: " + JSON.stringify(res)); active = false; this.tag("Activate.Button").src = Utils.asset( "images/settings/ToggleOffWhite.png" @@ -144,7 +152,7 @@ export default class LiveTVSettings extends Lightning.Component { }); } else { this.dtvApi.activate().then((res) => { - console.log(res); + this.LOG("Activate: " + JSON.stringify(res)); active = true; this.tag("Activate.Button").src = Utils.asset( "images/settings/ToggleOnOrange.png" diff --git a/accelerator-home-ui/src/screens/DetailsScreen.js b/accelerator-home-ui/src/screens/DetailsScreen.js index 05871a1..084c3c8 100644 --- a/accelerator-home-ui/src/screens/DetailsScreen.js +++ b/accelerator-home-ui/src/screens/DetailsScreen.js @@ -24,6 +24,14 @@ var homeApi = new HomeApi(); export default class DetailsScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(this.name); } @@ -173,7 +181,9 @@ this._setState("Subscriptions"); this.tag("Subscriptions.List").setIndex(0); }) - .catch((error) => console.log(error)); + .catch((error) => { + this.ERR("DetailsScreen getMovieSubscriptions error: " + JSON.stringify(error)); + }); } _init() {} @@ -223,4 +233,3 @@ ]; } } - \ No newline at end of file diff --git a/accelerator-home-ui/src/screens/EpgScreens/Epg.js b/accelerator-home-ui/src/screens/EpgScreens/Epg.js index eccd141..9b5bf54 100644 --- a/accelerator-home-ui/src/screens/EpgScreens/Epg.js +++ b/accelerator-home-ui/src/screens/EpgScreens/Epg.js @@ -33,6 +33,14 @@ const dtvApi = new DTVApi() export default class Epg extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Background: { @@ -286,14 +294,14 @@ export default class Epg extends Lightning.Component { } else { if (!Router.isNavigating()) { this.DTV.launchChannel(channel.dvburi).then(res => { - console.log("launchChannel method successful: ", JSON.stringify(res)); + this.LOG("launchChannel method successful: " + JSON.stringify(res)); this.widgets.channeloverlay.$focusChannel(this.D - 8 + this.currentlyFocusedRow); Router.navigate("dtvplayer"); }).catch(err => { - console.log("launchChannel method failed: ", JSON.stringify(err)); + this.ERR("launchChannel method failed: " + JSON.stringify(err)); }) } else { - console.error("Router is still navigating.") + this.ERR("Router is still navigating.") } } } @@ -321,15 +329,15 @@ export default class Epg extends Lightning.Component { shows[i].endtime = shows[i].duration + shows[i].starttime if (i >= shows.length) { - console.warn("Reached the end of data , can't traverse shows any further!") + self.WARN("Reached the end of data , can't traverse shows any further!") break } else if (new Date(shows[i].starttime) <= ltp && new Date(shows[i].endtime) > ltp) { break } else if (new Date(shows[i].starttime) > ltp) { - console.warn("there's chance that an empty space appear in one of the rows") + self.WARN("there's chance that an empty space appear in one of the rows") break } else if (i === shows.length - 1) { - console.warn( + self.WARN( 'traversed all of the shows and none of them are airing at this time for this channel' ) return @@ -488,14 +496,14 @@ export default class Epg extends Lightning.Component { } else { this.D++ } - console.log(`setting vertical scroll from ${this.D - 8} to ${this.D} based the value ${n}`) + this.LOG("setting vertical scroll from " + JSON.stringify(this.D - 8) + " to " + JSON.stringify(this.D) + " based the value " + JSON.stringify(n)) this.activeChannels = this.channels.slice(this.D - 8, this.D) this.setChannels(this.activeChannels) this.setShows4Channels(this.activeChannels) } onDataProvidedX() { - console.log(`on Data Provided`) + this.LOG("on Data Provided") this.initialize() this.scrollVertically() this.cellTimeTracker = this.gridInstance[this.currentCellIndex].starttime @@ -555,7 +563,7 @@ export default class Epg extends Lightning.Component { diff = shows[i + 1].starttime - currentShowETime if (diff > 0) { if (memLeakAlert < 0) { - console.warn('Memory leak alert; aborting black cell insert') + self.WARN("Memory leak alert; aborting black cell insert") } shows.splice(i + 1, 0, { name: '', @@ -603,7 +611,7 @@ export default class Epg extends Lightning.Component { ] if (channels.length - 1 === traversedChannels) { - console.log(`premium apps exclusive resolve`); + self.LOG("premium apps exclusive resolve") page.channels = channels resolve(true) } @@ -634,14 +642,13 @@ export default class Epg extends Lightning.Component { } }) .catch(err => { - // console.error(err) - // return "Home" - console.error('error', err) + self.ERR("error: " + JSON.stringify(err)) reject(err) }) }) }) .catch(err => { + self.ERR("error: " + JSON.stringify(err)) reject(err) }) }) @@ -653,7 +660,7 @@ export default class Epg extends Lightning.Component { loader.visible = false; wrapper.visible = true; }).catch(err => { - console.log(`error while fetching data from dtv`, err) + this.ERR("error while fetching data from dtv: " + JSON.stringify(err)) Router.navigate('menu') }) @@ -742,7 +749,7 @@ export default class Epg extends Lightning.Component { } else if (this.gridInstance[this.currentCellIndex].showIndex > 0) { this.scrollHorizontally(-1) } else { - console.log("can't traverse any left") + this.LOG("can't traverse any left") Router.focusWidget('Menu') } this.paintCell() @@ -761,7 +768,7 @@ export default class Epg extends Lightning.Component { ) { //current Cell index has to be updated at last this.scrollHorizontally(1) - } else console.log("can't go further right") + } else this.LOG("can't go further right") this.paintCell() } @@ -803,7 +810,7 @@ export default class Epg extends Lightning.Component { //--------------------------------- this.currentCellIndex = idx this.updateCursor() - } else console.log("can't go any further ,it's the last row") + } else this.LOG("can't go any further ,it's the last row") this.setBoldText() this.paintCell() } @@ -829,7 +836,7 @@ export default class Epg extends Lightning.Component { //--------------------------------- this.currentCellIndex = idx this.updateCursor() - } else console.log("can't go any further , it's the first row") + } else this.LOG("can't go any further , it's the first row") this.setBoldText() this.paintCell() } @@ -919,7 +926,7 @@ export default class Epg extends Lightning.Component { } $exit() { - console.log('exiting from state - CellSelector') + this.LOG('exiting from state - CellSelector') } }, ] diff --git a/accelerator-home-ui/src/screens/Error.js b/accelerator-home-ui/src/screens/Error.js index aa4650d..48f6806 100644 --- a/accelerator-home-ui/src/screens/Error.js +++ b/accelerator-home-ui/src/screens/Error.js @@ -20,6 +20,14 @@ import { Lightning, Router } from '@lightningjs/sdk' import { CONFIG } from '../Config/Config' export default class Error extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { rect: true, @@ -57,7 +65,7 @@ export default class Error extends Lightning.Component { } _focus() { - console.log('focus error page') + this.LOG("focus error page") } pageTransition() { diff --git a/accelerator-home-ui/src/screens/FailScreen.js b/accelerator-home-ui/src/screens/FailScreen.js index af06223..3e32620 100644 --- a/accelerator-home-ui/src/screens/FailScreen.js +++ b/accelerator-home-ui/src/screens/FailScreen.js @@ -23,8 +23,16 @@ const errorTitle = 'Error Title' const errorMsg = 'Error Message' export default class Failscreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + notify(args) { - console.log(args) + this.LOG("notify args: " + JSON.stringify(args)) if (args.title && args.msg) { this.tag('FailScreen.Title').text.text = args.title this.tag('FailScreen.Message').text.text = Language.translate(args.msg) diff --git a/accelerator-home-ui/src/screens/FailureScreen.js b/accelerator-home-ui/src/screens/FailureScreen.js index bfd91bc..489379b 100644 --- a/accelerator-home-ui/src/screens/FailureScreen.js +++ b/accelerator-home-ui/src/screens/FailureScreen.js @@ -27,6 +27,14 @@ import { Metrics } from '@firebolt-js/sdk'; var thunder = ThunderJS(CONFIG.thunderConfig); export default class FailureScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Wrapper: { @@ -102,7 +110,7 @@ export default class FailureScreen extends Lightning.Component { return [ class RetryButton extends this{ $enter() { - console.log("setState DoneButton CodeScreen") + this.LOG("setState DoneButton CodeScreen") this.tag("RetryButton") this._focus() this.tag('RetryButton.Title').text.textColor = CONFIG.theme.hex @@ -111,9 +119,9 @@ export default class FailureScreen extends Lightning.Component { if (GLOBALS.topmostApp !== GLOBALS.selfClientName) { if(GLOBALS.AlexaAvsstatus){ AlexaApi.get().resetAVSCredentials().then(() => { - console.log("avs credentials reseted") + this.LOG("avs credentials reseted") })} - console.log("Current app: " + GLOBALS.topmostApp + ", moving the app to front") + this.LOG("Current app: " + JSON.stringify(GLOBALS.topmostApp) + ", moving the app to front") RDKShellApis.moveToFront(GLOBALS.topmostApp) RDKShellApis.setFocus(GLOBALS.topmostApp).catch((err) => { Metrics.error(Metrics.ErrorType.OTHER, 'PluginError', "Thunder RDKshell set focus error" + JSON.stringify(err), false, null) diff --git a/accelerator-home-ui/src/screens/JoinAnotherNetworkComponent.js b/accelerator-home-ui/src/screens/JoinAnotherNetworkComponent.js index 291b4dd..9897580 100644 --- a/accelerator-home-ui/src/screens/JoinAnotherNetworkComponent.js +++ b/accelerator-home-ui/src/screens/JoinAnotherNetworkComponent.js @@ -21,11 +21,19 @@ import { CONFIG } from '../Config/Config'; import { Keyboard } from '../ui-components/index' import { KEYBOARD_FORMATS } from '../ui-components/components/Keyboard' import PasswordSwitch from './PasswordSwitch'; -import WiFi from '../api/WifiApi'; +import NetworkManager from '../api/NetworkManagerAPI'; import PersistentStoreApi from '../api/PersistentStore'; export default class JoinAnotherNetworkComponent extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -61,13 +69,13 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component { } async startConnectForAnotherNetwork(device, passphrase) { - await WiFi.get().connect(false, { ssid: device.ssid, security: device.security }, passphrase).then(() => { - WiFi.get().saveSSID(device.ssid, passphrase, device.security).then((response) => { - if (response.result === 0 && response.success === true) { + await NetworkManager.WiFiConnect(false, { ssid: device.ssid, security: device.security }, passphrase).then(() => { + NetworkManager.AddToKnownSSIDs(device.ssid, passphrase, device.security).then((response) => { + if (response === true ) { PersistentStoreApi.get().setValue('wifi', 'SSID', device.ssid) } - else if (response.result !== 0) { - WiFi.get().clearSSID() + else { + NetworkManager.RemoveKnownSSID(device.ssid) } }) if (!Router.isNavigating()) { @@ -410,7 +418,7 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component { if (this.prevState === 'PasswordSwitchState') { this.prevState = "EnterPassword" } - console.log("Prev state:", this.prevState) + this.LOG("Prev state: " + JSON.stringify(this.prevState)) if (key === 'Done') { this.handleDone(); } else if (key === 'Clear') { @@ -418,7 +426,7 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component { this.star = (this.prevState === "EnterPassword") ? this.star.substring(0, this.star.length - 1) : this.star this.tag(this.element).text.text = this.encrypt() ? this.star : this.textCollection[this.prevState]; } else if (key === '#@!' || key === 'abc' || key === 'áöû' || key === 'shift') { - console.log('no saving') + this.LOG('no saving') } else if (key === 'Space') { this.textCollection[this.prevState] += ' ' this.star += (this.prevState === "EnterPassword") ? '\u25CF' : this.star diff --git a/accelerator-home-ui/src/screens/MiracastNotification.js b/accelerator-home-ui/src/screens/MiracastNotification.js index b515e89..3b8e098 100644 --- a/accelerator-home-ui/src/screens/MiracastNotification.js +++ b/accelerator-home-ui/src/screens/MiracastNotification.js @@ -25,10 +25,17 @@ var devicemac = '' var miracast = new Miracast() export default class MiracastNotification extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } notify(args) { if (!args || !args.mac || !args.name) { - console.warn("Invalid arguments passed to notify"); + this.WARN("Invalid arguments passed to notify"); return; } devicename = args.name; @@ -37,9 +44,8 @@ export default class MiracastNotification extends Lightning.Component { } set params(args){ - console.log(args) + this.LOG("params: " + JSON.stringify(args)) this.notify(args) - } pageTransition() { return 'left' @@ -136,7 +142,7 @@ export default class MiracastNotification extends Lightning.Component { this.tag('Timer').text.text ="" this.timeout=30 this.initTimer() - console.info('MiracastNotification initialized'); + this.INFO('MiracastNotification initialized'); this._setState("Accept"); } _inactive() { @@ -158,7 +164,7 @@ export default class MiracastNotification extends Lightning.Component { } _focus() { this.alpha=1 - console.log('MiracastNotification focused'); + this.LOG('MiracastNotification focused'); } _unfocus() { this.alpha = 0 diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js index 29237df..ea828bb 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js @@ -27,6 +27,14 @@ import CECApi from '../../api/CECApi' export default class AdvanceSettingsScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Advanced Settings')); } @@ -196,7 +204,7 @@ export default class AdvanceSettingsScreen extends Lightning.Component { if (res.success) { this.cecApi.performOTP().then(otpRes => { if (otpRes.success) { - console.log('Otp Action success full') + this.LOG('Otp Action success full') } }) } @@ -206,7 +214,7 @@ export default class AdvanceSettingsScreen extends Lightning.Component { toggleCEC() { this.cecApi.getEnabled() .then(res => { - console.log(res) + this.LOG("cec getenabled result:" + JSON.stringify(res)) if (res.enabled) { this.cecApi.deactivate() .then(() => { diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/ConfigureManuallyScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/ConfigureManuallyScreen.js index 74c4f69..1c61b99 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/ConfigureManuallyScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/ConfigureManuallyScreen.js @@ -22,6 +22,13 @@ import { Keyboard } from '../../ui-components/index' import { KEYBOARD_FORMATS } from '../../ui-components/components/Keyboard' export default class ConfigureManuallyScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { Text: { @@ -146,7 +153,6 @@ export default class ConfigureManuallyScreen extends Lightning.Component { this.tag("SubnetText").text.text = ""; this.tag("GatewayText").text.text = ""; this.fireAncestors("$hideSideAndTopPanels"); - } _unfocus() { @@ -226,7 +232,6 @@ export default class ConfigureManuallyScreen extends Lightning.Component { this.prevState = state.prevState if (this.prevState === 'EnterIPv4') { this.element = 'IPv4Text' - } if (this.prevState === 'EnterSubnet') { this.element = 'SubnetText' @@ -246,7 +251,7 @@ export default class ConfigureManuallyScreen extends Lightning.Component { this.textCollection[this.prevState] = this.textCollection[this.prevState].substring(0, this.textCollection[this.prevState].length - 1); this.tag(this.element).text.text = this.textCollection[this.prevState]; } else if (key === '#@!' || key === 'abc' || key === 'áöû' || key === 'shift') { - console.log('no saving') + this.LOG("no saving") } else if (key === 'Space') { this.textCollection[this.prevState] += ' ' this.tag(this.element).text.text = this.textCollection[this.prevState]; diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/DeviceInformationScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/DeviceInformationScreen.js index 523a289..96eef21 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/DeviceInformationScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/DeviceInformationScreen.js @@ -20,7 +20,6 @@ import { Lightning, Language, Router, Settings, Storage } from '@lightningjs/sdk import { COLORS } from '../../colors/Colors' import { CONFIG, GLOBALS } from '../../Config/Config' import AppApi from '../../api/AppApi.js'; -import NetworkApi from '../../api/NetworkApi' import FireBoltApi from '../../api/firebolt/FireBoltApi'; /** @@ -29,6 +28,14 @@ import FireBoltApi from '../../api/firebolt/FireBoltApi'; export default class DeviceInformationScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Advanced Settings Device Info')); } @@ -192,7 +199,6 @@ export default class DeviceInformationScreen extends Lightning.Component { } _init() { - this._network = new NetworkApi(); this.appApi = new AppApi(); } @@ -207,20 +213,20 @@ export default class DeviceInformationScreen extends Lightning.Component { this.appApi.getSystemVersions().then(res => { this.tag('FirmwareVersions.Value').text.text = `UI Version - ${Settings.get('platform', 'version')} \nBuild Version - ${res.stbVersion} \nTime Stamp - ${res.stbTimestamp} ` }).catch(err => { - console.error(`error while getting the system versions`) + this.ERR("error while getting the system versions" + JSON.stringify(err)) }) } else { // Firebolt mode FireBoltApi.get().deviceinfo.getversion().then(res => { - console.log(`build verion${res.firmware.readable} Firebolt API Version - ${res.api.readable}`) + this.LOG("build verion" + JSON.stringify(res.firmware.readable) + " Firebolt API Version - " + JSON.stringify(res.api.readable)) this.tag('FirmwareVersions.Value').text.text = `UI Version - ${Settings.get('platform', 'version')} \nBuild Version - ${res.firmware.readable} \nFirebolt API Version - ${res.api.readable} ` }).catch(err => { - console.error(`error while getting the system versions from Firebolt.getversion API`) + this.ERR("error while getting the system versions from Firebolt.getversion API" + JSON.stringify(err)) }) } this.appApi.getDRMS().then(result => { - console.log('from device info supported drms ' + JSON.stringify(result)) + this.LOG("from device info supported drms " + JSON.stringify(result)) let drms = "" result.forEach(element => { drms += `${element.name} :` @@ -245,37 +251,37 @@ export default class DeviceInformationScreen extends Lightning.Component { self.appApi.getPluginStatus('Netflix') .then(result => { let sel = self; - console.log(`Netflix : plugin status : `, JSON.stringify(result)); + sel.LOG("Netflix : plugin status : " + JSON.stringify(result)); if (result[0].state === 'deactivated' || result[0].state === 'deactivation') { sel.appApi.launchPremiumAppInSuspendMode("Netflix").then(res => { - console.log("Netflix : netflix launch for esn value in suspend mode returns : ", JSON.stringify(res)); + sel.LOG("Netflix : netflix launch for esn value in suspend mode returns : " + JSON.stringify(res)); let se = sel; se.appApi.getNetflixESN() .then(res => { Storage.set('Netflix_ESN', res) - console.log(`Netflix : netflix esn call returns : `, JSON.stringify(res)); + se.LOG("Netflix : netflix esn call returns : " + JSON.stringify(res)); se.netflixESN = `Youtube: NA \nAmazon Prime: NA \nNetflix ESN: ${res}` }) .catch(err => { - console.error(`Netflix : error while getting netflix esn : `, JSON.stringify(err)) + se.ERR("Netflix : error while getting netflix esn : " + JSON.stringify(err)) }) }).catch(err => { - console.error(`Netflix : error while launching netflix in suspendMode : `, JSON.stringify(err)) + sel.ERR("Netflix : error while launching netflix in suspendMode : " + JSON.stringify(err)) }) } else { self.appApi.getNetflixESN() .then(res => { Storage.set('Netflix_ESN', res) - console.log(`Netflix : netflix esn call returns : `, JSON.stringify(res)); + self.LOG("Netflix : netflix esn call returns : " + JSON.stringify(res)); self.netflixESN = `Youtube: NA \nAmazon Prime: NA \nNetflix ESN: ${res}`; }) .catch(err => { - console.error(`Netflix : error while getting netflix esn : `, JSON.stringify(err)) + self.ERR("Netflix : error while getting netflix esn : " + JSON.stringify(err)) }) } }).catch(err => { - console.error(`Netflix : error while getting netflix plugin status ie. `, JSON.stringify(err)) + self.ERR("Netflix : error while getting netflix plugin status ie. " + JSON.stringify(err)) self.netflixESN = `Youtube: NA \nAmazon Prime: NA \nNetflix ESN: "Not Detected"`; }) } @@ -284,7 +290,7 @@ export default class DeviceInformationScreen extends Lightning.Component { } set netflixESN(v) { - console.log(`setting netflix ESN value to ${v}`); + this.LOG("setting netflix ESN value to " + JSON.stringify(v)); this.tag('AppVersions.Value').text.text = v; } diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/FactoryResetConfirmationScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/FactoryResetConfirmationScreen.js index 2293bb1..36d50e0 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/FactoryResetConfirmationScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/FactoryResetConfirmationScreen.js @@ -21,6 +21,7 @@ import AppApi from '../../api/AppApi' import BluetoothApi from '../../api/BluetoothApi' import { CONFIG,GLOBALS } from '../../Config/Config' import WiFi from '../../api/WifiApi' +import NetworkManager from '../../api/NetworkManagerAPI.js' import AlexaApi from '../../api/AlexaApi.js'; import RCApi from '../../api/RemoteControl' import Warehouse from '../../api/WarehouseApis.js' @@ -32,6 +33,14 @@ const _btApi = new BluetoothApi() * Class for Reboot Confirmation Screen. */ export default class RebootConfirmationScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -132,10 +141,10 @@ export default class RebootConfirmationScreen extends Lightning.Component { _firstEnable() { this.AppApi.checkStatus(Warehouse.get().callsign).then(resp => { - console.log("FactoryReset: warehouse plugin status : ", resp[0].status); + this.LOG("FactoryReset: warehouse plugin status : " + JSON.stringify(resp[0].status)); if (resp[0].status != 'activated') { Warehouse.get().activate().catch(err => { - console.error("FactoryReset: warehouse plugin activation failed; feature may not work."); + this.ERR("FactoryReset: warehouse plugin activation failed; feature may not work." + JSON.stringify(err)); }); } }); @@ -155,47 +164,52 @@ export default class RebootConfirmationScreen extends Lightning.Component { let getsuportedmode = await appApi.getSupportedAudioPorts(); for (let i = 0; i < getsuportedmode.supportedAudioPorts.length; i++) { if(getsuportedmode.supportedAudioPorts[i] != 'SPDIF0'){ - let rsbass = await appApi.resetBassEnhancer(getsuportedmode.supportedAudioPorts[i]).catch((err) =>{ console.log("resetBassEnhancer",err)}); - if (rsbass.success != true) { console.log("resetBassEnhancer",rsbass)}//throw new Error(rsbass); }//{Promise.reject(false); return} - let rsDialog = await appApi.resetDialogEnhancement(getsuportedmode.supportedAudioPorts[i]).catch((err) =>{ console.log("resetDialogEnhancement",err)})//{Promise.reject(JSON.stringify(err))}); - if (rsDialog.success != true) { console.log("resetDialogEnhancement",rsDialog) } - let rsVirtualizer = await appApi.resetSurroundVirtualizer(getsuportedmode.supportedAudioPorts[i]).catch(err =>{ console.log("resetSurroundVirtualizer",err)}); - if (rsVirtualizer.success != true) { console.log("resetSurroundVirtualizer",rsVirtualizer) } - let rsvolumelvel = await appApi.resetVolumeLeveller(getsuportedmode.supportedAudioPorts[i]).catch(err =>{ console.log("resetVolumeLeveller",err)}); - if (rsvolumelvel.success != true) { console.log("resetVolumeLeveller",rsvolumelvel) } + let rsbass = await appApi.resetBassEnhancer(getsuportedmode.supportedAudioPorts[i]).catch((err) =>{ this.ERR("resetBassEnhancer" + JSON.stringify(err)) }); + if (rsbass.success != true) { this.LOG("resetBassEnhancer" + JSON.stringify(rsbass)) } + let rsDialog = await appApi.resetDialogEnhancement(getsuportedmode.supportedAudioPorts[i]).catch((err) =>{ this.ERR("resetDialogEnhancement" + JSON.stringify(err)) }) + if (rsDialog.success != true) { this.LOG("resetDialogEnhancement" + JSON.stringify(rsDialog)) } + let rsVirtualizer = await appApi.resetSurroundVirtualizer(getsuportedmode.supportedAudioPorts[i]).catch(err =>{ this.ERR("resetSurroundVirtualizer" + JSON.stringify(err)) }); + if (rsVirtualizer.success != true) { this.LOG("resetSurroundVirtualizer" + JSON.stringify(rsVirtualizer)) } + let rsvolumelvel = await appApi.resetVolumeLeveller(getsuportedmode.supportedAudioPorts[i]).catch(err =>{ this.ERR("resetVolumeLeveller" + JSON.stringify(err)) }); + if (rsvolumelvel.success != true) { this.LOG("resetVolumeLeveller" + JSON.stringify(rsvolumelvel)) } } } - let btActivate = await _btApi.btactivate().then(result => console.log("Btactivate",result)).catch(err=> console.log(`error while activating bluetooth`)) + let btActivate = await _btApi.btactivate().then(result => this.LOG("Btactivate" + JSON.stringify(result))).catch(err=> this.ERR("error while activating bluetooth")) let getPairedDevices = await _btApi.getPairedDevices().then(res=>res).catch(err => 0) - console.log("getpairedDevices", getPairedDevices) + this.LOG("getpairedDevices" + JSON.stringify(getPairedDevices)) for(let i=0 ; i 0){ - let btunpair = await _btApi.unpair(getPairedDevices[i].deviceId).catch(err => { console.log("btunpair",err) }); - if(btunpair.success != true){ console.log("btunpair",btunpair) } + let btunpair = await _btApi.unpair(getPairedDevices[i].deviceId).catch(err => { this.ERR("btunpair" + JSON.stringify(err)) }); + if(btunpair.success != true){ this.LOG("btunpair" + JSON.stringify(btunpair)) } } } - await RCApi.get().activate().then(()=>{ RCApi.get().factoryReset(); }).catch(err => console.log(`error while resetting remote control`)); + await RCApi.get().activate().then(()=>{ RCApi.get().factoryReset(); }).catch(err => this.ERR("error while resetting remote control" + JSON.stringify(err))); let contollerStat = await appApi.checkStatus("Monitor") for(let i=0; i< contollerStat[0].configuration.observables.length; i++){ - let monitorstat = await appApi.monitorStatus(contollerStat[0].configuration.observables[i].callsign).catch(err =>{ console.log("monitorStatus",err) }); - if(monitorstat.length < 0){ console.log("monitorStatus",monitorstat) } + let monitorstat = await appApi.monitorStatus(contollerStat[0].configuration.observables[i].callsign).catch(err =>{ this.ERR("monitorStatus" + JSON.stringify(err)) }); + if(monitorstat.length < 0){ this.LOG("monitorStatus" + JSON.stringify(monitorstat)) } } - // warehouse apis - await Warehouse.get().internalReset().catch(err => { console.error("internalReset",err) }); - await Warehouse.get().isClean().catch(err => { console.error("isClean",err) }); - await Warehouse.get().lightReset().catch(err => { console.error("lightReset",err)}); - await Warehouse.get().resetDevice().catch(err => { console.error("resetDevice",err) }); + await Warehouse.get().internalReset().catch(err => { this.ERR("internalReset" + JSON.stringify(err)) }); + await Warehouse.get().isClean().catch(err => { this.ERR("isClean" + JSON.stringify(err)) }); + await Warehouse.get().lightReset().catch(err => { this.ERR("lightReset" + JSON.stringify(err))}); + await Warehouse.get().resetDevice().catch(err => { this.ERR("resetDevice" + JSON.stringify(err)) }); - let rsactivitytime = await appApi.resetInactivityTime().catch(err => { console.error("resetInactivityTime",err) }); - if (rsactivitytime.success != true) { console.log("rsactivitytime",rsactivitytime) } - let clearLastDeepSleepReason = await appApi.clearLastDeepSleepReason().catch(err => { console.error("clearLastDeepSleepReason",err) }); - if (clearLastDeepSleepReason.success != true) { console.log("clearLastDeepSleepReason",clearLastDeepSleepReason) } - let clearSSID = await WiFi.get().clearSSID().catch(err => { console.error("clearSSID",err) }); - if (clearSSID.success != true) { console.log("clearSSID",clearSSID) } - let wifidisconnect = await WiFi.get().disconnect().catch(err =>{ console.error("wifidisconnect",err) }); - if (wifidisconnect.success != true) { console.log("wifidisconnect",wifidisconnect) } - await appApi.clearCache().catch(err => { console.error("clearCache error: ", err)}) - await appApi.reboot("User Trigger").then(result => { console.log('device rebooting' + JSON.stringify(result))}) + let rsactivitytime = await appApi.resetInactivityTime().catch(err => { this.ERR("resetInactivityTime" + JSON.stringify(err)) }); + if (rsactivitytime.success != true) { this.LOG("rsactivitytime" + JSON.stringify(rsactivitytime)) } + let clearLastDeepSleepReason = await appApi.clearLastDeepSleepReason().catch(err => { this.ERR("clearLastDeepSleepReason" + JSON.stringify(err)) }); + if (clearLastDeepSleepReason.success != true) { this.LOG("clearLastDeepSleepReason" + JSON.stringify(clearLastDeepSleepReason)) } + let GetKnownSSIDs = await NetworkManager.GetKnownSSIDs().then((ssids)=>{ssids}).catch(err => { console.error("GetKnownssids",err) }); + let clearSSID =false + for(let i=0;i0) + {clearSSID= await NetworkManager.RemoveKnownSSID(ssids[i]).catch(err => { this.ERR("clearSSID" + JSON.stringify(err)) });} + } + if (clearSSID != true) { this.LOG("clearSSID" + JSON.stringify(clearSSID)) } + let wifidisconnect = await NetworkManager.WiFiDisconnect().catch(err =>{ this.ERR("wifidisconnect" + JSON.stringify(err)) }); + if (wifidisconnect.success != true) { this.LOG("wifidisconnect" + JSON.stringify(wifidisconnect)) } + await appApi.clearCache().catch(err => { this.ERR("clearCache error: " + JSON.stringify(err)) }) + await appApi.reboot("User Trigger").then(result => { this.LOG('device rebooting' + JSON.stringify(result))}) } static _states() { diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/FirmwareScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/FirmwareScreen.js index ef640f2..b5a101c 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/FirmwareScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/FirmwareScreen.js @@ -30,6 +30,14 @@ import { Metrics } from '@firebolt-js/sdk'; const thunder = ThunderJS(CONFIG.thunderConfig) export default class FirmwareScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Advanced Settings Device Firmware Update')); } @@ -133,11 +141,11 @@ export default class FirmwareScreen extends Lightning.Component { _active() { this.onFirmwareUpdateStateChangeCB = thunder.on('org.rdk.System', 'onFirmwareUpdateStateChange', notification => { this.tag('State.Title').text.text = Language.translate("Firmware State: ") + FirmwareScreen.STATES[notification.firmwareUpdateStateChange] - console.log('onFirmwareUpdateStateChange:' + JSON.stringify(notification)); + this.LOG('onFirmwareUpdateStateChange:' + JSON.stringify(notification)); if (FirmwareScreen.STATES[notification.firmwareUpdateStateChange] === "Downloading") { this.showUpdateButton(notification.firmwareUpdateStateChange) this.downloadInterval = setInterval(() => { - console.log(`Downloading...`); + this.LOG("Downloading..."); this.getDownloadPercent(); }, 1000) } else if (notification.firmwareUpdateStateChange > 3) { @@ -147,7 +155,7 @@ export default class FirmwareScreen extends Lightning.Component { this.tag('DownloadedPercent.Title').visible = false; this.showUpdateButton(notification.firmwareUpdateStateChange) if (this.downloadInterval) { - console.log(""); + this.LOG(""); clearInterval(this.downloadInterval); this.downloadInterval = null } @@ -155,7 +163,7 @@ export default class FirmwareScreen extends Lightning.Component { }); // TODO: This need to be in _init() as it should be system wide. this.onFirmwareUpdateInfoReceivedCB = thunder.on('org.rdk.System', 'onFirmwareUpdateInfoReceived', params => { - console.log("onFirmwareUpdateInfoReceived", JSON.stringify(params)) + this.LOG("onFirmwareUpdateInfoReceived" + JSON.stringify(params)) if (params.success) { if (params.updateAvailable) { switch(params.updateAvailableEnum) { @@ -201,7 +209,7 @@ export default class FirmwareScreen extends Lightning.Component { this.downloadInterval = null; await this._appApi.getFirmwareUpdateState().then(res => { if (res.success) { - console.log("getFirmwareUpdateState from firmware screen " + JSON.stringify(res)) + this.LOG("getFirmwareUpdateState from firmware screen " + JSON.stringify(res)) this.tag('State.Title').text.text = Language.translate("Firmware State: ") + FirmwareScreen.STATES[res.firmwareUpdateState] this.showUpdateButton(res.firmwareUpdateState) if (res.firmwareUpdateState === "Downloading") { @@ -210,7 +218,7 @@ export default class FirmwareScreen extends Lightning.Component { } }) this._appApi.getDownloadFirmwareInfo().then(res => { - console.log(`getDownloadFirmwareInfo : ${JSON.stringify(res)}`); + this.LOG("getDownloadFirmwareInfo : " + JSON.stringify(res)); this.tag('Version.Title').text.text = Language.translate("Firmware Versions: ") + res.currentFWVersion this.tag('DownloadedVersion.Title').text.text = Language.translate('Downloaded Firmware Version: ') + `${res.downloadedFWVersion ? res.downloadedFWVersion : 'NA'}` }) @@ -230,21 +238,21 @@ export default class FirmwareScreen extends Lightning.Component { } } }).catch(err => { - console.error(err); + this.ERR("Error: " + JSON.stringify(err)); }) } getDownloadFirmwareInfo() { this._appApi.updateFirmware().then(res => { this._appApi.getDownloadFirmwareInfo().then(result => { - console.log(`getDownloadFirmwareInfo : ${JSON.stringify(result.downloadedFWVersion)}`); + this.LOG("getDownloadFirmwareInfo : " + JSON.stringify(result.downloadedFWVersion)); this.tag('DownloadedVersion.Title').text.text = Language.translate('Downloaded Firmware Version: ') + `${result.downloadedFWVersion ? result.downloadedFWVersion :"" }` this.tag('Version.Title').text.text = Language.translate("Firmware Versions: ") + result.currentFWVersion }).catch(err => { - console.error(err); + this.ERR("Error: " + JSON.stringify(err)); }) }).catch(err => { - console.error(err); + this.ERR("Error: " + JSON.stringify(err)); }) } diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/LanguageScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/LanguageScreen.js index 5ddf3d9..ed150d5 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/LanguageScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/LanguageScreen.js @@ -33,6 +33,14 @@ const loader = 'Loader' export default class LanguageScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Language')); } @@ -71,7 +79,7 @@ export default class LanguageScreen extends Lightning.Component { _active() { if ("ResidentApp" !== GLOBALS.selfClientName) { this.OnLanguageChangedfirebolt = FireBoltApi.get().localization.listen("languageChanged", value => { - console.log('language changed successfully', value) + this.LOG('language changed successfully' + JSON.stringify(value)) }) } this._Languages = this.tag('LanguageScreenContents.Languages') @@ -89,12 +97,12 @@ export default class LanguageScreen extends Lightning.Component { appApi.deactivateResidentApp(loader) RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setFocus(GLOBALS.selfClientName).then(result => { - console.log('LanguageScreen: ResidentApp moveToFront Success'); + this.LOG('LanguageScreen: ResidentApp moveToFront Success'); RDKShellApis.getVisibility(GLOBALS.selfClientName).then(visible => { if (!visible) RDKShellApis.setVisibility(GLOBALS.selfClientName, true); }) }).catch(err => { - console.log('LanguageScreen: Error', err); + this.ERR('LanguageScreen: Error' + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, "AppLangugaeError", 'Thunder RDKShell setFocus Error' + JSON.stringify(err), false, null) }); } @@ -141,13 +149,13 @@ export default class LanguageScreen extends Lightning.Component { if ("ResidentApp" === GLOBALS.selfClientName) { appApi.setUILanguage(updatedLanguage) } else { - FireBoltApi.get().localization.setlanguage(availableLanguages[this._Languages.tag('List').index]).then(res => console.log("sucess language set ::::", res)) + FireBoltApi.get().localization.setlanguage(availableLanguages[this._Languages.tag('List').index]).then(res => this.LOG("sucess language set ::::" + JSON.stringify(res))) } localStorage.setItem('Language',availableLanguages[this._Languages.tag('List').index]) let path = location.pathname.split('index.html')[0] let url = path.slice(-1) === '/' ? "static/loaderApp/index.html" : "/static/loaderApp/index.html" let notification_url = location.origin + path + url - appApi.launchResident(notification_url, loader).catch(err => {console.error("error while launching loader url in resident app", err) }) + appApi.launchResident(notification_url, loader).catch(err => {this.ERR("error while launching loader url in resident app" + JSON.stringify(err)) }) RDKShellApis.setVisibility(GLOBALS.selfClientName, false) location.reload(); } diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkConfigurationScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkConfigurationScreen.js index 123df29..87a0e60 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkConfigurationScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkConfigurationScreen.js @@ -20,8 +20,8 @@ import { Lightning, Utils, Language, Router } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' import { CONFIG } from '../../Config/Config' -import Network from '../../api/NetworkApi' import { Metrics } from '@firebolt-js/sdk' +import NetworkManager from '../../api/NetworkManagerAPI' export default class NetworkConfigurationScreen extends Lightning.Component { pageTransition() { @@ -144,12 +144,14 @@ export default class NetworkConfigurationScreen extends Lightning.Component { let _currentIPSettings = {} let _newIPSettings = {} - Network.get().getDefaultInterface().then(interfaceName => { - this.$NetworkInterfaceText(interfaceName) + NetworkManager.GetPrimaryInterface().then(interfaceName => { + if(interfaceName === "eth0"){this.$NetworkInterfaceText("ETHERNET")} + if(interfaceName === "wlan0"){this.$NetworkInterfaceText("WIFI")} }) - this.onDefaultIfaceChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onDefaultInterfaceChanged', data => { - this.$NetworkInterfaceText(data.newInterfaceName) + this.onDefaultIfaceChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onActiveInterfaceChange', data => { + if(data.currentActiveInterface === "eth0"){this.$NetworkInterfaceText("ETHERNET")} + else{this.$NetworkInterfaceText("WIFI")} this.tag('TestInternetAccess.Title').text.text = Language.translate('Test Internet Access: ') Metrics.action("user", "User changed the network interface", null) }); @@ -239,9 +241,9 @@ export default class NetworkConfigurationScreen extends Lightning.Component { async _handleEnter() { this.loadingAnimation.start() this.tag('TestInternetAccess.Loader').visible = true - await Network.get().isConnectedToInternet().then(result => { + await NetworkManager.IsConnectedToInternet().then(result => { var connectionStatus = Language.translate("Internet Access: ") - if (result) { + if (result.connected) { connectionStatus += Language.translate("Connected") } else { connectionStatus += Language.translate("Disconnected") diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInfoScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInfoScreen.js index 27cb3f4..077e280 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInfoScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInfoScreen.js @@ -20,14 +20,21 @@ import { Lightning, Language, Router } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' import { CONFIG, GLOBALS } from '../../Config/Config' -import Network from '../../api/NetworkApi' -import WiFi from '../../api/WifiApi' import FireBoltApi from '../../api/firebolt/FireBoltApi' +import NetworkManager from '../../api/NetworkManagerAPI' var defaultInterface = ""; var currentInterface = []; export default class NetworkInfo extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -270,16 +277,16 @@ export default class NetworkInfo extends Lightning.Component { } _active() { - this.onInterfaceStatusChangedCB = Network.get()._thunder.on(Network.get().callsign,'onInterfaceStatusChanged', data => { - this.refreshDetails(); - }) - this.onConnectionStatusChangedCB = Network.get()._thunder.on(Network.get().callsign,'onConnectionStatusChanged', data => { + this.onInterfaceStatusChangedCB = NetworkManager.thunder.on(NetworkManager.callsign,'onInterfaceStateChange', data => { + this.WARN("Oninterfacestatuschanged" + JSON.stringify(data)) this.refreshDetails(); }) - this.onIPAddressStatusChangedCB = Network.get()._thunder.on(Network.get().callsign,'onIPAddressStatusChanged', data => { + this.onIPAddressStatusChangedCB = NetworkManager.thunder.on(NetworkManager.callsign,'onAddressChange', data => { + this.WARN("OnAdrresschanged" + JSON.stringify(data)) this.refreshDetails(); }) - this.onDefaultInterfaceChangedCB = Network.get()._thunder.on(Network.get().callsign,'onDefaultInterfaceChanged', data => { + this.onDefaultInterfaceChangedCB = NetworkManager.thunder.on(NetworkManager.callsign,'onActiveInterfaceChange', data => { + this.WARN("OnActiveInterfaceChange" + JSON.stringify(data)) this.refreshDetails(); }) if ("ResidentApp" !== GLOBALS.selfClientName) @@ -292,7 +299,6 @@ export default class NetworkInfo extends Lightning.Component { _inactive() { this.onInterfaceStatusChangedCB.dispose(); - this.onConnectionStatusChangedCB.dispose(); this.onIPAddressStatusChangedCB.dispose(); this.onDefaultInterfaceChangedCB.dispose(); } @@ -305,13 +311,14 @@ export default class NetworkInfo extends Lightning.Component { this.tag("MACAddress.Value").text.text = `NA` if ("ResidentApp" === GLOBALS.selfClientName) { - await Network.get().getDefaultInterface().then((defaultInterface) => { - Network.get().getIPSettings(defaultInterface).then((result) => { - if (result.interface === "WIFI") { + await NetworkManager.GetPrimaryInterface().then((defaultInterface) => { + console.log("defaultinterface"+defaultInterface) + NetworkManager.GetIPSettings(defaultInterface).then((result) => { + if (result.interface === "wlan0") { this.tag("ConnectionType.Value").text.text = Language.translate("Wireless") this.tag("SSID").alpha = 1 this.tag("SignalStrength").alpha = 1 - WiFi.get().getConnectedSSID().then((result) => { + NetworkManager.GetConnectedSSID().then((result) => { if (parseInt(result.signalStrength) >= -50) { this.tag("SignalStrength.Value").text.text = `Excellent` } @@ -325,28 +332,28 @@ export default class NetworkInfo extends Lightning.Component { this.tag("SignalStrength.Value").text.text = `Poor` } this.tag("SSID.Value").text.text = `${result.ssid}` - }).catch((error) => console.log(error)); - } else if (result.interface === "ETHERNET") { + }).catch((error) => this.ERR("Error: " + JSON.stringify(error))); + } else if (result.interface === "eth0") { this.tag("ConnectionType.Value").text.text = 'Ethernet' this.tag("SSID").alpha = 0 this.tag("SignalStrength").alpha = 0 } this.tag('InternetProtocol.Value').text.text = result.ipversion - this.tag('IPAddress.Value').text.text = result.ipaddr + this.tag('IPAddress.Value').text.text = result.ipaddress this.tag("Gateway.Value").text.text = result.gateway - }).catch((err) => console.error(err)) + }).catch((err) => this.ERR("Error: " + JSON.stringify(err))) - Network.get().getInterfaces().then((interfaces) => { - currentInterface = interfaces.filter((data) => data.interface === defaultInterface) + NetworkManager.GetAvailableInterfaces().then((interfaces) => { + currentInterface = interfaces.filter((data) => data.name === defaultInterface) if (currentInterface[0].connected) { this.tag("Status.Value").text.text = Language.translate('Connected') } else { this.tag('Status.Value').text.text = Language.translate('Disconnected') } - this.tag('MACAddress.Value').text.text = currentInterface[0].macAddress - }).catch((error) => console.log(error)); - }).catch((error) => console.log(error)); + this.tag('MACAddress.Value').text.text = currentInterface[0].mac + }).catch((error) => this.ERR("Error: " + JSON.stringify(error))); + }).catch((error) => this.ERR("Error: " + JSON.stringify(error))); } else{ await FireBoltApi.get().deviceinfo.getnetwork().then(res=>{ @@ -354,7 +361,7 @@ export default class NetworkInfo extends Lightning.Component { this.tag("ConnectionType.Value").text.text = Language.translate("Wireless") this.tag("SSID").alpha = 1 this.tag("SignalStrength").alpha = 1 - WiFi.get().getConnectedSSID().then((result) => { + NetworkManager.GetConnectedSSID().then((result) => { if (parseInt(result.signalStrength) >= -50) { this.tag("SignalStrength.Value").text.text = `Excellent` } @@ -368,7 +375,7 @@ export default class NetworkInfo extends Lightning.Component { this.tag("SignalStrength.Value").text.text = `Poor` } this.tag("SSID.Value").text.text = `${result.ssid}` - }).catch((error) => console.log(error)); + }).catch((error) => this.ERR("Error: " + JSON.stringify(error))); } else if (res.type === "ethernet") { this.tag("ConnectionType.Value").text.text = 'Ethernet' this.tag("SSID").alpha = 0 @@ -380,19 +387,19 @@ export default class NetworkInfo extends Lightning.Component { else { this.tag('Status.Value').text.text = Language.translate('Disconnected') } - Network.get().getDefaultInterface().then((defaultInterface) => { - Network.get().getIPSettings(defaultInterface).then((result) => { + NetworkManager.GetPrimaryInterface().then((defaultInterface) => { + NetworkManager.GetIPSettings(defaultInterface).then((result) => { this.tag('InternetProtocol.Value').text.text = result.ipversion - this.tag('IPAddress.Value').text.text = result.ipaddr + this.tag('IPAddress.Value').text.text = result.ipaddress this.tag("Gateway.Value").text.text = result.gateway }) - Network.get().getInterfaces().then((interfaces) => { - currentInterface = interfaces.filter((data) => data.interface === defaultInterface) - this.tag('MACAddress.Value').text.text = currentInterface[0].macAddress - }).catch((error) => console.log(error)); + NetworkManager.GetAvailableInterfaces().then((res) => { + currentInterface = res.interfaces.filter((data) => data.type === defaultInterface) + this.tag('MACAddress.Value').text.text = currentInterface[0].mac + }).catch((error) => this.ERR("Error: " + JSON.stringify(error))); }) - }).catch((error) => console.log(error)); + }).catch((error) => this.ERR("Error: " + JSON.stringify(error))); } } diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInterfaceScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInterfaceScreen.js index 653979a..ef714c3 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInterfaceScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/NetworkInterfaceScreen.js @@ -20,11 +20,19 @@ import { Lightning, Router, Utils } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' import { CONFIG } from '../../Config/Config' -import Network from '../../api/NetworkApi' import { Language } from '@lightningjs/sdk'; import { Metrics } from '@firebolt-js/sdk' +import NetworkManager from '../../api/NetworkManagerAPI' export default class NetworkInterfaceScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _construct() { this.LoadingIcon = Utils.asset('images/settings/Loading.png') } @@ -90,32 +98,32 @@ export default class NetworkInterfaceScreen extends Lightning.Component { } _focus() { - console.warn(new Date().toISOString() +" from: NetworkInterfaceScreen.js") + this.WARN(new Date().toISOString() +" from: NetworkInterfaceScreen.js") this._setState('WiFi'); } _active() { - this.onDefaultInterfaceChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onDefaultInterfaceChanged', (notification) => { - console.log('onDefaultInterfaceChanged notification from networkInterfaceScreen: ', notification) - if (notification.newInterfaceName === "ETHERNET") { + this.onDefaultInterfaceChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onActiveInterfaceChange', (notification) => { + this.LOG('onActiveInterfaceChange notification from networkInterfaceScreen: ' + JSON.stringify(notification)) + if (notification.currentActiveInterface === "eth0") { this.loadingAnimation.stop() this.tag('Ethernet.Loader').visible = false this.tag('Ethernet.Title').text.text = 'Ethernet: ' + Language.translate("Connected") - } else if (notification.newInterfaceName === "" && notification.oldInterfaceName === "WIFI") { + } else if (notification.currentActiveInterface === "" && notification.prevActiveInterface === "wlan0") { this.loadingAnimation.stop() this.tag('Ethernet.Loader').visible = false this.tag('Ethernet.Title').text.text = 'Ethernet: '+Language.translate('Error')+', '+Language.translate('Retry')+'!' - } else if (notification.newInterfaceName === "WIFI") { + } else if (notification.currentActiveInterface === "wlan0") { this.loadingAnimation.stop() this.tag('Ethernet.Loader').visible = false this.tag('Ethernet.Title').text.text = 'Ethernet' } Metrics.action("user", "The user changed the network interface", null) }); - this.onConnectionStatusChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onConnectionStatusChanged', (notification) => { - console.log('onConnectionStatusChanged notification from networkInterfaceScreen: ', notification) - if (notification.interface === "ETHERNET") { - this.tag('Ethernet.Title').text.text = 'Ethernet: ' + Language.translate(notification.status.toLowerCase()) + this.onConnectionStatusChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onInterfaceStateChange', (notification) => { + this.LOG('onInterfaceStateChange notification from networkInterfaceScreen: ' + JSON.stringify(notification)) + if (notification.interface === "eth0") { + this.tag('Ethernet.Title').text.text = 'Ethernet: ' + Language.translate(notification.state.toLowerCase()) } Metrics.action("App", "network connection of app changed", null) }); @@ -189,25 +197,21 @@ export default class NetworkInterfaceScreen extends Lightning.Component { this.tag('Ethernet.Title').text.text = 'Ethernet :' + Language.translate('Configuring as default') this.tag('Ethernet.Loader').visible = true this.loadingAnimation.start() - await Network.get().isInterfaceEnabled("ETHERNET").then(enabled => { + await NetworkManager.GetInterfaceState("eth0").then(enabled => { if (!enabled) { - Network.get().setInterfaceEnabled("ETHERNET").then(() => { - Network.get().setDefaultInterface("ETHERNET").then(result => { - if (result) { - this.loadingAnimation.stop() - this.tag('Ethernet.Title').text.text = 'Ethernet' - this.tag('Ethernet.Loader').visible = false - } - }); - }); - } else { - Network.get().setDefaultInterface("ETHERNET").then(result => { + NetworkManager.SetInterfaceState("eth0").then(() => { if (result) { - this.loadingAnimation.stop() - this.tag('Ethernet.Title').text.text = 'Ethernet' - this.tag('Ethernet.Loader').visible = false + this.loadingAnimation.stop() + this.tag('Ethernet.Title').text.text = 'Ethernet' + this.tag('Ethernet.Loader').visible = false } }); + } else { + setTimeout(() => { + this.loadingAnimation.stop() + this.tag('Ethernet.Title').text.text = 'Ethernet' + this.tag('Ethernet.Loader').visible = false + }, 1000) } }); } diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/PrivacyScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/PrivacyScreen.js index 61936be..19e5954 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/PrivacyScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/PrivacyScreen.js @@ -24,6 +24,7 @@ import { COLORS } from '../../colors/Colors' import { CONFIG,GLOBALS } from '../../Config/Config' import XcastApi from '../../api/XcastApi' import UsbApi from '../../api/UsbApi' +import Warehouse from '../../api/WarehouseApis' /** * Class for Privacy Screen. @@ -33,6 +34,14 @@ const xcastApi = new XcastApi() let cookieToggle = false export default class PrivacyScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Privacy')); } @@ -181,6 +190,7 @@ export default class PrivacyScreen extends Lightning.Component { this.checkLocalDeviceStatus() this.USBApi = new UsbApi() this.AppApi = new AppApi() + this.Warehouse= new Warehouse() } _focus() { @@ -235,7 +245,7 @@ export default class PrivacyScreen extends Lightning.Component { }) } }).catch(err => { - console.log('Service not active') + this.LOG('Service not active') this.tag('LocalDeviceDiscovery.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') }) } @@ -281,7 +291,7 @@ export default class PrivacyScreen extends Lightning.Component { this.tag('UsbMediaDevices.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') this.widgets.menu.refreshMainView() }).catch(err => { - console.error(`error while disabling the usb plugin = ${err}`) + this.ERR("error while disabling the usb plugin = " + JSON.stringify(err)) this.fireAncestors('$registerUsbMount') }) } else if (_UsbMedia === 'OFF') { @@ -336,15 +346,11 @@ export default class PrivacyScreen extends Lightning.Component { this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') } - this.AppApi.clearCache() - .then(() => { - //location.reload(true) - }) - setTimeout(() => { + setTimeout(async () => { if(GLOBALS.AlexaAvsstatus){ AlexaApi.get().resetAVSCredentials().then((result) => { - console.log("Triggering AVS credential reset." ,result) + this.LOG("Triggering AVS credential reset." + JSON.stringify(result)) if (result.success) { AlexaApi.get().setAlexaAuthStatus("AlexaAuthPending"); this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate('Finished') @@ -364,14 +370,31 @@ export default class PrivacyScreen extends Lightning.Component { } })} else{ - this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate('Finished') - setTimeout(() => { - this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') - this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') - cookieToggle = !cookieToggle - }, 2000) - } - }, 2000) + try { + await this.Warehouse.activate() + await this.Warehouse.lightReset()} + catch (err) { + this.ERR("FactoryReset: warehouse plugin activation failed; feature may not work." + JSON.stringify(err)); + } + this.AppApi.clearCache() + .then(() =>{ + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate('Finished') + setTimeout(() => { + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + cookieToggle = !cookieToggle + }, 2000) + }) + .catch((err) => { + this.ERR("Error clearing cache: " + JSON.stringify(err)); + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + " - " + Language.translate("Error!") + setTimeout(() => { + this.tag('ClearCookies.Title').text = Language.translate('Clear Cookies and App Data') + this.tag('ClearCookies.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') + cookieToggle = !cookieToggle + }, 2000) + }) + }}, 2000) } }, class PrivacyPolicy extends this { diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/RebootConfirmationScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/RebootConfirmationScreen.js index e1b7dcc..d661f46 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/RebootConfirmationScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/RebootConfirmationScreen.js @@ -26,6 +26,14 @@ const appApi = new AppApi() */ export default class RebootConfirmationScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -136,7 +144,7 @@ export default class RebootConfirmationScreen extends Lightning.Component { } _handleEnter() { appApi.reboot("User Trigger").then(result => { - console.log('device rebooting' + JSON.stringify(result)) + this.LOG('device rebooting' + JSON.stringify(result)) this._setState('Rebooting') }) } diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/TTSScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/TTSScreen.js index a570264..300f25f 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/TTSScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/TTSScreen.js @@ -26,6 +26,14 @@ import TTSApi from '../../api/TTSApi'; import UserSettingsApi from '../../api/UserSettingsApi'; export default class TTSScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Advanced Settings TTS')); } @@ -116,7 +124,7 @@ export default class TTSScreen extends Lightning.Component { this.userSettingsApi.getVoiceGuidance() .then(userSettingsApiIsEnabled => { this.ttsSupport = ttsApiIsEnabled && userSettingsApiIsEnabled; - console.log(`TTS API: ${ttsApiIsEnabled} US: ${userSettingsApiIsEnabled}`) + this.LOG("TTS API: " + JSON.stringify(ttsApiIsEnabled) + " US: " + JSON.stringify(userSettingsApiIsEnabled)) if (this.ttsSupport === true) { this.tag('Enable.Button').src = Utils.asset('images/settings/ToggleOnOrange.png'); } @@ -248,7 +256,7 @@ export default class TTSScreen extends Lightning.Component { this.textCollection = this.textCollection.substring(0, this.textCollection.length - 1); this.tag('EndpointText').text.text = this.textCollection; } else if (key === '#@!' || key === 'abc' || key === 'áöû' || key === 'shift') { - console.log('no saving') + this.LOG("no saving") } else if (key === 'Space') { this.textCollection += ' ' this.tag('EndpointText').text.text = this.textCollection; diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/TimeZone.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/TimeZone.js index d9289dc..4f12bca 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/TimeZone.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/TimeZone.js @@ -7,6 +7,14 @@ import FireBoltApi from "../../api/firebolt/FireBoltApi"; export default class TimeZone extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Advanced Settings Device Time')); } @@ -87,7 +95,7 @@ export default class TimeZone extends Lightning.Component { this.zone = await FireBoltApi.get().localization.getTimeZone() } try { - console.log(this.resp, this.zone) + this.LOG(JSON.stringify(this.resp) + " " + JSON.stringify(this.zone)) delete this.resp.Etc for (const i in this.resp) { if (typeof this.resp[i] === 'object') { @@ -98,10 +106,10 @@ export default class TimeZone extends Lightning.Component { AlexaApi.get().updateDeviceTimeZoneInAlexa(this.zone) } } catch (error) { - console.log('no api present', error) + this.ERR('no api present' + JSON.stringify(error)) } - console.log(data) + this.LOG("data: " + JSON.stringify(data)) if (data.length > 1) { this.tag('List').h = data.length * 90 this.tag('List').items = data.map((item, idx) => { diff --git a/accelerator-home-ui/src/screens/RcInformationScreen.js b/accelerator-home-ui/src/screens/RcInformationScreen.js index 5704b0c..03fe522 100644 --- a/accelerator-home-ui/src/screens/RcInformationScreen.js +++ b/accelerator-home-ui/src/screens/RcInformationScreen.js @@ -26,6 +26,14 @@ const _thunder = ThunderJS(CONFIG.thunderConfig) let onStatusCBhandle = null; export default class RCInformationScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Bluetooth Voice Remote Control')); } @@ -220,16 +228,16 @@ export default class RCInformationScreen extends Lightning.Component { } async _active() { - await RCApi.get().activate().catch(err => { console.error("RCInformationScreen error:", err) }); + await RCApi.get().activate().catch(err => { this.ERR("RCInformationScreen error: " + JSON.stringify(err)) }); await RCApi.get().getNetStatus().then(result => { - console.info("RCInformationScreen getNetStatus:", result) + this.INFO("RCInformationScreen getNetStatus: " + JSON.stringify(result)) onStatusCBhandle = _thunder.on('org.rdk.RemoteControl', 'onStatus', data => { this.onStatusCB(data) }); this.onStatusCB(result); - }).catch(err => console.error("RCInformationScreen error:", err)); + }).catch(err => this.ERR("RCInformationScreen error: " + JSON.stringify(err))); } _inactive() { - console.warn("RCInformationScreen _inactive."); + this.WARN("RCInformationScreen _inactive."); if(onStatusCBhandle != null)onStatusCBhandle.dispose(); this.tag("Status.Value").text.text = `N/A` this.tag("MacAddress.Value").text.text = `N/A` @@ -250,7 +258,7 @@ export default class RCInformationScreen extends Lightning.Component { cbDatastatus = cbData.status; } if (cbDatastatus.remoteData.length) { - console.log("RCInformationScreen rcPairingApis RemoteData Length", cbDatastatus.remoteData.length) + this.LOG("RCInformationScreen rcPairingApis RemoteData Length " + JSON.stringify(cbDatastatus.remoteData.length)) let RemoteName = []; let connectedStatus = []; let MacAddress = []; let swVersion = []; let BatteryPercent = []; @@ -278,9 +286,9 @@ export default class RCInformationScreen extends Lightning.Component { if(cbDatastatus.pairingState != "SEARCHING" && cbDatastatus.pairingState != "PAIRING" ) { for(let i=0;i { - console.err("RCInformationScreen startPairing error:", err); + this.ERR("RCInformationScreen startPairing error: " + JSON.stringify(err)); }); } } diff --git a/accelerator-home-ui/src/screens/ScreenSaverTimer.js b/accelerator-home-ui/src/screens/ScreenSaverTimer.js index c97076d..ff159ca 100644 --- a/accelerator-home-ui/src/screens/ScreenSaverTimer.js +++ b/accelerator-home-ui/src/screens/ScreenSaverTimer.js @@ -29,6 +29,14 @@ var thunder = ThunderJS(CONFIG.thunderConfig); export default class SreenSaverScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Screen Saver')); } @@ -37,7 +45,6 @@ export default class SreenSaverScreen extends Lightning.Component { return 'left' } - static _template() { return { rect: true, @@ -99,10 +106,10 @@ export default class SreenSaverScreen extends Lightning.Component { return "Off"; } }).catch(err => { - console.error("App PersistentStoreApi getValue error: " + JSON.stringify(err)); + this.ERR("App PersistentStoreApi getValue error: " + JSON.stringify(err)); return "Off"; }); - console.log("PersistentStoreApi focusedValue", FocusedValue); + this.LOG("PersistentStoreApi focusedValue" + JSON.stringify(FocusedValue)); this.options = [ { value: 'Off', tick: true }, @@ -139,27 +146,27 @@ export default class SreenSaverScreen extends Lightning.Component { setTimerValue(time) { if (time === "Off" || time === undefined || time === null) { - RDKShellApis.enableInactivityReporting(false).then(resp => console.log(resp)) + RDKShellApis.enableInactivityReporting(false).then(resp => this.LOG("setTimerValue response: " + JSON.stringify(resp))) Storage.remove('ScreenSaverTimeoutInterval') } else { // 10 RDKShellApis.enableInactivityReporting(true).then(() => { RDKShellApis.setInactivityInterval(parseInt(time)).then(res => { - console.log("setinactivityres", res) + this.LOG("setinactivityres" + JSON.stringify(res)) Storage.set('ScreenSaverTimeoutInterval', time) - console.log(`successfully set the timer to ${time} minutes`) + this.LOG("successfully set the timer to " + JSON.stringify(time) + " minutes") thunder.on('org.rdk.RDKShell', 'onUserInactivity', notification => { - console.log("UserInactivityStatusNotification: ", JSON.stringify(notification)) + this.LOG("UserInactivityStatusNotification: " + JSON.stringify(notification)) appApi.getAvCodeStatus().then(result => { - console.log("Avdecoder", result.avDecoderStatus); + this.LOG("Avdecoder" + JSON.stringify(result.avDecoderStatus)); if ((result.avDecoderStatus === "IDLE" || result.avDecoderStatus === "PAUSE") && GLOBALS.topmostApp === GLOBALS.selfClientName) { this.fireAncestors("$hideImage", 1); } }) }) }).catch(err => { - console.error(`error while setting the timer` + JSON.stringify(err)) + this.ERR("error while setting the timer" + JSON.stringify(err)) }); }) } @@ -184,9 +191,9 @@ export default class SreenSaverScreen extends Lightning.Component { this.tag('List').element.tag('Tick').visible = true this.timerValue = this.options[this.tag('List').index].value//10 minutes this.timerValue = this.timerValue === "Off" ? "Off" : this.timerValue.substring(0, 2) // 10 - console.log("ScreenSaverTime Value:" + JSON.stringify(this.timerValue)) + this.LOG("ScreenSaverTime Value:" + JSON.stringify(this.timerValue)) await PersistentStoreApi.get().setValue('ScreenSaverTime', 'timerValue', this.timerValue).catch(err => { - console.error("App PersistentStoreApi setValue error: " + JSON.stringify(err)); + this.ERR("App PersistentStoreApi setValue error: " + JSON.stringify(err)); }); this.setTimerValue(this.timerValue);// enable and setinactivity process this.fireAncestors('$screenSaverTime', this.options[this.tag('List').index].value) diff --git a/accelerator-home-ui/src/screens/SettingsScreen.js b/accelerator-home-ui/src/screens/SettingsScreen.js index 2205d9d..9659e8f 100644 --- a/accelerator-home-ui/src/screens/SettingsScreen.js +++ b/accelerator-home-ui/src/screens/SettingsScreen.js @@ -20,7 +20,7 @@ import { Lightning, Utils, Language, Router, Storage } from '@lightningjs/sdk' import ThunderJS from 'ThunderJS'; import { COLORS } from '../colors/Colors' import SettingsMainItem from '../items/SettingsMainItem' -import { CONFIG } from '../Config/Config' +import { CONFIG, GLOBALS } from '../Config/Config' import DTVApi from '../api/DTVApi'; import AppApi from '../api/AppApi'; import { Metrics } from '@firebolt-js/sdk'; @@ -31,6 +31,14 @@ var thunder = ThunderJS(CONFIG.thunderConfig); * Class for settings screen. */ export default class SettingsScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings')); } @@ -258,17 +266,17 @@ export default class SettingsScreen extends Lightning.Component { _firstActive() { if (Storage.get("NFRStatus")) { - console.log(`Netflix : NFRStatus is found to be enabled`) + this.LOG("Netflix : NFRStatus is found to be enabled") this.tag("NFRStatus.Button").src = "static/images/settings/ToggleOnOrange.png" } else { - console.log(`Netflix : NFRStatus is found to be disabled`) + this.LOG("Netflix : NFRStatus is found to be disabled") this.tag("NFRStatus.Button").src = "static/images/settings/ToggleOffWhite.png" } this.dtvApi = new DTVApi(); this.dtvPlugin = false; //plugin availability - if (Storage.get("deviceType") != "IpStb") { + if (GLOBALS.deviceType != "IpStb") { this.dtvApi.activate().then(() => { this.dtvPlugin = true; this.tag("DTVSettings").alpha = 1; @@ -404,10 +412,9 @@ export default class SettingsScreen extends Lightning.Component { thunder.call("Netflix.1", "nfrstatus", { "params": "disable" }).then(nr => { self.tag("NFRStatus.Button").src = "static/images/settings/ToggleOffWhite.png" Storage.set("NFRStatus", false) - console.log(`Netflix : nfr disable updation results in ${nr}`) + self.LOG("Netflix : nfr disable updation results in " + JSON.stringify(nr)) }).catch(nerr => { - console.error(`Netflix : error while updating nfrstatus`) - console.error(nerr) + self.ERR("Netflix : error while updating nfrstatus" + JSON.stringify(nerr)) Metrics.error(Metrics.ErrorType.OTHER, 'PluginError', "Thunder Netflix.1 nfrstatus disabling error"+JSON.stringify(nerr), false, null) }) @@ -417,10 +424,10 @@ export default class SettingsScreen extends Lightning.Component { thunder.call("Netflix.1", "nfrstatus", { "params": "enable" }).then(nr => { self.tag("NFRStatus.Button").src = "static/images/settings/ToggleOnOrange.png" Storage.set("NFRStatus", true) - console.log(`Netflix : nfr enable results in ${nr}`) + self.LOG("Netflix : nfr enable results in " + JSON.stringify(nr)) }).catch(nerr => { - console.error(`Netflix : error while updating nfrstatus `) - console.error(nerr) + self.ERR("Netflix : error while updating nfrstatus ") + self.ERR(nerr) Metrics.error(Metrics.ErrorType.OTHER, 'PluginError', "Thunder Netflix.1 nfrstatus enabling error"+JSON.stringify(nerr), false, null) }) diff --git a/accelerator-home-ui/src/screens/SleepTimerScreen.js b/accelerator-home-ui/src/screens/SleepTimerScreen.js index 53810a8..2779bef 100644 --- a/accelerator-home-ui/src/screens/SleepTimerScreen.js +++ b/accelerator-home-ui/src/screens/SleepTimerScreen.js @@ -21,6 +21,14 @@ import SettingsItem from '../items/SettingsItem' export default class SleepTimerScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Settings Other Settings Sleep Timer')); } @@ -82,7 +90,7 @@ export default class SleepTimerScreen extends Lightning.Component { this.fireAncestors('$registerInactivityMonitoringEvents').then(() => { this.fireAncestors('$resetSleepTimer', timeoutInterval); }).catch(err => { - console.error('error while registering the inactivity monitoring event' + JSON.stringify(err)) + this.ERR('error while registering the inactivity monitoring event' + JSON.stringify(err)) }) this._setState('Options') diff --git a/accelerator-home-ui/src/screens/SplashScreens/BluetoothScreen.js b/accelerator-home-ui/src/screens/SplashScreens/BluetoothScreen.js index 6bbe8bd..847e366 100644 --- a/accelerator-home-ui/src/screens/SplashScreens/BluetoothScreen.js +++ b/accelerator-home-ui/src/screens/SplashScreens/BluetoothScreen.js @@ -29,6 +29,14 @@ var bluetoothApi = new BluetoothApi(); const _thunder = ThunderJS(CONFIG.thunderConfig) export default class BluetoothScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { w: 1920, @@ -135,28 +143,28 @@ export default class BluetoothScreen extends Lightning.Component { //bluetoothApi.btactivate().then(enableResult =>{ // console.log('1') bluetoothApi.enable().then(res => { - console.log("SplashBluetoothScreen enable result: ", res) + this.LOG("SplashBluetoothScreen enable result: " + JSON.stringify(res)) bluetoothApi.startScanBluetooth().then(startScanresult => { - console.log('SplashBluetoothScreen startScanresult ', startScanresult) + this.LOG('SplashBluetoothScreen startScanresult ' + JSON.stringify(startScanresult)) var SubscribeEvent = _thunder.on('org.rdk.Bluetooth', 'onDiscoveredDevice', notification => { bluetoothApi.getDiscoveredDevices().then((getdocoveredInfo) => { - console.log('SplashBluetoothScreen onDiscoveredDevice ', getdocoveredInfo[0].name) + this.LOG('SplashBluetoothScreen onDiscoveredDevice ' + JSON.stringify(getdocoveredInfo[0].name)) this.tag('Info').text.text = `pairing this device ${getdocoveredInfo[0].name}` //bluetoothApi.connect(getdocoveredInfo[0].deviceID, getdocoveredInfo[0].deviceType).then(connectresult=>{ // console.log("connectresult",connectresult) bluetoothApi.pair(getdocoveredInfo[0].deviceID).then(Pairresult => { - console.log("SplashBluetoothScreen Pairresult", Pairresult) + this.LOG("SplashBluetoothScreen Pairresult" + JSON.stringify(Pairresult)) bluetoothApi.getConnectedDevices().then(getCdresult => { - console.log("SplashBluetoothScreen getConnectedDevices", getCdresult) + this.LOG("SplashBluetoothScreen getConnectedDevices" + JSON.stringify(getCdresult)) bluetoothApi.getPairedDevices().then(getpairedDevices => { - console.log("SplashBluetoothScreen getpairedDevices", getpairedDevices) + this.LOG("SplashBluetoothScreen getpairedDevices" + JSON.stringify(getpairedDevices)) bluetoothApi.stopScan().then(stopScan => { - console.log("SplashBluetoothScreen stopscan", stopScan) + this.LOG("SplashBluetoothScreen stopscan" + JSON.stringify(stopScan)) SubscribeEvent.dispose(); //bluetoothApi.disable().then(disable =>{ //console.log("disable") bluetoothApi.deactivateBluetooth().then(deactivateBluetooth => { - console.log("SplashBluetoothScreen DeactivatedBluetooth", deactivateBluetooth) + this.LOG("SplashBluetoothScreen DeactivatedBluetooth" + JSON.stringify(deactivateBluetooth)) if (Router.getActiveHash() === "splash/bluetooth") { Router.navigate('splash/language') } @@ -164,26 +172,26 @@ export default class BluetoothScreen extends Lightning.Component { }) .catch(err => { - console.error(`SplashBluetoothScreen cant stopscan device : ${JSON.stringify(err)}`) + this.ERR(`SplashBluetoothScreen cant stopscan device : ${JSON.stringify(err)}`) }) }) .catch(err => { - console.error(`SplashBluetoothScreen cant getpaired device : ${JSON.stringify(err)}`) + this.ERR("SplashBluetoothScreen cant stopscan device : " + JSON.stringify(err)) }) - }) + }) .catch(err => { - console.error(`SplashBluetoothScreen Can't getconnected device : ${JSON.stringify(err)}`) + this.ERR("SplashBluetoothScreen cant getpaired device : " + JSON.stringify(err)) }) - }) + }) .catch(err => { - console.error(`SplashBluetoothScreen Can't pair device : ${JSON.stringify(err)}`) + this.ERR(`SplashBluetoothScreen Can't pair device : ${JSON.stringify(err)}`) }) }) }) }) - .catch(err => { - console.error(`Can't scan enable : ${JSON.stringify(err)}`) - }) + .catch(err => { + this.ERR("Can't scan enable : " + JSON.stringify(err)) + }) }) } @@ -221,9 +229,9 @@ export default class BluetoothScreen extends Lightning.Component { if(cbDatastatus.pairingState != "SEARCHING" && cbDatastatus.pairingState != "PAIRING" ) { for(let i=0;i { - console.err("RCInformationScreen startPairing error:", err); + this.ERR("RCInformationScreen startPairing error: " + JSON.stringify(err)); }); } } @@ -234,7 +242,7 @@ export default class BluetoothScreen extends Lightning.Component { async rcPairingFlow(activatePlugin = false) { if (activatePlugin) { await RCApi.get().activate().catch(err => { - console.error("SplashBluetoothScreen org.rdk.RemoteControl activate error:", err) + this.ERR("SplashBluetoothScreen org.rdk.RemoteControl activate error: " + JSON.stringify(err)) return; }); } @@ -247,23 +255,23 @@ export default class BluetoothScreen extends Lightning.Component { _init() { appApi.getPluginStatus('org.rdk.RemoteControl').then(result => { if (result[0].state != "activated") { - console.log("SplashBluetoothScreen init RemoteControl activate.") + this.LOG("SplashBluetoothScreen init RemoteControl activate.") this.rcPairingFlow(true); } else { - console.log("SplashBluetoothScreen init RemoteControl already activated.") + this.LOG("SplashBluetoothScreen init RemoteControl already activated.") this.rcPairingFlow(); } }).catch(err => { - console.log('SplashBluetoothScreen getPluginStatus org.rdk.RemoteControl error:', JSON.stringify(err)) + this.ERR('SplashBluetoothScreen getPluginStatus org.rdk.RemoteControl error: ' + JSON.stringify(err)) appApi.getPluginStatusParams('org.rdk.Bluetooth').then(pluginresult => { - console.log("SplashBluetoothScreen getPluginStatusParams org.rdk.Bluetooth:", pluginresult[1]) + this.LOG("SplashBluetoothScreen getPluginStatusParams org.rdk.Bluetooth: " + JSON.stringify(pluginresult[1])) if (pluginresult[1] === 'deactivated') { bluetoothApi.btactivate().then(result => { - console.log("SplashBluetoothScreen init pairing bluetooth") + this.LOG("SplashBluetoothScreen init pairing bluetooth" + JSON.stringify(result)) this._PairingApis() }) } else { - console.log("SplashBluetoothScreen init status not deactivated") + this.LOG("SplashBluetoothScreen init status not deactivated") this._PairingApis() } }) diff --git a/accelerator-home-ui/src/screens/SplashScreens/LanguageScreen.js b/accelerator-home-ui/src/screens/SplashScreens/LanguageScreen.js index f235545..697d63b 100644 --- a/accelerator-home-ui/src/screens/SplashScreens/LanguageScreen.js +++ b/accelerator-home-ui/src/screens/SplashScreens/LanguageScreen.js @@ -29,6 +29,14 @@ const appApi = new AppApi() const loader = 'Loader' export default class LanguageScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { w: 1920, @@ -80,9 +88,9 @@ export default class LanguageScreen extends Lightning.Component { }, Continue: { - x: 820, y: 250, w: 300, mountX: 0.5, h: 60, rect: true, color: 0xFFFFFFFF, + x: 820, y: 250, w: 400, mountX: 0.5, h: 60, rect: true, color: 0xFFFFFFFF, Title: { - x: 150, + x: 200, y: 30, mount: 0.5, text: { @@ -117,17 +125,16 @@ export default class LanguageScreen extends Lightning.Component { appApi.deactivateResidentApp(loader) RDKShellApis.moveToFront(GLOBALS.selfClientName) RDKShellApis.setFocus(GLOBALS.selfClientName).then(result => { - console.log('LanguageScreen: ResidentApp moveToFront Success'); + this.LOG('LanguageScreen: ResidentApp moveToFront Success') RDKShellApis.getVisibility(GLOBALS.selfClientName).then(visible => { - if (!visible) RDKShellApis.setVisibility(GLOBALS.selfClientName, true); + if (!visible) RDKShellApis.setVisibility(GLOBALS.selfClientName, true) }) }).catch(err => { - console.log('LanguageScreen: Error', err); + this.ERR('LanguageScreen: Error' + JSON.stringify(err)) Metrics.error(Metrics.ErrorType.OTHER, "AppLangugaeError", 'Thunder RDKShell setFocus Error' + JSON.stringify(err), false, null) }); } - pageTransition() { return 'left' } @@ -144,7 +151,7 @@ export default class LanguageScreen extends Lightning.Component { if ("ResidentApp" === GLOBALS.selfClientName) { appApi.setUILanguage(availableLanguageCodes[availableLanguages[index]]) } else { - FireBoltApi.get().localization.setlanguage(availableLanguages[index]).then(res => console.log("sucess language set ::::",res)) + FireBoltApi.get().localization.setlanguage(availableLanguages[index]).then(res => this.LOG("sucess language set ::::" + JSON.stringify(res))) } localStorage.setItem('Language',availableLanguages[index]) } @@ -177,7 +184,7 @@ export default class LanguageScreen extends Lightning.Component { let path = location.pathname.split('index.html')[0] let url = path.slice(-1) === '/' ? "static/loaderApp/index.html" : "/static/loaderApp/index.html" let notification_url = location.origin + path + url - console.log(notification_url) + this.LOG("LanguageScreen notification_url: " + JSON.stringify(notification_url)) appApi.launchResident(notification_url, loader).catch(err => { }) RDKShellApis.setVisibility(GLOBALS.selfClientName, false) location.reload(); diff --git a/accelerator-home-ui/src/screens/SplashScreens/LogoScreen.js b/accelerator-home-ui/src/screens/SplashScreens/LogoScreen.js index b9f328c..c51c8f9 100644 --- a/accelerator-home-ui/src/screens/SplashScreens/LogoScreen.js +++ b/accelerator-home-ui/src/screens/SplashScreens/LogoScreen.js @@ -25,6 +25,14 @@ var appApi = new AppApi(); let path = ''; export default class LogoScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { rect: true, @@ -77,7 +85,7 @@ export default class LogoScreen extends Lightning.Component { _firstEnable() { console.timeEnd('PerformanceTest') - console.log('Splash Screen timer end - ', new Date().toUTCString()) + this.LOG('Splash Screen timer end - ' + JSON.stringify(new Date().toUTCString())) } async _focus() { @@ -108,15 +116,16 @@ export default class LogoScreen extends Lightning.Component { this._setState('Ok') } else { if(this._isBluetoothExist) { - await this.btApi.btactivate().then(res => { console.log("successfully btactivated", res) }) - .catch(err => console.log(`error in btactivate`)) + await this.btApi.btactivate().then(res => { this.LOG("successfully btactivated" + JSON.stringify(res)) }) + .catch(err => this.ERR("error in btactivate" + JSON.stringify(err))) this.btApi.getPairedDevices().then(devices => { if (devices.length > 0 || Storage.get('setup')) { path = this.checkPath(path) } }) - .catch(() => { + .catch((err) => { path = this.checkPath(path) + this.ERR("getPairedDevices error: " + JSON.stringify(err)) }) } this._setState('Next') @@ -126,7 +135,7 @@ export default class LogoScreen extends Lightning.Component { Registry.removeEventListener(document, 'keydown', this.handler) } _handleBack() { - console.error("Initial page; cannot go back."); + this.ERR("Initial page; cannot go back."); } static _states() { diff --git a/accelerator-home-ui/src/screens/SplashScreens/NetworkList.js b/accelerator-home-ui/src/screens/SplashScreens/NetworkList.js index 8fc8ad1..fbbd85d 100644 --- a/accelerator-home-ui/src/screens/SplashScreens/NetworkList.js +++ b/accelerator-home-ui/src/screens/SplashScreens/NetworkList.js @@ -21,11 +21,18 @@ import { Lightning, Utils, Router, Registry, Language, Storage } from '@lightnin import { COLORS } from '../../colors/Colors' import { CONFIG,GLOBALS } from '../../Config/Config' import SettingsMainItem from '../../items/SettingsMainItem' -import Network from '../../api/NetworkApi' -import WiFi, { WiFiError, WiFiState, WiFiErrorMessages } from '../../api/WifiApi' import WiFiItem from '../../items/WiFiItem' +import NetworkManager,{WiFiState}from '../../api/NetworkManagerAPI' export default class NetworkList extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { w: 1920, @@ -126,7 +133,16 @@ export default class NetworkList extends Lightning.Component { pageTransition() { return 'left' } - + set params(args) { + if (args.wifiError) { + if(args.wifiError.code && args.wifiError.message){ + this.tag('Info').text.text = Language.translate(`Error Code : ${args.wifiError.code} \t Error Msg : ${args.wifiError.message}`); + } + else{ + this.tag('Info').text.text = Language.translate(args.wifiError); + } + } + } _firstEnable() { this.wifiLoading = this.tag('Loader').animation({ duration: 3, @@ -145,33 +161,28 @@ export default class NetworkList extends Lightning.Component { this.tag('JoinAnotherNetwork').visible = true } this._setState('JoinAnotherNetwork') - Network.get().activate().then(result => { + NetworkManager.activate().then(result => { if (result) { - Network.get()._thunder.on(Network.get().callsign, 'onIPAddressStatusChanged', notification => { - console.log(JSON.stringify(notification)) - if (notification.status == 'ACQUIRED') { - // Nothing to do here. - } else if (notification.status == 'LOST') { - if (notification.interface === 'WIFI') { - Network.get().setInterfaceEnabled('ETHERNET').then(res => { - if (res) { - Network.get().setDefaultInterface('ETHERNET') - } - }) - } - } + NetworkManager.thunder.on(NetworkManager.callsign, 'onAddressChange', notification => { + this.LOG("OnAddresschange result "+JSON.stringify(notification)) + // if (notification.status == 'ACQUIRED') { + // // Nothing to do here. + // } else if (notification.status == 'LOST') { + // if (notification.interface === 'wlan0') { + // NetworkManager.SetInterfaceState('eth0').then(res => { + // }) + // } + // } }) - Network.get()._thunder.on(Network.get().callsign, 'onDefaultInterfaceChanged', notification => { - console.log(JSON.stringify(notification)) - if (notification.newInterfaceName === 'ETHERNET') { - Network.get().setInterfaceEnabled('ETHERNET').then(result => { - if (result) { - Network.get().setDefaultInterface('ETHERNET') - } - }) - } else if ( - notification.newInterfaceName == 'ETHERNET' || - notification.oldInterfaceName == 'WIFI' + NetworkManager.thunder.on(NetworkManager.callsign, 'onActiveInterfaceChange', notification => { + this.LOG("Onactiveinterfacechange result"+JSON.stringify(notification)) + // if (notification.currentActiveInterface === 'eth0') { + // NetworkManager.SetInterfaceState('eth0').then(result => { + // }) + // } else if ( + if( + notification.currentActiveInterface == 'eth0' || + notification.prevActiveInterface == 'wlan0' ) { //WiFi.get().disconnect() this.wifiStatus = false @@ -181,33 +192,22 @@ export default class NetworkList extends Lightning.Component { this.wifiLoading.stop() this.tag('Switch.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') this._setState('Switch') - Network.get().setInterfaceEnabled('ETHERNET').then(result => { - if (result) { - Network.get().setDefaultInterface('ETHERNET') - } - }) - } - else if ( - notification.newInterfaceName === "" && - notification.oldInterfaceName === "WIFI" - ) { - console.log('emplty new old wifi') - Network.get().setDefaultInterface('ETHERNET') + // NetworkManager.SetInterfaceState('eth0').then(result => { + // }) } }) - Network.get()._thunder.on(Network.get().callsign, 'onConnectionStatusChanged', notification => { - if (notification.interface === 'ETHERNET' && notification.status === 'CONNECTED') { - Network.get().setInterfaceEnabled('ETHERNET').then(res => { - if (res) { - Network.get().setDefaultInterface('ETHERNET') - } + NetworkManager.thunder.on(NetworkManager.callsign, 'onInterfaceStateChange', notification => { + if (notification.interface === 'eth0' && notification.status === 'INTERFACE_ADDED') { + NetworkManager.SetInterfaceState('eth0').then(res => { }) } }) } }) } - + _handleBack(){ + Router.navigate('splash/network') + } /** * Function to be executed when the Wi-Fi screen is enabled. */ @@ -217,7 +217,7 @@ export default class NetworkList extends Lightning.Component { if (this.showConnectMessage) { this.tag('Info').text.text = Language.translate("Searching, please wait"); } - WiFi.get().startScan() + NetworkManager.StartWiFiScan() } } @@ -225,7 +225,7 @@ export default class NetworkList extends Lightning.Component { * Function to be executed when the Wi-Fi screen is disabled. */ _unfocus() { - WiFi.get().stopScan() + NetworkManager.StopWiFiScan() } /** @@ -233,11 +233,10 @@ export default class NetworkList extends Lightning.Component { */ async renderDeviceList(ssids) { console.log("WIFI renderDeviceList ssids.length:", ssids.length) - this.tag('Networks.AvailableNetworks').tag('List').rollMax = ssids.length * 90 this._pairedList = []; - await WiFi.get().getCurrentState().then(async (state) => { + await NetworkManager.GetWifiState().then(async (state) => { if (state === WiFiState.CONNECTED) { - await WiFi.get().getConnectedSSID().then(result => { + await NetworkManager.GetConnectedSSID().then(result => { if (result.ssid != '') { console.log("Connected network detected " + JSON.stringify(result.ssid)) this._pairedList = [result] @@ -315,6 +314,7 @@ export default class NetworkList extends Lightning.Component { } _handleEnter() { console.log(this.tag('Networks.AvailableNetworks').tag('List').element._item) + GLOBALS.NetworkListStatus = true Router.navigate('settings/network/interface/wifi/connect', { wifiItem: this.tag('Networks.AvailableNetworks').tag('List').element._item }) } }, @@ -353,7 +353,7 @@ export default class NetworkList extends Lightning.Component { if (dir === 'down') { if (list.index < list.length - 1) list.setNext() else if (list.index == list.length - 1) { - WiFi.get().startScan() + NetworkManager.StartWiFiScan() this._setState('JoinAnotherNetwork') if (listname === 'MyDevices' && this.tag('Networks.AvailableNetworks').tag('List').length > 0) { this._setState('AvailableDevices') @@ -376,30 +376,26 @@ export default class NetworkList extends Lightning.Component { */ switch() { if (!this.wifiStatus) { - WiFi.get().disconnect() - console.log('turning off wifi') - Network.get().setInterfaceEnabled('ETHERNET', true).then(result => { + NetworkManager.WiFiDisconnect() + this.LOG('turning off wifi') + NetworkManager.SetInterfaceState('eth0').then(result => { if (result) { - Network.get().setDefaultInterface('ETHERNET', true).then(result => { - if (result) { - WiFi.get().disconnect() + NetworkManager.WiFiDisconnect() this.wifiStatus = false this.tag('Networks').visible = false this.tag('JoinAnotherNetwork').visible = false this.tag('Loader').visible = false this.wifiLoading.stop() - } - }) } }) } else { - console.log('turning on wifi') + this.LOG('turning on wifi') //this.wifiStatus = true this.tag('Networks').visible = true this.tag('JoinAnotherNetwork').visible = true this.wifiLoading.play() this.tag('Loader').visible = true - WiFi.get().startScan() + NetworkManager.StartWiFiScan() } } @@ -408,42 +404,38 @@ export default class NetworkList extends Lightning.Component { * Function to activate Wi-Fi plugin. */ _activateWiFi() { - WiFi.get().activate().then(() => { this.switch() - }) - WiFi.get().thunder.on(WiFi.get().callsign, 'onWIFIStateChanged', notification => { - console.log(JSON.stringify(notification)) - if (notification.state === WiFiState.CONNECTED && ! GLOBALS.Setup) { + NetworkManager.thunder.on(NetworkManager.callsign, 'onWiFiStateChange', notification => { + this.LOG(JSON.stringify(notification)) + if (notification.state === WiFiState.WIFI_STATE_CONNECTED && ! GLOBALS.Setup) { this.tag('Info').text.text = Language.translate("Connection successful"); Registry.setTimeout(() => { Router.navigate('menu') }, 2000) - } else if (notification.state === WiFiState.CONNECTING || notification.state === WiFiState.PAIRING) { + } else if (notification.state === WiFiState.WIFI_STATE_CONNECTING || notification.state === WiFiState.WIFI_STATE_PAIRING) { this.tag('Info').text.text = Language.translate("Connecting, please wait"); } - }) - WiFi.get().thunder.on(WiFi.get().callsign, 'onError', error => { - WiFi.get().startScan() - Network.get().getDefaultInterface().then(defIface => { - if (defIface != "ETHERNET") { - Network.get().setInterfaceEnabled('ETHERNET').then(res => { - if (res) { - Network.get().setDefaultInterface('ETHERNET') + else if(notification.state === WiFiState.WIFI_STATE_SSID_CHANGED|| notification.state === WiFiState.WIFI_STATE_CONNECTION_LOST || + notification.state === WiFiState.WIFI_STATE_CONNECTION_FAILED || + notification.state === WiFiState.WIFI_STATE_CONNECTION_INTERRUPTED || + notification.state === WiFiState.WIFI_STATE_INVALID_CREDENTIALS || + notification.state === WiFiState.WIFI_STATE_AUTHENTICATION_FAILED || + notification.state === WiFiState.WIFI_STATE_ERROR ) + { + NetworkManager.StartWiFiScan() + NetworkManager.GetPrimaryInterface().then(defIface => { + if (defIface != "eth0") { + NetworkManager.SetInterfaceState('eth0').then(res => { + }) } - }) + }); + // Show error message. + this.tag('Info').text.text = Language.translate(`Error Code : ${notification.state} \t Error Msg : ${Object.keys(WiFiState).find(key=>WiFiState[key]===notification.state)}`); } - }); - if (error.code === WiFiError.INVALID_CREDENTIALS - || error.code === WiFiError.SSID_CHANGED - || error.code === WiFiError.CONNECTION_FAILED - || error.code === WiFiError.CONNECTION_INTERRUPTED) { - // Show error message. - this.tag('Info').text.text = Language.translate(WiFiErrorMessages[error.code]); - } }) - WiFi.get().thunder.on(WiFi.get().callsign, 'onAvailableSSIDs', notification => { + NetworkManager.thunder.on(NetworkManager.callsign, 'onAvailableSSIDs', notification => { this.ssids = [...this.ssids, ...notification.ssids] - if (!notification.moreData) { + // if (!notification.moreData) { if (this.showConnectMessage) { this.showConnectMessage = false this.tag('Info').text.text = Language.translate("Select a network to connect"); @@ -453,7 +445,7 @@ export default class NetworkList extends Lightning.Component { this.tag('Loader').visible = false this.wifiLoading.stop() }, 1000) - } + // } }) } } diff --git a/accelerator-home-ui/src/screens/SplashScreens/NetworkScreen.js b/accelerator-home-ui/src/screens/SplashScreens/NetworkScreen.js index 5090e4c..6cf2ea6 100644 --- a/accelerator-home-ui/src/screens/SplashScreens/NetworkScreen.js +++ b/accelerator-home-ui/src/screens/SplashScreens/NetworkScreen.js @@ -21,11 +21,18 @@ import { Lightning, Router, Storage, Language, Registry } from '@lightningjs/sdk import { COLORS } from '../../colors/Colors' import { CONFIG, GLOBALS } from '../../Config/Config' import SettingsMainItem from '../../items/SettingsMainItem' -import Network from '../../api/NetworkApi' import AlexaApi from '../../api/AlexaApi' import AppApi from '../../api/AppApi' +import NetworkManager from '../../api/NetworkManagerAPI' export default class NetworkScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { w: 1920, @@ -115,9 +122,10 @@ export default class NetworkScreen extends Lightning.Component { async _init() { this.appApi = new AppApi(); - await this.appApi.checkStatus(Network.get().callsign).then(nwPluginStatus => { + await this.appApi.checkStatus(NetworkManager.callsign).then(nwPluginStatus => { if (nwPluginStatus[0].state.toLowerCase() !== "activated") { - Network.get().activate(); + console.log("Iniate the activate call") + NetworkManager.activate(); } }); } @@ -144,16 +152,14 @@ export default class NetworkScreen extends Lightning.Component { } _handleEnter() { // this._setState('WiFiScreen') - Network.get().setInterfaceEnabled('WIFI').then(res => { + NetworkManager.SetInterfaceState('wlan0').then(res => { if (res) { - Network.get().setDefaultInterface('WIFI').then(() => { Registry.setTimeout(() => { Router.navigate('splash/networkList') }, (Router.isNavigating() ? 20 : 0)); - }) } }) - console.log("Wifi") + this.LOG("Wifi") } }, class Ethernet extends this { @@ -164,23 +170,22 @@ export default class NetworkScreen extends Lightning.Component { this.tag('Ethernet')._unfocus() } _handleEnter() { - Network.get().setInterfaceEnabled('ETHERNET').then(res => { + NetworkManager.SetInterfaceState('eth0').then(res => { if (res) { - Network.get().setDefaultInterface('ETHERNET').then(() => { - Network.get().getInterfaces().then(res => { - let eth = res.filter((item) => item.interface == 'ETHERNET') - if (eth[0].interface == 'ETHERNET' && eth[0].enabled == true && eth[0].connected == true) { + NetworkManager.GetAvailableInterfaces().then(res => { + console.log(JSON.stringify(res)) + let eth = res.filter((item) => item.type == 'ETHERNET') + if (eth[0].type == 'ETHERNET' && eth[0].enabled == true && eth[0].connected == true) { Registry.setTimeout(() => { Router.navigate('menu') }, (Router.isNavigating() ? 20 : 0)); } - else if (eth[0].interface == 'ETHERNET' && eth[0].connected == false) { + else if (eth[0].type == 'ETHERNET' && eth[0].connected == false) { Registry.setTimeout(() => { Router.navigate('splash/networkPrompt') }, (Router.isNavigating() ? 20 : 0)); } }) - }) } }) } @@ -217,8 +222,8 @@ export default class NetworkScreen extends Lightning.Component { } _handleEnter() { if (AlexaApi.get().checkAlexaAuthStatus() !== "AlexaUserDenied" && GLOBALS.AlexaAvsstatus) { - Network.get().isConnectedToInternet().then(result => { - if (result) + NetworkManager.IsConnectedToInternet().then(result => { + if (result.connected) Registry.setTimeout(() => { Router.navigate('AlexaLoginScreen') }, (Router.isNavigating() ? 20 : 0)); diff --git a/accelerator-home-ui/src/screens/UsbAppsScreen.js b/accelerator-home-ui/src/screens/UsbAppsScreen.js index 5ecb87a..4a5d9e3 100644 --- a/accelerator-home-ui/src/screens/UsbAppsScreen.js +++ b/accelerator-home-ui/src/screens/UsbAppsScreen.js @@ -30,6 +30,14 @@ var usbApi = new UsbApi(); export default class UsbAppsScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText('USB') } @@ -233,7 +241,7 @@ export default class UsbAppsScreen extends Lightning.Component { this.cwd.pop(); this.loadData(); }).catch(err => { - console.error(`error while getting the usb contents; error = ${JSON.stringify(err)}`); + this.ERR("error while getting the usb contents; error = " + JSON.stringify(err)); }); } else { Router.navigate('menu'); @@ -438,7 +446,7 @@ export default class UsbAppsScreen extends Lightning.Component { // `); this.loadData(); }).catch(err => { - console.error(`error while getting the usb contents; error = ${JSON.stringify(err)}`); + this.ERR("error while getting the usb contents; error = " + JSON.stringify(err)); }); } @@ -533,7 +541,7 @@ export default class UsbAppsScreen extends Lightning.Component { loadData() { - // console.log(`loading data from the directory ${this.cwd}`); + this.LOG("loading data from the directory " + JSON.stringify(this.cwd)); let sumY = 0; this.index = 0; this.traversableRows = []; @@ -614,7 +622,6 @@ export default class UsbAppsScreen extends Lightning.Component { } this._setState(this.traversableRows[0]); } - } _focus() { @@ -626,7 +633,7 @@ export default class UsbAppsScreen extends Lightning.Component { this.loadData(); this._setState(this.traversableRows[this.index] + `.${this.currentIndex}`)//focus on first element }).catch(err => { - console.error(`error while getting the usb contents; error = ${JSON.stringify(err)}`); + this.ERR("error while getting the usb contents; error = " + JSON.stringify(err)); }); } } else { @@ -637,7 +644,7 @@ export default class UsbAppsScreen extends Lightning.Component { this.loadData(); this._setState(this.traversableRows[this.index]) }).catch(err => { - console.error(`error while getting the usb contents; error = ${JSON.stringify(err)}`); + this.ERR("error while getting the usb contents; error = " + JSON.stringify(err)); }) } // this._setState(this.traversableRows[this.index]) diff --git a/accelerator-home-ui/src/screens/Video.js b/accelerator-home-ui/src/screens/Video.js index 3b01b42..c984bc8 100644 --- a/accelerator-home-ui/src/screens/Video.js +++ b/accelerator-home-ui/src/screens/Video.js @@ -1,12 +1,20 @@ import { Lightning, Utils, VideoPlayer } from "@lightningjs/sdk"; export default class Splash extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return {}; } _active() { - console.log("Activevideo") + this.LOG("Activevideo") VideoPlayer.playPause() VideoPlayer.consumer(this); VideoPlayer.size(1920, 1080); diff --git a/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioOutputScreen.js b/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioOutputScreen.js index 99be53f..253d684 100644 --- a/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioOutputScreen.js +++ b/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioOutputScreen.js @@ -24,6 +24,13 @@ import AudioOutputItem from "../../items/AudioOutputItem" */ export default class AudioOutputScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } static _template() { return { rect: true, @@ -79,7 +86,7 @@ export default class AudioOutputScreen extends Lightning.Component { }) this._setState("Options"); }).catch(err => { - console.log(`Error while getting Connected AudioPorts :${err}`); + this.ERR("Error while getting Connected AudioPorts :" + JSON.stringify(err)); }) } diff --git a/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioScreen.js b/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioScreen.js index 27f0370..664ebfd 100644 --- a/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioScreen.js +++ b/accelerator-home-ui/src/screens/VideoAndAudioScreens/AudioScreen.js @@ -20,7 +20,7 @@ import { Lightning, Utils, Language, Router, Storage } from '@lightningjs/sdk' import SettingsMainItem from '../../items/SettingsMainItem' import { COLORS } from '../../colors/Colors' -import { CONFIG } from '../../Config/Config' +import { CONFIG, GLOBALS } from '../../Config/Config' import AppApi from '../../api/AppApi.js'; /** @@ -29,6 +29,14 @@ import AppApi from '../../api/AppApi.js'; export default class AudioScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -285,58 +293,58 @@ export default class AudioScreen extends Lightning.Component { * 1 - get DRC Mode which doesnot return a drc mode and the success value is mostly false * 2- set Volume - able to set the value to 100 * 3- get Volume - able to get the volume successfully as well - * 4- - * + * 4- + * */ //console.log(`Enter input was given to dynamic range ... `); // gets the drc mode this.appApi.getDRCMode().then(res => { }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }) - this.appApi.setVolumeLevel(((Storage.get("deviceType")=="tv")?"SPEAKER0":"HDMI0"), 100).then(res => { + this.appApi.setVolumeLevel(((GLOBALS.deviceType=="IpTv")?"SPEAKER0":"HDMI0"), 100).then(res => { this.appApi.getVolumeLevel().catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }) }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }); this.appApi.getConnectedAudioPorts().then(res => { }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }) // gets the enabled Audio Port - this.appApi.getEnableAudioPort(((Storage.get("deviceType")=="tv")?"SPEAKER0":"HDMI0")).then(res => { + this.appApi.getEnableAudioPort(((GLOBALS.deviceType=="IpTv")?"SPEAKER0":"HDMI0")).then(res => { }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }) this.appApi.getSupportedAudioPorts().catch(err => { - console.log(`Error while getting the supported Audio ports ie. ${err}`); + this.ERR("Error while getting the supported Audio ports ie. " + JSON.stringify(err)); }); // set enable Audio POrt - this.appApi.setEnableAudioPort(((Storage.get("deviceType")=="tv")?"SPEAKER0":"HDMI0")).then(res => { + this.appApi.setEnableAudioPort(((GLOBALS.deviceType=="IpTv")?"SPEAKER0":"HDMI0")).then(res => { - this.appApi.getEnableAudioPort(((Storage.get("deviceType")=="tv")?"SPEAKER0":"HDMI0")).then(res => { + this.appApi.getEnableAudioPort(((GLOBALS.deviceType=="IpTv")?"SPEAKER0":"HDMI0")).then(res => { }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }) }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }); // set zoom setting ,possible values : FULL, NONE, Letterbox 16x9, Letterbox 14x9, CCO, PanScan, Letterbox 2.21 on 4x3, Letterbox 2.21 on 16x9, Platform, Zoom 16x9, Pillarbox 4x3, Widescreen 4x3 this.appApi.setZoomSetting("FULL").then(res => { this.appApi.getZoomSetting().then(res => { }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }) }).catch(err => { - console.log(err) + this.ERR("Error: " + JSON.stringify(err)) }) } }, diff --git a/accelerator-home-ui/src/screens/VideoAndAudioScreens/HdmiOutputScreen.js b/accelerator-home-ui/src/screens/VideoAndAudioScreens/HdmiOutputScreen.js index 7313b13..ddc1740 100644 --- a/accelerator-home-ui/src/screens/VideoAndAudioScreens/HdmiOutputScreen.js +++ b/accelerator-home-ui/src/screens/VideoAndAudioScreens/HdmiOutputScreen.js @@ -26,6 +26,14 @@ import AppApi from '../../api/AppApi.js'; var appApi = new AppApi(); export default class HdmiOutputScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -118,11 +126,11 @@ export default class HdmiOutputScreen extends Lightning.Component { this._setState("Options") }) .catch(err => { - console.log('error', err) + this.ERR('error' + JSON.stringify(err)) }) }) .catch(err => { - console.log('error', JSON.stringify(err)) + this.ERR('error' + JSON.stringify(err)) }) } diff --git a/accelerator-home-ui/src/screens/VideoAndAudioScreens/ResolutionScreen.js b/accelerator-home-ui/src/screens/VideoAndAudioScreens/ResolutionScreen.js index 9433862..972a7f1 100644 --- a/accelerator-home-ui/src/screens/VideoAndAudioScreens/ResolutionScreen.js +++ b/accelerator-home-ui/src/screens/VideoAndAudioScreens/ResolutionScreen.js @@ -31,6 +31,14 @@ const thunder = thunderJS(CONFIG.thunderConfig) export default class ResolutionScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -81,12 +89,12 @@ export default class ResolutionScreen extends Lightning.Component { }); thunder.on('org.rdk.DisplaySettings', 'resolutionPreChange', notification => { - console.log(new Date().toISOString() + " ResolutionScreen got resolutionPreChange"); + this.LOG(new Date().toISOString() + " ResolutionScreen got resolutionPreChange"); Storage.set("ResolutionChangeInProgress", true); }) thunder.on('org.rdk.DisplaySettings', 'resolutionChanged', notification => { - console.log(new Date().toISOString() + " ResolutionScreen got resolutionChanged"); + this.LOG(new Date().toISOString() + " ResolutionScreen got resolutionChanged"); const items = this.tag('List').items items.forEach(element => { element.tag('Item.Tick').visible = false @@ -141,7 +149,7 @@ export default class ResolutionScreen extends Lightning.Component { this.tag('List').setIndex(sIndex) this._setState("Options") }).catch(err => { - console.log(`error while fetching the supported resolution ${err}`); + this.ERR("error while fetching the supported resolution " + JSON.stringify(err)); }) }) } diff --git a/accelerator-home-ui/src/screens/VideoAndAudioScreens/VideoScreen.js b/accelerator-home-ui/src/screens/VideoAndAudioScreens/VideoScreen.js index 9ee1297..141164f 100644 --- a/accelerator-home-ui/src/screens/VideoAndAudioScreens/VideoScreen.js +++ b/accelerator-home-ui/src/screens/VideoAndAudioScreens/VideoScreen.js @@ -29,6 +29,14 @@ import FireBoltApi from '../../api/firebolt/FireBoltApi' export default class VideoScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -214,7 +222,7 @@ export default class VideoScreen extends Lightning.Component { this._appApi.getResolution().then(resolution => { this.tag("Resolution.Title").text.text = Language.translate('Resolution: ') + resolution; }).catch(err => { - console.log("Error fetching the Resolution") + this.ERR("Error fetching the Resolution: " + JSON.stringify(err)) }) this._appApi.getHDCPStatus().then(result => { if (result.isHDCPCompliant && result.isHDCPEnabled) { diff --git a/accelerator-home-ui/src/screens/WiFiPairingScreen.js b/accelerator-home-ui/src/screens/WiFiPairingScreen.js index 9084900..31eb9ad 100644 --- a/accelerator-home-ui/src/screens/WiFiPairingScreen.js +++ b/accelerator-home-ui/src/screens/WiFiPairingScreen.js @@ -17,17 +17,26 @@ * limitations under the License. **/ import { Language, Lightning, Registry, Router } from '@lightningjs/sdk' -import { CONFIG } from '../Config/Config' +import { CONFIG, GLOBALS } from '../Config/Config' import ConfirmAndCancel from '../items/ConfirmAndCancel' import PasswordSwitch from './PasswordSwitch' import { Keyboard } from '../ui-components/index' import { KEYBOARD_FORMATS } from '../ui-components/components/Keyboard' -import WiFi, { WiFiError, WiFiState } from '../api/WifiApi' -import Network from '../api/NetworkApi' import PersistentStoreApi from '../api/PersistentStore' +import NetworkManager,{WiFiState} from '../api/NetworkManagerAPI' + +let Ssid = null export default class WifiPairingScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -147,6 +156,7 @@ export default class WifiPairingScreen extends Lightning.Component { this.passwd = ""; this.tag("Pwd").text.text = "" this.tag('Title').text = item.ssid + Ssid=item.ssid let options = [] this._item = item if (item.connected) { @@ -173,7 +183,6 @@ export default class WifiPairingScreen extends Lightning.Component { this._setState('Pair') } _unfocus() { - } _active() { @@ -183,24 +192,30 @@ export default class WifiPairingScreen extends Lightning.Component { } _inactive() { - if (this.onErrorCB) this.onErrorCB.dispose(); if (this.onWIFIStateChangedCB) this.onWIFIStateChangedCB.dispose(); if (this.waitToConnectTO) Registry.clearTimeout(this.waitToConnectTO); } - pressEnter(option) { + async pressEnter(option) { if (option === 'Cancel') { Router.back() } else if (option === 'Connect') { + GLOBALS.Wificonnectinprogress = true + const wificurrentstate=await NetworkManager.GetWifiState() + if(wificurrentstate === WiFiState.CONNECTED){ + setTimeout(() => { + GLOBALS.Wificonnectinprogress = false + }, 5000); + } if (this._item) { - WiFi.get().connect(false, this._item, '').then(() => { }) + NetworkManager.WiFiConnect(false, this._item, '').then(() => { }) .catch(err => { - console.error('Not able to connect to wifi', JSON.stringify(err)) + this.ERR("Not able to connect to wifi" + JSON.stringify(err)) }) } Router.back() } else if (option === 'Disconnect') { - WiFi.get().disconnect().then(() => { + NetworkManager.WiFiDisconnect().then(() => { Registry.setTimeout(() => { Router.back() }, (Router.isNavigating() ? 20 : 0)); @@ -208,35 +223,31 @@ export default class WifiPairingScreen extends Lightning.Component { } } - startConnect(password = "") { + async startConnect(password = "") { + GLOBALS.Wificonnectinprogress = true + const wificurrentstate=await NetworkManager.GetWifiState() + if(wificurrentstate === WiFiState.WIFI_STATE_CONNECTED){ + setTimeout(() => { + GLOBALS.Wificonnectinprogress = false + }, 5000); + } let flag = 0 - this.onErrorCB = WiFi.get().thunder.on(WiFi.get().callsign, 'onError', notification => { - if (notification.code === WiFiError.INVALID_CREDENTIALS || notification.code === WiFiError.SSID_CHANGED) { - console.log("INVALID_CREDENTIALS; deleting WiFi Persistence data.") - WiFi.get().clearSSID().then(() => { + this.onWIFIStateChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onWiFiStateChange', notification => { + if (notification.state === WiFiState.WIFI_STATE_INVALID_CREDENTIALS|| notification.state === WiFiState.WIFI_STATE_SSID_CHANGED) { + this.LOG("INVALID_CREDENTIALS; deleting WiFi Persistence data.") + NetworkManager.RemoveKnownSSID(Ssid).then(() => { PersistentStoreApi.get().deleteNamespace('wifi') }); flag = 1 - this.onErrorCB.dispose() - } - }) - this.onWIFIStateChangedCB = WiFi.get().thunder.on(WiFi.get().callsign, 'onWIFIStateChanged', notification => { - if (notification.state === WiFiState.CONNECTED) { - Network.get().setDefaultInterface("WIFI").then(() => { - console.log("Successfully set WIFI as default interface.") - }).catch(err => { - console.error("Could not set WIFI as default interface." + JSON.stringify(err)) - }); - this.onWIFIStateChangedCB.dispose() } }) - WiFi.get().connect(false, this._item, password).then(() => { - WiFi.get().saveSSID(this._item.ssid, password, this._item.security).then((response) => { - if (response.result === 0 && response.success === true && flag === 0) { + NetworkManager.WiFiConnect(false, this._item, password).then(() => { + NetworkManager.AddToKnownSSIDs(this._item.ssid, password, this._item.security).then((response) => { + if (response === true && flag === 0) { PersistentStoreApi.get().setValue('wifi', 'SSID', this._item.ssid) } - else if (response.result !== 0) { - WiFi.get().clearSSID(); + else { + NetworkManager.RemoveKnownSSID(Ssid) } }).then(() => { // Immediate return causes some clash at plugin implementation level resulting not saving/connecting. @@ -247,6 +258,17 @@ export default class WifiPairingScreen extends Lightning.Component { }, 5000); }); }) + .catch(err => { + this.ERR("Not able to connect to wifi" + JSON.stringify(err)); + if (GLOBALS.Setup !== true) { + Router.navigate('splash/networkList', { wifiError: `Wificonnect API response: ${err}` }); + } + else { + Router.back(); + this.widgets.fail.notify({ title: 'WiFi Status', msg: Language.translate(`Wificonnect API response: ${err}`) }) + Router.focusWidget('Fail') + } + }) } static _states() { diff --git a/accelerator-home-ui/src/screens/WifiScreen.js b/accelerator-home-ui/src/screens/WifiScreen.js index a0022bd..d4d48ae 100644 --- a/accelerator-home-ui/src/screens/WifiScreen.js +++ b/accelerator-home-ui/src/screens/WifiScreen.js @@ -17,19 +17,27 @@ * limitations under the License. **/ import { Language, Lightning, Registry, Router, Utils } from '@lightningjs/sdk' -import Network from './../api/NetworkApi' import WiFiItem from '../items/WiFiItem' import SettingsMainItem from '../items/SettingsMainItem' -import WiFi, { WiFiErrorMessages, WiFiState, WiFiError } from './../api/WifiApi' import { COLORS } from './../colors/Colors' -import { CONFIG } from '../Config/Config' +import { CONFIG, GLOBALS } from '../Config/Config' import AppApi from './../api/AppApi' import PersistentStoreApi from '../api/PersistentStore.js' +import NetworkManager ,{WiFiState}from '../api/NetworkManagerAPI.js' let appApi = new AppApi() var previousFocusedItemSSid +let selectedssid; export default class WiFiScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + pageTransition() { return 'left' } @@ -129,16 +137,16 @@ export default class WiFiScreen extends Lightning.Component { } async _init() { - await appApi.checkStatus(WiFi.get().callsign).then(result => { + await appApi.checkStatus(NetworkManager.callsign).then(result => { if (result[0].state !== "activated") { - WiFi.get().activate() + NetworkManager.activate() } }) } async _active() { this.renderSSIDS = this.ssids = [] - await Network.get().isInterfaceEnabled("WIFI").then(enabled => { + await NetworkManager.GetInterfaceState("wlan0").then(enabled => { this.wifiStatus = enabled }); this.onInterfaceStatusChangedCB = null @@ -147,7 +155,7 @@ export default class WiFiScreen extends Lightning.Component { _focus() { if (this.wifiStatus) { - WiFi.get().startScan() + NetworkManager.StartWiFiScan() this.tag('Networks').visible = true this.tag('JoinAnotherNetwork').visible = true this.tag('Switch.Loader').visible = true @@ -177,9 +185,9 @@ export default class WiFiScreen extends Lightning.Component { * Function to be executed when the Wi-Fi screen is disabled. */ _disable() { - Network.get().isInterfaceEnabled("WIFI").then(enabled => { + NetworkManager.GetInterfaceState("wlan0").then(enabled => { if (enabled) { - WiFi.get().stopScan() + NetworkManager.StopWiFiScan() this.wifiLoading.stop() this.tag('Switch.Loader').visible = false } @@ -198,16 +206,16 @@ export default class WiFiScreen extends Lightning.Component { * Function to render list of Wi-Fi networks. */ async renderDeviceList(ssids) { - console.log("WIFI renderDeviceList ssids.length:" + JSON.stringify(ssids.length)) + this.LOG("WIFI renderDeviceList ssids.length:" + JSON.stringify(ssids.length)) ssids.sort((a, b) => { if (a.signalStrength >= b.signalStrength) return -1; else return 1 }) this._pairedList = []; this.tag('Networks.PairedNetworks').h = 0; this.tag('Networks.AvailableNetworks').tag('List').rollMax = ssids.length * 90 this.tag('Networks.PairedNetworks').tag('List').items = [] this.tag('Networks.PairedNetworks').tag('List').h = 0 - await WiFi.get().getCurrentState().then(async (state) => { - if (state === WiFiState.CONNECTED) { - await WiFi.get().getConnectedSSID().then(result => { + await NetworkManager.GetWifiState().then(async (state) => { + if (state === WiFiState.WIFI_STATE_CONNECTED) { + await NetworkManager.GetConnectedSSID().then(result => { if (result.ssid != '') { console.log("Connected network detected " + JSON.stringify(result.ssid)) this._pairedList = [result] @@ -250,7 +258,7 @@ export default class WiFiScreen extends Lightning.Component { } }) let IndexVal = 0 - console.log("previousFocusedItemSSid:::", previousFocusedItemSSid) + this.LOG("previousFocusedItemSSid:::" + JSON.stringify(previousFocusedItemSSid)) this.tag('Networks.AvailableNetworks').tag('List').items.forEach(element => { if (element._item.ssid == previousFocusedItemSSid) { IndexVal = element.index @@ -324,50 +332,36 @@ export default class WiFiScreen extends Lightning.Component { this._navigate('AvailableDevices', 'up') } async _handleEnter() { - console.log("SSID check" + JSON.stringify(this.tag('Networks.AvailableNetworks').tag('List').element._item)) - let item = this.tag('Networks.AvailableNetworks').tag('List').element._item - await WiFi.get().isPaired().then(ispaired => { - if (!ispaired) { // ispaired.result == 0 means saved SSID. - WiFi.get().getPairedSSID().then(pairedssid => { - if (pairedssid === item.ssid) { - console.log("WiFiScreen getPairedSSID matched with current selection; try auto connect."); - WiFi.get().connect(true).then(() => { - WiFi.get().thunder.on('onError', notification => { - if (notification.code === WiFiError.SSID_CHANGED || notification.code === WiFiError.INVALID_CREDENTIALS) { - WiFi.get().clearSSID().then(() => { + this.LOG("SSID check" + JSON.stringify(this.tag('Networks.AvailableNetworks').tag('List').element._item)) + selectedssid = this.tag('Networks.AvailableNetworks').tag('List').element._item + await NetworkManager.GetKnownSSIDs().then(ssids => { + if (ssids.length) { // ispaired.result == 0 means saved SSID. + if (ssids.includes(selectedssid.ssid) ) { + this.LOG("WiFiScreen getPairedSSID matched with current selection; try auto connect.") + NetworkManager.WiFiConnect(true).then(() => { + NetworkManager.thunder.on('onWiFiStateChange', notification => { + if (notification.state === WiFiState.WIFI_STATE_SSID_CHANGED || notification.state === WiFiState.WIFI_STATE_INVALID_CREDENTIALS) { + NetworkManager.RemoveKnownSSID(selectedssid).then(() => { Router.navigate('settings/network/interface/wifi/connect', { wifiItem: this.tag('Networks.AvailableNetworks').tag('List').element._item }) }) } }) - WiFi.get().thunder.on('onWIFIStateChanged', notification => { - if (notification.state === WiFiState.CONNECTED) { - Network.get().setDefaultInterface("WIFI").then(() => { - console.log("Successfully set WIFI as default interface.") - }).catch(err => { - console.error("Could not set WIFI as default interface." + JSON.stringify(err)) - }); - } - }) }).catch(err => { - console.error("WiFiScreen auto-connect error:", JSON.stringify(err)); + this.ERR("WiFiScreen auto-connect error: " + JSON.stringify(err)); PersistentStoreApi.get().deleteKey('wifi', 'SSID').then(() => { Router.navigate('settings/network/interface/wifi/connect', { wifiItem: this.tag('Networks.AvailableNetworks').tag('List').element._item }) }) }) } else { - console.log("WiFiScreen getPairedSSID differs with current selection."); + this.LOG("WiFiScreen GetKnownSSIDs differs with current selection."); Router.navigate('settings/network/interface/wifi/connect', { wifiItem: this.tag('Networks.AvailableNetworks').tag('List').element._item }) } - }).catch(err => { - console.error("WiFi.getPairedSSID() error: ", JSON.stringify(err)); - Router.navigate('settings/network/interface/wifi/connect', { wifiItem: this.tag('Networks.AvailableNetworks').tag('List').element._item }) - }); } else { - console.log("WiFi.isPaired() is false; attempting regular connect."); + this.LOG("GetKnownSSIDs is false; attempting regular connect."); Router.navigate('settings/network/interface/wifi/connect', { wifiItem: this.tag('Networks.AvailableNetworks').tag('List').element._item }) } }).catch(err => { - console.error("WiFi.isPaired() error: ", JSON.stringify(err)); + this.ERR("GetKnownSSIDs error: " + JSON.stringify(err)); PersistentStoreApi.get().deleteKey('wifi', 'SSID').then(() => { Router.navigate('settings/network/interface/wifi/connect', { wifiItem: this.tag('Networks.AvailableNetworks').tag('List').element._item }) }) @@ -444,8 +438,8 @@ export default class WiFiScreen extends Lightning.Component { */ async switch() { if (this.wifiStatus) { - console.log('Disabling Wi-Fi.') - await Network.get().setInterfaceEnabled('WIFI', false).then(result => { + this.LOG('Disabling Wi-Fi.') + await NetworkManager.SetInterfaceState('wlan0', false).then(result => { if (result) { this.wifiStatus = false this.tag('Networks').visible = false @@ -454,32 +448,32 @@ export default class WiFiScreen extends Lightning.Component { this.wifiLoading.stop() this.tag('Switch.Button').src = Utils.asset('images/settings/ToggleOffWhite.png') } else { - console.error("setInterfaceEnabled WIFI false returned error: " + JSON.stringify(result)); + this.ERR("setInterfaceEnabled WIFI false returned error: " + JSON.stringify(result)); } }) } else { - console.log('Enabling Wi-Fi.') - await Network.get().isInterfaceEnabled("WIFI").then(ifaceStatus => { + this.LOG('Enabling Wi-Fi.') + await NetworkManager.GetInterfaceState("wlan0").then(ifaceStatus => { if (!ifaceStatus) { - this.onInterfaceStatusChangedCB = Network.get()._thunder.on(Network.get().callsign, 'onInterfaceStatusChanged', ifaceStatus => { - if ((ifaceStatus.interface === "WIFI") && ifaceStatus.enabled) { + this.onInterfaceStatusChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onInterfaceStatusChange', ifaceStatus => { + if ((ifaceStatus.interface === "wlan0") && ifaceStatus.enabled) { this.onInterfaceStatusChangedCB.dispose(); this.wifiStatus = true this.tag('Networks').visible = true this.tag('JoinAnotherNetwork').visible = true this.tag('Switch.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') - WiFi.get().startScan() + NetworkManager.StartWiFiScan() this.wifiLoading.play() this.tag('Switch.Loader').visible = true } }); - Network.get().setInterfaceEnabled("WIFI") + NetworkManager.SetInterfaceState("wlan0") } else { this.wifiStatus = true this.tag('Networks').visible = true this.tag('JoinAnotherNetwork').visible = true this.tag('Switch.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') - WiFi.get().startScan() + NetworkManager.StartWiFiScan() this.wifiLoading.play() this.tag('Switch.Loader').visible = true } @@ -489,34 +483,39 @@ export default class WiFiScreen extends Lightning.Component { } wifiEventHandlers() { - this.onWIFIStateChangedCB = WiFi.get().thunder.on(WiFi.get().callsign, 'onWIFIStateChanged', notification => { + this.onWIFIStateChangedCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onWiFiStateChange', async notification => { + this.WARN("OnWifistatechanged"+JSON.stringify(notification)) if (this.renderSSIDS.length) { this.renderDeviceList(this.renderSSIDS) } - if (notification.state === WiFiState.CONNECTED) { - WiFi.get().getConnectedSSID().then(result => { - PersistentStoreApi.get().setValue('wifi', 'SSID', result.ssid).then((response) => { console.log(response) }) + if (notification.state === WiFiState.WIFI_STATE_CONNECTED) { + NetworkManager.GetConnectedSSID().then(result => { + PersistentStoreApi.get().setValue('wifi', 'SSID', result.ssid).then((response) => { this.LOG("Set SSID response: " + JSON.stringify(response)) }) }) } + if(notification.state === WiFiState.WIFI_STATE_SSID_CHANGED|| notification.state === WiFiState.WIFI_STATE_CONNECTION_LOST || + notification.state === WiFiState.WIFI_STATE_CONNECTION_FAILED || + notification.state === WiFiState.WIFI_STATE_CONNECTION_INTERRUPTED || + notification.state === WiFiState.WIFI_STATE_INVALID_CREDENTIALS || + notification.state === WiFiState.WIFI_STATE_AUTHENTICATION_FAILED || + notification.state === WiFiState.WIFI_STATE_ERROR || notification.state === WiFiState.WIFI_STATE_DISCONNECTED) + { + if ((notification.code === WiFiState.WIFI_STATE_INVALID_CREDENTIALS) || (notification.code === WiFiState.WIFI_STATE_SSID_CHANGED)) { + await NetworkManager.RemoveKnownSSID(selectedssid) + } + if (this.renderSSIDS.length) { + this.renderDeviceList(this.renderSSIDS) + } + if (this.widgets && !((notification.code === WiFiState.WIFI_STATE_CONNECTION_LOST) && GLOBALS.Wificonnectinprogress)) { + this.widgets.fail.notify({ title: Language.translate('WiFi Status'), msg: `${Language.translate("Error Code :")} ${notification.state} \t ${Language.translate("Error Msg :")} ${Language.translate(Object.keys(WiFiState).find(key=>WiFiState[key]===notification.state))}` }) + Router.focusWidget('Fail') + } + } }); - this.onErrorCB = WiFi.get().thunder.on(WiFi.get().callsign, 'onError', notification => { - if (notification.code === WiFiError.INVALID_CREDENTIALS) { - WiFi.get().clearSSID() - } - if (this.renderSSIDS.length) { - this.renderDeviceList(this.renderSSIDS) - } - if (this.widgets) { - this.widgets.fail.notify({ title: 'WiFi Status', msg: Language.translate(`Error Code : ${notification.code} \t Error Msg : ${WiFiErrorMessages[notification.code]}`) }) - Router.focusWidget('Fail') - } - }); - - this.onAvailableSSIDsCB = WiFi.get().thunder.on(WiFi.get().callsign, 'onAvailableSSIDs', notification => { - console.log("Notification[onAvailableSSIDs]: found " + JSON.stringify(notification.ssids.length)) + this.onAvailableSSIDsCB = NetworkManager.thunder.on(NetworkManager.callsign, 'onAvailableSSIDs', notification => { + this.LOG("Notification[onAvailableSSIDs]: found " + JSON.stringify(notification.ssids.length)) this.ssids = [...this.ssids, ...notification.ssids] - if (!notification.moreData) { this.renderSSIDS = this.ssids this.ssids = [] this.renderDeviceList(this.renderSSIDS) @@ -524,12 +523,11 @@ export default class WiFiScreen extends Lightning.Component { this.tag('Switch.Loader').visible = false this.wifiLoading.stop() }, 1000) - } if (!notification.ssids.length) { - console.log("onAvailableSSIDs length is ZERO; scanning again.") - Network.get().isInterfaceEnabled("WIFI").then(enabled => { + this.LOG("onAvailableSSIDs length is ZERO; scanning again.") + NetworkManager.GetInterfaceState("wlan0").then(enabled => { if (enabled) { - WiFi.get().startScan() + NetworkManager.StartWiFiScan() this.wifiLoading.play() this.tag('Switch.Loader').visible = true } @@ -541,7 +539,6 @@ export default class WiFiScreen extends Lightning.Component { _inactive() { previousFocusedItemSSid = undefined this.onWIFIStateChangedCB.dispose(); - this.onErrorCB.dispose(); this.onAvailableSSIDsCB.dispose(); } } diff --git a/accelerator-home-ui/src/tvOverlay/TvOverlayScreen.js b/accelerator-home-ui/src/tvOverlay/TvOverlayScreen.js index b4ddbf7..bc59195 100644 --- a/accelerator-home-ui/src/tvOverlay/TvOverlayScreen.js +++ b/accelerator-home-ui/src/tvOverlay/TvOverlayScreen.js @@ -29,9 +29,17 @@ import { Metrics } from "@firebolt-js/sdk"; var thunder = ThunderJS(CONFIG.thunderConfig); export default class TvOverlayScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + set params(args) { this._type = args.type; - console.log("setting to idlestate"); + this.LOG("setting to idlestate"); setTimeout(() => { if (this._type === "inputs") { this._setState("OverlayInputScreen"); @@ -101,13 +109,13 @@ export default class TvOverlayScreen extends Lightning.Component { _handleBack() { this._setState("IdleState"); - console.log("currentApp: ", GLOBALS.topmostApp); + this.LOG("currentApp: " + JSON.stringify(GLOBALS.topmostApp)); setTimeout(() => { if (GLOBALS.topmostApp !== GLOBALS.selfClientName) { RDKShellApis.setVisibility(GLOBALS.selfClientName, false); RDKShellApis.moveToFront(GLOBALS.topmostApp).then(() => { RDKShellApis.setFocus(GLOBALS.topmostApp).catch((err) => { - console.log("Error", err); + this.ERR("Error" + JSON.stringify(err)); Metrics.error(Metrics.ErrorType.OTHER, 'pluginError', `Thunder RDKShell setfocus error ${JSON.stringify(err)}`, false, null) }); }); @@ -115,7 +123,7 @@ export default class TvOverlayScreen extends Lightning.Component { if (Router.getActiveHash() === "dtvplayer") { //don't navigate to menu if route is dtvplayer Router.focusPage(); } else { - console.log("else block navigating to menu"); + this.LOG("else block navigating to menu"); Router.navigate("menu"); //if user is currently on resident app, might not be needed as user should not be able to get on this screen while on resident app } } @@ -126,17 +134,17 @@ export default class TvOverlayScreen extends Lightning.Component { return [ class IdleState extends this { $enter() { - console.log("entering overlay IdleState"); + this.LOG("entering overlay IdleState"); } $exit() { - console.log("exiting overlay IdleState"); + this.LOG("exiting overlay IdleState"); } }, class OverlaySettingsScreen extends this { $enter() { this._topPanelAnimation.finish(); this._sidePanelAnimation.start(); - console.log("$enter from OverlaySettingsScreen"); + this.LOG("$enter from OverlaySettingsScreen"); } $exit() { this._sidePanelAnimation.stop(); @@ -149,7 +157,7 @@ export default class TvOverlayScreen extends Lightning.Component { $enter() { this._sidePanelAnimation.finish(); this._topPanelAnimation.start(); - console.log("$enter from OverlayInputScreen"); + this.LOG("$enter from OverlayInputScreen"); } $exit() { this._topPanelAnimation.stop(); diff --git a/accelerator-home-ui/src/tvOverlay/components/TvOverlayInputScreen.js b/accelerator-home-ui/src/tvOverlay/components/TvOverlayInputScreen.js index 11eabec..3880731 100644 --- a/accelerator-home-ui/src/tvOverlay/components/TvOverlayInputScreen.js +++ b/accelerator-home-ui/src/tvOverlay/components/TvOverlayInputScreen.js @@ -23,6 +23,14 @@ import TvOverlayInputItem from "../../items/TvOverlayInputItem"; import HDMIApi from "../../api/HDMIApi"; export default class TvOverlayInputScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Contents: { @@ -86,7 +94,7 @@ export default class TvOverlayInputScreen extends Lightning.Component { } refreshItems(selected) { - console.log("refreshItems called: rendering the items"); + this.LOG("refreshItems called: rendering the items"); this.tag("List").items = this.inputItems.map((item, index) => { return { ref: "Inputs" + index, @@ -125,7 +133,7 @@ export default class TvOverlayInputScreen extends Lightning.Component { } $getInputs() { - console.log("fetching hdmi input options"); //call get inputs and refresh items after an event + this.LOG("fetching hdmi input options"); //call get inputs and refresh items after an event this.hdmiApi .getHDMIDevices() @@ -134,7 +142,7 @@ export default class TvOverlayInputScreen extends Lightning.Component { this.refreshItems(Storage.get("_currentInputMode")); }) .catch((err) => { - console.log("inputScreen: getHDMIDevices Error: ", JSON.stringify(err)); + this.ERR("inputScreen: getHDMIDevices Error: " + JSON.stringify(err)); }); } diff --git a/accelerator-home-ui/src/tvOverlay/components/TvOverlaySettingsScreen.js b/accelerator-home-ui/src/tvOverlay/components/TvOverlaySettingsScreen.js index 97c66de..8946ad3 100644 --- a/accelerator-home-ui/src/tvOverlay/components/TvOverlaySettingsScreen.js +++ b/accelerator-home-ui/src/tvOverlay/components/TvOverlaySettingsScreen.js @@ -22,6 +22,14 @@ import TvOverlaySettingsItem from "../../items/TvOverlaySettingsItem"; import PictureSettingsApi from "../../api/PictureSettingsApi"; export default class TvOverlaySettingsScreen extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { Contents: { @@ -69,10 +77,7 @@ export default class TvOverlaySettingsScreen extends Lightning.Component { } }) .catch((err) => { - console.log( - "ERROR from settings overlay screen firstEnable: getSupportedPictureModes: ", - JSON.stringify(err) - ); + this.ERR("ERROR from settings overlay screen firstEnable: getSupportedPictureModes: " + JSON.stringify(err)); }); //the getSupportedColorTemps api call has some issue when working on chrome browser this.pictureApi @@ -84,15 +89,12 @@ export default class TvOverlaySettingsScreen extends Lightning.Component { } }) .catch((err) => { - console.log( - "ERROR from settings overlay screen firstEnable: getSupportedColorTemps: ", - JSON.stringify(err) - ); + this.ERR("ERROR from settings overlay screen firstEnable: getSupportedColorTemps: " + JSON.stringify(err)); }); } refreshList() { - console.log("this.refreshList got called"); + this.LOG("this.refreshList got called"); this.tag("List").items = this.options.map((item) => { return { w: 500, @@ -105,7 +107,7 @@ export default class TvOverlaySettingsScreen extends Lightning.Component { _focus() { this.fireAncestors('$focusOverlay'); - console.log("index: ", this.tag("List").index); + this.LOG("index: " + JSON.stringify(this.tag("List").index)); // this.tag("List").setIndex(0);//not necessary } @@ -126,7 +128,7 @@ export default class TvOverlaySettingsScreen extends Lightning.Component { if (!this.customLock) { //customLock value is true means api call is happening wait before moving down this.moveDownOnCustom() } else { - console.log("changing the preset value cant moveDown now!!") + this.LOG("changing the preset value cant moveDown now!!") } } else { this.tag("List").setNext(); @@ -153,14 +155,14 @@ export default class TvOverlaySettingsScreen extends Lightning.Component { try { const pictureMode = await this.pictureApi.getPictureMode(); const colorTemp = await this.pictureApi.getColorTemperature(); - console.log("picture mode: ", pictureMode, " color temperature: ", colorTemp); + this.LOG("picture mode: " + JSON.stringify(pictureMode) + " color temperature: " + JSON.stringify(colorTemp)); if (pictureMode === "custom" && colorTemp === "User Defined") { this.tag("List").setNext(); } else { this.tag("List").setIndex(1); } - } catch { - console.log("error occoured in api call"); + } catch (err) { + this.ERR("error occoured in api call" + JSON.stringify(err)); } } diff --git a/accelerator-home-ui/src/tvOverlay/components/Volume.js b/accelerator-home-ui/src/tvOverlay/components/Volume.js index 4f2bdcf..e86b5e2 100644 --- a/accelerator-home-ui/src/tvOverlay/components/Volume.js +++ b/accelerator-home-ui/src/tvOverlay/components/Volume.js @@ -19,9 +19,17 @@ import { Lightning, Registry, Utils, Storage } from "@lightningjs/sdk"; import AppApi from "../../api/AppApi"; -import { CONFIG } from "../../Config/Config"; +import { CONFIG, GLOBALS } from "../../Config/Config"; export default class Volume extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { rect: true, w: 1920, h: 320, color: 0xFF000000, y: -320, alpha: 0.9, @@ -66,13 +74,13 @@ export default class Volume extends Lightning.Component { this.volTimeout = null this.volume = 0 this.getMuteStatus(); - console.log("_firstEnable this.mute-", this.mute); + this.LOG("_firstEnable this.mute-" + JSON.stringify(this.mute)); } async onVolumeKeyDown() { this.volume = await this.getVolume(); this.focus(); - console.log("onVolumeKeyDown this.mute-", this.mute); + this.LOG("onVolumeKeyDown this.mute-" + JSON.stringify(this.mute)); this._updateIcon(this.mute) this._updateText(this.volume); this.volTimeout && Registry.clearTimeout(this.volTimeout) @@ -82,6 +90,10 @@ export default class Volume extends Lightning.Component { if (this.volume > 0) { this.volume -= 5; if (this.setVolume(this.volume)) { + if(this.mute) { + this._updateIcon((!this.mute)) + this.setMute(!this.mute) + } this._updateText(this.volume) } } @@ -90,6 +102,7 @@ export default class Volume extends Lightning.Component { async onVolumeKeyUp() { this.volume = await this.getVolume(); this.focus(); + this.LOG("onVolumeKeyUp this.mute-" + JSON.stringify(this.mute)); this._updateIcon(this.mute) this._updateText(this.volume); this.volTimeout && Registry.clearTimeout(this.volTimeout) @@ -106,6 +119,13 @@ export default class Volume extends Lightning.Component { this._updateText(this.volume) } } + else{ + this.setVolume(this.volume) + if(this.mute) { + this._updateIcon((!this.mute)) + this.setMute(!this.mute) + } + } } async onVolumeMute(requestedState = undefined) { @@ -126,6 +146,7 @@ export default class Volume extends Lightning.Component { this.volume = await this.getVolume(); this.getMuteStatus() this.focus(); + this.LOG("onVolumeChanged v-" + JSON.stringify(v)); if(v) { this._updateIcon(!v) this.setMute(!v) @@ -141,8 +162,8 @@ export default class Volume extends Lightning.Component { setVolume = async (val) => { let audioport = await this.getAudioPorts() for (let i = 0; i < audioport.length; i++) { - if ((Storage.get("deviceType") == "tv" && audioport[i].startsWith("SPEAKER")) || - (Storage.get("deviceType") != "tv" && audioport[i].startsWith("HDMI"))) { + if ((GLOBALS.deviceType == "IpTv" && audioport[i].startsWith("SPEAKER")) || + (GLOBALS.deviceType != "IpTv" && audioport[i].startsWith("HDMI"))) { await this.appApi.setVolumeLevel(audioport[i], val) } } @@ -152,8 +173,8 @@ export default class Volume extends Lightning.Component { setMute = async (val) => { let audioport = await this.getAudioPorts() for (let i = 0; i < audioport.length; i++) { - if ((Storage.get("deviceType") == "tv" && audioport[i].startsWith("SPEAKER")) || - (Storage.get("deviceType") != "tv" && audioport[i].startsWith("HDMI"))) { + if ((GLOBALS.deviceType == "IpTv" && audioport[i].startsWith("SPEAKER")) || + (GLOBALS.deviceType != "IpTv" && audioport[i].startsWith("HDMI"))) { this.appApi.audio_mute(audioport[i], val) } } @@ -163,8 +184,8 @@ export default class Volume extends Lightning.Component { getMuteStatus = async () => { let audioport = await this.getAudioPorts() for (let i = 0; i < audioport.length; i++) { - if ((Storage.get("deviceType") == "tv" && audioport[i].startsWith("SPEAKER")) || - (Storage.get("deviceType") != "tv" && audioport[i].startsWith("HDMI"))) { + if ((GLOBALS.deviceType == "IpTv" && audioport[i].startsWith("SPEAKER")) || + (GLOBALS.deviceType != "IpTv" && audioport[i].startsWith("HDMI"))) { this.appApi.getMuted(audioport[i]).then(result => { if (result.success) { this.mute = result.muted; @@ -209,7 +230,7 @@ export default class Volume extends Lightning.Component { this.appApi.getConnectedAudioPorts().then(res => { resolve(res.connectedAudioPorts) }).catch(err => { - console.error('Volume getConnectedAudioPorts error:', JSON.stringify(err, 3, null)) + this.ERR('Volume getConnectedAudioPorts error:' + JSON.stringify(err, 3, null)) reject(false) }) }) @@ -222,7 +243,7 @@ export default class Volume extends Lightning.Component { this._updateIcon(this.mute); resolve(true) }).catch(err => { - console.error('Volume updateIcon error:', JSON.stringify(err, 3, null)) + this.ERR('Volume updateIcon error:' + JSON.stringify(err, 3, null)) reject(false) }); }) @@ -233,15 +254,15 @@ export default class Volume extends Lightning.Component { let audioport = await this.getAudioPorts() /* Returns an array. */ for (let i = 0; i < audioport.length; i++) { - if ((Storage.get("deviceType") == "tv" && audioport[i].startsWith("SPEAKER")) || - (Storage.get("deviceType") != "tv" && audioport[i].startsWith("HDMI"))) { + if ((GLOBALS.deviceType == "IpTv" && audioport[i].startsWith("SPEAKER")) || + (GLOBALS.deviceType != "IpTv" && audioport[i].startsWith("HDMI"))) { this.appApi.getVolumeLevel(audioport[i]).then(async res1 => { await this.updateIcon(audioport[i]) if (res1) { resolve(parseInt(res1.volumeLevel)); } }).catch(err => { - console.error('Volume getVolumeLevel error:', JSON.stringify(err, 3, null)) + this.ERR('Volume getVolumeLevel error:' + JSON.stringify(err, 3, null)) reject(false) }) } diff --git a/accelerator-home-ui/src/views/AppStore.js b/accelerator-home-ui/src/views/AppStore.js index 0e499c4..8412746 100644 --- a/accelerator-home-ui/src/views/AppStore.js +++ b/accelerator-home-ui/src/views/AppStore.js @@ -9,6 +9,14 @@ import { getInstalledDACApps, getAppCatalogInfo } from "../api/DACApi" export default class AppStore extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + _onChanged() { this.widgets.menu.updateTopPanelText(Language.translate('Apps')) } @@ -76,7 +84,7 @@ export default class AppStore extends Lightning.Component { try { Catalog = await getAppCatalogInfo() } catch (error) { - console.error("Failed to get App Catalog Info:", error) + this.ERR("Failed to get App Catalog Info:" + JSON.stringify(error)) } const options = ['My Apps', 'App Catalog', 'Manage Apps'] this.tag('Options').add(options.map((element, idx) => { diff --git a/accelerator-home-ui/src/views/MainView.js b/accelerator-home-ui/src/views/MainView.js index fdadc06..62facf2 100644 --- a/accelerator-home-ui/src/views/MainView.js +++ b/accelerator-home-ui/src/views/MainView.js @@ -28,11 +28,18 @@ import HomeApi from '../api/HomeApi.js' import GracenoteItem from '../items/GracenoteItem.js' import { List } from '@lightningjs/ui' import HDMIApi from '../api/HDMIApi.js' -import Network from '../api/NetworkApi.js' +import NetworkManager from '../api/NetworkManagerAPI.js' import FireBoltApi from '../api/firebolt/FireBoltApi.js' /** Class for main view component in home UI */ export default class MainView extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } /** * Function to render various elements in main view. */ @@ -317,7 +324,7 @@ export default class MainView extends Lightning.Component { await this.homeApi.checkAppCompatability(appItems).then(res => { appItems = res - }) + }).catch((err)=>console.log("checkappcompatability"+err)) let prop_apps = 'applications' @@ -349,7 +356,7 @@ export default class MainView extends Lightning.Component { } } catch (e) { appdetails_format = appItems - console.log('Query data is not proper: ' + e) + this.LOG('Query data is not proper: ' + JSON.stringify(e)) } this.firstRowItems = appdetails_format this.tempRow = JSON.parse(JSON.stringify(this.firstRowItems)); @@ -363,15 +370,15 @@ export default class MainView extends Lightning.Component { .then(() => { this.hdmiApi.registerEvent('onDevicesChanged', notification => { this.fireAncestors("$hideImage", 0); - console.log('onDevicesChanged ', JSON.stringify(notification)) + this.LOG('onDevicesChanged ' + JSON.stringify(notification)) }) this.hdmiApi.registerEvent('onInputStatusChanged', notification => { this.fireAncestors("$hideImage", 0); - console.log('onInputStatusChanged ', JSON.stringify(notification)) + this.LOG('onInputStatusChanged ' + JSON.stringify(notification)) }) this.hdmiApi.registerEvent('onSignalChanged', notification => { this.fireAncestors("$hideImage", 0); - console.log('onSignalChanged ', JSON.stringify(notification)) + this.LOG('onSignalChanged ' + JSON.stringify(notification)) if (notification.signalStatus !== 'stableSignal') { RDKShellApis.setVisibility(GLOBALS.selfClientName, true) this.widgets.fail.notify({ title: this.tag('Inputs.Slider').items[this.tag('Inputs.Slider').index].data.displayName, msg: Language.translate("Input disconnected") }) @@ -380,9 +387,9 @@ export default class MainView extends Lightning.Component { }) this.hdmiApi.registerEvent('videoStreamInfoUpdate', notification => { this.fireAncestors("$hideImage", 0); - console.log('videoStreamInfoUpdate ', JSON.stringify(notification)) + this.LOG('videoStreamInfoUpdate ' + JSON.stringify(notification)) }) - if(Storage.get("deviceType") == "tv") + if(GLOBALS.deviceType == "IpTv") { this.inputSelect = true //set the inputSelect to true if the device is tv, here considering hdmiApi is only available on tv } @@ -394,7 +401,7 @@ export default class MainView extends Lightning.Component { }) }) .catch(err => { - console.log('HDMIInput Plugin not activated', err) + this.ERR('HDMIInput Plugin not activated' + JSON.stringify(err)) }) //get the available input methods from the api @@ -404,7 +411,7 @@ export default class MainView extends Lightning.Component { let listener; listener = thunder.on('org.rdk.UsbAccess', 'onUSBMountChanged', (notification) => { - console.log('onUsbMountChanged notification: ', JSON.stringify(notification)) + this.LOG('onUsbMountChanged notification: ' + JSON.stringify(notification)) Storage.set('UsbMountedStatus', notification.mounted ? 'mounted' : 'unmounted') const currentPage = window.location.href.split('#').slice(-1)[0] if (Storage.get('UsbMedia') === 'ON') { @@ -416,10 +423,10 @@ export default class MainView extends Lightning.Component { this.appItems = this.tempRow this._setState('AppList.0') } - console.log(`app items = ${this.appItems} ; `); + this.LOG('app items = ' + JSON.stringify(this.appItems)); if (currentPage === 'menu') { //refresh page to hide or show usb icon - console.log('page refreshed on unplug/plug') + this.LOG('page refreshed on unplug/plug') } @@ -430,13 +437,13 @@ export default class MainView extends Lightning.Component { } } } - console.log(`usb event successfully registered`); + this.LOG('usb event successfully registered'); }) return listener; } - Network.get()._thunder.on('org.rdk.Network.1', 'onInternetStatusChange', notification => { - console.log('on InternetStatus Change', JSON.stringify(notification)) + NetworkManager.thunder.on('org.rdk.NetworkManager', 'onInternetStatusChange', notification => { + this.LOG('on InternetStatus Change' + JSON.stringify(notification)) this.refreshSecondRow() }) @@ -467,9 +474,9 @@ export default class MainView extends Lightning.Component { } else if (Storage.get('UsbMedia') === 'OFF') { // deactivate usb Plugin here this.usbApi.deactivate().then(() => { - console.log(`disabled the Usb Plugin`); + this.LOG(`disabled the Usb Plugin`); }).catch(err => { - console.error(`error while disabling the usb plugin = ${err}`) + this.ERR(`error while disabling the usb plugin = ${err}`) }) } @@ -495,7 +502,7 @@ export default class MainView extends Lightning.Component { _firstEnable() { console.timeEnd('PerformanceTest') - console.log('Mainview Screen timer end - ', new Date().toUTCString()) + this.LOG('Mainview Screen timer end - ' + JSON.stringify(new Date().toUTCString())) this.internetConnectivity = false; } @@ -767,17 +774,17 @@ export default class MainView extends Lightning.Component { } _handleEnter() { - console.log(this.tag('Inputs.Slider').items[this.tag('Inputs.Slider').index].data) + this.LOG(JSON.stringify(this.tag('Inputs.Slider').items[this.tag('Inputs.Slider').index].data)) this.hdmiApi.setHDMIInput(this.tag('Inputs.Slider').items[this.tag('Inputs.Slider').index].data) .then(() => { - console.log('completed') + this.LOG('completed') GLOBALS.topmostApp = 'HDMI'; const currentInput = this.tag('Inputs.Slider').items[this.tag('Inputs.Slider').index].data Storage.set("_currentInputMode", { id: currentInput.id, locator: currentInput.locator }); RDKShellApis.setVisibility(GLOBALS.selfClientName, false) }) .catch(err => { - console.log('failed', err) + this.ERR('failed' + JSON.stringify(err)) this.widgets.fail.notify({ title: this.tag('Inputs.Slider').items[this.tag('Inputs.Slider').index].data.displayName, msg: 'Select a different input.' }) Router.focusWidget('Fail') }) @@ -838,7 +845,7 @@ export default class MainView extends Lightning.Component { appIdentifier: appIdentifier } this.appApi.launchApp(applicationType, params).catch(err => { - console.log("ApplaunchError: ", err) + this.ERR("ApplaunchError: "+ JSON.stringify(err)) }); } } @@ -891,11 +898,11 @@ export default class MainView extends Lightning.Component { launchLocation: "mainView", appIdentifier: appIdentifier } - await Network.get().isConnectedToInternet() + await NetworkManager.IsConnectedToInternet() .then(result => { - if (result) { + if (result.connected) { this.appApi.launchApp(applicationType, params).catch(err => { - console.log("ApplaunchError: ", JSON.stringify(err), err) + this.ERR("ApplaunchError: " + JSON.stringify(err)) }); } else { @@ -904,7 +911,7 @@ export default class MainView extends Lightning.Component { } }) .catch(err => { - console.log(err) + this.ERR("isconnectedtointernet failed" + JSON.stringify(err)) }) } }, @@ -950,11 +957,11 @@ export default class MainView extends Lightning.Component { async _handleEnter() { if (Router.isNavigating()) return; try { - this.internetConnectivity = await Network.get().isConnectedToInternet(); + this.internetConnectivity = await NetworkManager.IsConnectedToInternet(); } catch { this.internetConnectivity = false } - console.log("MainView: internetConnectivity ", JSON.stringify(this.internetConnectivity)); + this.LOG("MainView: internetConnectivity " + JSON.stringify(this.internetConnectivity)); let params ={url: this.tag('TVShows').items[this.tag('TVShows').index].data.uri, } if (this.internetConnectivity) { @@ -1020,13 +1027,13 @@ export default class MainView extends Lightning.Component { } if (applicationType == "FireboltApp") { FireBoltApi.get().discovery.launch(appId, intent).then(res => { - console.log(res) + this.LOG("Firebolt launch response" + JSON.stringify(res)) GLOBALS.topmostApp = "FireboltApp"; }) } else { this.appApi.launchApp(applicationType, params).catch(err => { - console.log("ApplaunchError: ", JSON.stringify(err), err) + this.ERR("ApplaunchError: " + JSON.stringify(err)) }); } } @@ -1082,7 +1089,7 @@ export default class MainView extends Lightning.Component { Router.navigate("camera/player", cameraParams) } else { this.appApi.launchApp(applicationType, params).catch(err => { - console.log("ApplaunchError: ", JSON.stringify(err), err) + this.ERR("ApplaunchError: " + JSON.stringify(err)) }); } } diff --git a/accelerator-home-ui/src/views/UIList.js b/accelerator-home-ui/src/views/UIList.js index a9e229f..cfcbe08 100644 --- a/accelerator-home-ui/src/views/UIList.js +++ b/accelerator-home-ui/src/views/UIList.js @@ -25,6 +25,14 @@ import Item from "../items/item"; const homeApi = new HomeApi() export default class UIList extends Lightning.Component { + constructor(...args) { + super(...args); + this.INFO = console.info; + this.LOG = console.log; + this.ERR = console.error; + this.WARN = console.warn; + } + static _template() { return { w: 1920, @@ -69,7 +77,7 @@ export default class UIList extends Lightning.Component { _handleEnter() { if (this.tag('UI').currentItem._item.title != 'DEFAULT') { - console.log('Redirect to url') + this.LOG('Redirect to url') return } Router.navigate('menu') diff --git a/accelerator-home-ui/static/language/translations/en.json b/accelerator-home-ui/static/language/translations/en.json index 4f90ad0..427ed25 100644 --- a/accelerator-home-ui/static/language/translations/en.json +++ b/accelerator-home-ui/static/language/translations/en.json @@ -19,6 +19,7 @@ "App Info": "App Info", "Clear Cookies and App Data": "Clear Cookies and App Data", "Settings Other Settings Advanced Settings": "Settings / Other Settings / Advanced Settings", + "Settings Other Settings Advanced Settings TTS": "Settings / Other Settings / Advanced Settings / TTS", "Settings Other Settings Advanced Settings Device Info": "Settings / Other Settings / Advanced Settings / Device / Info", "Settings Other Settings Advanced Settings Device Time": "Settings / Other Settings / Advanced Settings / Device / Time Zone", "Settings Other Settings Advanced Settings Device": "Settings / Other Settings / Advanced Settings / Device", diff --git a/accelerator-home-ui/static/language/translations/es.json b/accelerator-home-ui/static/language/translations/es.json index ffa25db..49191c1 100644 --- a/accelerator-home-ui/static/language/translations/es.json +++ b/accelerator-home-ui/static/language/translations/es.json @@ -120,6 +120,7 @@ "Settings Network Configuration Network Info": "Ajustes / Configuración de red / Información de red", "Settings Network Configuration Network Interface": "Ajustes / Configuración de red / Interfaz de red", "Settings Other Settings Advanced Settings": "Ajustes / Otras configuraciones / Configuración avanzada", + "Settings Other Settings Advanced Settings TTS": "Ajustes / Otras configuraciones / Configuración avanzada / TTS", "Settings Other Settings Advanced Settings Device Info": "Ajustes / Otras configuraciones / Configuración avanzada / Dispositivo / Información", "Settings Other Settings Advanced Settings Device Time": "Ajustes / Otras configuraciones / Configuración avanzada / Dispositivo / Zona Horaria", "Settings Other Settings Advanced Settings Device": "Ajustes / Otras configuraciones / Configuración avanzada / Dispositivo", @@ -177,6 +178,7 @@ "No Shows are being aired at the moment": "No Shows se están emitiendo en este momento", "Press OK to enter Password": "Presione OK para ingresar la contraseña", "Press OK to enter SSID": "Presione OK para ingresar SSID", + "Press OK to enter TTS endpoint": "Presione OK para ingresar el punto final TTS", "Alexa welcome message": "Alexa te permite usar tu voz para escuchar las noticias, consultar el clima, controlar tu hogar inteligente y más.", "Alexa something went wrong message": "Algo salió mal. Por favor, vuelva a intentarlo", "Retry": "Rever", @@ -254,6 +256,7 @@ "INVALID_CREDENTIALS - The connection failed due to invalid credentials": "INVALID_CREDENTIALS: la conexión falló debido a credenciales no válidas", "NO_SSID - The SSID does not exist": "NO_SSID: el SSID no existe", "UNKNOWN - Any other error": "DESCONOCIDO - Cualquier otro error", + "WIFI_AUTH_FAILED - Authentication Failed": "WIFI_AUTH_FAILED: Falló la autenticación", "Configuring as default": "Configurando como predeterminado", "Exit the overlay mode and use the Settings.": "Salga del modo de superposición y use la Configuración.", "Searching, please wait": "Buscando, por favor espera", @@ -275,5 +278,9 @@ "MAC:Default MAC":"MAC: MAC predeterminada", "Miracast Status":"Estado de Miracast", "Reason Code :":"Código de motivo:", - "Reason :":"Razón :" + "Reason :":"Razón :", + "TTS Endpoint":"Punto final TTS", + "WiFi Status":"Estado WiFi", + "Error Code :":"Código de error:", + "Error Msg :":"Mensaje de error:" }