[Convergence] Uncomment app_control_destroy() and remove JS logs. 76/103176/1
authorTomasz Marciniak <t.marciniak@samsung.com>
Wed, 7 Dec 2016 11:45:27 +0000 (20:45 +0900)
committerTomasz Marciniak <t.marciniak@samsung.com>
Wed, 7 Dec 2016 11:45:27 +0000 (20:45 +0900)
[Verification] Code compiles. There is no crash on 20161206 image.

Change-Id: Ia50579d2db56b88efe449dc8475b179b6b45870b
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/convergence/convergence_api.js
src/convergence/convergence_remote_app_control_service.cc

index 8abc3c2..d8c1baf 100644 (file)
@@ -90,8 +90,7 @@ function getServiceConnectionStateName(connectionStateNumber) {
   case 2:
     return ConnectionState.CONNECTING;
   default:
-    console.log('ERROR: Unknown connection state');
-    return 'UNKNOWN'; // TODO throw exception
+    return 'UNKNOWN';
   }
 }
 
@@ -133,7 +132,6 @@ function ConvergenceManager() {
 
 ConvergenceManager.prototype.startDiscovery = function(successCallback,
   errorCallback, timeout) {
-  console.log('Entered ConvergenceManager.startDiscovery()');
 
   var args = validator_.validateArgs(arguments, [
     {name: 'successCallback', type: types_.LISTENER, values: ['onfound', 'onfinished' ]},
@@ -152,7 +150,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
   convergenceDevices = [];
 
   native_.addListener('CONVERGENCE_DISCOVERY_LISTENER', function(result) {
-    console.log('Entered discovery listener');
 
     if (native_.isFailure(result)) {
       native_.callIfPossible(errorCallback, native_.getErrorObject(result));
@@ -161,11 +158,9 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
 
         // Prepare service array
         if (!result || !result.device || !result.device.services) {
-          console.log('INVALID device info obtained from Native API'); // TODO throw exception
           return;
         }
 
-        console.log('Service number: ' + result.device.services.length);
         var services = [];
         var id = result.device.id;
         for (var i = 0; i < result.device.services.length; ++i) {
@@ -176,9 +171,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
           } else if (service_data.serviceType == 1) { // Remote App Control
             s = new RemoteAppControlService();
           } else {
-            // Error: unknown service type
-            // TODO throw exception
-            console.log('UNKNOWN SERVICE TYPE: ' + service_data.serviceType);
             continue;
           }
 
@@ -212,7 +204,7 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
         convergenceDevices = [];
 
       } else {
-        console.log('UNKNOWN discovery state exception'); // TODO throw exception
+        console.log('UNKNOWN discovery state exception');
       }
     }
   });
@@ -234,8 +226,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
 };
 
 ConvergenceManager.prototype.stopDiscovery = function() {
-  console.log('Entered ConvergenceManager.stopDiscovery()');
-
   if (discoveryStarted === false)
     throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Discovery has not started yet.');
 
@@ -247,8 +237,6 @@ ConvergenceManager.prototype.stopDiscovery = function() {
 };
 
 function Service(connectionState_, type_) {
-  console.log('Entered Service.constructor()');
-
   var connectionState = connectionState_;
 
   Object.defineProperties(this, {
@@ -274,18 +262,10 @@ function Service(connectionState_, type_) {
 native_.addListener('REMOTE_APP_CONTROL_SERVICE_LISTENER', function(result) {
   if (native_.isFailure(result)) {
     //native_.callIfPossible(errorCallback, native_.getErrorObject(result));
-    console.log('Error in REMOTE_APP_CONTROL_SERVICE_LISTENER');
   } else {
-
-      console.log('');
-      console.log('REMOTE_APP_CONTROL_SERVICE_LISTENER invoked with data');
-      console.log(JSON.stringify(result));
-      console.log('');
-
     // Invoke corresponding callback
     var lid = result.curListenerId;
     if (!lid || !convergenceServices.hasOwnProperty(lid)) {
-      console.log('ERROR: Remote App Ctrl listener is not registered [' + lid + ']');
       return; // Something is wrong: listener MUST be there
     }
     var s = convergenceServices[lid];
@@ -321,15 +301,12 @@ native_.addListener('REMOTE_APP_CONTROL_SERVICE_LISTENER', function(result) {
       native_.callIfPossible(s._stopCallback, null);
       break;
     default:
-      console.log('Ignoring result type: [' + result_type + ']');
       break;
     }
   }
 });
 
 function RemoteAppControlService() {
-  console.log('Entered RemoteAppControlService.constructor()');
-
   validator_.isConstructorCall(this, RemoteAppControlService);
 
   // The device id is needed for getting the valid service handle on the
@@ -371,8 +348,6 @@ RemoteAppControlService.prototype = new Service();
 RemoteAppControlService.prototype.constructor = RemoteAppControlService;
 
 RemoteAppControlService.prototype.connect = function(successCallback, errorCallback) {
-  console.log('Entered RemoteAppControlService.connect()');
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'successCallback',
@@ -409,8 +384,6 @@ RemoteAppControlService.prototype.connect = function(successCallback, errorCallb
 };
 
 RemoteAppControlService.prototype.disconnect = function(successCallback, errorCallback) {
-  console.log('Entered RemoteAppControlService.disconnect()');
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'successCallback',
@@ -460,7 +433,6 @@ RemoteAppControlService.prototype.start = function() {
       nullable: true
     }]);
 
-
   if (this.connectionState === ConnectionState.NOT_CONNECTED) {
     throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.');
   }
@@ -521,7 +493,6 @@ RemoteAppControlService.prototype.stop = function() {
 };
 
 RemoteAppControlService.prototype.launch = function(appId, successCallback, errorCallback) {
-  console.log('Entered RemoteAppControlService.launch()');
   var args = validator_.validateArgs(arguments, [
     {
       name: 'appId',
@@ -619,8 +590,6 @@ RemoteAppControlService.prototype.launchAppControl = function() {
 };
 
 function AppCommunicationService(connectionState_, type_) {
-  console.log('Entered AppCommunicationService.constructor()');
-
   Service.call(this, connectionState_, type_);
   // The device id is needed for getting the valid service handle on the
   // native layer
@@ -671,8 +640,6 @@ function AppCommunicationService(connectionState_, type_) {
     }
   });
 
-  // TODO add callbacks in runtime instead of constructor
-
   // Registering the service in the table of issued services
   convergenceServices[this._serviceId] = this;
 }
@@ -682,22 +649,12 @@ AppCommunicationService.prototype.constructor = AppCommunicationService;
 
 native_.addListener('APP_COMMUNICATION_SERVICE_LISTENER', function(result) {
 
-  console.log('On App Communication Service Success Callback');
-
   if (native_.isFailure(result)) {
-    console.log('ERROR in APP_COMMUNICATION_SERVICE_LISTENER');
     //native_.callIfPossible(errorCallback, native_.getErrorObject(result));
   } else {
-
-      console.log('');
-      console.log('APP_COMMUNICATION_SERVICE_LISTENER invoked with data');
-      console.log(JSON.stringify(result));
-      console.log('');
-
     // Invoke corresponding callback
     var lid = result.curListenerId;
     if (!lid || !convergenceServices.hasOwnProperty(lid)) {
-      console.log('ERROR: App Comm listener is not registered [' + lid + ']');
       return; // Something is wrong: listener MUST be there
     }
     var s = convergenceServices[lid];
@@ -745,15 +702,12 @@ native_.addListener('APP_COMMUNICATION_SERVICE_LISTENER', function(result) {
       }
       break;
     default:
-      console.log('Ignoring result type: [' + result_type + ']');
       break;
     }
   }
 });
 
 AppCommunicationService.prototype.start = function(channel, successCallback, errorCallback) {
-  console.log('Entered AppCommunicationService.start()');
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'channel',
@@ -796,8 +750,6 @@ AppCommunicationService.prototype.start = function(channel, successCallback, err
 };
 
 AppCommunicationService.prototype.stop = function(channel, successCallback, errorCallback) {
-  console.log('Entered AppCommunicationService.stop()');
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'channel',
@@ -843,8 +795,6 @@ AppCommunicationService.prototype.stop = function(channel, successCallback, erro
 };
 
 AppCommunicationService.prototype.send = function(channel, payload, successCallback, errorCallback) {
-  console.log('Entered AppCommunicationService.send()');
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'channel',
@@ -935,21 +885,14 @@ AppCommunicationService.prototype.getClientList = function() {
 };
 
 AppCommunicationService.prototype.setListener = function(listenerCallback) {
-  console.log('Entered AppCommunicationService.setListener()');
   var args = validator_.validateArgs(arguments, [
     {name: 'listenerCallback', type: types_.FUNCTION}
   ]);
 
   var lid = this._serviceId;
-  // TODO in fact, it should be even the list of callbacks instead of
-  // the single callback
   this._listenerCallback = listenerCallback;
   convergenceServices[lid] = this;
 
-      console.log('');
-      console.log('AppCommunicationServiceCommandListeners ADDED [' + lid + ']');
-      console.log('');
-
   var result = native_.callSync('AppCommunicationService_setListener', {
       deviceId: this._deviceId,
       curListenerId: lid
@@ -958,34 +901,29 @@ AppCommunicationService.prototype.setListener = function(listenerCallback) {
   if (native_.isFailure(result))
     throw native_.getErrorObject(result);
 
-  return args.curListenerId; // TODO return proper index of listener
+  return args.curListenerId;
 };
 
 AppCommunicationService.prototype.unsetListener = function(id) {
-  console.log('Entered AppCommunicationService.unsetListener()');
   var args = validator_.validateArgs(arguments, [
     {name: 'id', type: types_.LONG, optional: false}
   ]);
 
   var result = native_.callSync('AppCommunicationService_unsetListener', {
       deviceId: this._deviceId
-      //curListenerId: id // not needed in below layers
     });
 
   if (native_.isFailure(result))
     throw native_.getErrorObject(result);
 
   var lid = this._serviceId;
-  if (this._listenerCallback) {// TODO extend this to manage the list of callbacks
-    //delete this._listenerCallback;
+  if (this._listenerCallback) {
     this._listenerCallback = null;
   }
   convergenceServices[lid] = this;
 };
 
 function AppCommunicationServerService() {
-  console.log('Entered AppCommunicationServerService.constructor()');
-
   validator_.isConstructorCall(this, AppCommunicationServerService);
 
   AppCommunicationService.call(this, ConnectionState.NOT_CONNECTED, ServiceType.APP_COMM_SERVER);
@@ -999,8 +937,6 @@ AppCommunicationServerService.prototype = new AppCommunicationService();
 AppCommunicationServerService.prototype.constructor = AppCommunicationServerService;
 
 function AppCommunicationClientService() {
-  console.log('Entered AppCommunicationClientService.constructor()');
-
   validator_.isConstructorCall(this, AppCommunicationClientService);
 
   AppCommunicationService.call(this, ConnectionState.NOT_CONNECTED, ServiceType.APP_COMM_CLIENT);
@@ -1010,8 +946,6 @@ AppCommunicationClientService.prototype = new AppCommunicationService();
 AppCommunicationClientService.prototype.constructor = AppCommunicationClientService;
 
 AppCommunicationClientService.prototype.connect = function(successCallback, errorCallback) {
-  console.log('Entered AppCommunicationClientService.connect()');
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'successCallback',
@@ -1048,26 +982,23 @@ AppCommunicationClientService.prototype.connect = function(successCallback, erro
 };
 
 AppCommunicationClientService.prototype.disconnect = function(successCallback, errorCallback) {
-  console.log('Entered AppCommunicationClientService.disconnect()');
-
   var args = validator_.validateArgs(arguments, [
     {
       name: 'successCallback',
       type: types_.FUNCTION,
-      //values: ConnectSuccessCallback,
       optional: true,
       nullable: true
     },
     {
       name: 'errorCallback',
       type: types_.FUNCTION,
-      //values: ErrorCallback,
       optional: true,
       nullable: true
     }
   ]);
-  if (this.connectionState != ConnectionState.CONNECTED)
+  if (this.connectionState != ConnectionState.CONNECTED) {
     throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.');
+  }
 
   var that = this;
   var result = native_.call('AppCommunicationClientService_disconnect', {
index f652523..d10a370 100644 (file)
@@ -300,21 +300,12 @@ TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, const
   conv_payload_h payload = nullptr;
   app_control_h app_control = nullptr;
 
-  //regarding to native team app_control can be released
-  //after setting it in payload handle, unfortunately
-  //when it is done here or in triggered callback or even
-  //if they are kept in vector and released in
-  //~ConvergenceRemoteAppControlService() application crashes.
-  //it seems that ownership is taken over somewhere and
-  //handle is released. We need to wait for convergence
-  //native team answer. Now app_control_destroy is commented
   SCOPE_EXIT {
     if (payload) {
       conv_payload_destroy(payload);
     }
     if (app_control) {
-      //uncomment below line when issue will be explained
-      //app_control_destroy(app_control);
+      app_control_destroy(app_control);
     }
   };
 
@@ -349,12 +340,8 @@ TizenResult ConvergenceRemoteAppControlService::Launch(const char *appId, const
     return LogAndCreateTizenError(AbortError, "Failed to set app control in payload");
   }
 
-  //if the 'reply' was set callback was not triggered because
-  //D2D-CONV-MANAGER received error IOTCON_ERROR_INVALID_PARAMETER -22
-  //RemoteAppControlServiceProvider.cpp: __on_response(741) > iotcon_response_get_result() Fail(-22)
-
   // Update listener: assign it if it is not yet assigned
-    UpdateListener(cur_listener_id, "launch");
+  UpdateListener(cur_listener_id, "launch");
 
   // Sending app control on the remote device
   ret = conv_service_publish(service_handle, nullptr, payload);
@@ -380,21 +367,12 @@ TizenResult ConvergenceRemoteAppControlService::LaunchAppControl(const picojson:
   conv_payload_h payload = nullptr;
   app_control_h app_control = nullptr;
 
-  //regarding to native team app_control can be released
-  //after setting it in payload handle, unfortunately
-  //when it is done here or in triggered callback or even
-  //if they are kept in vector and released in
-  //~ConvergenceRemoteAppControlService() application crashes.
-  //it seems that ownership is taken over somewhere and
-  //handle is released. We need to wait for convergence
-  //native team answer. Now app_control_destroy is commented
   SCOPE_EXIT {
     if (payload) {
       conv_payload_destroy(payload);
     }
     if (app_control) {
-      //uncomment below line when issue will be explained
-      //app_control_destroy(app_control);
+      app_control_destroy(app_control);
     }
   };