Use tizen base parcel API 48/250348/2
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 23 Dec 2020 23:05:03 +0000 (08:05 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 23 Dec 2020 23:12:13 +0000 (08:12 +0900)
The parcel implmentation is removed. Bacause, Parcel APi is added on
Bundle repository. We use tizen_base::Parcel API instread.

Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/base/bundle/+/249500/

Change-Id: I996f43ca0cac9c68315aee45287e8a4316c36167
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
CMakeLists.txt
packaging/rpc-port.spec
src/debug-port-internal.cc
src/debug-port-internal.hh
src/parcel-internal.cc [deleted file]
src/parcel-internal.hh [deleted file]
src/rpc-port-parcel.cc

index 82d5c9e..7f93a11 100644 (file)
@@ -6,7 +6,7 @@ INCLUDE_DIRECTORIES (
        ${CMAKE_SOURCE_DIR}/src
        )
 
-SET(${this_target}_requires "dlog bundle glib-2.0 gio-2.0 aul capi-base-common pkgmgr-info gio-unix-2.0 cynara-client cynara-creds-gdbus uuid")
+SET(${this_target}_requires "dlog bundle glib-2.0 gio-2.0 aul capi-base-common pkgmgr-info gio-unix-2.0 cynara-client cynara-creds-gdbus uuid parcel")
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${this_target} REQUIRED ${${this_target}_requires})
index 435953a..4bd6586 100644 (file)
@@ -17,6 +17,7 @@ BuildRequires:  pkgconfig(gmock)
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-creds-gdbus)
 BuildRequires:  pkgconfig(uuid)
+BuildRequires:  pkgconfig(parcel)
 
 %if 0%{?gcov:1}
 BuildRequires:  lcov
index 4723a87..debd51e 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <parcel.hh>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/un.h>
@@ -21,7 +22,6 @@
 
 #include "debug-port-internal.hh"
 #include "log-private.hh"
