diff --git a/accelerator-home-ui/settings.json b/accelerator-home-ui/settings.json index 2d334d0..a0d036b 100644 --- a/accelerator-home-ui/settings.json +++ b/accelerator-home-ui/settings.json @@ -13,6 +13,6 @@ "log": true, "enableAppSuspended": true, "showVersion": false, - "version": "6.0.27" + "version": "6.0.28" } } diff --git a/accelerator-home-ui/src/App.js b/accelerator-home-ui/src/App.js index 55aef49..ac89ab5 100644 --- a/accelerator-home-ui/src/App.js +++ b/accelerator-home-ui/src/App.js @@ -780,30 +780,7 @@ export default class App extends Router.App { this.LOG("App getActiveSourceStatus: " + JSON.stringify(res) + " UICacheCECActiveSourceStatus:" + JSON.stringify(Storage.get("UICacheCECActiveSourceStatus"))); }); } else { - cecApi.activate().then(() => { - let getfriendlyname, getosdname; - setTimeout(() => { - appApi.getFriendlyName().then(res => { - getfriendlyname = res.friendlyName; - this.LOG("AppApi getFriendlyName :" + JSON.stringify(getfriendlyname)); - }).catch(err => { - this.ERR("AppApi getFriendlyName Error: " + JSON.stringify(err)); - }) - cecApi.getOSDName().then(result => { - getosdname = result.name; - this.LOG("CECApi getOSDName :" + JSON.stringify(getosdname)); - if (getfriendlyname !== getosdname) { - cecApi.setOSDName(getfriendlyname); - } - }).catch(err => { - this.ERR("CECApi getOSDName Error :" + JSON.stringify(err)); - }) - }, 5000); - cecApi.getActiveSourceStatus().then((res) => { - Storage.set("UICacheCECActiveSourceStatus", res); - this.LOG("App getActiveSourceStatus: " + JSON.stringify(res) + " UICacheCECActiveSourceStatus:" + JSON.stringify(Storage.get("UICacheCECActiveSourceStatus"))); - }); - }).catch((err) => this.ERR(JSON.stringify(err))) + this.LOG('HdmiCecSource is inactive during boot; leaving it disabled until the user enables it from the UI') } }) this._subscribeToIOPortNotifications() diff --git a/accelerator-home-ui/src/api/CECApi.js b/accelerator-home-ui/src/api/CECApi.js index 7e730f2..3be4b5c 100644 --- a/accelerator-home-ui/src/api/CECApi.js +++ b/accelerator-home-ui/src/api/CECApi.js @@ -69,9 +69,9 @@ export default class CECApi { }) } - setEnabled() { + setEnabled(enabled = true) { return new Promise((resolve) => { - thunder.call('org.rdk.HdmiCecSource', 'setEnabled', { enabled: true }) + thunder.call('org.rdk.HdmiCecSource', 'setEnabled', { enabled }) .then(result => { resolve(result) }) diff --git a/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js b/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js index 26d46bc..f23a046 100644 --- a/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js +++ b/accelerator-home-ui/src/overlays/OtherSettings/AdvancedSettingsScreenOverlay.js @@ -174,10 +174,17 @@ _init() { this.cecApi = new CECApi() - this.cecApi.activate() - .then(() => { - this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') - this.performOTPAction() + this.cecApi.getEnabled() + .then(res => { + const isEnabled = !!(res && res.enabled) + this.tag('CECControl.Button').src = Utils.asset( + isEnabled + ? 'images/settings/ToggleOnOrange.png' + : 'images/settings/ToggleOffWhite.png' + ) + if (isEnabled) { + this.performOTPAction() + } }) this._setState('CECControl') } @@ -185,7 +192,7 @@ this._setState('CECControl') } performOTPAction() { - this.cecApi.setEnabled().then(res => { + this.cecApi.setEnabled(true).then(res => { if (res.success) { this.cecApi.performOTP().then(otpRes => { if (otpRes.success) { @@ -200,18 +207,22 @@ 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') - }) - } + const newEnabledState = !(res && res.enabled) + this.cecApi.setEnabled(newEnabledState) + .then(setRes => { + if (!(setRes && setRes.success)) { + this.WARN('CEC setEnabled failed: ' + JSON.stringify(setRes)) + return + } + const imageSrc = newEnabledState + ? 'images/settings/ToggleOnOrange.png' + : 'images/settings/ToggleOffWhite.png' + this.tag('CECControl.Button').src = Utils.asset(imageSrc) + + if (newEnabledState) { + this.performOTPAction() + } + }) }) } diff --git a/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js b/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js index ea828bb..edc8e06 100644 --- a/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js +++ b/accelerator-home-ui/src/screens/OtherSettingsScreens/AdvancedSettingsScreen.js @@ -182,10 +182,20 @@ export default class AdvanceSettingsScreen extends Lightning.Component { _init() { this.cecApi = new CECApi() - this.cecApi.activate() - .then(() => { - this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png') - this.performOTPAction() + this.cecApi.getEnabled() + .then(res => { + // get the current state of CEC and set the toggle button based on status. + const isEnabled = !!(res && res.enabled) + console.log(`CEC initial status: ${isEnabled}`) + + this.tag('CECControl.Button').src = Utils.asset( + isEnabled + ? 'images/settings/ToggleOnOrange.png' + : 'images/settings/ToggleOffWhite.png' + ) + if (isEnabled) { + this.performOTPAction() + } }) this._setState('TTSOptions') } @@ -200,7 +210,7 @@ export default class AdvanceSettingsScreen extends Lightning.Component { } performOTPAction() { - this.cecApi.setEnabled().then(res => { + this.cecApi.setEnabled(true).then(res => { if (res.success) { this.cecApi.performOTP().then(otpRes => { if (otpRes.success) { @@ -215,18 +225,19 @@ export default class AdvanceSettingsScreen extends Lightning.Component { this.cecApi.getEnabled() .then(res => { this.LOG("cec 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') - }) - } + // get the current state and toggle it. + const newEnabledState = !(res && res.enabled) + this.cecApi.setEnabled(newEnabledState) + .then(() => { + // Update UI based on new state + const imageSrc = newEnabledState + ? 'images/settings/ToggleOnOrange.png' + : 'images/settings/ToggleOffWhite.png' + this.tag('CECControl.Button').src = Utils.asset(imageSrc) + if (newEnabledState) { + this.performOTPAction() + } + }) }) } static _states() { diff --git a/bolt/package-configs/com.rdkcentral.refui.json b/bolt/package-configs/com.rdkcentral.refui.json index 1279f94..5ccfa2a 100644 --- a/bolt/package-configs/com.rdkcentral.refui.json +++ b/bolt/package-configs/com.rdkcentral.refui.json @@ -1,7 +1,7 @@ { "id": "com.rdkcentral.refui", - "version": "6.0.27", - "versionName": "6.0.27", + "version": "6.0.28", + "versionName": "6.0.28", "name": "RDK Ref UI Home Screen", "packageType": "application", "entryPoint": "--lightning --dev file:///usr/share/refui/index.html",