1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef MESSAGE_PARCEL_HELPER_H
17 #define MESSAGE_PARCEL_HELPER_H
18 
19 #include <string>
20 
21 #include "business_error.h"
22 #include "check_result.h"
23 #include "clear_options.h"
24 #include "current_version_info.h"
25 #include "description_options.h"
26 #include "download_options.h"
27 #include "event_info.h"
28 #include "message_parcel.h"
29 #include "new_version_info.h"
30 #include "parcel.h"
31 #include "pause_download_options.h"
32 #include "resume_download_options.h"
33 #include "task_info.h"
34 #include "upgrade_info.h"
35 #include "upgrade_options.h"
36 #include "upgrade_policy.h"
37 #include "version_description_info.h"
38 #include "version_digest_info.h"
39 
40 namespace OHOS::UpdateEngine {
41 class MessageParcelHelper {
42 public:
43     static int32_t ReadUpgradeInfo(MessageParcel &reply, UpgradeInfo &info);
44     static int32_t WriteUpgradeInfo(MessageParcel &data, const UpgradeInfo &info);
45 
46     static int32_t ReadVersionDescriptionInfo(MessageParcel &reply, VersionDescriptionInfo &newVersionDescriptionInfo);
47     static int32_t WriteVersionDescriptionInfo(MessageParcel &data,
48         const VersionDescriptionInfo &newVersionDescriptionInfo);
49 
50     static int32_t ReadBusinessError(MessageParcel &reply, BusinessError &businessError);
51     static int32_t WriteBusinessError(MessageParcel &data, const BusinessError &businessError);
52 
53     static int32_t ReadCheckResult(MessageParcel &reply, CheckResult &checkResult);
54     static int32_t WriteCheckResult(MessageParcel &data, const CheckResult &checkResult);
55 
56     static int32_t ReadNewVersionInfo(MessageParcel &reply, NewVersionInfo &newVersionInfo);
57     static int32_t WriteNewVersionInfo(MessageParcel &data, const NewVersionInfo &newVersionInfo);
58 
59     static int32_t ReadCurrentVersionInfo(MessageParcel &reply, CurrentVersionInfo &info);
60     static int32_t WriteCurrentVersionInfo(MessageParcel &data, const CurrentVersionInfo &info);
61 
62     static int32_t ReadTaskInfo(MessageParcel &reply, TaskInfo &info);
63     static int32_t WriteTaskInfo(MessageParcel &data, const TaskInfo &info);
64 
65     static int32_t ReadUpgradePolicy(MessageParcel &reply, UpgradePolicy &policy);
66     static int32_t WriteUpgradePolicy(MessageParcel &data, const UpgradePolicy &policy);
67 
68     static int32_t ReadEventInfo(MessageParcel &reply, EventInfo &eventInfo);
69     static int32_t WriteEventInfo(MessageParcel &data, const EventInfo &eventInfo);
70 
71     static int32_t ReadVersionDigestInfo(MessageParcel &reply, VersionDigestInfo &versionDigestInfo);
72     static int32_t WriteVersionDigestInfo(MessageParcel &data, const VersionDigestInfo &versionDigestInfo);
73 
74     static int32_t ReadDescriptionOptions(MessageParcel &reply, DescriptionOptions &descriptionOptions);
75     static int32_t WriteDescriptionOptions(MessageParcel &data, const DescriptionOptions &descriptionOptions);
76 
77     static int32_t ReadDownloadOptions(MessageParcel &reply, DownloadOptions &downloadOptions);
78     static int32_t WriteDownloadOptions(MessageParcel &data, const DownloadOptions &downloadOptions);
79 
80     static int32_t ReadPauseDownloadOptions(MessageParcel &reply, PauseDownloadOptions &pauseDownloadOptions);
81     static int32_t WritePauseDownloadOptions(MessageParcel &data, const PauseDownloadOptions &pauseDownloadOptions);
82 
83     static int32_t ReadResumeDownloadOptions(MessageParcel &reply, ResumeDownloadOptions &resumeDownloadOptions);
84     static int32_t WriteResumeDownloadOptions(MessageParcel &data, const ResumeDownloadOptions &resumeDownloadOptions);
85 
86     static int32_t ReadUpgradeOptions(MessageParcel &reply, UpgradeOptions &upgradeOptions);
87     static int32_t WriteUpgradeOptions(MessageParcel &data, const UpgradeOptions &upgradeOptions);
88 
89     static int32_t ReadClearOptions(MessageParcel &reply, ClearOptions &clearOptions);
90     static int32_t WriteClearOptions(MessageParcel &data, const ClearOptions &clearOptions);
91 };
92 } // namespace OHOS::UpdateEngine
93 #endif // MESSAGE_PARCEL_HELPER_H
94