Revise ambient_viewer_notify_ambient_event 32/236032/3
authorInkyun Kil <inkyun.kil@samsung.com>
Fri, 12 Jun 2020 06:16:09 +0000 (15:16 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Mon, 15 Jun 2020 07:38:40 +0000 (07:38 +0000)
The 'extra' parameter can be NULL.
Therefore, the ambient_viewer_notify_ambient_event should be able to
pass an empty bundle.

Change-Id: I18be28d5a4d0dc5ffb8de97cc0a998b198ebfb0b
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
ambient-viewer/src/stub.cc

index 875cc85..550b1fc 100644 (file)
@@ -181,14 +181,18 @@ extern "C" EXPORT_API int ambient_viewer_destroy(ambient_viewer_h handle) {
 extern "C" EXPORT_API int ambient_viewer_notify_ambient_event(
     ambient_viewer_h handle, ambient_viewer_state_e state,
     ambient_viewer_direction_e dir, bundle *extra) {
-  if (handle == nullptr || extra == nullptr) {
+  if (handle == nullptr) {
     LOGE("Invalid parameter");
     return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
   }
 
+  Bundle bundle;
+  if (extra)
+    bundle = Bundle(extra, false, false);
+
   AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
   stub->NotifyAmbientEvent((AmbientViewer::AmbientState)state,
-    static_cast<AmbientViewer::Direction>(dir), Bundle(extra, false, false));
+    static_cast<AmbientViewer::Direction>(dir), std::move(bundle));
 
   return AMBIENT_VIEWER_ERROR_NONE;
 }