Adding some checks to ensure objects aren't undefined before using them 01/23701/2 submit/tizen_ivi/20140701.201509
authorbrianjjones <brian.j.jones@intel.com>
Tue, 1 Jul 2014 18:07:48 +0000 (11:07 -0700)
committerbrianjjones <brian.j.jones@intel.com>
Tue, 1 Jul 2014 20:04:24 +0000 (13:04 -0700)
Change-Id: Ie00132ae33c8fc2026d451bd4764701b72f83e7e

js/services/carIndicator.js

index 0aa50ab..1ad83b6 100644 (file)
@@ -466,10 +466,13 @@ CarIndicator.prototype.addListener = function(aCallbackObject) {
                                        if (mapping.callBackPropertyName.toLowerCase() === prop.toLowerCase() && !mapping.subscribeCount) {
                                                mapping.subscribeCount = typeof (mapping.subscribeCount) === 'undefined' ? 0 : mapping.subscribeCount++;
 
-                                               if (typeof (tizen) !== 'undefined') {
+                                               if (typeof (tizen) !== 'undefined' && tizen.vehicle !== undefined && tizen.vehicle[subscribeName] !== undefined) {
                                                        if (!(subscribeName.toString().trim().toLowerCase() === "nightmode" && id === this._listenerIDs[0])) {
-                                                               var setUpData = tizen.vehicle[subscribeName].get(zone);
-                                                               self.onDataUpdate(setUpData, self, id);
+                                                               if (tizen.vehicle[subscribeName]){
+                                                                       var setUpData = tizen.vehicle[subscribeName].get(zone);
+                                                                       if (setUpData !== undefined)
+                                                                               self.onDataUpdate(setUpData, self, id);
+                                                               }
                                                        }
                                                        tizen.vehicle[subscribeName].subscribe(subscribeCallback, zone);
                                                } else {
@@ -493,7 +496,10 @@ CarIndicator.prototype.addListener = function(aCallbackObject) {
 CarIndicator.prototype.onDataUpdate = function(data, self, lisenersID) {
        "use strict";
        if (data !== undefined) {
-               var zone = data.zone.toString(2);
+               if (data.zone !== undefined);
+                       var zone = data.zone.toString(2);
+               else
+                       var zone = "0";
                var mapping;
 
                for ( var property in data) {