Fix some bugs of SendRemoteAppControl
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 2 Aug 2018 09:00:46 +0000 (18:00 +0900)
committer장상윤/Tizen Platform Lab(SR)/Engineer/삼성전자 <jeremy.jang@samsung.com>
Wed, 8 Aug 2018 09:03:05 +0000 (18:03 +0900)
- Fix invalid access when using g_variant_iter_loop()
- Fix wrong parameter of dbus service
- Use async version of aul_svc_run_service

Change-Id: I794b13087dcb198f539c9277b161ae56fc51bb95
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/appcontrol_manager.cc
src/common/dbus_service.cc
src/common/mdg_manager.cc

index 90f2c252b35c248e361e4fb27226dd68131beb7a..2af45c6ef91573ec75a8754c73fdead11f60ae96 100644 (file)
@@ -48,9 +48,9 @@ bool AppControlManager::LaunchApplication(const unsigned char* data,
     return false;
   }
 
-  // FIXME: for uid..?
-  int ret = aul_svc_run_service(b, 0, ReplyCb, nullptr);
-  if (ret < AUL_R_OK) {
+  // FIXME: for uid 5001 is temporary code. request code should be set properly.
+  int ret = aul_svc_run_service_async_for_uid(b, 0, ReplyCb, nullptr, 5001);
+  if (ret < AUL_SVC_RET_OK) {
     LOG(ERROR) << "launch failed : " << ret;
     bundle_free(b);
     return false;
index c48ce86cdf4ba9de24d002abc937edc62528b2db..56fa33eb89cf9e31a54c2882377535290c5263cc 100644 (file)
@@ -29,8 +29,8 @@ const char kDBusInstropectionXml[] =
   "      <arg type='v' name='result' direction='out'/>"
   "    </method>"
   "    <method name='SendRemoteAppControl'>"
-  "      <arg type='s' name='devicd_id' direction='in'/>"
-  "      <arg type='s' name='appcontrol' direction='in'/>"
+  "      <arg type='s' name='device_id' direction='in'/>"
+  "      <arg type='ay' name='appcontrol' direction='in'/>"
   "      <arg type='u' name='len' direction='in'/>"
   "      <arg type='b' name='result' direction='out'/>"
   "    </method>"
@@ -101,7 +101,7 @@ bool DBusService::HandleExchangeCapabilities(GVariant* params,
 
 bool DBusService::HandleSendRemoteAppControl(GVariant* params,
     GDBusMethodInvocation* invocation) {
-  LOG(INFO) << "HandleGetRemoteCapabilities ";
+  LOG(INFO) << "HandleSendRemoteCapabilities ";
   gchar* device_id;
   GVariantIter* iter;
   guchar* data;
@@ -115,9 +115,13 @@ bool DBusService::HandleSendRemoteAppControl(GVariant* params,
     return false;
   }
 
-  int i = 0;
-  while (g_variant_iter_loop(iter, "y", &data[i]))
-    i++;
+  for (unsigned int i = 0; i < len; i++) {
+    if (!g_variant_iter_loop(iter, "y", &data[i])) {
+      LOG(ERROR) << "Failed to get data from GVariant!";
+      break;
+    }
+  }
+  g_variant_iter_free(iter);
 
   EventHandler().send_app_control_event(device_id, data, len);
   return true;
index 70cbc7d3c703337b94e6f12c913550a3356ae053..522eadcc3966a45cfb1748a4596812b16c24e5a9 100644 (file)
@@ -164,9 +164,8 @@ void MDGManager::ChannelCb(int result, char* device_id, char* channel_id,
     RemoteDeviceManager::RegisterRemoteCapabilities(device_id, caps);
   } else if (cmd == Command::SEND_APPCONTROL) {
     unsigned char* data = p;
-    int r = AppControlManager::LaunchApplication(data, datasize);
-    if (r != 0)
-      LOG(ERROR) << "Failed to launch application: " << r;
+    if (!AppControlManager::LaunchApplication(data, datasize))
+      LOG(ERROR) << "Failed to launch application";
   }
 }