From b83469e0acda7d1d9e3f11f84f2a403e4b8b9a89 Mon Sep 17 00:00:00 2001 From: Surya Kumar Date: Mon, 25 Apr 2022 20:16:36 +0530 Subject: [PATCH] [DeviceHome] Fix crash due to empty appid Platform team has reported crashes on wrt calling webapis with empty appid, which happens on installation of resource packages without app. This change safeguards such instances. Change-Id: Ied8e3f6f7253aa1bc38421e296842c8c09d54e6c Signed-off-by: Surya Kumar --- device_home/service/service.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/device_home/service/service.js b/device_home/service/service.js index 7cd039d..1bedb6f 100755 --- a/device_home/service/service.js +++ b/device_home/service/service.js @@ -200,6 +200,10 @@ function getWebclipsManifest() { function setPackageInfoEventListener() { const packageEventCallback = { oninstalled: async function(packageInfo) { + if (typeof(packageInfo.name) !== 'string' || !packageInfo.name.length) { + console.debug(`${TAG} Package with no appid is installed`); + return; + } console.log(`${TAG} The package ${packageInfo.name} is installed`); const app = addD2Ddata(packageInfo.id, packageInfo.appIds[0], packageInfo.name, packageInfo.iconPath); if (app.path !== undefined) { @@ -216,9 +220,17 @@ function setPackageInfoEventListener() { } }, onupdated: function(packageInfo) { + if (typeof(packageInfo.name) !== 'string' || !packageInfo.name.length) { + console.debug(`${TAG} Package with no appid is updated`); + return; + } console.log(`${TAG} The package ${packageInfo.name} is updated`); }, onuninstalled: function(packageId) { + if (typeof(packageId) !== 'string' || !packageId.length) { + console.debug(`${TAG} Package with no appid is uninstalled`); + return; + } console.log(`${TAG} The package ${packageId} is uninstalled`); removeD2Ddata(packageId); evtEmit.emit('updateapplist', 'message', dataApps); -- 2.7.4