-#include "parcel-internal.hh"
 
 namespace rpc_port {
 namespace internal {
@@ -95,7 +95,7 @@ int DebugPort::Send(int port, bool is_read, uint32_t seq,
   }
 
   // time + port_name + destination + is_delegate + port + is_read + seq + size + data
-  Parcel parcel;
+  tizen_base::Parcel parcel;
   parcel.WriteInt64(time(nullptr));
   parcel.WriteString(session->GetPortName().c_str());
   parcel.WriteString(session->GetDestination().c_str());
@@ -106,7 +106,7 @@ int DebugPort::Send(int port, bool is_read, uint32_t seq,
   parcel.WriteInt32(size);
   parcel.Write(static_cast<const unsigned char*>(buf), size);
 
-  queue_.Push(std::make_shared<Parcel>(parcel));
+  queue_.Push(std::make_shared<tizen_base::Parcel>(parcel));
   return 0;
 }
 
@@ -313,7 +313,7 @@ void DebugPort::CreateThread() {
   thread_ = std::thread([&]() {
       _W("START");
       do {
-        std::shared_ptr<Parcel> parcel;
+        std::shared_ptr<tizen_base::Parcel> parcel;
         queue_.WaitAndPop(parcel);
         int len = parcel->GetRaw().size();
         if (len == 0) {
@@ -345,7 +345,7 @@ void DebugPort::CreateThread() {
 
 void DebugPort::JoinThread() {
   if (is_running_)
-    queue_.Push(std::shared_ptr<Parcel>(new Parcel()));
+    queue_.Push(std::shared_ptr<tizen_base::Parcel>(new tizen_base::Parcel()));
 
   if (thread_.joinable()) {
     _W("Join thread");
index 8904bba..caff4ac 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <gio/gio.h>
 #include <glib.h>
+#include <parcel.hh>
 
 #include <atomic>
 #include <list>
@@ -27,7 +28,6 @@
 #include <string>
 #include <thread>
 
-#include "parcel-internal.hh"
 #include "port-internal.hh"
 #include "shared-queue-internal.hh"
 
@@ -133,7 +133,7 @@ class DebugPort {
   std::list<std::shared_ptr<DebugPort::Session>> sessions_;
   std::thread thread_;
   std::atomic<bool> is_running_;
-  SharedQueue<std::shared_ptr<Parcel>> queue_;
+  SharedQueue<std::shared_ptr<tizen_base::Parcel>> queue_;
   mutable std::recursive_mutex mutex_;
 };
 
diff --git a/src/parcel-internal.cc b/src/parcel-internal.cc
deleted file mode 100644 (file)
index 0667929..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <cstring>
-
-#include "parcel-internal.hh"
-
-namespace rpc_port {
-
-Parcel::Parcel(const unsigned char* buf, unsigned int size)
-    : data_(buf, buf + size) {}
-
-void Parcel::WriteByte(char b) {
-  Write<char>(b);
-}
-
-void Parcel::WriteInt16(short i) {
-  Write<short>(i);
-}
-
-void Parcel::WriteInt32(int i) {
-  Write<int>(i);
-}
-
-void Parcel::WriteInt64(long long i) {
-  Write<long long>(i);
-}
-
-void Parcel::WriteFloat(float f) {
-  Write<float>(f);
-}
-
-void Parcel::WriteDouble(double d) {
-  Write<double>(d);
-}
-
-void Parcel::WriteString(const char* str) {
-  int l = std::strlen(str) + 1;
-
-  Write<int>(l);
-  std::copy(str, str + l, std::back_inserter(data_));
-}
-
-void Parcel::WriteBool(bool b) {
-  Write<bool>(b);
-}
-
-void Parcel::WriteBundle(bundle* b) {
-  bundle_raw *r;
-  int len;
-  bundle_encode(b, &r, &len);
-  unsigned char* c = reinterpret_cast<unsigned char*>(r);
-
-  Write<int>(len + 1);
-  std::copy(c, c + len + 1, std::back_inserter(data_));
-  free(r);
-}
-
-void Parcel::WriteArrayCount(int count) {
-  Write<int>(count);
-}
-
-char Parcel::ReadByte() {
-  return Read<char>();
-}
-
-short Parcel::ReadInt16() {
-  return Read<short>();
-}
-
-int Parcel::ReadInt32() {
-  return Read<int>();
-}
-
-long long Parcel::ReadInt64() {
-  return Read<long long>();
-}
-
-float Parcel::ReadFloat() {
-  return Read<float>();
-}
-
-double Parcel::ReadDouble() {
-  return Read<double>();
-}
-
-const char* Parcel::ReadString() {
-  int l = Read<int>();
-
-  if (l <= 0)
-    return nullptr;
-  if (reader_ + l > data_.size())
-      return nullptr;
-  if (data_[reader_ + l - 1] != 0)
-    return nullptr;
-  const char* str = reinterpret_cast<const char*>(&data_[reader_]);
-  reader_ += l;
-
-  return str;
-}
-
-bool Parcel::ReadBool() {
-  return Read<bool>();
-}
-
-bundle* Parcel::ReadBundle() {
-  int l = Read<int>();
-
-  if (l <= 0)
-    return nullptr;
-  if (reader_ + l > data_.size())
-      return nullptr;
-  if (data_[reader_ + l - 1] != 0)
-    return nullptr;
-  const bundle_raw* str = reinterpret_cast<const bundle_raw*>(&data_[reader_]);
-  reader_ += l;
-
-  bundle* b = bundle_decode(str, l - 1);
-
-  return b;
-}
-
-int Parcel::ReadArrayCount() {
-  return Read<int>();
-}
-
-const std::vector<unsigned char>& Parcel::GetRaw() {
-  return data_;
-}
-
-void Parcel::Write(const unsigned char* buf, unsigned int size) {
-  std::copy(buf, buf + size, std::back_inserter(data_));
-}
-
-void Parcel::Read(unsigned char* buf, unsigned int size) {
-  if (reader_ + size > data_.size())
-      return;
-  std::copy(&data_[reader_], &data_[reader_] + size, buf);
-  reader_ += size;
-}
-
-// LCOV_EXCL_START
-void Parcel::ResetReader() {
-  reader_ = 0;
-}
-// LCOV_EXCL_STOP
-
-// LCOV_EXCL_START
-void Parcel::Clear() {
-  data_.clear();
-  reader_ = 0;
-}
-// LCOV_EXCL_STOP
-
-// LCOV_EXCL_START
-void Parcel::Reset(const unsigned char* buf, unsigned int size) {
-  Clear();
-  Write(buf, size);
-}
-// LCOV_EXCL_STOP
-
-template<typename T>
-void Parcel::Write(T d) {
-  unsigned char* p = reinterpret_cast<unsigned char*>(&d);
-
-  std::copy(p, p + sizeof(T), std::back_inserter(data_));
-}
-
-template<typename T>
-T Parcel::Read() {
-  T d = 0;
-  unsigned char* p = reinterpret_cast<unsigned char*>(&d);
-
-  if (reader_ + sizeof(T) > data_.size())
-    return d;
-  std::copy(&data_[reader_], &data_[reader_] + sizeof(T), p);
-  reader_ += sizeof(T);
-  return d;
-}
-
-
-}  // namespace rpc_port
diff --git a/src/parcel-internal.hh b/src/parcel-internal.hh
deleted file mode 100644 (file)
index acf9b6f..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef PARCEL_INTERNAL_H_
-#define PARCEL_INTERNAL_H_
-
-#include <bundle.h>
-
-#include <vector>
-#include <iterator>
-#include <algorithm>
-#include <string>
-
-namespace rpc_port {
-
-class Parcel {
- public:
-  Parcel() = default;
-  Parcel(const unsigned char* buf, unsigned int size);
-
-  void Write(const unsigned char* buf, unsigned int size);
-  void Read(unsigned char* buf, unsigned int size);
-  void WriteByte(char b);
-  void WriteInt16(short i);
-  void WriteInt32(int i);
-  void WriteInt64(long long i);
-  void WriteFloat(float f);
-  void WriteDouble(double d);
-  void WriteString(const char* str);
-  void WriteBool(bool b);
-  void WriteBundle(bundle* b);
-  void WriteArrayCount(int count);
-  char ReadByte();
-  short ReadInt16();
-  int ReadInt32();
-  long long ReadInt64();
-  float ReadFloat();
-  double ReadDouble();
-  const char* ReadString();
-  bool ReadBool();
-  bundle* ReadBundle();
-  int ReadArrayCount();
-  const std::vector<unsigned char>& GetRaw();
-  void ResetReader();
-  void Clear();
-  void Reset(const unsigned char* buf, unsigned int size);
-
- private:
-  template<typename T>
-  void Write(T d);
-
-  template<typename T>
-  T Read();
-
- private:
-  std::vector<unsigned char> data_;
-  unsigned int reader_ = 0;
-};
-
-}  // namespace rpc_port
-
-#endif  // PARCEL_INTERNAL_H_
index c4fa7fb..c5802f2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2018 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
+#include <parcel.h>
+#include <stdint.h>
 #include <string.h>
 
-#include "rpc-port-parcel.h"
-
-#include "parcel-internal.hh"
+#include "log-private.hh"
 #include "port-internal.hh"
+#include "rpc-port-parcel.h"
 
 #define MAX_PARCEL_SIZE   (1024 * 1024 * 10)
 
 
 using namespace rpc_port;
 
+static int __convert_parcel_error(int error) {
+  switch (error) {
+  case PARCEL_ERROR_ILLEGAL_BYTE_SEQ:
+  case PARCEL_ERROR_NO_DATA:
+    return RPC_PORT_ERROR_IO_ERROR;
+  case PARCEL_ERROR_OUT_OF_MEMORY:
+    return RPC_PORT_ERROR_OUT_OF_MEMORY;
+  default:
+    return RPC_PORT_ERROR_INVALID_PARAMETER;
+  }
+}
+
 RPC_API int rpc_port_parcel_create(rpc_port_parcel_h* h) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = new Parcel();
-
-  *h = p;
+  parcel_h parcel = nullptr;
+  int ret = parcel_create(&parcel);
+  if (ret != PARCEL_ERROR_NONE)
+    return __convert_parcel_error(ret);
 
+  *h = static_cast<rpc_port_parcel_h>(parcel);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -56,19 +71,23 @@ RPC_API int rpc_port_parcel_create_from_port(rpc_port_parcel_h* h,
 
     if (len <= 0 || len > MAX_PARCEL_SIZE)
       return RPC_PORT_ERROR_IO_ERROR;
+
     buf = new unsigned char[len];
     ret = rpc_port_read(port, buf, len);
     if (ret != 0) {
-      delete[] buf; // LCOV_EXCL_LINE
-      return ret;  // LCOV_EXCL_LINE
+      delete[] buf;
+      return ret;
     }
   }
 
-  Parcel* p = new Parcel(buf, len);
+  parcel_h parcel = nullptr;
+  int ret = parcel_create(&parcel);
+  if (ret != PARCEL_ERROR_NONE)
+    return RPC_PORT_ERROR_IO_ERROR;
 
+  parcel_burst_write(parcel, buf, len);
   delete[] buf;
-  *h = p;
-
+  *h = static_cast<rpc_port_parcel_h>(parcel);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -76,8 +95,10 @@ RPC_API int rpc_port_parcel_send(rpc_port_parcel_h h, rpc_port_h port) {
   if (h == nullptr || port == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-  int len = p->GetRaw().size();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  void* raw = nullptr;
+  uint32_t len = 0;
+  parcel_get_raw(parcel, &raw, &len);
 
   if (len <= 0)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
@@ -85,11 +106,11 @@ RPC_API int rpc_port_parcel_send(rpc_port_parcel_h h, rpc_port_h port) {
   internal::Port* pt = static_cast<internal::Port*>(port);
   {
     std::lock_guard<std::recursive_mutex> lock(pt->GetMutex());
-    int ret = rpc_port_write(port, &len, 4);
+    int ret = rpc_port_write(port, &len, sizeof(len));
     if (ret != 0)
       return ret;
 
-    ret = rpc_port_write(port, &*(p->GetRaw().cbegin()), len);
+    ret = rpc_port_write(port, raw, len);
     if (ret != 0)
       return ret;
   }
@@ -101,8 +122,8 @@ RPC_API int rpc_port_parcel_destroy(rpc_port_parcel_h h) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  delete static_cast<Parcel*>(h);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_destroy(parcel);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -110,10 +131,8 @@ RPC_API int rpc_port_parcel_write_byte(rpc_port_parcel_h h, char b) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteByte(b);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_byte(parcel, b);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -121,10 +140,8 @@ RPC_API int rpc_port_parcel_write_int16(rpc_port_parcel_h h, short i) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteInt16(i);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_int16(parcel, i);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -132,10 +149,8 @@ RPC_API int rpc_port_parcel_write_int32(rpc_port_parcel_h h, int i) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteInt32(i);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_int32(parcel, i);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -143,10 +158,8 @@ RPC_API int rpc_port_parcel_write_int64(rpc_port_parcel_h h, long long i) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteInt64(i);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_int64(parcel, i);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -154,10 +167,8 @@ RPC_API int rpc_port_parcel_write_float(rpc_port_parcel_h h, float f) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteFloat(f);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_float(parcel, f);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -165,10 +176,8 @@ RPC_API int rpc_port_parcel_write_double(rpc_port_parcel_h h, double d) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteDouble(d);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_double(parcel, d);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -176,10 +185,8 @@ RPC_API int rpc_port_parcel_write_string(rpc_port_parcel_h h, const char* str) {
   if (h == nullptr || str == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteString(str);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_string(parcel, str);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -187,10 +194,8 @@ RPC_API int rpc_port_parcel_write_bool(rpc_port_parcel_h h, bool b) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteBool(b);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_bool(parcel, b);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -198,10 +203,8 @@ RPC_API int rpc_port_parcel_write_bundle(rpc_port_parcel_h h, bundle* b) {
   if (h == nullptr || b == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteBundle(b);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_bundle(parcel, b);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -209,10 +212,8 @@ RPC_API int rpc_port_parcel_write_array_count(rpc_port_parcel_h h, int count) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->WriteArrayCount(count);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_write_int32(parcel, count);
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -225,7 +226,6 @@ RPC_API int rpc_port_parcel_write(rpc_port_parcel_h h,
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   parcelable->to(h, data);
-
   return RPC_PORT_ERROR_NONE;
 }
 
@@ -233,9 +233,10 @@ RPC_API int rpc_port_parcel_read_byte(rpc_port_parcel_h h, char* b) {
   if (h == nullptr || b == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *b = p->ReadByte();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_byte(parcel, b);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_byte() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -244,9 +245,10 @@ RPC_API int rpc_port_parcel_read_int16(rpc_port_parcel_h h, short* i) {
   if (h == nullptr || i == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *i = p->ReadInt16();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_int16(parcel, i);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_int16() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -255,9 +257,10 @@ RPC_API int rpc_port_parcel_read_int32(rpc_port_parcel_h h, int* i) {
   if (h == nullptr || i == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *i = p->ReadInt32();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_int32(parcel, i);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_int32() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -266,9 +269,10 @@ RPC_API int rpc_port_parcel_read_int64(rpc_port_parcel_h h, long long* i) {
   if (h == nullptr || i == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *i = p->ReadInt64();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_int64(parcel, i);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_int64() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -277,9 +281,10 @@ RPC_API int rpc_port_parcel_read_float(rpc_port_parcel_h h, float* f) {
   if (h == nullptr || f == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *f = p->ReadFloat();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_float(parcel, f);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_float() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -288,9 +293,10 @@ RPC_API int rpc_port_parcel_read_double(rpc_port_parcel_h h, double* d) {
   if (h == nullptr || d == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *d = p->ReadDouble();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_double(parcel, d);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_double() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -299,9 +305,12 @@ RPC_API int rpc_port_parcel_read_string(rpc_port_parcel_h h, char** str) {
   if (h == nullptr || str == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-  const char* read = p->ReadString();
-  *str = read == nullptr ? strdup("") : strdup(read);
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_string(parcel, str);
+  if (ret != PARCEL_ERROR_NONE) {
+    _E("parcel_read_string() is failed. error(%d)", ret);
+    *str = strdup("");
+  }
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -310,9 +319,10 @@ RPC_API int rpc_port_parcel_read_bool(rpc_port_parcel_h h, bool* b) {
   if (h == nullptr || b == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *b = p->ReadBool();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_bool(parcel, b);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_bool() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -321,10 +331,12 @@ RPC_API int rpc_port_parcel_read_bundle(rpc_port_parcel_h h, bundle** b) {
   if (h == nullptr || b == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-  bundle* read = p->ReadBundle();
-
-  *b = read == nullptr ? bundle_create() : read;
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_bundle(parcel, b);
+  if (ret != PARCEL_ERROR_NONE) {
+    _E("parcel_read_bundle() is failed. error(%d)", ret);
+    *b = bundle_create();
+  }
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -333,9 +345,10 @@ RPC_API int rpc_port_parcel_read_array_count(rpc_port_parcel_h h, int* count) {
   if (h == nullptr || count == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  *count = p->ReadArrayCount();
+  parcel_h parcel = static_cast<parcel_h>(h);
+  int ret = parcel_read_int32(parcel, count);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_read_int32() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -358,9 +371,11 @@ RPC_API int rpc_port_parcel_burst_read(rpc_port_parcel_h h, unsigned char *buf,
   if (h == nullptr || buf == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->Read(buf, size);
+  parcel_h parcel = static_cast<parcel_h>(h);
+  uint32_t valid_size = size & UINT32_MAX;
+  int ret = parcel_burst_read(parcel, static_cast<void*>(buf), valid_size);
+  if (ret != PARCEL_ERROR_NONE)
+    _E("parcel_burst_read() is failed. error(%d)", ret);
 
   return RPC_PORT_ERROR_NONE;
 }
@@ -370,57 +385,48 @@ RPC_API int rpc_port_parcel_burst_write(rpc_port_parcel_h h,
   if (h == nullptr || buf == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->Write(buf, size);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  uint32_t valid_size = size & UINT32_MAX;
+  parcel_burst_write(parcel, static_cast<const void*>(buf), valid_size);
   return RPC_PORT_ERROR_NONE;
 }
 
-// LCOV_EXCL_START
 RPC_API int rpc_port_parcel_reset_reader(rpc_port_parcel_h h) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->ResetReader();
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  parcel_reset_reader(parcel);
   return RPC_PORT_ERROR_NONE;
 }
-// LCOV_EXCL_STOP
 
-// LCOV_EXCL_START
 RPC_API int rpc_port_parcel_to_array(rpc_port_parcel_h h, void** array,
     unsigned int* size) {
   if (h == nullptr || !array || !size)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
+  parcel_h parcel = static_cast<parcel_h>(h);
+  void* raw = nullptr;
+  uint32_t raw_size = 0;
+  parcel_get_raw(parcel, &raw, &raw_size);
 
-  const auto& ptr = p->GetRaw();
-  void* array_ptr = malloc(ptr.size());
-  if (!array_ptr)
+  void* array_ptr = malloc(raw_size);
+  if (array_ptr == nullptr)
     return RPC_PORT_ERROR_OUT_OF_MEMORY;
 
-  memcpy(array_ptr, ptr.data(), ptr.size());
+  memcpy(array_ptr, raw, raw_size);
   *array = array_ptr;
-  *size = ptr.size();
-
+  *size = static_cast<unsigned int>(raw_size);
   return RPC_PORT_ERROR_NONE;
 }
-// LCOV_EXCL_STOP
 
-// LCOV_EXCL_START
 RPC_API int rpc_port_parcel_from_array(rpc_port_parcel_h h, const void* array,
     unsigned int size) {
   if (h == nullptr || !array || size == 0)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
-  Parcel* p = static_cast<Parcel*>(h);
-
-  p->Reset(reinterpret_cast<const unsigned char*>(array), size);
-
+  parcel_h parcel = static_cast<parcel_h>(h);
+  uint32_t valid_size = size & UINT32_MAX;
+  parcel_reset(parcel, array, valid_size);
   return RPC_PORT_ERROR_NONE;
 }
-// LCOV_EXCL_STOP