From: Surya Kumar Date: Mon, 25 Apr 2022 14:46:36 +0000 (+0530) Subject: [DeviceHome] Fix crash due to empty appid X-Git-Tag: accepted/tizen/unified/20220429.003344^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b83469e0acda7d1d9e3f11f84f2a403e4b8b9a89;p=platform%2Fframework%2Fweb%2Fwrtjs.git [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 --- 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);