Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1"
"version": "6.0.2"
}
}
8 changes: 7 additions & 1 deletion accelerator-home-ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ export default class App extends Router.App {
if(GLOBALS.MiracastNotificationstatus && key.keyCode !== Keymap.Power && key.keyCode !== Keymap.Home ){
return false
} else if ((key.keyCode == Keymap.Home || key.keyCode == Keymap.Escape) && !Router.isNavigating()) {
if (Router.getActiveHash().startsWith("splash")) {
if (Router.getActiveHash() !== "splash/language") {
Router.navigate("splash/language");
}
return true;
}
if (GLOBALS.topmostApp.includes("dac.native")) {
this.jumpToRoute("apps");
} else if (GLOBALS.Miracastclientdevicedetails.state === "INITIATED" || GLOBALS.Miracastclientdevicedetails.state === "INPROGRESS ") {
Expand Down Expand Up @@ -2868,4 +2874,4 @@ export default class App extends Router.App {
}
}
}
}
}
44 changes: 36 additions & 8 deletions accelerator-home-ui/src/api/RemoteControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,33 @@ export default class RCApi {
})
}

startPairing(timeout = 30, netType ) {
startPairing(timeout = 30) {
return new Promise((resolve, reject) => {
//this.INFO("RCApi: startPairing netType " + netType + " timeout " + timeout);
this.thunder.call('org.rdk.RemoteControl', 'startPairing', { netType: netType, timeout: timeout }).then(result => {
//this.INFO("RCApi: startPairing result: ", JSON.stringify(result))
this.thunder.call('org.rdk.RemoteControl', 'startPairing', { timeout: timeout, screenBindEnable: false }).then(result => {
this.INFO("RCApi: startPairing result: " + JSON.stringify(result))
resolve(result.success);
}).catch(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);
});
resolve(true);
})
}

stopPairing() {
return new Promise((resolve, reject) => {
this.INFO("RCApi: stopPairing");
this.thunder.call('org.rdk.RemoteControl', 'stopPairing', {scanDisable: true}).then(result => {
this.INFO("RCApi: stopPairing result: " + JSON.stringify(result))
resolve(result.success);
}).catch(err => {
this.ERR("RCApi: stopPairing error: " + JSON.stringify(err));
Metrics.error(Metrics.ErrorType.OTHER, "RemoteControlApiError", "Error in Thunder RemoteControl stopPairing " + JSON.stringify(err), false, null)
reject(err);
});
});
}

initializeIRDB() {
return new Promise((resolve, reject) => {
/*TODO: implement when requirement comes.*/
Expand Down Expand Up @@ -186,10 +198,10 @@ export default class RCApi {
})
}

findMyRemote(netType = 1, level = "mid") {
findMyRemote(level = "mid") {
return new Promise((resolve, reject) => {
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 level:" + JSON.stringify(level));
this.thunder.call('org.rdk.RemoteControl', 'findMyRemote', { level: level }).then(result => {
this.INFO("RCApi: findMyRemote result: " + JSON.stringify(result))
resolve(result.success);
}).catch(err => {
Expand All @@ -200,6 +212,8 @@ export default class RCApi {
})
}

// This is to reset the remote control firmware; not to be confused with factory reset of the device.
// This will not erase user data or settings on the device.
factoryReset() {
return new Promise((resolve, reject) => {
this.INFO("RCApi: factoryReset");
Expand All @@ -213,4 +227,18 @@ export default class RCApi {
});
})
}

unpair(macAddressList) {
return new Promise((resolve, reject) => {
this.INFO("RCApi: unpair macAddressList:" + JSON.stringify(macAddressList));
this.thunder.call('org.rdk.RemoteControl', 'unpair', { macAddressList: macAddressList }).then(result => {
this.INFO("RCApi: unpair result: " + JSON.stringify(result))
resolve(result.success);
}).catch(err => {
this.ERR("RCApi: unpair error: " + JSON.stringify(err));
Metrics.error(Metrics.ErrorType.OTHER, "RemoteControlApiError", "Error in Thunder RemoteControl unpair " + JSON.stringify(err), false, null)
reject(err);
});
});
}
}
2 changes: 1 addition & 1 deletion accelerator-home-ui/src/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default {
if ("ResidentApp" !== GLOBALS.selfClientName) {
Metrics.page(request.hash)
.then(success => {
console.log("successfully routed to page ==>", request.hash)
console.log("successfully routed to page ==>" + JSON.stringify(request.hash))
})
.catch(err => console.log("error in metrics.page", err))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default class RebootConfirmationScreen extends Lightning.Component {
try {
localStorage.clear();
this.LOG("localStorage cleared successfully");
}
}
catch (err) {
this.ERR("Error clearing localStorage: " + JSON.stringify(err));
}
Expand Down
61 changes: 51 additions & 10 deletions accelerator-home-ui/src/screens/RcInformationScreen.js
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, Language, Router } from '@lightningjs/sdk'
import { Lightning, Language, Registry, Router } from '@lightningjs/sdk'
import { COLORS } from './../colors/Colors'
import { CONFIG } from '../Config/Config'
import ThunderJS from 'ThunderJS'
Expand Down Expand Up @@ -228,6 +228,8 @@ export default class RCInformationScreen extends Lightning.Component {
}

async _active() {
this.scanTrigger = null;
this.findRemoteTrigger = true;
await RCApi.get().activate().catch(err => { this.ERR("RCInformationScreen error: " + JSON.stringify(err)) });
await RCApi.get().getNetStatus().then(result => {
this.INFO("RCInformationScreen getNetStatus: " + JSON.stringify(result))
Expand All @@ -244,16 +246,21 @@ export default class RCInformationScreen extends Lightning.Component {
this.tag("SwVersion.Value").text.text = `N/A`
this.tag("BatteryPercent.Value").text.text = `N/A`
this.tag("RCUName.Value").text.text = `N/A`
//RCApi.get().deactivate().catch(err=> { console.error("RCInformationScreen error:", err)});
if (this.scanTrigger) {
Registry.clearTimeout(this.scanTrigger);
this.scanTrigger = null;
}
this.findRemoteTrigger = false;
}

onStatusCB(cbData) {
// getStatus response has 'success' property; notification payload does not have that.
// this.LOG("RCInformationScreen onStatusCB cbData:" + JSON.stringify(cbData));
if ((cbData !== undefined) && ("success" in cbData ? cbData.success : true)) {
let cbDatastatus
if (Array.isArray(cbData.status)) {
cbDatastatus = cbData.status[0] || {};
}
}
else if (cbData.status && typeof cbData.status === 'object') {
cbDatastatus = cbData.status;
}
Expand All @@ -262,6 +269,11 @@ export default class RCInformationScreen extends Lightning.Component {
let RemoteName = []; let connectedStatus = []; let MacAddress = [];
let swVersion = []; let BatteryPercent = [];

if (this.scanTrigger) {
Registry.clearTimeout(this.scanTrigger);
this.scanTrigger = null;
}

cbDatastatus.remoteData.map(item => {
RemoteName.push(item.name)
})
Expand All @@ -282,14 +294,43 @@ export default class RCInformationScreen extends Lightning.Component {
this.tag("SwVersion.Value").text.text = swVersion
this.tag("BatteryPercent.Value").text.text = BatteryPercent
this.tag("RCUName.Value").text.text = RemoteName
if (this.findRemoteTrigger) {
this.findRemoteTrigger = false;
RCApi.get().findMyRemote().catch(err => {
this.ERR("RCInformationScreen findMyRemote error: " + JSON.stringify(err))
});
}
} else {
if(cbDatastatus.pairingState != "SEARCHING" && cbDatastatus.pairingState != "PAIRING" ) {
for(let i=0;i<cbDatastatus.netTypesSupported.length;i++)
{
this.LOG("Netypesupported" + JSON.stringify(cbDatastatus.netTypesSupported[i]))
RCApi.get().startPairing(30,cbDatastatus.netTypesSupported[i]).catch(err => {
this.ERR("RCInformationScreen startPairing error: " + JSON.stringify(err));
});
if (cbDatastatus.pairingState === "IDLE" || cbDatastatus.pairingState === "FAILED") {
// after 2 seconds, initiate pairing flow if status is IDLE, as there is no paired device.
if (!this.scanTrigger) {
this.scanTrigger = Registry.setTimeout(() => {
this.scanTrigger = null;
RCApi.get().getNetStatus().then(result => {
let latestStatus = {};
if (Array.isArray(result.status)) {
latestStatus = result.status[0] || {};
} else if (result.status && typeof result.status === 'object') {
latestStatus = result.status;
}

const latestHasRemoteData = Array.isArray(latestStatus.remoteData) && latestStatus.remoteData.length;
const latestInRetryState = latestStatus.pairingState === "IDLE" || latestStatus.pairingState === "FAILED";

if (!latestHasRemoteData && latestInRetryState) {
RCApi.get().startPairing().catch(err => {
this.ERR("RCInformationScreen startPairing error: " + JSON.stringify(err));
});
}
}).catch(err => {
this.ERR("RCInformationScreen getNetStatus before startPairing error: " + JSON.stringify(err));
});
}, 2000);
}
} else {
if (this.scanTrigger) {
Registry.clearTimeout(this.scanTrigger);
this.scanTrigger = null;
}
}
}
Expand Down
81 changes: 56 additions & 25 deletions accelerator-home-ui/src/screens/SplashScreens/BluetoothScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class BluetoothScreen extends Lightning.Component {
this.LOG = console.log;
this.ERR = console.error;
this.WARN = console.warn;
this.scanTrigger = null;
}

static _template() {
Expand Down Expand Up @@ -135,10 +136,6 @@ export default class BluetoothScreen extends Lightning.Component {
}
}

_active() {
this.timeout = 30;
}

_PairingApis() {
//bluetoothApi.btactivate().then(enableResult =>{
// console.log('1')
Expand Down Expand Up @@ -169,23 +166,22 @@ export default class BluetoothScreen extends Lightning.Component {
Router.navigate('splash/language')
}
})

})
.catch(err => {
this.ERR(`SplashBluetoothScreen cant stopscan device : ${JSON.stringify(err)}`)
})
})
.catch(err => {
this.ERR("SplashBluetoothScreen cant stopscan device : " + JSON.stringify(err))
this.ERR(`SplashBluetoothScreen can't stop scan device : ${JSON.stringify(err)}`)
})
})
.catch(err => {
this.ERR("SplashBluetoothScreen cant getpaired device : " + JSON.stringify(err))
this.ERR("SplashBluetoothScreen getpairedDevices failed : " + JSON.stringify(err))
})
})
.catch(err => {
this.ERR(`SplashBluetoothScreen Can't pair device : ${JSON.stringify(err)}`)
this.ERR("SplashBluetoothScreen getConnectedDevices failed : " + JSON.stringify(err))
})
})
.catch(err => {
this.ERR(`SplashBluetoothScreen Can't pair device : ${JSON.stringify(err)}`)
})
})
})
})
Expand All @@ -196,19 +192,24 @@ export default class BluetoothScreen extends Lightning.Component {
}

