diff --git a/frameworks/sandbox_manager/src/policy_info_parcel.cpp b/frameworks/sandbox_manager/src/policy_info_parcel.cpp index 09d66ff036872c4ce9adb9d89293c31c6bc22f6f..c82ee06b48e2bcafda332aca413f007f134a92c3 100644 --- a/frameworks/sandbox_manager/src/policy_info_parcel.cpp +++ b/frameworks/sandbox_manager/src/policy_info_parcel.cpp @@ -13,12 +13,32 @@ * limitations under the License. */ +#include "policy_info.h" #include "policy_info_parcel.h" #include "parcel_utils.h" namespace OHOS { namespace AccessControl { namespace SandboxManager { +bool PolicyInfo::Marshalling(Parcel &out) const +{ + RETURN_IF_FALSE(out.WriteString(this->path)); + RETURN_IF_FALSE(out.WriteUint64(this->mode)); + return true; +} + +PolicyInfo* PolicyInfo::Unmarshalling(Parcel &in) +{ + PolicyInfo* policyInfo = new (std::nothrow) PolicyInfo(); + if (policyInfo == nullptr) { + return nullptr; + } + + policyInfo->path = in.ReadString(); + RELEASE_IF_FALSE(in.ReadUint64(policyInfo->mode), policyInfo); + return policyInfo; +} + bool PolicyInfoParcel::Marshalling(Parcel &out) const { RETURN_IF_FALSE(out.WriteString(policyInfo.path)); diff --git a/interfaces/inner_api/sandbox_manager/include/policy_info.h b/interfaces/inner_api/sandbox_manager/include/policy_info.h index 9d56d354d5551d5c6bbc7d76c28cc36660f6be67..ef602eddfd9a295be843ed6dd65438c09657b9ea 100644 --- a/interfaces/inner_api/sandbox_manager/include/policy_info.h +++ b/interfaces/inner_api/sandbox_manager/include/policy_info.h @@ -18,12 +18,15 @@ #include #include +#include "parcel.h" namespace OHOS { namespace AccessControl { namespace SandboxManager { struct PolicyInfo final { public: + bool Marshalling(Parcel &out) const override; + static PolicyInfo* Unmarshalling(Parcel &in); std::string path; uint64_t mode; };