Skip to content
2 changes: 1 addition & 1 deletion accelerator-home-ui/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"log": true,
"enableAppSuspended": true,
"showVersion": false,
"version": "6.0.27"
"version": "6.0.28"
}
}
4 changes: 2 additions & 2 deletions accelerator-home-ui/src/api/CECApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import { Lightning, Utils, Language } from '@lightningjs/sdk'
import { Lightning, Utils, Language, Storage } from '@lightningjs/sdk'
import SettingsMainItem from '../../items/SettingsMainItem'
import { COLORS } from '../../colors/Colors'
import { CONFIG } from '../../Config/Config'
Expand Down Expand Up @@ -171,21 +171,47 @@
}

}

// function which handles changes on and off toggle image.
updateCECButtonState(isEnabled) {
this.tag('CECControl.Button').src = Utils.asset(
isEnabled
? 'images/settings/ToggleOnOrange.png'
: 'images/settings/ToggleOffWhite.png'
)
}

_init() {
this.cecApi = new CECApi()
this.cecApi.activate()
.then(() => {
this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png')
// get current state from store preference for CEC status
const storedPreference = Storage.get('CECEnabledPreference')
if (storedPreference !== undefined && storedPreference !== null) {
const isEnabled = storedPreference === true || storedPreference === 'true'
// if the state is true,then update the CEC toggle.
this.updateCECButtonState(isEnabled)
if (isEnabled) {
this.performOTPAction()
}
this._setState('CECControl')
return
}
this.cecApi.getEnabled()
.then(res => {
Comment thread
SudarsananComcast marked this conversation as resolved.
const isEnabled = !!(res && res.enabled)
this.updateCECButtonState(isEnabled)
// update the store preference for CEC state.
Storage.set('CECEnabledPreference', isEnabled)
if (isEnabled) {
this.performOTPAction()
}
})
this._setState('CECControl')
}
_focus() {
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) {
Expand All @@ -199,19 +225,27 @@
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')
})
}
this.LOG('toggleCEC getEnabled result: ' + JSON.stringify(res))
const newEnabledState = !(res && res.enabled)
// if newEnabledState is true,then first activate CEC and then setEnabled to true,
// else just setEnabled to false
const togglePromise = newEnabledState
? this.cecApi.activate().then(() => this.cecApi.setEnabled(true))
: this.cecApi.setEnabled(false)

togglePromise
.then(() => {
// update the stored preference and button state after toggle
Storage.set('CECEnabledPreference', newEnabledState)
this.updateCECButtonState(newEnabledState)

if (newEnabledState) {
this.performOTPAction()
}
})
.catch(err => {
this.ERR('CEC toggle failed: ' + JSON.stringify(err))
})
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
import { Lightning, Utils, Language, Router } from '@lightningjs/sdk'
import { Lightning, Utils, Language, Router, Storage } from '@lightningjs/sdk'
import SettingsMainItem from '../../items/SettingsMainItem'
import { COLORS } from '../../colors/Colors'
import { CONFIG } from '../../Config/Config'
Expand Down Expand Up @@ -179,13 +179,39 @@ export default class AdvanceSettingsScreen extends Lightning.Component {
}

}
// function which handles changes on and off toggle image.
updateCECButtonState(isEnabled) {
this.tag('CECControl.Button').src = Utils.asset(
isEnabled
? 'images/settings/ToggleOnOrange.png'
: 'images/settings/ToggleOffWhite.png'
)
}

_init() {
this.cecApi = new CECApi()
this.cecApi.activate()
.then(() => {
this.tag('CECControl.Button').src = Utils.asset('images/settings/ToggleOnOrange.png')
const storedPreference = Storage.get('CECEnabledPreference')
// get current state from store preference for CEC status
if (storedPreference !== undefined && storedPreference !== null) {
const isEnabled = storedPreference === true || storedPreference === 'true'
// if the state is true,then update the CEC toggle.
this.updateCECButtonState(isEnabled)
if (isEnabled) {
this.performOTPAction()
}
this._setState('TTSOptions')
return
}

this.cecApi.getEnabled()
.then(res => {
Comment thread
SudarsananComcast marked this conversation as resolved.
const isEnabled = !!(res && res.enabled)
this.updateCECButtonState(isEnabled)
// update the store preference for CEC state.
Storage.set('CECEnabledPreference', isEnabled)
if (isEnabled) {
this.performOTPAction()
}
})
this._setState('TTSOptions')
}
Expand All @@ -200,7 +226,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) {
Expand All @@ -214,19 +240,27 @@ export default class AdvanceSettingsScreen extends Lightning.Component {
toggleCEC() {
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')
})
}
this.LOG('toggleCEC getEnabled result: ' + JSON.stringify(res))
const newEnabledState = !(res && res.enabled)
// if newEnabledState is true,then first activate CEC and then setEnabled to true,
// else just setEnabled to false
const togglePromise = newEnabledState
? this.cecApi.activate().then(() => this.cecApi.setEnabled(true))
: this.cecApi.setEnabled(false)

togglePromise
.then(() => {
// update the stored preference and button state after toggle
Storage.set('CECEnabledPreference', newEnabledState)
this.updateCECButtonState(newEnabledState)

if (newEnabledState) {
this.performOTPAction()
}
})
.catch(err => {
this.ERR('CEC toggle failed: ' + JSON.stringify(err))
})
})
}
static _states() {
Expand Down
4 changes: 2 additions & 2 deletions bolt/package-configs/com.rdkcentral.refui.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down