• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 "parcel.h"
22 #include "update_helper.h"
23 
24 namespace OHOS {
25 namespace UpdateEngine {
26 class MessageParcelHelper {
27 public:
28     static int32_t ReadUpgradeInfo(MessageParcel &reply, UpgradeInfo &info);
29     static int32_t WriteUpgradeInfo(MessageParcel &data, const UpgradeInfo &info);
30 
31     static int32_t ReadVersionDescriptionInfo(MessageParcel &reply, VersionDescriptionInfo &newVersionDescriptionInfo);
32     static int32_t WriteVersionDescriptionInfo(MessageParcel &data,
33         const VersionDescriptionInfo &newVersionDescriptionInfo);
34 
35     static int32_t ReadBusinessError(MessageParcel &reply, BusinessError &businessError);
36     static int32_t WriteBusinessError(MessageParcel &data, const BusinessError &businessError);
37 
38     static int32_t ReadCheckResult(MessageParcel &reply, CheckResult &checkResult);
39     static int32_t WriteCheckResult(MessageParcel &data, const CheckResult &checkResult);
40 
41     static int32_t ReadNewVersionInfo(MessageParcel &reply, NewVersionInfo &newVersionInfo);
42     static int32_t WriteNewVersionInfo(MessageParcel &data, const NewVersionInfo &newVersionInfo);
43 
44     static int32_t ReadCurrentVersionInfo(MessageParcel &reply, CurrentVersionInfo &info);
45     static int32_t WriteCurrentVersionInfo(MessageParcel &data, const CurrentVersionInfo &info);
46 
47     static int32_t ReadTaskInfo(MessageParcel &reply, TaskInfo &info);
48     static int32_t WriteTaskInfo(MessageParcel &data, const TaskInfo &info);
49 
50     static int32_t ReadUpgradePolicy(MessageParcel &reply, UpgradePolicy &policy);
51     static int32_t WriteUpgradePolicy(MessageParcel &data, const UpgradePolicy &policy);
52 
53     static int32_t ReadEventInfo(MessageParcel &reply, EventInfo &eventInfo);
54     static int32_t WriteEventInfo(MessageParcel &data, const EventInfo &eventInfo);
55 
56     static int32_t ReadVersionDigestInfo(MessageParcel &reply, VersionDigestInfo &versionDigestInfo);
57     static int32_t WriteVersionDigestInfo(MessageParcel &data, const VersionDigestInfo &versionDigestInfo);
58 
59     static int32_t ReadDescriptionOptions(MessageParcel &reply, DescriptionOptions &descriptionOptions);
60     static int32_t WriteDescriptionOptions(MessageParcel &data, const DescriptionOptions &descriptionOptions);
61 
62     static int32_t ReadDownloadOptions(MessageParcel &reply, DownloadOptions &downloadOptions);
63     static int32_t WriteDownloadOptions(MessageParcel &data, const DownloadOptions &downloadOptions);
64 
65     static int32_t ReadPauseDownloadOptions(MessageParcel &reply, PauseDownloadOptions &pauseDownloadOptions);
66     static int32_t WritePauseDownloadOptions(MessageParcel &data, const PauseDownloadOptions &pauseDownloadOptions);
67 
68     static int32_t ReadResumeDownloadOptions(MessageParcel &reply, ResumeDownloadOptions &resumeDownloadOptions);
69     static int32_t WriteResumeDownloadOptions(MessageParcel &data, const ResumeDownloadOptions &resumeDownloadOptions);
70 
71     static int32_t ReadUpgradeOptions(MessageParcel &reply, UpgradeOptions &upgradeOptions);
72     static int32_t WriteUpgradeOptions(MessageParcel &data, const UpgradeOptions &upgradeOptions);
73 
74     static int32_t ReadClearOptions(MessageParcel &reply, ClearOptions &clearOptions);
75     static int32_t WriteClearOptions(MessageParcel &data, const ClearOptions &clearOptions);
76 
77     static int32_t CompareVersion(const std::string &version1, const std::string &version2);
78     static std::vector<std::string> SplitString(const std::string &str, const std::string &delimiter);
79 };
80 } // namespace UpdateEngine
81 } // namespace OHOS
82 #endif // MESSAGE_PARCEL_HELPER_H
83