onStatusCB(cbData) {
//console.log("BluetoothScreen cbData:", JSON.stringify(cbData));
//console.log("BluetoothScreen cbData:" + JSON.stringify(cbData));
// getStatus response has 'success' property; notification payload does not have that.
if ((cbData !== undefined) && (cbData.hasOwnProperty("success") ? cbData.success : true)) {
let cbDatastatus
let cbDatastatus = {};
if (Array.isArray(cbData.status)) {
cbDatastatus = cbData.status[0] || {};
}
}
else if (cbData.status && typeof cbData.status === 'object') {
cbDatastatus = cbData.status;
}
if (cbDatastatus.remoteData.length) {
}
const remoteData = Array.isArray(cbDatastatus.remoteData) ? cbDatastatus.remoteData : [];
if (remoteData.length > 0) {
//console.log("BluetoothScreen rcPairingApis RemoteData Length ", cbData.status.remoteData.length)
cbDatastatus.remoteData.map(item => {
if (this.scanTrigger) {
Registry.clearTimeout(this.scanTrigger);
this.scanTrigger = null;
}
remoteData.map(item => {
this.tag('Info').text.text = `paired with device ${item.name}`
// Do not clear this.RCTimeout if need to run this in background to reconnect on loss.
// if (this.RCTimeout) {
Expand All @@ -226,13 +227,35 @@ export default class BluetoothScreen extends Lightning.Component {
}
})
} else {
if(cbDatastatus.pairingState != "SEARCHING" && cbDatastatus.pairingState != "PAIRING" ) {
for(let i=0;i<cbDatastatus.netTypesSupported.length;i++)
{
this.LOG("Netypesupported" + JSON.stringify(cbDatastatus.netTypesSupported[i]))
RCApi.get().startPairing(30,cbDatastatus.netTypesSupported[i]).catch(err => {
this.ERR("RCInformationScreen startPairing error: " + JSON.stringify(err));
});
if (cbDatastatus.pairingState === "IDLE" || cbDatastatus.pairingState === "FAILED") {
// after 2 seconds, initiate pairing flow if status is IDLE, as there is no paired device.
if (!this.scanTrigger) {
this.scanTrigger = Registry.setTimeout(() => {
this.scanTrigger = null;
RCApi.get().getNetStatus().then(result => {
let latestStatus = {};
if (Array.isArray(result.status)) {
latestStatus = result.status[0] || {};
} else if (result.status && typeof result.status === 'object') {
latestStatus = result.status;
}

const latestHasRemoteData = Array.isArray(latestStatus.remoteData) && latestStatus.remoteData.length;
const latestInRetryState = latestStatus.pairingState === "IDLE" || latestStatus.pairingState === "FAILED";
if (!latestHasRemoteData && latestInRetryState) {
RCApi.get().startPairing().catch(err => {
this.ERR("SplashBluetoothScreen startPairing error: " + JSON.stringify(err));
});
}
}).catch(err => {
this.ERR("SplashBluetoothScreen getNetStatus before startPairing error: " + JSON.stringify(err));
});
}, 2000);
}
} else {
if (this.scanTrigger) {
Registry.clearTimeout(this.scanTrigger);
this.scanTrigger = null;
}
}
}
Expand Down Expand Up @@ -279,7 +302,11 @@ export default class BluetoothScreen extends Lightning.Component {
}

_active() {
this.timeout = 30;
this.initTimer()
if (typeof this.scanTrigger === 'undefined') {
this.scanTrigger = null;
}
}

pageTransition() {
Expand All @@ -302,6 +329,10 @@ export default class BluetoothScreen extends Lightning.Component {
if (this.RCTimeout) {
Registry.clearTimeout(this.RCTimeout)
}
if (this.scanTrigger) {
Registry.clearTimeout(this.scanTrigger)
this.scanTrigger = null;
}
}

static _states() {
Expand Down
Loading