[DeviceHome] Fix crash due to empty appid 80/274280/2
authorSurya Kumar <surya.kumar7@samsung.com>
Mon, 25 Apr 2022 14:46:36 +0000 (20:16 +0530)
committerSurya Kumar <surya.kumar7@samsung.com>
Mon, 25 Apr 2022 14:56:04 +0000 (20:26 +0530)
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 <surya.kumar7@samsung.com>
device_home/service/service.js

index 7cd039d..1bedb6f 100755 (executable)
@@ -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);